Skip to content

Commit

Permalink
[DS-1272] Setting discovery to be the default search/browse engine
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVdV committed Oct 4, 2012
1 parent bed7fc6 commit 2cb2fa0
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 490 deletions.
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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:
Expand Down
@@ -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);
}
}
}

0 comments on commit 2cb2fa0

Please sign in to comment.