mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 07:53:08 +00:00
Using default filter.
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
<root.basedir>${basedir}/..</root.basedir>
|
<root.basedir>${basedir}/..</root.basedir>
|
||||||
<spring.version>3.2.3.RELEASE</spring.version>
|
<spring.version>3.2.3.RELEASE</spring.version>
|
||||||
<xoai.version>3.2.5</xoai.version>
|
<xoai.version>3.2.5</xoai.version>
|
||||||
<jtwig.version>1.0.2</jtwig.version>
|
<jtwig.version>2.0.0</jtwig.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
<!-- Templating Engine -->
|
<!-- Templating Engine -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.lyncode</groupId>
|
<groupId>com.lyncode</groupId>
|
||||||
<artifactId>jtwig</artifactId>
|
<artifactId>jtwig-spring</artifactId>
|
||||||
<version>${jtwig.version}</version>
|
<version>${jtwig.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@@ -1,119 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.xoai.filter;
|
|
||||||
|
|
||||||
import com.lyncode.xoai.dataprovider.core.ReferenceSet;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.core.Context;
|
|
||||||
import org.dspace.xoai.data.DSpaceItem;
|
|
||||||
import org.dspace.xoai.filter.results.DatabaseFilterResult;
|
|
||||||
import org.dspace.xoai.filter.results.SolrFilterResult;
|
|
||||||
import org.dspace.xoai.services.api.database.CollectionsService;
|
|
||||||
import org.dspace.xoai.services.api.database.HandleResolver;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Lyncode Development Team <dspace@lyncode.com>
|
|
||||||
*/
|
|
||||||
public class DSpaceSetSpecFilter extends DSpaceFilter
|
|
||||||
{
|
|
||||||
private static Logger log = LogManager.getLogger(DSpaceSetSpecFilter.class);
|
|
||||||
|
|
||||||
private String setSpec;
|
|
||||||
private HandleResolver handleResolver;
|
|
||||||
private CollectionsService collectionsService;
|
|
||||||
|
|
||||||
public DSpaceSetSpecFilter(CollectionsService collectionsService, HandleResolver handleResolver, String spec)
|
|
||||||
{
|
|
||||||
this.collectionsService = collectionsService;
|
|
||||||
this.handleResolver = handleResolver;
|
|
||||||
setSpec = spec;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DatabaseFilterResult buildDatabaseQuery(Context context)
|
|
||||||
{
|
|
||||||
if (setSpec.startsWith("col_"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DSpaceObject dso = handleResolver.resolve(setSpec.replace("col_", ""));
|
|
||||||
return new DatabaseFilterResult(
|
|
||||||
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id = ?)",
|
|
||||||
dso.getID());
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.error(ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (setSpec.startsWith("com_"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DSpaceObject dso = handleResolver.resolve(setSpec.replace("com_", ""));
|
|
||||||
List<Integer> list = collectionsService.getAllSubCollections(dso.getID());
|
|
||||||
String subCollections = StringUtils.join(list.iterator(), ",");
|
|
||||||
return new DatabaseFilterResult(
|
|
||||||
"EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id IN ("
|
|
||||||
+ subCollections + "))");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new DatabaseFilterResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShown(DSpaceItem item)
|
|
||||||
{
|
|
||||||
for (ReferenceSet s : item.getSets())
|
|
||||||
if (s.getSetSpec().equals(setSpec))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SolrFilterResult buildSolrQuery()
|
|
||||||
{
|
|
||||||
if (setSpec.startsWith("col_"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return new SolrFilterResult("item.collections:"
|
|
||||||
+ ClientUtils.escapeQueryChars(setSpec));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.error(ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (setSpec.startsWith("com_"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return new SolrFilterResult("item.communities:"
|
|
||||||
+ ClientUtils.escapeQueryChars(setSpec));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new SolrFilterResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
<Contexts>
|
<Contexts>
|
||||||
<Context baseurl="request" name="Default Context">
|
<Context baseurl="request" name="Default Context">
|
||||||
|
<!-- Restrict access to hidden items by default -->
|
||||||
|
<Filter ref="defaultFilter" />
|
||||||
|
|
||||||
<Format ref="oaidc"/>
|
<Format ref="oaidc"/>
|
||||||
<Format ref="mets"/>
|
<Format ref="mets"/>
|
||||||
<Format ref="xoai"/>
|
<Format ref="xoai"/>
|
||||||
@@ -106,7 +109,8 @@
|
|||||||
<Prefix>didl</Prefix>
|
<Prefix>didl</Prefix>
|
||||||
<XSLT>metadataFormats/didl.xsl</XSLT>
|
<XSLT>metadataFormats/didl.xsl</XSLT>
|
||||||
<Namespace>urn:mpeg:mpeg21:2002:02-DIDL-NS</Namespace>
|
<Namespace>urn:mpeg:mpeg21:2002:02-DIDL-NS</Namespace>
|
||||||
<SchemaLocation>http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didl.xsd</SchemaLocation>
|
<SchemaLocation>http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didl.xsd
|
||||||
|
</SchemaLocation>
|
||||||
</Format>
|
</Format>
|
||||||
<Format id="dim">
|
<Format id="dim">
|
||||||
<Prefix>dim</Prefix>
|
<Prefix>dim</Prefix>
|
||||||
@@ -155,11 +159,7 @@
|
|||||||
<XSLT>metadataFormats/uketd_dc.xsl</XSLT>
|
<XSLT>metadataFormats/uketd_dc.xsl</XSLT>
|
||||||
<Namespace>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/</Namespace>
|
<Namespace>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/</Namespace>
|
||||||
<SchemaLocation>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/uketd_dc.xsd</SchemaLocation>
|
<SchemaLocation>http://naca.central.cranfield.ac.uk/ethos-oai/2.0/uketd_dc.xsd</SchemaLocation>
|
||||||
<<<<<<< HEAD
|
|
||||||
<Filter refid="thesisFilter" />
|
|
||||||
=======
|
|
||||||
<Filter ref="uketdDcFilter"/>
|
<Filter ref="uketdDcFilter"/>
|
||||||
>>>>>>> 7c0f545... OAI 2.1
|
|
||||||
</Format>
|
</Format>
|
||||||
<Format id="junii2">
|
<Format id="junii2">
|
||||||
<Prefix>junii2</Prefix>
|
<Prefix>junii2</Prefix>
|
||||||
@@ -247,6 +247,12 @@
|
|||||||
</Definition>
|
</Definition>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
||||||
|
<Filter id="defaultFilter">
|
||||||
|
<Definition>
|
||||||
|
<Custom ref="bitstreamAccessCondition"/>
|
||||||
|
</Definition>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
<CustomCondition id="thesisDocumentTypeCondition">
|
<CustomCondition id="thesisDocumentTypeCondition">
|
||||||
<Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
|
<Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
|
||||||
<Configuration>
|
<Configuration>
|
||||||
@@ -314,37 +320,12 @@
|
|||||||
|
|
||||||
<CustomCondition id="openaireRelationCondition">
|
<CustomCondition id="openaireRelationCondition">
|
||||||
<Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
|
<Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
|
||||||
<<<<<<< HEAD
|
|
||||||
<Parameter key="field">
|
|
||||||
<Value>dc.relation</Value>
|
|
||||||
</Parameter>
|
|
||||||
<Parameter key="operator">
|
|
||||||
<Value>starts_with</Value>
|
|
||||||
</Parameter>
|
|
||||||
<Parameter key="value">
|
|
||||||
<Value>info:eu-repo/grantAgreement/EC/FP</Value>
|
|
||||||
</Parameter>
|
|
||||||
</Filter>
|
|
||||||
<Filter id="thesisFilter">
|
|
||||||
<Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
|
|
||||||
<Parameter key="field">
|
|
||||||
<Value>dc.type</Value>
|
|
||||||
</Parameter>
|
|
||||||
<Parameter key="operator">
|
|
||||||
<Value>contains</Value>
|
|
||||||
</Parameter>
|
|
||||||
<Parameter key="value">
|
|
||||||
<Value>Thesis</Value>
|
|
||||||
</Parameter>
|
|
||||||
</Filter>
|
|
||||||
=======
|
|
||||||
<Configuration>
|
<Configuration>
|
||||||
<string name="field">dc.relation</string>
|
<string name="field">dc.relation</string>
|
||||||
<string name="operator">starts_with</string>
|
<string name="operator">starts_with</string>
|
||||||
<string name="value">info:eu-repo/grantAgreement/EC/FP</string>
|
<string name="value">info:eu-repo/grantAgreement/EC/FP</string>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</CustomCondition>
|
</CustomCondition>
|
||||||
>>>>>>> 7c0f545... OAI 2.1
|
|
||||||
</Filters>
|
</Filters>
|
||||||
|
|
||||||
<Sets>
|
<Sets>
|
||||||
|
Reference in New Issue
Block a user