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,18 +15,21 @@
|
|||||||
|
|
||||||
<Contexts>
|
<Contexts>
|
||||||
<Context baseurl="request" name="Default Context">
|
<Context baseurl="request" name="Default Context">
|
||||||
<Format ref="oaidc" />
|
<!-- Restrict access to hidden items by default -->
|
||||||
<Format ref="mets" />
|
<Filter ref="defaultFilter" />
|
||||||
<Format ref="xoai" />
|
|
||||||
<Format ref="didl" />
|
<Format ref="oaidc"/>
|
||||||
<Format ref="dim" />
|
<Format ref="mets"/>
|
||||||
<Format ref="ore" />
|
<Format ref="xoai"/>
|
||||||
<Format ref="rdf" />
|
<Format ref="didl"/>
|
||||||
<Format ref="etdms" />
|
<Format ref="dim"/>
|
||||||
<Format ref="mods" />
|
<Format ref="ore"/>
|
||||||
<Format ref="qdc" />
|
<Format ref="rdf"/>
|
||||||
<Format ref="marc" />
|
<Format ref="etdms"/>
|
||||||
<Format ref="uketd_dc" />
|
<Format ref="mods"/>
|
||||||
|
<Format ref="qdc"/>
|
||||||
|
<Format ref="marc"/>
|
||||||
|
<Format ref="uketd_dc"/>
|
||||||
<!--<Format ref="junii2" />-->
|
<!--<Format ref="junii2" />-->
|
||||||
<Description>
|
<Description>
|
||||||
This is the default context of the DSpace data provider.
|
This is the default context of the DSpace data provider.
|
||||||
@@ -44,13 +47,13 @@
|
|||||||
<!-- Date format, field prefixes, etc are ensured by the transformer -->
|
<!-- Date format, field prefixes, etc are ensured by the transformer -->
|
||||||
<Transformer ref="driverTransformer"/>
|
<Transformer ref="driverTransformer"/>
|
||||||
<!-- The driver filter -->
|
<!-- The driver filter -->
|
||||||
<Filter ref="driverFilter" />
|
<Filter ref="driverFilter"/>
|
||||||
<!-- Just an alias, if fact it returns all items within the driver context -->
|
<!-- Just an alias, if fact it returns all items within the driver context -->
|
||||||
<Set ref="driverSet" />
|
<Set ref="driverSet"/>
|
||||||
<!-- Metadata Formats -->
|
<!-- Metadata Formats -->
|
||||||
<Format ref="oaidc"/>
|
<Format ref="oaidc"/>
|
||||||
<Format ref="mets" />
|
<Format ref="mets"/>
|
||||||
<Format ref="didl" />
|
<Format ref="didl"/>
|
||||||
<Description>
|
<Description>
|
||||||
This contexts complains with Driver rules.
|
This contexts complains with Driver rules.
|
||||||
</Description>
|
</Description>
|
||||||
@@ -67,14 +70,14 @@
|
|||||||
-->
|
-->
|
||||||
<Context baseurl="openaire" name="OpenAIRE Context">
|
<Context baseurl="openaire" name="OpenAIRE Context">
|
||||||
<!-- Date format, field prefixes, etc are ensured by the transformer -->
|
<!-- Date format, field prefixes, etc are ensured by the transformer -->
|
||||||
<Transformer ref="openaireTransformer" />
|
<Transformer ref="openaireTransformer"/>
|
||||||
<!-- OpenAIRE filter -->
|
<!-- OpenAIRE filter -->
|
||||||
<Filter ref="openAireFilter" />
|
<Filter ref="openAireFilter"/>
|
||||||
<!-- Just an alias, if fact it returns all items within the driver context -->
|
<!-- Just an alias, if fact it returns all items within the driver context -->
|
||||||
<Set ref="openaireSet" />
|
<Set ref="openaireSet"/>
|
||||||
<!-- Metadata Formats -->
|
<!-- Metadata Formats -->
|
||||||
<Format ref="oaidc" />
|
<Format ref="oaidc"/>
|
||||||
<Format ref="mets" />
|
<Format ref="mets"/>
|
||||||
<Description>
|
<Description>
|
||||||
This contexts complains with OpenAIRE rules.
|
This contexts complains with OpenAIRE rules.
|
||||||
</Description>
|
</Description>
|
||||||
@@ -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 ref="uketdDcFilter"/>
|
||||||
<Filter refid="thesisFilter" />
|
|
||||||
=======
|
|
||||||
<Filter ref="uketdDcFilter" />
|
|
||||||
>>>>>>> 7c0f545... OAI 2.1
|
|
||||||
</Format>
|
</Format>
|
||||||
<Format id="junii2">
|
<Format id="junii2">
|
||||||
<Prefix>junii2</Prefix>
|
<Prefix>junii2</Prefix>
|
||||||
@@ -186,25 +186,25 @@
|
|||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<And>
|
<And>
|
||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<Custom ref="titleExistsCondition" />
|
<Custom ref="titleExistsCondition"/>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<Custom ref="authorExistsCondition" />
|
<Custom ref="authorExistsCondition"/>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
</And>
|
</And>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<And>
|
<And>
|
||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<Custom ref="driverDocumentTypeCondition" />
|
<Custom ref="driverDocumentTypeCondition"/>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<And>
|
<And>
|
||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<Custom ref="bitstreamAccessCondition" />
|
<Custom ref="bitstreamAccessCondition"/>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<Custom ref="driverAccessCondition" />
|
<Custom ref="driverAccessCondition"/>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
</And>
|
</And>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
@@ -220,20 +220,20 @@
|
|||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<And>
|
<And>
|
||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<Custom ref="titleExistsFilter" />
|
<Custom ref="titleExistsFilter"/>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<Custom ref="authorExistsFilter" />
|
<Custom ref="authorExistsFilter"/>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
</And>
|
</And>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<And>
|
<And>
|
||||||
<LeftCondition>
|
<LeftCondition>
|
||||||
<Custom ref="driverDocumentTypeFilter" />
|
<Custom ref="driverDocumentTypeFilter"/>
|
||||||
</LeftCondition>
|
</LeftCondition>
|
||||||
<RightCondition>
|
<RightCondition>
|
||||||
<Custom ref="openaireRelationFilter" />
|
<Custom ref="openaireRelationFilter"/>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
</And>
|
</And>
|
||||||
</RightCondition>
|
</RightCondition>
|
||||||
@@ -243,7 +243,13 @@
|
|||||||
|
|
||||||
<Filter id="uketdDcFilter">
|
<Filter id="uketdDcFilter">
|
||||||
<Definition>
|
<Definition>
|
||||||
<Custom ref="thesisDocumentTypeCondition" />
|
<Custom ref="thesisDocumentTypeCondition"/>
|
||||||
|
</Definition>
|
||||||
|
</Filter>
|
||||||
|
|
||||||
|
<Filter id="defaultFilter">
|
||||||
|
<Definition>
|
||||||
|
<Custom ref="bitstreamAccessCondition"/>
|
||||||
</Definition>
|
</Definition>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
||||||
@@ -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