All Versions
- DSpace 7.x (Current Release)
- DSpace 8.x (Unreleased)
- DSpace 6.x (EOL)
- DSpace 5.x (EOL)
- More Versions...
...
webui.submit.upload.required
Visual indicators per item allow users to mark items in browse and search results. This could be useful in many scenarios, some of them follow:
The visual indicators extension has the following specs:
Some theory:
A mark is an instance of the class: org.dspace.app.itemmarking.ItemMarkingInfo.
Each mark can have the following properties:
When you need to add a mark in an Item then you need to create a strategy that determined what mark to display per item. Strategy classes need to implement the interface:
Code Block |
---|
org.dspace.app.itemmarking.ItemMarkingExtractor |
Your strategy class just needs to implement the following method from the above Interface:
Code Block | ||
---|---|---|
| ||
public ItemMarkingInfo getItemMarkingInfo(Context context, Item item) throws SQLException; |
Which is, given an item, return the Mark info to display.
Currently, there are three Strategies included by default:
ItemMarkingMetadataStrategy
This strategy decides the mark to display per item based on a value of a metadata field (i.e. dc:type)
It accepts two properties:
If the String (key of the map) is found as a value in the metadataField field, then the mark denoted by the value of the map will be displayed.
ItemMarkingCollectionStrategy
This strategy decides the mark to display per item based on the collection this item belongs to.
It accepts one property:
The String (key of the map) is the collection handle (i.e.: 123456789/1) and if an items belongs to this collection, the mark denoted by the object of the map will be displayed
ItemMarkingAvailabilityBitStreamStrategy
This strategy decides the mark to display per item based on the availability (exists or not) of a bitstream within the item.
It accepts to properties:
Moreover, this strategy add a link in the mark (in case there are bitstreams in the item) to the first bitstream of the item
How to:
In order to enable a mark for the result or browse list you need to change the option:
Code Block | ||
---|---|---|
| ||
webui.itemlist.columns |
of the dspace.cfg file.
You need to include a ‘mark_[value]’ key in any column order you like. Do not add the brackets and you can replace the “value” with any word has a meaning for your marking type. You may add multiple marks (i.e.: one in the first column and one at the last)
For example, the following line is a valid option value:
Code Block | ||
---|---|---|
| ||
webui.itemlist.columns = mark_type, dc.date.issued(date), dc.title, dc.contributor.*, mark_availability
|
In the aforementioned case, you just added two marks, one in the first column for the type of the item and one in the last item for the availability.
Now it’s time to declare what “mark_type” and “mark_availability” means. This is done in the Spring configuration file config/sping/api/item-marking.xml, via the dependency injection feature.
In this file, for each “mark_[value]” key you add in the dspace.cfg file, you need to add a Spring bean with id=org.dspace.app.itemmarking.ItemMarkingExtractor.[value]. The class of this bean must be an implementation of org.dspace.app.itemmarking.ItemMarkingExtractor.
That’s all!
For our example, we need to declare two beans (one for “mark_type” and one for “mark_availability”).
Code Block | ||
---|---|---|
| ||
<!-- Enable this strategy in order to mark item based on the value of a metadata field -->
<bean class="org.dspace.app.itemmarking.ItemMarkingMetadataStrategy" id="org.dspace.app.itemmarking.ItemMarkingExtractor.type">
<property name="metadataField" value="dc.type" />
<property name="mapping" ref="typeMap"/>
</bean>
<!-- Enable this strategy in order to mark items based on the availability of their bitstreams -->
<bean class="org.dspace.app.itemmarking.ItemMarkingAvailabilityBitstreamStrategy" id="org.dspace.app.itemmarking.ItemMarkingExtractor.availability">
<property name="availableImageName" value="image/available.png" />
<property name="nonAvailableImageName" value="image/nonavailable.png" />
</bean> |
For the “mark_type”, we have declared the strategy to be ItemMarkingMetadataStrategy which means that the value of a metadata field (dc.type in our case) will determine the mark of each item. Here is the mapping:
Code Block | ||
---|---|---|
| ||
<bean class="java.util.HashMap" id="typeMap">
<constructor-arg>
<map>
<entry>
<key>
<value>image</value>
</key>
<ref bean="type1MarkingInfo"/>
</entry>
<entry>
<key>
<value>video</value>
</key>
<ref bean="type2MarkingInfo"/>
</entry>
</map>
</constructor-arg>
</bean> |
Thus, if the value of dc.type field is equal to image the “type1MarkingInfo” bean will be used for the marking, if it is equal to video the “type2MarkingInfo” bean will be used, otherwise, no mark will be displayed.
Code Block | ||
---|---|---|
| ||
<bean class="org.dspace.app.itemmarking.ItemMarkingInfo" id="type1MarkingInfo">
<property name="classInfo" value="glyphicon glyphicon-picture"/>
<property name="tooltip" value="itemlist.mark.type1MarkingInfo"/>
</bean>
<bean class="org.dspace.app.itemmarking.ItemMarkingInfo" id="type2MarkingInfo">
<property name="imageName" value="image/type2.png"/>
<property name="tooltip" value="itemlist.mark.type2MarkingInfo"/>
</bean> |
Tooltip property contains the localized key to display.
Keep in mind that the Strategy that you may write can have its own logic on how to create the ItemMarkingInfo per item. The only requirement of the feature is to add in the Spring configuration file the initial beans one for each mark you have declared in the dspace.cfg file.
Styling:
The title for the column of each mark is titled based on the localized key “itemlist.mark_[value]”, so you just need to add the specific keys in the messages.propertied files.
Moreover, the following CSS styles are applied to the various aspects of the mark:
Add these classes to the css file and apply any style you like (like centering the text or the image)