Permalink
Browse files

Merge remote-tracking branch 'atmire/discovery-default' into discover…

…y-default
  • Loading branch information...
Andrea Bollini
Andrea Bollini committed Oct 6, 2012
2 parents fdaffdc + 2cb2fa0 commit cfc242479aacf4b5ed6f4c5c26fc4be64598e466
@@ -10,8 +10,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
-import java.util.Map;
-import java.util.HashMap;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.util.HashUtil;
@@ -25,11 +23,8 @@
import org.dspace.app.xmlui.wing.element.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.ReferenceSet;
-import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.authorize.AuthorizeException;
-import org.dspace.browse.BrowseException;
-import org.dspace.browse.BrowseIndex;
import org.dspace.content.Collection;
import org.dspace.content.DSpaceObject;
import org.dspace.core.ConfigurationManager;
@@ -54,19 +49,6 @@
public static final Message T_untitled =
message("xmlui.general.untitled");
-
- private static final Message T_head_browse =
- message("xmlui.ArtifactBrowser.CollectionViewer.head_browse");
-
- private static final Message T_browse_titles =
- message("xmlui.ArtifactBrowser.CollectionViewer.browse_titles");
-
- private static final Message T_browse_authors =
- message("xmlui.ArtifactBrowser.CollectionViewer.browse_authors");
-
- private static final Message T_browse_dates =
- message("xmlui.ArtifactBrowser.CollectionViewer.browse_dates");
-
/** Cached validity object */
private SourceValidity validity;
@@ -218,41 +200,10 @@ public void addBody(Body body) throws SAXException, WingException,
home.setHead(name);
}
- // The search / browse box.
+ // The search / browse box placeholder, this division will be populated either in the browse or discovery aspect
{
-// TODO: move browse stuff out of here
- Division search = home.addDivision("collection-search-browse",
+ home.addDivision("collection-search-browse",
"secondary search-browse");
-
- // Browse by list
- Division browseDiv = search.addDivision("collection-browse","secondary browse");
- List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE,
- "collection-browse");
- browse.setHead(T_head_browse);
- String url = contextPath + "/handle/" + collection.getHandle();
-
- try
- {
- // Get a Map of all the browse tables
- BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
- for (BrowseIndex bix : bis)
- {
- // Create a Map of the query parameters for this link
- Map<String, String> queryParams = new HashMap<String, String>();
-
- queryParams.put("type", bix.getName());
-
- // Add a link to this browse
- browse.addItemXref(super.generateURL(url + "/browse", queryParams),
- message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
- }
- }
- catch (BrowseException bex)
- {
- browse.addItemXref(url + "/browse?type=title",T_browse_titles);
- browse.addItemXref(url + "/browse?type=author",T_browse_authors);
- browse.addItemXref(url + "/browse?type=dateissued",T_browse_dates);
- }
}
// Add the reference
@@ -10,8 +10,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
-import java.util.Map;
-import java.util.HashMap;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.util.HashUtil;
@@ -25,12 +23,9 @@
import org.dspace.app.xmlui.wing.element.Body;
import org.dspace.app.xmlui.wing.element.Division;
import org.dspace.app.xmlui.wing.element.ReferenceSet;
-import org.dspace.app.xmlui.wing.element.List;
import org.dspace.app.xmlui.wing.element.Reference;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.authorize.AuthorizeException;
-import org.dspace.browse.BrowseException;
-import org.dspace.browse.BrowseIndex;
import org.dspace.browse.ItemCountException;
import org.dspace.browse.ItemCounter;
import org.dspace.content.Collection;
@@ -59,20 +54,7 @@
public static final Message T_untitled =
message("xmlui.general.untitled");
- private static final Message T_head_browse =
- message("xmlui.ArtifactBrowser.CommunityViewer.head_browse");
-
- private static final Message T_browse_titles =
- message("xmlui.ArtifactBrowser.CommunityViewer.browse_titles");
-
- private static final Message T_browse_authors =
- message("xmlui.ArtifactBrowser.CommunityViewer.browse_authors");
-
- private static final Message T_browse_dates =
- message("xmlui.ArtifactBrowser.CommunityViewer.browse_dates");
-
-
- private static final Message T_head_sub_communities =
+ private static final Message T_head_sub_communities =
message("xmlui.ArtifactBrowser.CommunityViewer.head_sub_communities");
private static final Message T_head_sub_collections =
@@ -261,42 +243,10 @@ public void addBody(Body body) throws SAXException, WingException,
home.setHead(name);
}
- // The search / browse box.
+ // The search / browse box placeholder, this division will be populated either in the browse or discovery aspect
{
- Division search = home.addDivision("community-search-browse",
+ home.addDivision("community-search-browse",
"secondary search-browse");
-
-
-// TODO: move browse stuff out of here
- // Browse by list
- Division browseDiv = search.addDivision("community-browse","secondary browse");
- List browse = browseDiv.addList("community-browse", List.TYPE_SIMPLE,
- "community-browse");
- browse.setHead(T_head_browse);
- String url = contextPath + "/handle/" + community.getHandle();
-
- try
- {
- // Get a Map of all the browse tables
- BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
- for (BrowseIndex bix : bis)
- {
- // Create a Map of the query parameters for this link
- Map<String, String> queryParams = new HashMap<String, String>();
-
- queryParams.put("type", bix.getName());
-
- // Add a link to this browse
- browse.addItemXref(super.generateURL(url + "/browse", queryParams),
- message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
- }
- }
- catch (BrowseException bex)
- {
- browse.addItemXref(url + "/browse?type=title",T_browse_titles);
- browse.addItemXref(url + "/browse?type=author",T_browse_authors);
- browse.addItemXref(url + "/browse?type=dateissued",T_browse_dates);
- }
}
// Add main reference:
@@ -0,0 +1,93 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.xmlui.aspect.browseArtifacts;
+
+import org.apache.cocoon.ProcessingException;
+import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
+import org.dspace.app.xmlui.utils.HandleUtil;
+import org.dspace.app.xmlui.wing.Message;
+import org.dspace.app.xmlui.wing.WingException;
+import org.dspace.app.xmlui.wing.element.Body;
+import org.dspace.app.xmlui.wing.element.Division;
+import org.dspace.app.xmlui.wing.element.List;
+import org.dspace.authorize.AuthorizeException;
+import org.dspace.browse.BrowseException;
+import org.dspace.browse.BrowseIndex;
+import org.dspace.content.Collection;
+import org.dspace.content.DSpaceObject;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Renders the browse links for a collection
+ *
+ * @author Kevin Van de Velde (kevin at atmire dot com)
+ * @author Mark Diggory (markd at atmire dot com)
+ * @author Ben Bosman (ben at atmire dot com)
+ */
+public class CollectionBrowse extends AbstractDSpaceTransformer {
+
+ private static final Message T_head_browse =
+ message("xmlui.ArtifactBrowser.CollectionViewer.head_browse");
+
+ private static final Message T_browse_titles =
+ message("xmlui.ArtifactBrowser.CollectionViewer.browse_titles");
+
+ private static final Message T_browse_authors =
+ message("xmlui.ArtifactBrowser.CollectionViewer.browse_authors");
+
+ private static final Message T_browse_dates =
+ message("xmlui.ArtifactBrowser.CollectionViewer.browse_dates");
+
+ @Override
+ public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException, ProcessingException {
+ DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
+ if (!(dso instanceof Collection))
+ {
+ return;
+ }
+
+ // Set up the major variables
+ Collection collection = (Collection) dso;
+
+ Division home = body.addDivision("collection-home", "primary repository collection");
+
+ Division search = home.addDivision("collection-search-browse",
+ "secondary search-browse");
+
+ // Browse by list
+ Division browseDiv = search.addDivision("collection-browse", "secondary browse");
+ List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE,
+ "collection-browse");
+ browse.setHead(T_head_browse);
+ String url = contextPath + "/handle/" + collection.getHandle();
+
+ try {
+ // Get a Map of all the browse tables
+ BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
+ for (BrowseIndex bix : bis) {
+ // Create a Map of the query parameters for this link
+ Map<String, String> queryParams = new HashMap<String, String>();
+
+ queryParams.put("type", bix.getName());
+
+ // Add a link to this browse
+ browse.addItemXref(generateURL(url + "/browse", queryParams),
+ message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
+ }
+ } catch (BrowseException bex) {
+ browse.addItemXref(url + "/browse?type=title", T_browse_titles);
+ browse.addItemXref(url + "/browse?type=author", T_browse_authors);
+ browse.addItemXref(url + "/browse?type=dateissued", T_browse_dates);
+ }
+ }
+}
@@ -0,0 +1,93 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.xmlui.aspect.browseArtifacts;
+
+import org.apache.cocoon.ProcessingException;
+import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
+import org.dspace.app.xmlui.utils.HandleUtil;
+import org.dspace.app.xmlui.wing.Message;
+import org.dspace.app.xmlui.wing.WingException;
+import org.dspace.app.xmlui.wing.element.Body;
+import org.dspace.app.xmlui.wing.element.Division;
+import org.dspace.app.xmlui.wing.element.List;
+import org.dspace.authorize.AuthorizeException;
+import org.dspace.browse.BrowseException;
+import org.dspace.browse.BrowseIndex;
+import org.dspace.content.Community;
+import org.dspace.content.DSpaceObject;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Renders the browse links for a community
+ *
+ * @author Kevin Van de Velde (kevin at atmire dot com)
+ * @author Mark Diggory (markd at atmire dot com)
+ * @author Ben Bosman (ben at atmire dot com)
+ */
+public class CommunityBrowse extends AbstractDSpaceTransformer {
+
+ private static final Message T_head_browse =
+ message("xmlui.ArtifactBrowser.CommunityViewer.head_browse");
+
+ private static final Message T_browse_titles =
+ message("xmlui.ArtifactBrowser.CommunityViewer.browse_titles");
+
+ private static final Message T_browse_authors =
+ message("xmlui.ArtifactBrowser.CommunityViewer.browse_authors");
+
+ private static final Message T_browse_dates =
+ message("xmlui.ArtifactBrowser.CommunityViewer.browse_dates");
+
+ @Override
+ public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException, ProcessingException {
+ DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
+ if (!(dso instanceof Community))
+ {
+ return;
+ }
+
+ // Set up the major variables
+ Community community = (Community) dso;
+
+ Division home = body.addDivision("community-home", "primary repository community");
+
+ Division search = home.addDivision("community-search-browse",
+ "secondary search-browse");
+
+ // Browse by list
+ Division browseDiv = search.addDivision("community-browse", "secondary browse");
+ List browse = browseDiv.addList("community-browse", List.TYPE_SIMPLE,
+ "community-browse");
+ browse.setHead(T_head_browse);
+ String url = contextPath + "/handle/" + community.getHandle();
+
+ try {
+ // Get a Map of all the browse tables
+ BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
+ for (BrowseIndex bix : bis) {
+ // Create a Map of the query parameters for this link
+ Map<String, String> queryParams = new HashMap<String, String>();
+
+ queryParams.put("type", bix.getName());
+
+ // Add a link to this browse
+ browse.addItemXref(generateURL(url + "/browse", queryParams),
+ message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
+ }
+ } catch (BrowseException bex) {
+ browse.addItemXref(url + "/browse?type=title", T_browse_titles);
+ browse.addItemXref(url + "/browse?type=author", T_browse_authors);
+ browse.addItemXref(url + "/browse?type=dateissued", T_browse_dates);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit cfc2424

Please sign in to comment.