Archived / Obsolete Documentation

Documentation in this space is no longer accurate.
Looking for official DSpace documentation? See all documentation

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Tagging DSpace records by users

The goal of this patch is to add the possibility to tag DSpace records with words proposed by users.

It is based on a previous patch that Desmond Elliott proposed to bookmark records.

It is for DSpace 1.4.2 JSP UI only but it should not be too difficult to port it to newer DSpace versions.

For the users:

  • multiple tags can be added to any displayed item by any logged in user: 
  • in MyDSpace, the tags of the logged-in user are listed with their frequency. Clicking on any word brings the list of the items tagged with this word:
  • In the left navigation bar, a "Tag" entry can appear. It gives access to the tags owned by the user but also to the tags of all the other users (collaborative tagging)
  • a special tag "v" (viewed) is used to simply tick records. This special tag can be set/reset directly from a result list or from the top of a record.

For the application manager:

In dspace/config/dspace.cfg, you can define:

# "v" is recommended as a tag for "ticked" records:

webui.itemlist.tagviewed = v

# HTML code to show that a record is ticked (and can be unticked)
webui.itemlist.viewed = <a href="[root]/handle/[handle]?bookmarkremoved=v[framed]"[targetbibl_record]><img src="[root]/image/viewed.gif" border="0" align="left"/></a>

# HTML code to show that a record is unticked (and can be ticked)
webui.itemlist.notviewed = <a href="[root]/handle/[handle]?bookmarkadded=v[framed]"[targetbibl_record]><img src="[root]/image/notviewed.gif" border="0" align="left"/></a>

For the developpers:

in the PostgreSQL database:

A new database table must be added:

CREATE SEQUENCE bookmark_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
ALTER TABLE bookmark_seq OWNER TO <<<Put here the right PostgreSQL user as the table owner>>>;

CREATE TABLE bookmark
(
  bookmark_id integer NOT NULL DEFAULT nextval('bookmark_seq'::regclass),
  eperson_id integer,
  item_id integer,
  tag_value character varying(128),
  CONSTRAINT bookmark_pkey PRIMARY KEY (bookmark_id),
  CONSTRAINT bookmark_eperson_id_fkey FOREIGN KEY (eperson_id)
      REFERENCES eperson (eperson_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT bookmark_item_id_fkey FOREIGN KEY (item_id)
      REFERENCES item (item_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (OIDS=FALSE);
ALTER TABLE bookmark OWNER TO <<<Put here the right PostgreSQL user as the table owner>>>;
CREATE INDEX bookmark_idx1
  ON bookmark
  USING btree
  (eperson_id);
CREATE INDEX bookmark_idx2
  ON bookmark
  USING btree
  (item_id);
CREATE INDEX bookmark_idx3
  ON bookmark
  USING btree
  (md5(tag_value::text));

In the Java Code:

New classes (java files attached to this page):

  • org.dspace.eperson.BookmarkManager
  • org.dspace.eperson.Tag
  • org.dspace.app.webui.servlet.BookmarkServlet
  • org.dspace.app.webui.servlet.ListTagsServlet

Modified classes:

In org.dspace.app.webui.jsptag.ItemListTag:

At the beginning of "getThumbMarkup", you can add the display of the "viewed" tag in search result lists:

    /* generate the (X)HTML required to show the thumbnail */
    private String getThumbMarkup(HttpServletRequest hrq, Context c, Item item, LinkOut aLinkOut, String suffix)
            throws JspException
    {
        String handle = item.getHandle();
        Bundle[] original = null;
        String tag = "";
        String tagVu = ConfigurationManager.getProperty("webui.itemlist.tagviewed");
        String htmlVu = ConfigurationManager.getProperty("webui.itemlist.viewed");
        String htmlNotVu = ConfigurationManager.getProperty("webui.itemlist.notviewed");
        String vu = "";

        EPerson eperson = c.getCurrentUser();
        if (eperson != null) {
           tag = BookmarkManager.getBookmarkTag(c,eperson,item);
           if (tag != null && (!"".equals(tag))) {
              if ( tag.startsWith(tagVu+";") || (tag.indexOf("; "+tagVu+";")>=0) )
                vu = aLinkOut.mainSubstitutions(htmlVu);
              tag = " "+UIUtil.addLinksURL(hrq.getContextPath()+"/bookmark?tag=",";",tag);
           }
           if ("".equals(vu)) vu = aLinkOut.mainSubstitutions(htmlNotVu);
        }

        Collection colls[] = null;
        try
        {
        	original = item.getBundles("ORIGINAL");
                colls = item.getCollections();
        }
        catch(SQLException sqle)
        {
        	throw new JspException(sqle.getMessage());
        }

in WEB-INF/web.xml:

You must add the definitions for the two new servlets (tagging servlet and tags list servlet):

...
    <servlet>
        <servlet-name>browse-tags</servlet-name>
        <servlet-class>org.dspace.app.webui.servlet.ListTagsServlet</servlet-class>
    </servlet>
  <servlet>
    <servlet-name>bookmark</servlet-name>
    <servlet-class>org.dspace.app.webui.servlet.BookmarkServlet</servlet-class>
  </servlet>
...
    <servlet-mapping>
        <servlet-name>browse-tags</servlet-name>
        <url-pattern>/browse-tags</url-pattern>
    </servlet-mapping>
   <servlet-mapping>
      <servlet-name>bookmark</servlet-name>
      <url-pattern>/bookmark</url-pattern>
  </servlet-mapping>   


For any help, I check the DSpace Developpers list.

Good luck!

Christophe Dupriez

  • No labels