From 2cb2fa0c41a04745a1affcde6c808c60fba3fc95 Mon Sep 17 00:00:00 2001 From: KevinVdV Date: Thu, 4 Oct 2012 13:13:01 +0200 Subject: [PATCH] [DS-1272] Setting discovery to be the default search/browse engine --- .../artifactbrowser/CollectionViewer.java | 53 +--- .../artifactbrowser/CommunityViewer.java | 56 +--- .../browseArtifacts/CollectionBrowse.java | 93 ++++++ .../browseArtifacts/CommunityBrowse.java | 93 ++++++ ...earch.java => CollectionSearchBrowse.java} | 63 +++- ...Search.java => CommunitySearchBrowse.java} | 74 +++-- .../xmlui/aspect/discovery/Navigation.java | 110 ++++++- .../aspects/ArtifactBrowser/dspace-home.xml | 28 -- .../aspects/ArtifactBrowser/sitemap.xmap | 295 ------------------ .../aspects/BrowseArtifacts/sitemap.xmap | 4 + .../resources/aspects/Discovery/sitemap.xmap | 12 +- dspace/config/dspace.cfg | 4 +- dspace/config/launcher.xml | 7 + dspace/config/modules/discovery.cfg | 2 +- dspace/config/xmlui.xconf | 17 +- 15 files changed, 421 insertions(+), 490 deletions(-) create mode 100644 dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CollectionBrowse.java create mode 100644 dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CommunityBrowse.java rename dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/{CollectionSearch.java => CollectionSearchBrowse.java} (73%) rename dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/{CommunitySearch.java => CommunitySearchBrowse.java} (69%) delete mode 100644 dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/dspace-home.xml delete mode 100644 dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CollectionViewer.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CollectionViewer.java index 705486c4952b..20cf590b8668 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CollectionViewer.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CollectionViewer.java @@ -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 class CollectionViewer extends AbstractDSpaceTransformer implements Cache 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 queryParams = new HashMap(); - - 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 diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CommunityViewer.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CommunityViewer.java index 7284868d0c72..4c9002faa2f3 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CommunityViewer.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/CommunityViewer.java @@ -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 class CommunityViewer extends AbstractDSpaceTransformer implements Cachea 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 queryParams = new HashMap(); - - 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: diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CollectionBrowse.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CollectionBrowse.java new file mode 100644 index 000000000000..bc76e561c8e6 --- /dev/null +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CollectionBrowse.java @@ -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 queryParams = new HashMap(); + + 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); + } + } +} \ No newline at end of file diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CommunityBrowse.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CommunityBrowse.java new file mode 100644 index 000000000000..04b3a0110415 --- /dev/null +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/CommunityBrowse.java @@ -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 queryParams = new HashMap(); + + 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); + } + } +} \ No newline at end of file diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearch.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearchBrowse.java similarity index 73% rename from dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearch.java rename to dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearchBrowse.java index df8c2bd2baa7..00068151fbf9 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearch.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CollectionSearchBrowse.java @@ -10,6 +10,8 @@ import java.io.IOException; import java.io.Serializable; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.util.HashUtil; @@ -25,16 +27,20 @@ import org.dspace.content.Collection; import org.dspace.content.DSpaceObject; import org.dspace.core.ConfigurationManager; +import org.dspace.discovery.SearchUtils; +import org.dspace.discovery.configuration.DiscoveryConfiguration; +import org.dspace.discovery.configuration.DiscoveryConfigurationParameters; +import org.dspace.discovery.configuration.DiscoverySearchFilterFacet; import org.xml.sax.SAXException; /** - * Renders the search box for a collection + * Renders the search box & browse urls 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 CollectionSearch extends AbstractDSpaceTransformer implements CacheableProcessingComponent +public class CollectionSearchBrowse extends AbstractDSpaceTransformer implements CacheableProcessingComponent { /** Language Strings */ private static final Message T_dspace_home = @@ -43,6 +49,9 @@ public class CollectionSearch extends AbstractDSpaceTransformer implements Cache private static final Message T_full_text_search = message("xmlui.ArtifactBrowser.CollectionViewer.full_text_search"); + private static final Message T_head_browse = + message("xmlui.ArtifactBrowser.CommunityViewer.head_browse"); + private static final Message T_go = message("xmlui.general.go"); @@ -219,11 +228,38 @@ public void addBody(Body body) throws SAXException, WingException, // The search / browse box. { - Division search = home.addDivision("collection-search-browse", + Division searchBrowseDivision = home.addDivision("collection-search-browse", "secondary search-browse"); + List browse = searchBrowseDivision.addList("community-browse", List.TYPE_SIMPLE, + "community-browse"); + browse.setHead(T_head_browse); + String url = contextPath + "/handle/" + collection.getHandle(); + + addBrowseTitle(browse, url); + // Get a Map of all the browse tables + DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(collection); + java.util.List facets = discoveryConfiguration.getSidebarFacets(); + for (DiscoverySearchFilterFacet facet : facets) + { + if(facet.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) + { + //Browse by date isn't support for our facets. + continue; + } + + // Create a Map of the query parameters for this link + Map queryParams = new HashMap(); + + queryParams.put("field", facet.getIndexFieldName()); + + // Add a link to this browse + browse.addItemXref(generateURL(url + "/search-filter", queryParams), + message("xmlui.ArtifactBrowser.Navigation.browse_" + facet.getIndexFieldName())); + } + // Search query - Division query = search.addInteractiveDivision("collection-search", + Division query = searchBrowseDivision.addInteractiveDivision("collection-search", contextPath + "/handle/" + collection.getHandle() + "/discover", Division.METHOD_POST, "secondary search"); @@ -233,21 +269,18 @@ public void addBody(Body body) throws SAXException, WingException, para.addText("query"); para.addContent(" "); para.addButton("submit").setValue(T_go); - //query.addPara().addXref(contextPath + "/handle/" + collection.getHandle()+ "/advanced-search", T_advanced_search_link); - - // 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(); - //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); } } + private void addBrowseTitle(List browse, String url) throws WingException { + Map browseTitleParams = new HashMap(); + browseTitleParams.put("sort_by", "dc.title_sort"); + browseTitleParams.put("order", "asc"); + browse.addItemXref(generateURL(url + "/discover", browseTitleParams), + message("xmlui.ArtifactBrowser.AdvancedSearch.type_title")); + } + /** * Recycle diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearch.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearchBrowse.java similarity index 69% rename from dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearch.java rename to dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearchBrowse.java index 592531e4b6a9..02c38133ee25 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearch.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/CommunitySearchBrowse.java @@ -10,6 +10,8 @@ import java.io.IOException; import java.io.Serializable; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.util.HashUtil; @@ -21,32 +23,36 @@ import org.dspace.app.xmlui.utils.UIException; 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.PageMeta; -import org.dspace.app.xmlui.wing.element.Para; +import org.dspace.app.xmlui.wing.element.*; import org.dspace.authorize.AuthorizeException; import org.dspace.content.Collection; import org.dspace.content.Community; import org.dspace.content.DSpaceObject; import org.dspace.core.LogManager; +import org.dspace.discovery.SearchUtils; +import org.dspace.discovery.configuration.DiscoveryConfiguration; +import org.dspace.discovery.configuration.DiscoveryConfigurationParameters; +import org.dspace.discovery.configuration.DiscoverySearchFilterFacet; import org.xml.sax.SAXException; /** - * Renders the search box for a community + * Renders the search box & browse urls 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 CommunitySearch extends AbstractDSpaceTransformer implements CacheableProcessingComponent +public class CommunitySearchBrowse extends AbstractDSpaceTransformer implements CacheableProcessingComponent { - private static final Logger log = Logger.getLogger(CommunitySearch.class); + private static final Logger log = Logger.getLogger(CommunitySearchBrowse.class); /** Language Strings */ private static final Message T_full_text_search = message("xmlui.ArtifactBrowser.CommunityViewer.full_text_search"); + private static final Message T_head_browse = + message("xmlui.ArtifactBrowser.CommunityViewer.head_browse"); + private static final Message T_go = message("xmlui.general.go"); @@ -181,11 +187,38 @@ public void addBody(Body body) throws SAXException, WingException, // The search / browse box. { - Division search = home.addDivision("community-search-browse", + Division searchBrowseDivision = home.addDivision("community-search-browse", "secondary search-browse"); + List browse = searchBrowseDivision.addList("community-browse", List.TYPE_SIMPLE, + "community-browse"); + browse.setHead(T_head_browse); + String url = contextPath + "/handle/" + community.getHandle(); + + addBrowseTitle(browse, url); + // Get a Map of all the browse tables + DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(community); + java.util.List facets = discoveryConfiguration.getSidebarFacets(); + for (DiscoverySearchFilterFacet facet : facets) + { + if(facet.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) + { + //Browse by date isn't support for our facets. + continue; + } + + // Create a Map of the query parameters for this link + Map queryParams = new HashMap(); + + queryParams.put("field", facet.getIndexFieldName()); + + // Add a link to this browse + browse.addItemXref(generateURL(url + "/search-filter", queryParams), + message("xmlui.ArtifactBrowser.Navigation.browse_" + facet.getIndexFieldName())); + } + // Search query - Division query = search.addInteractiveDivision("community-search", + Division query = searchBrowseDivision.addInteractiveDivision("community-search", contextPath + "/handle/" + community.getHandle() + "/discover", Division.METHOD_POST, "secondary search"); @@ -196,20 +229,18 @@ public void addBody(Body body) throws SAXException, WingException, para.addContent(" "); para.addButton("submit").setValue(T_go); //query.addPara().addXref(contextPath + "/handle/" + community.getHandle() + "/advanced-search", T_advanced_search_link); - - // 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(); - // 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); } } + private void addBrowseTitle(List browse, String url) throws WingException { + Map browseTitleParams = new HashMap(); + browseTitleParams.put("sort_by", "dc.title_sort"); + browseTitleParams.put("order", "asc"); + browse.addItemXref(generateURL(url + "/discover", browseTitleParams), + message("xmlui.ArtifactBrowser.AdvancedSearch.type_title")); + } + /** * Recycle */ @@ -219,7 +250,4 @@ public void recycle() this.validity = null; super.recycle(); } - - - -} +} \ No newline at end of file diff --git a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/Navigation.java b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/Navigation.java index eea761d30d16..e7346826b0e4 100644 --- a/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/Navigation.java +++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/discovery/Navigation.java @@ -10,6 +10,8 @@ import java.io.IOException; import java.io.Serializable; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.environment.ObjectModelHelper; @@ -20,11 +22,20 @@ import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer; import org.dspace.app.xmlui.utils.HandleUtil; import org.dspace.app.xmlui.utils.UIException; +import org.dspace.app.xmlui.wing.Message; import org.dspace.app.xmlui.wing.WingException; +import org.dspace.app.xmlui.wing.element.List; import org.dspace.app.xmlui.wing.element.Options; import org.dspace.app.xmlui.wing.element.PageMeta; import org.dspace.authorize.AuthorizeException; +import org.dspace.content.Collection; +import org.dspace.content.Community; import org.dspace.content.DSpaceObject; +import org.dspace.content.Item; +import org.dspace.discovery.SearchUtils; +import org.dspace.discovery.configuration.DiscoveryConfiguration; +import org.dspace.discovery.configuration.DiscoveryConfigurationParameters; +import org.dspace.discovery.configuration.DiscoverySearchFilterFacet; import org.xml.sax.SAXException; /** @@ -36,6 +47,22 @@ */ public class Navigation extends AbstractDSpaceTransformer implements CacheableProcessingComponent { + /** Language Strings */ + private static final Message T_head_all_of_dspace = + message("xmlui.ArtifactBrowser.Navigation.head_all_of_dspace"); + + private static final Message T_head_browse = + message("xmlui.ArtifactBrowser.Navigation.head_browse"); + + private static final Message T_communities_and_collections = + message("xmlui.ArtifactBrowser.Navigation.communities_and_collections"); + + private static final Message T_head_this_collection = + message("xmlui.ArtifactBrowser.Navigation.head_this_collection"); + + private static final Message T_head_this_community = + message("xmlui.ArtifactBrowser.Navigation.head_this_community"); + /** * Generate the unique caching key. * This key must be unique inside the space of this component. @@ -121,19 +148,96 @@ public void addOptions(Options options) throws SAXException, WingException, */ /* regulate the ordering */ + List browse = options.addList("browse"); options.addList("discovery"); - options.addList("browse"); options.addList("account"); options.addList("context"); options.addList("administrative"); + browse.setHead(T_head_browse); + + List browseGlobal = browse.addList("global"); + List browseContext = browse.addList("context"); + + browseGlobal.setHead(T_head_all_of_dspace); + + browseGlobal.addItemXref(contextPath + "/community-list",T_communities_and_collections); + + Map browseTitleParams = new HashMap(); + browseTitleParams.put("sort_by", "dc.title_sort"); + browseTitleParams.put("order", "asc"); + + browseGlobal.addItemXref(generateURL(contextPath + "/discover", browseTitleParams), + message("xmlui.ArtifactBrowser.AdvancedSearch.type_title")); + + // Add the configured browse lists for 'top level' browsing + addBrowseOptions(browseGlobal, contextPath + "/search-filter", null); + + DSpaceObject dso = HandleUtil.obtainHandle(objectModel); + if (dso != null) + { + if (dso instanceof Item) + { + // If we are an item change the browse scope to the parent + // collection. + dso = ((Item) dso).getOwningCollection(); + } + + if (dso instanceof Collection) + { + browseContext.setHead(T_head_this_collection); + } + if (dso instanceof Community) + { + browseContext.setHead(T_head_this_community); + } + + // Add the configured browse lists for scoped browsing + String handle = dso.getHandle(); + browseContext.addItemXref(generateURL(contextPath + "/handle/" + handle + "/discover", browseTitleParams), + message("xmlui.ArtifactBrowser.AdvancedSearch.type_title")); + addBrowseOptions(browseContext, contextPath + "/handle/" + handle + "/search-filter", dso); + } + } + + /** + * Add navigation for the configured browse tables to the supplied list. + * + * @param browseList + * @param browseURL + * @throws WingException + */ + private void addBrowseOptions(List browseList, String browseURL, DSpaceObject scope) throws WingException + { + // Get a Map of all the browse tables + DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(scope); + java.util.List facets = discoveryConfiguration.getSidebarFacets(); + + for (DiscoverySearchFilterFacet facet : facets) + { + if(facet.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) + { + //Browse by date isn't support for our facets. + continue; + } + + // Create a Map of the query parameters for this link + Map queryParams = new HashMap(); + + queryParams.put("field", facet.getIndexFieldName()); + + // Add a link to this browse + browseList.addItemXref(generateURL(browseURL, queryParams), + message("xmlui.ArtifactBrowser.AdvancedSearch.type_" + facet.getIndexFieldName())); + } } + /** * Ensure that the context path is added to the page meta. */ public void addPageMeta(PageMeta pageMeta) throws SAXException, - WingException, UIException, SQLException, IOException, + WingException, SQLException, IOException, AuthorizeException { @@ -146,4 +250,4 @@ public void addPageMeta(PageMeta pageMeta) throws SAXException, } -} +} \ No newline at end of file diff --git a/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/dspace-home.xml b/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/dspace-home.xml deleted file mode 100644 index 14e1e7165c3e..000000000000 --- a/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/dspace-home.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - xmlui.general.dspace_home - xmlui.general.dspace_home - - - - diff --git a/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap b/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap deleted file mode 100644 index ab058d09b303..000000000000 --- a/dspace-xmlui/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap +++ /dev/null @@ -1,295 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dspace-xmlui/src/main/resources/aspects/BrowseArtifacts/sitemap.xmap b/dspace-xmlui/src/main/resources/aspects/BrowseArtifacts/sitemap.xmap index 39f9c682fd5b..6b5705cf7e95 100644 --- a/dspace-xmlui/src/main/resources/aspects/BrowseArtifacts/sitemap.xmap +++ b/dspace-xmlui/src/main/resources/aspects/BrowseArtifacts/sitemap.xmap @@ -23,6 +23,8 @@ collections / items / and bitstreams. + + @@ -81,12 +83,14 @@ collections / items / and bitstreams. + + diff --git a/dspace-xmlui/src/main/resources/aspects/Discovery/sitemap.xmap b/dspace-xmlui/src/main/resources/aspects/Discovery/sitemap.xmap index d44220d847d9..c97489b5cd02 100644 --- a/dspace-xmlui/src/main/resources/aspects/Discovery/sitemap.xmap +++ b/dspace-xmlui/src/main/resources/aspects/Discovery/sitemap.xmap @@ -23,6 +23,7 @@ and searching the repository. + @@ -31,11 +32,11 @@ and searching the repository. - + - + @@ -81,6 +82,9 @@ and searching the repository. --> + + + @@ -89,13 +93,13 @@ and searching the repository. - - --> + diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 7924248cfe64..90276856560e 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -631,9 +631,7 @@ event.dispatcher.default.class = org.dspace.event.BasicDispatcher # # uncomment below and comment out original property to enable discovery indexing -# event.dispatcher.default.consumers = versioning, search, browse, discovery, eperson, harvester -# -event.dispatcher.default.consumers = versioning, search, browse, eperson, harvester +event.dispatcher.default.consumers = versioning, search, browse, discovery, eperson, harvester # The noindex dispatcher will not create search or browse indexes (useful for batch item imports) event.dispatcher.noindex.class = org.dspace.event.BasicDispatcher diff --git a/dspace/config/launcher.xml b/dspace/config/launcher.xml index 52d9a3c90069..72a755ebdd12 100644 --- a/dspace/config/launcher.xml +++ b/dspace/config/launcher.xml @@ -142,6 +142,10 @@ org.dspace.search.DSIndexer -b + + org.dspace.discovery.IndexClient + -f + @@ -157,6 +161,9 @@ org.dspace.search.DSIndexer + + org.dspace.discovery.IndexClient + diff --git a/dspace/config/modules/discovery.cfg b/dspace/config/modules/discovery.cfg index 1f5c3e1207eb..13caf9c22f86 100644 --- a/dspace/config/modules/discovery.cfg +++ b/dspace/config/modules/discovery.cfg @@ -5,7 +5,7 @@ # faceted-search system. # #---------------------------------------------------------------# ##### Search Indexing ##### -search.server = http://localhost:8080/solr/search +search.server = ${solr.server}/search #Char used to ensure that the sidebar facets are case insensitive #solr.facets.split.char=\n|||\n diff --git a/dspace/config/xmlui.xconf b/dspace/config/xmlui.xconf index ea40b3e9d3da..f7c872dea42e 100644 --- a/dspace/config/xmlui.xconf +++ b/dspace/config/xmlui.xconf @@ -59,15 +59,11 @@ /xmlui/cocoon/aspects/ directory followed by a slash. --> - - - + + + @@ -75,13 +71,6 @@ -