mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Merge pull request #52 from EKT/DS-1223
[DS-1223] Display frequencies of items in single browsing for selected indices
This commit is contained in:
@@ -386,4 +386,8 @@ public interface BrowseDAO
|
|||||||
public void setAuthorityValue(String value);
|
public void setAuthorityValue(String value);
|
||||||
|
|
||||||
public String getAuthorityValue();
|
public String getAuthorityValue();
|
||||||
|
|
||||||
|
public boolean isEnableBrowseFrequencies();
|
||||||
|
|
||||||
|
public void setEnableBrowseFrequencies(boolean enableBrowseFrequencies);
|
||||||
}
|
}
|
||||||
|
@@ -117,6 +117,8 @@ public class BrowseDAOOracle implements BrowseDAO
|
|||||||
private boolean itemsInArchive = true;
|
private boolean itemsInArchive = true;
|
||||||
private boolean itemsWithdrawn = false;
|
private boolean itemsWithdrawn = false;
|
||||||
|
|
||||||
|
private boolean enableBrowseFrequencies = true;
|
||||||
|
|
||||||
public BrowseDAOOracle(Context context)
|
public BrowseDAOOracle(Context context)
|
||||||
throws BrowseException
|
throws BrowseException
|
||||||
{
|
{
|
||||||
@@ -405,7 +407,12 @@ public class BrowseDAOOracle implements BrowseDAO
|
|||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
String valueResult = row.getStringColumn("value");
|
String valueResult = row.getStringColumn("value");
|
||||||
String authorityResult = row.getStringColumn("authority");
|
String authorityResult = row.getStringColumn("authority");
|
||||||
results.add(new String[]{valueResult,authorityResult});
|
if (enableBrowseFrequencies){
|
||||||
|
long frequency = row.getLongColumn("num");
|
||||||
|
results.add(new String[]{valueResult,authorityResult, String.valueOf(frequency)});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
results.add(new String[]{valueResult,authorityResult, ""});
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@@ -768,6 +775,17 @@ public class BrowseDAOOracle implements BrowseDAO
|
|||||||
// prepare the limit and offset clauses
|
// prepare the limit and offset clauses
|
||||||
buildRowLimitAndOffset(queryBuf, params);
|
buildRowLimitAndOffset(queryBuf, params);
|
||||||
|
|
||||||
|
//If we want frequencies and this is not a count query, enchance the query accordingly
|
||||||
|
if (isEnableBrowseFrequencies() && countValues==null){
|
||||||
|
String before = "SELECT count(*) AS num, dvalues.value, dvalues.authority FROM (";
|
||||||
|
String after = ") dvalues , "+tableMap+" WHERE dvalues.id = "+tableMap+".distinct_id GROUP BY "+tableMap+
|
||||||
|
".distinct_id, dvalues.value, dvalues.authority, dvalues.sort_value";
|
||||||
|
|
||||||
|
queryBuf.insert(0, before);
|
||||||
|
queryBuf.append(after);
|
||||||
|
buildOrderBy(queryBuf);
|
||||||
|
}
|
||||||
|
|
||||||
return queryBuf.toString();
|
return queryBuf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1395,4 +1413,12 @@ public class BrowseDAOOracle implements BrowseDAO
|
|||||||
public String getAuthorityValue() {
|
public String getAuthorityValue() {
|
||||||
return authority;
|
return authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnableBrowseFrequencies() {
|
||||||
|
return enableBrowseFrequencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableBrowseFrequencies(boolean enableBrowseFrequencies) {
|
||||||
|
this.enableBrowseFrequencies = enableBrowseFrequencies;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -117,6 +117,8 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
private boolean itemsInArchive = true;
|
private boolean itemsInArchive = true;
|
||||||
private boolean itemsWithdrawn = false;
|
private boolean itemsWithdrawn = false;
|
||||||
|
|
||||||
|
private boolean enableBrowseFrequencies = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required constructor for use by BrowseDAOFactory
|
* Required constructor for use by BrowseDAOFactory
|
||||||
*
|
*
|
||||||
@@ -392,6 +394,7 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
throws BrowseException
|
throws BrowseException
|
||||||
{
|
{
|
||||||
String query = getQuery();
|
String query = getQuery();
|
||||||
|
|
||||||
Object[] params = getQueryParams();
|
Object[] params = getQueryParams();
|
||||||
log.debug(LogManager.getHeader(context, "executing_value_query", "query=" + query));
|
log.debug(LogManager.getHeader(context, "executing_value_query", "query=" + query));
|
||||||
|
|
||||||
@@ -409,7 +412,12 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
String valueResult = row.getStringColumn("value");
|
String valueResult = row.getStringColumn("value");
|
||||||
String authorityResult = row.getStringColumn("authority");
|
String authorityResult = row.getStringColumn("authority");
|
||||||
results.add(new String[]{valueResult,authorityResult});
|
if (enableBrowseFrequencies){
|
||||||
|
long frequency = row.getLongColumn("num");
|
||||||
|
results.add(new String[]{valueResult,authorityResult, String.valueOf(frequency)});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
results.add(new String[]{valueResult,authorityResult, ""});
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
@@ -773,6 +781,17 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
// prepare the limit and offset clauses
|
// prepare the limit and offset clauses
|
||||||
buildRowLimitAndOffset(queryBuf, params);
|
buildRowLimitAndOffset(queryBuf, params);
|
||||||
|
|
||||||
|
//If we want frequencies and this is not a count query, enchance the query accordingly
|
||||||
|
if (isEnableBrowseFrequencies() && countValues==null){
|
||||||
|
String before = "SELECT count(*) AS num, dvalues.value, dvalues.authority FROM (";
|
||||||
|
String after = ") dvalues , "+tableMap+" WHERE dvalues.id = "+tableMap+".distinct_id GROUP BY "+tableMap+
|
||||||
|
".distinct_id, dvalues.value, dvalues.authority, dvalues.sort_value";
|
||||||
|
|
||||||
|
queryBuf.insert(0, before);
|
||||||
|
queryBuf.append(after);
|
||||||
|
buildOrderBy(queryBuf);
|
||||||
|
}
|
||||||
|
|
||||||
return queryBuf.toString();
|
return queryBuf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,4 +1411,12 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
public String getAuthorityValue() {
|
public String getAuthorityValue() {
|
||||||
return authority;
|
return authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnableBrowseFrequencies() {
|
||||||
|
return enableBrowseFrequencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableBrowseFrequencies(boolean enableBrowseFrequencies) {
|
||||||
|
this.enableBrowseFrequencies = enableBrowseFrequencies;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -414,11 +414,20 @@ public class BrowseEngine
|
|||||||
// tell the browse query whether we are ascending or descending on the value
|
// tell the browse query whether we are ascending or descending on the value
|
||||||
dao.setAscending(scope.isAscending());
|
dao.setAscending(scope.isAscending());
|
||||||
|
|
||||||
|
// inform dao about the display frequencies flag
|
||||||
|
dao.setEnableBrowseFrequencies(browseIndex.isDisplayFrequencies());
|
||||||
|
|
||||||
|
// if we want to display frequencies, we need to pass the map table
|
||||||
|
if (browseIndex.isDisplayFrequencies()){
|
||||||
|
dao.setFilterMappingTables(null, browseIndex.getMapTableName());
|
||||||
|
}
|
||||||
|
|
||||||
// set our constraints on community or collection
|
// set our constraints on community or collection
|
||||||
if (scope.inCollection() || scope.inCommunity())
|
if (scope.inCollection() || scope.inCommunity())
|
||||||
{
|
{
|
||||||
// Scoped browsing of distinct metadata requires the mapping
|
// Scoped browsing of distinct metadata requires the mapping
|
||||||
// table to be specified.
|
// table to be specified.
|
||||||
|
if (!browseIndex.isDisplayFrequencies())
|
||||||
dao.setFilterMappingTables(null, browseIndex.getMapTableName());
|
dao.setFilterMappingTables(null, browseIndex.getMapTableName());
|
||||||
|
|
||||||
if (scope.inCollection())
|
if (scope.inCollection())
|
||||||
|
@@ -58,6 +58,9 @@ public final class BrowseIndex
|
|||||||
/** default order (asc / desc) for this index */
|
/** default order (asc / desc) for this index */
|
||||||
private String defaultOrder = SortOption.ASCENDING;
|
private String defaultOrder = SortOption.ASCENDING;
|
||||||
|
|
||||||
|
/** whether to display frequencies or not, in case of a "metadata" browse index*/
|
||||||
|
private boolean displayFrequencies = true;
|
||||||
|
|
||||||
/** additional 'internal' tables that are always defined */
|
/** additional 'internal' tables that are always defined */
|
||||||
private static BrowseIndex itemIndex = new BrowseIndex("bi_item");
|
private static BrowseIndex itemIndex = new BrowseIndex("bi_item");
|
||||||
private static BrowseIndex withdrawnIndex = new BrowseIndex("bi_withdrawn");
|
private static BrowseIndex withdrawnIndex = new BrowseIndex("bi_withdrawn");
|
||||||
@@ -303,6 +306,10 @@ public final class BrowseIndex
|
|||||||
return sortOption;
|
return sortOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisplayFrequencies() {
|
||||||
|
return displayFrequencies;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the internal array containing the bits of metadata, for
|
* Populate the internal array containing the bits of metadata, for
|
||||||
* ease of use later
|
* ease of use later
|
||||||
@@ -594,7 +601,7 @@ public final class BrowseIndex
|
|||||||
/**
|
/**
|
||||||
* Is the browse index of display type single?
|
* Is the browse index of display type single?
|
||||||
*
|
*
|
||||||
* @return true if single, false if not
|
* @return true if singe, false if not
|
||||||
*/
|
*/
|
||||||
public boolean isMetadataIndex()
|
public boolean isMetadataIndex()
|
||||||
{
|
{
|
||||||
@@ -682,6 +689,12 @@ public final class BrowseIndex
|
|||||||
while ( ((definition = ConfigurationManager.getProperty("webui.browse.index." + idx))) != null)
|
while ( ((definition = ConfigurationManager.getProperty("webui.browse.index." + idx))) != null)
|
||||||
{
|
{
|
||||||
BrowseIndex bi = new BrowseIndex(definition, idx);
|
BrowseIndex bi = new BrowseIndex(definition, idx);
|
||||||
|
|
||||||
|
//Load the frequency configuration
|
||||||
|
String freqDefinition = ConfigurationManager.getProperty("webui.browse.metadata.show-freq." + idx);
|
||||||
|
if (freqDefinition!=null)
|
||||||
|
bi.displayFrequencies = Boolean.valueOf(freqDefinition);
|
||||||
|
|
||||||
browseIndices.add(bi);
|
browseIndices.add(bi);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@@ -135,6 +135,8 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
private boolean itemsWithdrawn = false;
|
private boolean itemsWithdrawn = false;
|
||||||
private boolean itemsPrivate = false;
|
private boolean itemsPrivate = false;
|
||||||
|
|
||||||
|
private boolean showFrequencies;
|
||||||
|
|
||||||
private DiscoverResult getSolrResponse() throws BrowseException
|
private DiscoverResult getSolrResponse() throws BrowseException
|
||||||
{
|
{
|
||||||
if (sResponse == null)
|
if (sResponse == null)
|
||||||
@@ -265,8 +267,10 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
for (int i = start; i < (start + max) && i < count; i++)
|
for (int i = start; i < (start + max) && i < count; i++)
|
||||||
{
|
{
|
||||||
FacetResult c = facet.get(i);
|
FacetResult c = facet.get(i);
|
||||||
|
String freq = showFrequencies ? String.valueOf(c.getCount())
|
||||||
|
: "";
|
||||||
result.add(new String[] { c.getDisplayedValue(),
|
result.add(new String[] { c.getDisplayedValue(),
|
||||||
c.getAuthorityKey() });
|
c.getAuthorityKey(), freq });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -275,8 +279,10 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
&& i >= 0; i--)
|
&& i >= 0; i--)
|
||||||
{
|
{
|
||||||
FacetResult c = facet.get(i);
|
FacetResult c = facet.get(i);
|
||||||
|
String freq = showFrequencies ? String.valueOf(c.getCount())
|
||||||
|
: "";
|
||||||
result.add(new String[] { c.getDisplayedValue(),
|
result.add(new String[] { c.getDisplayedValue(),
|
||||||
c.getAuthorityKey() });
|
c.getAuthorityKey(), freq });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,6 +382,18 @@ public class SolrBrowseDAO implements BrowseDAO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnableBrowseFrequencies()
|
||||||
|
{
|
||||||
|
return showFrequencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnableBrowseFrequencies(boolean enableBrowseFrequencies)
|
||||||
|
{
|
||||||
|
showFrequencies = enableBrowseFrequencies;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
<%@ page import="java.net.URLEncoder" %>
|
<%@ page import="java.net.URLEncoder" %>
|
||||||
<%@ page import="org.dspace.core.Utils" %>
|
<%@ page import="org.dspace.core.Utils" %>
|
||||||
<%@ page import="org.dspace.app.webui.util.UIUtil" %>
|
<%@ page import="org.dspace.app.webui.util.UIUtil" %>
|
||||||
|
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
request.setAttribute("LanguageSwitch", "hide");
|
request.setAttribute("LanguageSwitch", "hide");
|
||||||
@@ -308,6 +309,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="<%= row %>RowOddCol">
|
<td class="<%= row %>RowOddCol">
|
||||||
<a href="<%= sharedLink %><% if (results[i][1] != null) { %>&authority=<%= URLEncoder.encode(results[i][1], "UTF-8") %>" class="authority <%= bix.getName() %>"><%= Utils.addEntities(results[i][0]) %></a> <% } else { %>&value=<%= URLEncoder.encode(results[i][0], "UTF-8") %>"><%= Utils.addEntities(results[i][0]) %></a> <% } %>
|
<a href="<%= sharedLink %><% if (results[i][1] != null) { %>&authority=<%= URLEncoder.encode(results[i][1], "UTF-8") %>" class="authority <%= bix.getName() %>"><%= Utils.addEntities(results[i][0]) %></a> <% } else { %>&value=<%= URLEncoder.encode(results[i][0], "UTF-8") %>"><%= Utils.addEntities(results[i][0]) %></a> <% } %>
|
||||||
|
<%= StringUtils.isNotBlank(results[i][2])?" ["+results[i][2]+"]":""%>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
|
@@ -18,6 +18,7 @@ import org.apache.cocoon.environment.ObjectModelHelper;
|
|||||||
import org.apache.cocoon.environment.Request;
|
import org.apache.cocoon.environment.Request;
|
||||||
import org.apache.cocoon.environment.http.HttpEnvironment;
|
import org.apache.cocoon.environment.http.HttpEnvironment;
|
||||||
import org.apache.cocoon.util.HashUtil;
|
import org.apache.cocoon.util.HashUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.excalibur.source.SourceValidity;
|
import org.apache.excalibur.source.SourceValidity;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||||
@@ -328,6 +329,10 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
|
|||||||
Cell cell = singleTable.addRow().addCell();
|
Cell cell = singleTable.addRow().addCell();
|
||||||
cell.addXref(super.generateURL(BROWSE_URL_BASE, queryParams),
|
cell.addXref(super.generateURL(BROWSE_URL_BASE, queryParams),
|
||||||
singleEntry[0]);
|
singleEntry[0]);
|
||||||
|
if (StringUtils.isNotEmpty(singleEntry[2]))
|
||||||
|
{
|
||||||
|
cell.addContent(" ["+singleEntry[2]+"]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1063,7 +1063,18 @@ plugin.named.org.dspace.sort.OrderFormatDelegate= \
|
|||||||
#
|
#
|
||||||
webui.browse.link.1 = author:dc.contributor.*
|
webui.browse.link.1 = author:dc.contributor.*
|
||||||
|
|
||||||
|
#### Display browse frequencies
|
||||||
|
#
|
||||||
|
# webui.browse.metadata.show-freq.<n> = true | false
|
||||||
|
# where n is the same index as in webui.browse.index.<n> configurations
|
||||||
|
#
|
||||||
|
# For the browse indexes that this property is omitted, it is assumed as true
|
||||||
|
# please note that only a few overhead is required to compute frequencies when
|
||||||
|
# DBMS BrowseDAO is used and not overhead at all when SOLRBrowseDAO is used
|
||||||
|
# webui.browse.metadata.show-freq.1 = false
|
||||||
|
# webui.browse.metadata.show-freq.2 = false
|
||||||
|
# webui.browse.metadata.show-freq.3 = false
|
||||||
|
# webui.browse.metadata.show-freq.4 = true
|
||||||
|
|
||||||
#### Additional configuration for Recent Submissions code ####
|
#### Additional configuration for Recent Submissions code ####
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user