mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 10:34:25 +00:00
Merge remote-tracking branch 'upstream/master' into DS-626
# Conflicts: # dspace/config/spring/api/core-factory-services.xml # dspace/config/spring/api/core-services.xml # dspace/src/main/config/build.xml
This commit is contained in:
@@ -20,11 +20,15 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- assetstore:/dspace/assetstore
|
- assetstore:/dspace/assetstore
|
||||||
- ./dspace/src/main/docker-compose/local.cfg:/dspace/config/local.cfg
|
- ./dspace/src/main/docker-compose/local.cfg:/dspace/config/local.cfg
|
||||||
# Ensure that the database is ready before starting tomcat
|
# Ensure that the database is ready BEFORE starting tomcat
|
||||||
|
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||||
|
# 2. Then, run database migration to init database tables
|
||||||
|
# 3. Finally, start Tomcat
|
||||||
entrypoint:
|
entrypoint:
|
||||||
- /bin/bash
|
- /bin/bash
|
||||||
- '-c'
|
- '-c'
|
||||||
- |
|
- |
|
||||||
|
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
||||||
/dspace/bin/dspace database migrate
|
/dspace/bin/dspace database migrate
|
||||||
catalina.sh run
|
catalina.sh run
|
||||||
dspacedb:
|
dspacedb:
|
||||||
@@ -34,6 +38,9 @@ services:
|
|||||||
image: dspace/dspace-postgres-pgcrypto
|
image: dspace/dspace-postgres-pgcrypto
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
dspacenet:
|
||||||
|
ports:
|
||||||
|
- published: 5432
|
||||||
|
target: 5432
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
|
@@ -296,16 +296,7 @@
|
|||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-core</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.jboss.logging</groupId>
|
|
||||||
<artifactId>jboss-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-ehcache</artifactId>
|
<artifactId>hibernate-ehcache</artifactId>
|
||||||
@@ -315,10 +306,11 @@
|
|||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate.validator</groupId>
|
||||||
<artifactId>hibernate-validator-cdi</artifactId>
|
<artifactId>hibernate-validator-cdi</artifactId>
|
||||||
<version>${hibernate-validator.version}</version>
|
<version>${hibernate-validator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-orm</artifactId>
|
<artifactId>spring-orm</artifactId>
|
||||||
@@ -355,28 +347,6 @@
|
|||||||
<groupId>org.apache.jena</groupId>
|
<groupId>org.apache.jena</groupId>
|
||||||
<artifactId>apache-jena-libs</artifactId>
|
<artifactId>apache-jena-libs</artifactId>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-cli</groupId>
|
|
||||||
<artifactId>commons-cli</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
@@ -434,18 +404,6 @@
|
|||||||
<groupId>org.jdom</groupId>
|
<groupId>org.jdom</groupId>
|
||||||
<artifactId>jdom</artifactId>
|
<artifactId>jdom</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-1.2-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
<artifactId>log4j-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>oro</groupId>
|
<groupId>oro</groupId>
|
||||||
<artifactId>oro</artifactId>
|
<artifactId>oro</artifactId>
|
||||||
@@ -458,10 +416,6 @@
|
|||||||
<groupId>org.apache.pdfbox</groupId>
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
<artifactId>fontbox</artifactId>
|
<artifactId>fontbox</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-scratchpad</artifactId>
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
@@ -481,12 +435,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xerces</groupId>
|
<groupId>xerces</groupId>
|
||||||
<artifactId>xercesImpl</artifactId>
|
<artifactId>xercesImpl</artifactId>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xml-apis</groupId>
|
|
||||||
<artifactId>xml-apis</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xml-apis</groupId>
|
<groupId>xml-apis</groupId>
|
||||||
@@ -539,66 +487,21 @@
|
|||||||
<artifactId>rome-modules</artifactId>
|
<artifactId>rome-modules</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>gr.ekt.bte</groupId>
|
|
||||||
<artifactId>bte-core</artifactId>
|
|
||||||
<version>0.9.3.5</version>
|
|
||||||
<exclusions>
|
|
||||||
<!-- A more recent version is retrieved from another dependency -->
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.ekt.bte</groupId>
|
<groupId>gr.ekt.bte</groupId>
|
||||||
<artifactId>bte-io</artifactId>
|
<artifactId>bte-io</artifactId>
|
||||||
<version>0.9.3.5</version>
|
<version>0.9.3.5</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<!-- A more recent version is retrieved from another dependency -->
|
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>net.bytebuddy</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>byte-buddy</artifactId>
|
||||||
</exclusion>
|
|
||||||
<!-- A more recent version is retrieved from another dependency -->
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.solr</groupId>
|
|
||||||
<artifactId>solr-solrj</artifactId>
|
|
||||||
<version>${solr.client.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.solr</groupId>
|
<groupId>org.apache.solr</groupId>
|
||||||
@@ -606,10 +509,6 @@
|
|||||||
<version>${solr.client.version}</version>
|
<version>${solr.client.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-configuration2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.maxmind.geoip2</groupId>
|
<groupId>com.maxmind.geoip2</groupId>
|
||||||
<artifactId>geoip2</artifactId>
|
<artifactId>geoip2</artifactId>
|
||||||
@@ -625,12 +524,6 @@
|
|||||||
<version>2.1.7</version>
|
<version>2.1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.lucene</groupId>
|
|
||||||
<artifactId>lucene-core</artifactId>
|
|
||||||
<version>${solr.client.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.coverity.security</groupId>
|
<groupId>com.coverity.security</groupId>
|
||||||
<artifactId>coverity-escapers</artifactId>
|
<artifactId>coverity-escapers</artifactId>
|
||||||
@@ -655,11 +548,6 @@
|
|||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jdbm</groupId>
|
<groupId>jdbm</groupId>
|
||||||
<artifactId>jdbm</artifactId>
|
<artifactId>jdbm</artifactId>
|
||||||
@@ -744,12 +632,6 @@
|
|||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
<version>1.10.50</version>
|
<version>1.10.50</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- For ORCID v2 integration -->
|
<!-- For ORCID v2 integration -->
|
||||||
@@ -791,6 +673,7 @@
|
|||||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||||
<version>1.0.0.Final</version>
|
<version>1.0.0.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -19,6 +19,7 @@ import org.dspace.content.Item;
|
|||||||
* @author Stuart Lewis
|
* @author Stuart Lewis
|
||||||
*/
|
*/
|
||||||
public class BulkEditChange {
|
public class BulkEditChange {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item these changes relate to
|
* The item these changes relate to
|
||||||
*/
|
*/
|
||||||
|
@@ -50,9 +50,11 @@ import org.dspace.content.service.CollectionService;
|
|||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCommunity;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -200,8 +202,8 @@ public class SyndicationFeed {
|
|||||||
logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
|
logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
|
||||||
} else {
|
} else {
|
||||||
Bitstream logo = null;
|
Bitstream logo = null;
|
||||||
if (dso.getType() == Constants.COLLECTION) {
|
if (dso instanceof IndexableCollection) {
|
||||||
Collection col = (Collection) dso;
|
Collection col = ((IndexableCollection) dso).getIndexedObject();
|
||||||
defaultTitle = col.getName();
|
defaultTitle = col.getName();
|
||||||
feed.setDescription(collectionService.getMetadata(col, "short_description"));
|
feed.setDescription(collectionService.getMetadata(col, "short_description"));
|
||||||
logo = col.getLogo();
|
logo = col.getLogo();
|
||||||
@@ -210,8 +212,8 @@ public class SyndicationFeed {
|
|||||||
podcastFeed = true;
|
podcastFeed = true;
|
||||||
}
|
}
|
||||||
objectURL = resolveURL(request, col);
|
objectURL = resolveURL(request, col);
|
||||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
} else if (dso instanceof IndexableCommunity) {
|
||||||
Community comm = (Community) dso;
|
Community comm = ((IndexableCommunity) dso).getIndexedObject();
|
||||||
defaultTitle = comm.getName();
|
defaultTitle = comm.getName();
|
||||||
feed.setDescription(communityService.getMetadata(comm, "short_description"));
|
feed.setDescription(communityService.getMetadata(comm, "short_description"));
|
||||||
logo = comm.getLogo();
|
logo = comm.getLogo();
|
||||||
@@ -251,10 +253,10 @@ public class SyndicationFeed {
|
|||||||
if (items != null) {
|
if (items != null) {
|
||||||
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
||||||
for (IndexableObject idxObj : items) {
|
for (IndexableObject idxObj : items) {
|
||||||
if (idxObj.getType() != Constants.ITEM) {
|
if (!(idxObj instanceof IndexableItem)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Item item = (Item) idxObj;
|
Item item = ((IndexableItem) idxObj).getIndexedObject();
|
||||||
boolean hasDate = false;
|
boolean hasDate = false;
|
||||||
SyndEntry entry = new SyndEntryImpl();
|
SyndEntry entry = new SyndEntryImpl();
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
|
@@ -12,6 +12,8 @@ import org.dspace.content.Community;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCommunity;
|
||||||
import org.dspace.sort.SortException;
|
import org.dspace.sort.SortException;
|
||||||
import org.dspace.sort.SortOption;
|
import org.dspace.sort.SortOption;
|
||||||
|
|
||||||
@@ -136,10 +138,10 @@ public class BrowserScope {
|
|||||||
*/
|
*/
|
||||||
public void setBrowseContainer(IndexableObject dso)
|
public void setBrowseContainer(IndexableObject dso)
|
||||||
throws BrowseException {
|
throws BrowseException {
|
||||||
if (dso instanceof Collection) {
|
if (dso instanceof IndexableCollection) {
|
||||||
this.collection = (Collection) dso;
|
this.collection = ((IndexableCollection) dso).getIndexedObject();
|
||||||
} else if (dso instanceof Community) {
|
} else if (dso instanceof IndexableCommunity) {
|
||||||
this.community = (Community) dso;
|
this.community = ((IndexableCommunity) dso).getIndexedObject();
|
||||||
} else {
|
} else {
|
||||||
throw new BrowseException("The container must be a community or a collection");
|
throw new BrowseException("The container must be a community or a collection");
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import org.dspace.discovery.DiscoverResult.FacetResult;
|
|||||||
import org.dspace.discovery.SearchService;
|
import org.dspace.discovery.SearchService;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +123,7 @@ public class ItemCountDAOSolr implements ItemCountDAO {
|
|||||||
query.addFacetField(new DiscoverFacetField("location.coll",
|
query.addFacetField(new DiscoverFacetField("location.coll",
|
||||||
DiscoveryConfigurationParameters.TYPE_STANDARD, -1,
|
DiscoveryConfigurationParameters.TYPE_STANDARD, -1,
|
||||||
DiscoveryConfigurationParameters.SORT.COUNT));
|
DiscoveryConfigurationParameters.SORT.COUNT));
|
||||||
query.addFilterQueries("search.resourcetype:2"); // count only items
|
query.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE); // count only items
|
||||||
query.addFilterQueries("NOT(discoverable:false)"); // only discoverable
|
query.addFilterQueries("NOT(discoverable:false)"); // only discoverable
|
||||||
query.setMaxResults(0);
|
query.setMaxResults(0);
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.DiscoverFacetField;
|
import org.dspace.discovery.DiscoverFacetField;
|
||||||
import org.dspace.discovery.DiscoverQuery;
|
import org.dspace.discovery.DiscoverQuery;
|
||||||
@@ -32,6 +31,7 @@ import org.dspace.discovery.IndexableObject;
|
|||||||
import org.dspace.discovery.SearchService;
|
import org.dspace.discovery.SearchService;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,7 +207,7 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
}
|
}
|
||||||
// filter on item to be sure to don't include any other object
|
// filter on item to be sure to don't include any other object
|
||||||
// indexed in the Discovery Search core
|
// indexed in the Discovery Search core
|
||||||
query.addFilterQueries("search.resourcetype:" + Constants.ITEM);
|
query.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE);
|
||||||
if (orderField != null) {
|
if (orderField != null) {
|
||||||
query.setSortField("bi_" + orderField + "_sort",
|
query.setSortField("bi_" + orderField + "_sort",
|
||||||
ascending ? SORT_ORDER.asc : SORT_ORDER.desc);
|
ascending ? SORT_ORDER.asc : SORT_ORDER.desc);
|
||||||
@@ -297,10 +297,10 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
DiscoverResult resp = getSolrResponse();
|
DiscoverResult resp = getSolrResponse();
|
||||||
|
|
||||||
List<Item> bitems = new ArrayList<>();
|
List<Item> bitems = new ArrayList<>();
|
||||||
for (IndexableObject<UUID> solrDoc : resp.getIndexableObjects()) {
|
for (IndexableObject solrDoc : resp.getIndexableObjects()) {
|
||||||
// FIXME introduce project, don't retrieve Item immediately when
|
// FIXME introduce project, don't retrieve Item immediately when
|
||||||
// processing the query...
|
// processing the query...
|
||||||
Item item = (Item) solrDoc;
|
Item item = ((IndexableItem) solrDoc).getIndexedObject();
|
||||||
bitems.add(item);
|
bitems.add(item);
|
||||||
}
|
}
|
||||||
return bitems;
|
return bitems;
|
||||||
@@ -311,7 +311,7 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
throws BrowseException {
|
throws BrowseException {
|
||||||
DiscoverQuery query = new DiscoverQuery();
|
DiscoverQuery query = new DiscoverQuery();
|
||||||
query.setQuery("search.resourceid:" + itemID
|
query.setQuery("search.resourceid:" + itemID
|
||||||
+ " AND search.resourcetype:" + Constants.ITEM);
|
+ " AND search.resourcetype:" + IndexableItem.TYPE);
|
||||||
query.setMaxResults(1);
|
query.setMaxResults(1);
|
||||||
DiscoverResult resp = null;
|
DiscoverResult resp = null;
|
||||||
try {
|
try {
|
||||||
@@ -334,7 +334,7 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
addLocationScopeFilter(query);
|
addLocationScopeFilter(query);
|
||||||
addStatusFilter(query);
|
addStatusFilter(query);
|
||||||
query.setMaxResults(0);
|
query.setMaxResults(0);
|
||||||
query.addFilterQueries("search.resourcetype:" + Constants.ITEM);
|
query.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE);
|
||||||
|
|
||||||
// We need to take into account the fact that we may be in a subset of the items
|
// We need to take into account the fact that we may be in a subset of the items
|
||||||
if (authority != null) {
|
if (authority != null) {
|
||||||
|
@@ -12,7 +12,6 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -32,7 +31,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
@@ -55,7 +53,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "collection")
|
@Table(name = "collection")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||||
|
|
||||||
@Column(name = "collection_id", insertable = false, updatable = false)
|
@Column(name = "collection_id", insertable = false, updatable = false)
|
||||||
private Integer legacyId;
|
private Integer legacyId;
|
||||||
@@ -331,9 +329,4 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
|||||||
return collectionService;
|
return collectionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeText() {
|
|
||||||
return Constants.typeText[Constants.COLLECTION];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@ import org.dspace.harvest.HarvestedCollection;
|
|||||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
|
import org.dspace.xmlworkflow.XmlWorkflowFactoryImpl;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
||||||
import org.dspace.xmlworkflow.state.Workflow;
|
import org.dspace.xmlworkflow.state.Workflow;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
||||||
@@ -277,15 +278,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
return collectionDAO.findByID(context, Collection.class, id);
|
return collectionDAO.findByID(context, Collection.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
|
||||||
* and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public Collection findIndexableObject(Context context, UUID id) throws SQLException {
|
|
||||||
return collectionDAO.findByID(context, Collection.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMetadata(Context context, Collection collection, String field, String value)
|
public void setMetadata(Context context, Collection collection, String field, String value)
|
||||||
throws MissingResourceException, SQLException {
|
throws MissingResourceException, SQLException {
|
||||||
@@ -379,11 +371,11 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
Workflow workflow = null;
|
Workflow workflow = null;
|
||||||
try {
|
try {
|
||||||
workflow = workflowFactory.getWorkflow(collection);
|
workflow = workflowFactory.getWorkflow(collection);
|
||||||
} catch (IOException | WorkflowConfigurationException e) {
|
} catch (WorkflowConfigurationException e) {
|
||||||
log.error(LogManager.getHeader(context, "setWorkflowGroup",
|
log.error(LogManager.getHeader(context, "setWorkflowGroup",
|
||||||
"collection_id=" + collection.getID() + " " + e.getMessage()), e);
|
"collection_id=" + collection.getID() + " " + e.getMessage()), e);
|
||||||
}
|
}
|
||||||
if (!StringUtils.equals(XmlWorkflowFactory.LEGACY_WORKFLOW_NAME, workflow.getID())) {
|
if (!StringUtils.equals(XmlWorkflowFactoryImpl.LEGACY_WORKFLOW_NAME, workflow.getID())) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"setWorkflowGroup can be used only on collection with the default basic dspace workflow. "
|
"setWorkflowGroup can be used only on collection with the default basic dspace workflow. "
|
||||||
+ "Instead, the collection: "
|
+ "Instead, the collection: "
|
||||||
@@ -794,15 +786,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
return Constants.COLLECTION;
|
return Constants.COLLECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
|
||||||
* IndexableObjectService interface and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return getSupportsTypeConstant();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
||||||
List<Collection> myResults = new ArrayList<>();
|
List<Collection> myResults = new ArrayList<>();
|
||||||
|
@@ -11,7 +11,6 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -32,7 +31,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
@@ -51,7 +49,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "community")
|
@Table(name = "community")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
@@ -254,11 +252,6 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
return Constants.COMMUNITY;
|
return Constants.COMMUNITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeText() {
|
|
||||||
return Constants.typeText[Constants.COMMUNITY];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String value = getCommunityService()
|
String value = getCommunityService()
|
||||||
|
@@ -137,15 +137,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
return communityDAO.findByID(context, Community.class, id);
|
return communityDAO.findByID(context, Community.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
|
||||||
* and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public Community findIndexableObject(Context context, UUID id) throws SQLException {
|
|
||||||
return find(context, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Community> findAll(Context context) throws SQLException {
|
public List<Community> findAll(Context context) throws SQLException {
|
||||||
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
@@ -520,15 +511,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
return Constants.COMMUNITY;
|
return Constants.COMMUNITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
|
||||||
* IndexableObjectService interface and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return getSupportsTypeConstant();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to remove the community and all its children from the
|
* Internal method to remove the community and all its children from the
|
||||||
* database, and perform any pre/post-cleanup
|
* database, and perform any pre/post-cleanup
|
||||||
|
@@ -7,10 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,13 +19,13 @@ import org.dspace.eperson.EPerson;
|
|||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmission<ID extends Serializable> extends IndexableObject<ID> {
|
public interface InProgressSubmission extends ReloadableEntity<Integer> {
|
||||||
/**
|
/**
|
||||||
* Get the internal ID of this submission
|
* Get the internal ID of this submission
|
||||||
*
|
*
|
||||||
* @return the internal identifier
|
* @return the internal identifier
|
||||||
*/
|
*/
|
||||||
ID getID();
|
Integer getID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the incomplete item object
|
* Get the incomplete item object
|
||||||
@@ -48,7 +47,7 @@ public interface InProgressSubmission<ID extends Serializable> extends Indexable
|
|||||||
* @return the submitting e-person
|
* @return the submitting e-person
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
EPerson getSubmitter() throws SQLException;
|
EPerson getSubmitter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if the submission has (or is intended to have) more than one
|
* Find out if the submission has (or is intended to have) more than one
|
||||||
|
@@ -13,7 +13,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -35,7 +34,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
|
|
||||||
@@ -55,7 +53,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "item")
|
@Table(name = "item")
|
||||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
@@ -376,10 +374,4 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, Ind
|
|||||||
}
|
}
|
||||||
return itemService;
|
return itemService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTypeText() {
|
|
||||||
return getItemService().getTypeText(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -172,15 +172,6 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
|
||||||
* and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public Item findIndexableObject(Context context, UUID id) throws SQLException {
|
|
||||||
return find(context, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException {
|
public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException {
|
||||||
if (workspaceItem.getItem() != null) {
|
if (workspaceItem.getItem() != null) {
|
||||||
@@ -677,15 +668,6 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return Constants.ITEM;
|
return Constants.ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
|
||||||
* IndexableObjectService interface and the DSpaceObjectService interface
|
|
||||||
*/
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return getSupportsTypeConstant();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
||||||
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,10 +26,7 @@ import javax.persistence.SequenceGenerator;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
@@ -45,7 +41,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "workspaceitem")
|
@Table(name = "workspaceitem")
|
||||||
public class WorkspaceItem
|
public class WorkspaceItem
|
||||||
implements InProgressSubmission<Integer>, Serializable, ReloadableEntity<Integer>, IndexableObject<Integer> {
|
implements InProgressSubmission, Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
||||||
@@ -197,7 +193,7 @@ public class WorkspaceItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EPerson getSubmitter() throws SQLException {
|
public EPerson getSubmitter() {
|
||||||
return item.getSubmitter();
|
return item.getSubmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,10 +238,4 @@ public class WorkspaceItem
|
|||||||
void addSupervisorGroup(Group group) {
|
void addSupervisorGroup(Group group) {
|
||||||
supervisorGroups.add(group);
|
supervisorGroups.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return Constants.WORKSPACEITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -60,11 +60,6 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return Constants.WORKSPACEITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItem find(Context context, int id) throws SQLException {
|
public WorkspaceItem find(Context context, int id) throws SQLException {
|
||||||
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
||||||
@@ -83,14 +78,6 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
|||||||
return workspaceItem;
|
return workspaceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkspaceItem findIndexableObject(Context context, Integer id) throws SQLException {
|
|
||||||
if (id != null) {
|
|
||||||
return find(context, id);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content.factory;
|
package org.dspace.content.factory;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
@@ -24,7 +23,6 @@ import org.dspace.content.service.DSpaceObjectService;
|
|||||||
import org.dspace.content.service.EntityService;
|
import org.dspace.content.service.EntityService;
|
||||||
import org.dspace.content.service.EntityTypeService;
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.InProgressSubmissionService;
|
import org.dspace.content.service.InProgressSubmissionService;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -35,7 +33,6 @@ import org.dspace.content.service.RelationshipTypeService;
|
|||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
|
||||||
@@ -47,13 +44,6 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|||||||
*/
|
*/
|
||||||
public abstract class ContentServiceFactory {
|
public abstract class ContentServiceFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the list of all the available implementations of the IndexableObjectService interface
|
|
||||||
*
|
|
||||||
* @return the list of IndexableObjectService
|
|
||||||
*/
|
|
||||||
public abstract List<IndexableObjectService> getIndexableObjectServices();
|
|
||||||
|
|
||||||
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
||||||
|
|
||||||
public abstract List<DSpaceObjectLegacySupportService<? extends DSpaceObject>>
|
public abstract List<DSpaceObjectLegacySupportService<? extends DSpaceObject>>
|
||||||
@@ -142,18 +132,6 @@ public abstract class ContentServiceFactory {
|
|||||||
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
throw new UnsupportedOperationException("Unknown DSpace type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T extends IndexableObject<PK>, PK extends Serializable> IndexableObjectService<T, PK>
|
|
||||||
getIndexableObjectService(int type) {
|
|
||||||
for (int i = 0; i < getIndexableObjectServices().size(); i++) {
|
|
||||||
IndexableObjectService objectService = getIndexableObjectServices().get(i);
|
|
||||||
if (objectService.getSupportsIndexableObjectTypeConstant() == type) {
|
|
||||||
return (IndexableObjectService<T, PK>) objectService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new UnsupportedOperationException("Unknown Findable Object type: " + type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
||||||
for (int i = 0; i < getDSpaceObjectLegacySupportServices().size(); i++) {
|
for (int i = 0; i < getDSpaceObjectLegacySupportServices().size(); i++) {
|
||||||
DSpaceObjectLegacySupportService<? extends DSpaceObject> objectLegacySupportService =
|
DSpaceObjectLegacySupportService<? extends DSpaceObject> objectLegacySupportService =
|
||||||
|
@@ -20,7 +20,6 @@ import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
|||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
import org.dspace.content.service.EntityService;
|
import org.dspace.content.service.EntityService;
|
||||||
import org.dspace.content.service.EntityTypeService;
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -31,7 +30,6 @@ import org.dspace.content.service.RelationshipTypeService;
|
|||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
import org.dspace.utils.DSpace;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,11 +83,6 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private EntityService entityService;
|
private EntityService entityService;
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IndexableObjectService> getIndexableObjectServices() {
|
|
||||||
return new DSpace().getServiceManager().getServicesByType(IndexableObjectService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
public List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices() {
|
||||||
return dSpaceObjectServices;
|
return dSpaceObjectServices;
|
||||||
|
@@ -13,7 +13,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -31,8 +30,7 @@ import org.dspace.eperson.Group;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface CollectionService
|
public interface CollectionService
|
||||||
extends DSpaceObjectService<Collection>, DSpaceObjectLegacySupportService<Collection>,
|
extends DSpaceObjectService<Collection>, DSpaceObjectLegacySupportService<Collection> {
|
||||||
IndexableObjectService<Collection, UUID> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new collection with a new ID.
|
* Create a new collection with a new ID.
|
||||||
|
@@ -12,7 +12,6 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -28,8 +27,7 @@ import org.dspace.eperson.Group;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community>,
|
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community> {
|
||||||
IndexableObjectService<Community, UUID> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content.service;
|
package org.dspace.content.service;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.app.util.DCInputsReaderException;
|
import org.dspace.app.util.DCInputsReaderException;
|
||||||
@@ -25,8 +24,7 @@ import org.dspace.core.Context;
|
|||||||
* @param <T> class type
|
* @param <T> class type
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmissionService<T extends InProgressSubmission<ID>, ID extends Serializable>
|
public interface InProgressSubmissionService<T extends InProgressSubmission> {
|
||||||
extends IndexableObjectService<T, ID> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes submission wrapper, doesn't delete item contents
|
* Deletes submission wrapper, doesn't delete item contents
|
||||||
|
@@ -1,44 +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.content.service;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import org.dspace.core.Context;
|
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base Service interface class for any IndexableObject. The name of the methods contains IndexableObject to avoid
|
|
||||||
* ambiguity reference as some implementation supports both this interface than the DSpaceObectService interface
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* class type of the indexable object
|
|
||||||
* @param <PK>
|
|
||||||
* class type of the primary key
|
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
|
||||||
*/
|
|
||||||
public interface IndexableObjectService<T extends IndexableObject<PK>, PK extends Serializable> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic find for when the precise type of an IndexableObject is not known
|
|
||||||
*
|
|
||||||
* @param context - the context
|
|
||||||
* @param id - id within table of type'd indexable objects
|
|
||||||
* @return the indexable object found, or null if it does not exist.
|
|
||||||
* @throws SQLException only upon failure accessing the database.
|
|
||||||
*/
|
|
||||||
public T findIndexableObject(Context context, PK id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Constants which this service supports
|
|
||||||
*
|
|
||||||
* @return a org.dspace.core.Constants that represents a IndexableObject type
|
|
||||||
*/
|
|
||||||
public int getSupportsIndexableObjectTypeConstant();
|
|
||||||
}
|
|
@@ -38,7 +38,7 @@ import org.dspace.eperson.Group;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ItemService
|
public interface ItemService
|
||||||
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item>, IndexableObjectService<Item, UUID> {
|
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item> {
|
||||||
|
|
||||||
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem, Integer> {
|
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a workspace item from the database. The item, collection and
|
* Get a workspace item from the database. The item, collection and
|
||||||
|
@@ -55,31 +55,11 @@ public class Constants {
|
|||||||
*/
|
*/
|
||||||
public static final int EPERSON = 7;
|
public static final int EPERSON = 7;
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of workspace item objects
|
|
||||||
*/
|
|
||||||
public static final int WORKSPACEITEM = 8;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of workflow item objects
|
|
||||||
*/
|
|
||||||
public static final int WORKFLOWITEM = 9;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of pool task objects
|
|
||||||
*/
|
|
||||||
public static final int POOLTASK = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of claimed task objects
|
|
||||||
*/
|
|
||||||
public static final int CLAIMEDTASK = 11;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lets you look up type names from the type IDs
|
* lets you look up type names from the type IDs
|
||||||
*/
|
*/
|
||||||
public static final String[] typeText = { "BITSTREAM", "BUNDLE", "ITEM", "COLLECTION", "COMMUNITY", "SITE", "GROUP",
|
public static final String[] typeText = { "BITSTREAM", "BUNDLE", "ITEM", "COLLECTION", "COMMUNITY", "SITE", "GROUP",
|
||||||
"EPERSON", "WORKSPACEITEM", "WORKFLOWITEM", "POOLTASK", "CLAIMEDTASK" };
|
"EPERSON"};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special Bundle and Bitstream Names:
|
* Special Bundle and Bitstream Names:
|
||||||
|
@@ -31,7 +31,7 @@ public class DiscoverQuery {
|
|||||||
**/
|
**/
|
||||||
private String query;
|
private String query;
|
||||||
private List<String> filterQueries;
|
private List<String> filterQueries;
|
||||||
private int DSpaceObjectFilter = -1;
|
private String DSpaceObjectFilter = null;
|
||||||
private List<String> fieldPresentQueries;
|
private List<String> fieldPresentQueries;
|
||||||
private boolean spellCheck;
|
private boolean spellCheck;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public class DiscoverQuery {
|
|||||||
*
|
*
|
||||||
* @param DSpaceObjectFilter the DSpace object filer
|
* @param DSpaceObjectFilter the DSpace object filer
|
||||||
*/
|
*/
|
||||||
public void setDSpaceObjectFilter(int DSpaceObjectFilter) {
|
public void setDSpaceObjectFilter(String DSpaceObjectFilter) {
|
||||||
this.DSpaceObjectFilter = DSpaceObjectFilter;
|
this.DSpaceObjectFilter = DSpaceObjectFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ public class DiscoverQuery {
|
|||||||
*
|
*
|
||||||
* @return the DSpace object filer
|
* @return the DSpace object filer
|
||||||
*/
|
*/
|
||||||
public int getDSpaceObjectFilter() {
|
public String getDSpaceObjectFilter() {
|
||||||
return DSpaceObjectFilter;
|
return DSpaceObjectFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -243,7 +243,7 @@ public class DiscoverResult {
|
|||||||
String dsoString = SearchDocument.getIndexableObjectStringRepresentation(idxObj);
|
String dsoString = SearchDocument.getIndexableObjectStringRepresentation(idxObj);
|
||||||
List<SearchDocument> result = searchDocuments.get(dsoString);
|
List<SearchDocument> result = searchDocuments.get(dsoString);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return new ArrayList<SearchDocument>();
|
return new ArrayList<>();
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ package org.dspace.discovery;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
@@ -17,11 +18,16 @@ import org.apache.commons.cli.Options;
|
|||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCommunity;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
|
import org.dspace.discovery.indexobject.factory.IndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.IndexObjectFactoryFactory;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.scripts.DSpaceRunnable;
|
import org.dspace.scripts.DSpaceRunnable;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -79,28 +85,42 @@ public class IndexClient extends DSpaceRunnable {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// nothing to do, it should be an handle
|
// nothing to do, it should be an handle
|
||||||
}
|
}
|
||||||
IndexableObject dso = null;
|
Optional<IndexableObject> indexableObject = Optional.empty();
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
dso = ContentServiceFactory.getInstance().getItemService().find(context, uuid);
|
final Item item = ContentServiceFactory.getInstance().getItemService().find(context, uuid);
|
||||||
if (dso == null) {
|
if (item != null) {
|
||||||
|
indexableObject = Optional.of(new IndexableItem(item));
|
||||||
|
} else {
|
||||||
// it could be a community
|
// it could be a community
|
||||||
dso = ContentServiceFactory.getInstance().getCommunityService().find(context, uuid);
|
final Community community = ContentServiceFactory.getInstance().
|
||||||
if (dso == null) {
|
getCommunityService().find(context, uuid);
|
||||||
|
if (community != null) {
|
||||||
|
indexableObject = Optional.of(new IndexableCommunity(community));
|
||||||
|
} else {
|
||||||
// it could be a collection
|
// it could be a collection
|
||||||
dso = ContentServiceFactory.getInstance().getCollectionService().find(context, uuid);
|
final Collection collection = ContentServiceFactory.getInstance().
|
||||||
|
getCollectionService().find(context, uuid);
|
||||||
|
if (collection != null) {
|
||||||
|
indexableObject = Optional.of(new IndexableCollection(collection));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dso = (IndexableObject) HandleServiceFactory.getInstance()
|
final DSpaceObject dso = HandleServiceFactory.getInstance()
|
||||||
.getHandleService().resolveToObject(context, param);
|
.getHandleService().resolveToObject(context, param);
|
||||||
|
if (dso != null) {
|
||||||
|
final IndexFactory indexableObjectService = IndexObjectFactoryFactory.getInstance().
|
||||||
|
getIndexFactoryByType(String.valueOf(dso.getType()));
|
||||||
|
indexableObject = indexableObjectService.findIndexableObject(context, dso.getID().toString());
|
||||||
}
|
}
|
||||||
if (dso == null) {
|
}
|
||||||
|
if (!indexableObject.isPresent()) {
|
||||||
throw new IllegalArgumentException("Cannot resolve " + param + " to a DSpace object");
|
throw new IllegalArgumentException("Cannot resolve " + param + " to a DSpace object");
|
||||||
}
|
}
|
||||||
handler.logInfo("Indexing " + param + " force " + commandLine.hasOption("f"));
|
handler.logInfo("Indexing " + param + " force " + commandLine.hasOption("f"));
|
||||||
final long startTimeMillis = System.currentTimeMillis();
|
final long startTimeMillis = System.currentTimeMillis();
|
||||||
final long count = indexAll(indexer, ContentServiceFactory.getInstance().getItemService(), context,
|
final long count = indexAll(indexer, ContentServiceFactory.getInstance().
|
||||||
dso);
|
getItemService(), context, indexableObject.get());
|
||||||
final long seconds = (System.currentTimeMillis() - startTimeMillis) / 1000;
|
final long seconds = (System.currentTimeMillis() - startTimeMillis) / 1000;
|
||||||
handler.logInfo("Indexed " + count + " object" + (count > 1 ? "s" : "") + " in " + seconds + " seconds");
|
handler.logInfo("Indexed " + count + " object" + (count > 1 ? "s" : "") + " in " + seconds + " seconds");
|
||||||
} else if (indexClientOptions == IndexClientOptions.UPDATE ||
|
} else if (indexClientOptions == IndexClientOptions.UPDATE ||
|
||||||
@@ -163,11 +183,11 @@ public class IndexClient extends DSpaceRunnable {
|
|||||||
|
|
||||||
indexingService.indexContent(context, dso, true, true);
|
indexingService.indexContent(context, dso, true, true);
|
||||||
count++;
|
count++;
|
||||||
if (dso.getType() == Constants.COMMUNITY) {
|
if (dso.getIndexedObject() instanceof Community) {
|
||||||
final Community community = (Community) dso;
|
final Community community = (Community) dso;
|
||||||
final String communityHandle = community.getHandle();
|
final String communityHandle = community.getHandle();
|
||||||
for (final Community subcommunity : community.getSubcommunities()) {
|
for (final Community subcommunity : community.getSubcommunities()) {
|
||||||
count += indexAll(indexingService, itemService, context, subcommunity);
|
count += indexAll(indexingService, itemService, context, new IndexableCommunity(subcommunity));
|
||||||
//To prevent memory issues, discard an object from the cache after processing
|
//To prevent memory issues, discard an object from the cache after processing
|
||||||
context.uncacheEntity(subcommunity);
|
context.uncacheEntity(subcommunity);
|
||||||
}
|
}
|
||||||
@@ -176,13 +196,13 @@ public class IndexClient extends DSpaceRunnable {
|
|||||||
communityHandle);
|
communityHandle);
|
||||||
for (final Collection collection : reloadedCommunity.getCollections()) {
|
for (final Collection collection : reloadedCommunity.getCollections()) {
|
||||||
count++;
|
count++;
|
||||||
indexingService.indexContent(context, collection, true, true);
|
indexingService.indexContent(context, new IndexableCollection(collection), true, true);
|
||||||
count += indexItems(indexingService, itemService, context, collection);
|
count += indexItems(indexingService, itemService, context, collection);
|
||||||
//To prevent memory issues, discard an object from the cache after processing
|
//To prevent memory issues, discard an object from the cache after processing
|
||||||
context.uncacheEntity(collection);
|
context.uncacheEntity(collection);
|
||||||
}
|
}
|
||||||
} else if (dso.getType() == Constants.COLLECTION) {
|
} else if (dso instanceof IndexableCollection) {
|
||||||
count += indexItems(indexingService, itemService, context, (Collection) dso);
|
count += indexItems(indexingService, itemService, context, (Collection) dso.getIndexedObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
@@ -209,7 +229,7 @@ public class IndexClient extends DSpaceRunnable {
|
|||||||
final Iterator<Item> itemIterator = itemService.findByCollection(context, collection);
|
final Iterator<Item> itemIterator = itemService.findByCollection(context, collection);
|
||||||
while (itemIterator.hasNext()) {
|
while (itemIterator.hasNext()) {
|
||||||
Item item = itemIterator.next();
|
Item item = itemIterator.next();
|
||||||
indexingService.indexContent(context, item, true, false);
|
indexingService.indexContent(context, new IndexableItem(item), true, false);
|
||||||
count++;
|
count++;
|
||||||
//To prevent memory issues, discard an object from the cache after processing
|
//To prevent memory issues, discard an object from the cache after processing
|
||||||
context.uncacheEntity(item);
|
context.uncacheEntity(item);
|
||||||
|
@@ -15,6 +15,7 @@ import org.dspace.content.Bundle;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.factory.IndexObjectFactoryFactory;
|
||||||
import org.dspace.event.Consumer;
|
import org.dspace.event.Consumer;
|
||||||
import org.dspace.event.Event;
|
import org.dspace.event.Event;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -33,15 +34,17 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IndexEventConsumer.class);
|
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IndexEventConsumer.class);
|
||||||
|
|
||||||
// collect Items, Collections, Communities that need indexing
|
// collect Items, Collections, Communities that need indexing
|
||||||
private Set<IndexableObject> objectsToUpdate = null;
|
private Set<IndexableObject> objectsToUpdate = new HashSet<>();
|
||||||
|
|
||||||
// unique search IDs to delete
|
// unique search IDs to delete
|
||||||
private Set<String> uniqueIdsToDelete = null;
|
private Set<String> uniqueIdsToDelete = new HashSet<>();
|
||||||
|
|
||||||
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager()
|
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
.getServiceByName(IndexingService.class.getName(),
|
.getServiceByName(IndexingService.class.getName(),
|
||||||
IndexingService.class);
|
IndexingService.class);
|
||||||
|
|
||||||
|
IndexObjectFactoryFactory indexObjectServiceFactory = IndexObjectFactoryFactory.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
|
|
||||||
@@ -58,8 +61,8 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
public void consume(Context ctx, Event event) throws Exception {
|
public void consume(Context ctx, Event event) throws Exception {
|
||||||
|
|
||||||
if (objectsToUpdate == null) {
|
if (objectsToUpdate == null) {
|
||||||
objectsToUpdate = new HashSet<IndexableObject>();
|
objectsToUpdate = new HashSet<>();
|
||||||
uniqueIdsToDelete = new HashSet<String>();
|
uniqueIdsToDelete = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int st = event.getSubjectType();
|
int st = event.getSubjectType();
|
||||||
@@ -103,11 +106,11 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
if (subject == null) {
|
if (subject == null) {
|
||||||
log.warn(event.getEventTypeAsString() + " event, could not get object for "
|
log.warn(event.getEventTypeAsString() + " event, could not get object for "
|
||||||
+ event.getSubjectTypeAsString() + " id="
|
+ event.getSubjectTypeAsString() + " id="
|
||||||
+ String.valueOf(event.getSubjectID())
|
+ event.getSubjectID()
|
||||||
+ ", perhaps it has been deleted.");
|
+ ", perhaps it has been deleted.");
|
||||||
} else {
|
} else {
|
||||||
log.debug("consume() adding event to update queue: " + event.toString());
|
log.debug("consume() adding event to update queue: " + event.toString());
|
||||||
objectsToUpdate.add((IndexableObject)subject);
|
objectsToUpdate.addAll(indexObjectServiceFactory.getIndexableObjects(ctx, subject));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -116,11 +119,11 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
log.warn(event.getEventTypeAsString() + " event, could not get object for "
|
log.warn(event.getEventTypeAsString() + " event, could not get object for "
|
||||||
+ event.getObjectTypeAsString() + " id="
|
+ event.getObjectTypeAsString() + " id="
|
||||||
+ String.valueOf(event.getObjectID())
|
+ event.getObjectID()
|
||||||
+ ", perhaps it has been deleted.");
|
+ ", perhaps it has been deleted.");
|
||||||
} else {
|
} else {
|
||||||
log.debug("consume() adding event to update queue: " + event.toString());
|
log.debug("consume() adding event to update queue: " + event.toString());
|
||||||
objectsToUpdate.add((IndexableObject)object);
|
objectsToUpdate.addAll(indexObjectServiceFactory.getIndexableObjects(ctx, subject));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -151,22 +154,21 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
@Override
|
@Override
|
||||||
public void end(Context ctx) throws Exception {
|
public void end(Context ctx) throws Exception {
|
||||||
|
|
||||||
if (objectsToUpdate != null && uniqueIdsToDelete != null) {
|
try {
|
||||||
|
|
||||||
// update the changed Items not deleted because they were on create list
|
// update the changed Items not deleted because they were on create list
|
||||||
for (IndexableObject iu : objectsToUpdate) {
|
for (IndexableObject iu : objectsToUpdate) {
|
||||||
/* we let all types through here and
|
/* we let all types through here and
|
||||||
* allow the search indexer to make
|
* allow the search indexer to make
|
||||||
* decisions on indexing and/or removal
|
* decisions on indexing and/or removal
|
||||||
*/
|
*/
|
||||||
iu = ctx.reloadEntity(iu);
|
iu.setIndexedObject(ctx.reloadEntity(iu.getIndexedObject()));
|
||||||
String uniqueIndexID = iu.getUniqueIndexID();
|
String uniqueIndexID = iu.getUniqueIndexID();
|
||||||
if (uniqueIndexID != null && !uniqueIdsToDelete.contains(uniqueIndexID)) {
|
if (uniqueIndexID != null && !uniqueIdsToDelete.contains(uniqueIndexID)) {
|
||||||
try {
|
try {
|
||||||
indexer.indexContent(ctx, iu, true, true);
|
indexer.indexContent(ctx, iu, true, false);
|
||||||
log.debug("Indexed "
|
log.debug("Indexed "
|
||||||
+ Constants.typeText[iu.getType()]
|
+ iu.getTypeText()
|
||||||
+ ", id=" + String.valueOf(iu.getID())
|
+ ", id=" + iu.getID()
|
||||||
+ ", unique_id=" + uniqueIndexID);
|
+ ", unique_id=" + uniqueIndexID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed while indexing object: ", e);
|
log.error("Failed while indexing object: ", e);
|
||||||
@@ -176,21 +178,24 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
|
|
||||||
for (String uid : uniqueIdsToDelete) {
|
for (String uid : uniqueIdsToDelete) {
|
||||||
try {
|
try {
|
||||||
indexer.unIndexContent(ctx, uid, true);
|
indexer.unIndexContent(ctx, uid, false);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("UN-Indexed Item, handle=" + uid);
|
log.debug("UN-Indexed Item, handle=" + uid);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed while UN-indexing object: " + uid, e);
|
log.error("Failed while UN-indexing object: " + uid, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (!objectsToUpdate.isEmpty() || !uniqueIdsToDelete.isEmpty()) {
|
||||||
|
|
||||||
}
|
indexer.commit();
|
||||||
|
|
||||||
// "free" the resources
|
// "free" the resources
|
||||||
objectsToUpdate = null;
|
objectsToUpdate.clear();
|
||||||
uniqueIdsToDelete = null;
|
uniqueIdsToDelete.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
@@ -20,13 +21,31 @@ import org.dspace.core.ReloadableEntity;
|
|||||||
* @param <PK>
|
* @param <PK>
|
||||||
* the Class of the primary key
|
* the Class of the primary key
|
||||||
*/
|
*/
|
||||||
public interface IndexableObject<PK extends Serializable> extends ReloadableEntity<PK> {
|
public interface IndexableObject<T extends ReloadableEntity, PK extends Serializable> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the integer constant representing the Entity Type, @see {@link Constants}
|
* @return the string constant representing the Entity Type, @see {@link Constants}
|
||||||
*/
|
*/
|
||||||
public int getType();
|
String getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the identifier of this indexableObject, this will be the identifier of the object in the database
|
||||||
|
* @return for a DSpaceObject a uuid will be returned, for a tasks or workflow items an integer will be returned
|
||||||
|
*/
|
||||||
|
PK getID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the entity that is linked to this indexable object
|
||||||
|
* @return a database entity
|
||||||
|
*/
|
||||||
|
T getIndexedObject();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the entity that is linked to this indexable object
|
||||||
|
* @param object the database entity
|
||||||
|
*/
|
||||||
|
void setIndexedObject(T object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -40,8 +59,13 @@ public interface IndexableObject<PK extends Serializable> extends ReloadableEnti
|
|||||||
*
|
*
|
||||||
* @return a textual alias of the Entity Type @see {@link #getType()}
|
* @return a textual alias of the Entity Type @see {@link #getType()}
|
||||||
*/
|
*/
|
||||||
default public String getTypeText() {
|
String getTypeText();
|
||||||
return Constants.typeText[getType()];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the last modified date of an of an object, or if no modification dates are stored, return NUll
|
||||||
|
* @return the last modified date
|
||||||
|
*/
|
||||||
|
default Date getLastModified() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,14 +51,11 @@ public interface IndexingService {
|
|||||||
|
|
||||||
void updateIndex(Context context, boolean force);
|
void updateIndex(Context context, boolean force);
|
||||||
|
|
||||||
void updateIndex(Context context, boolean force, int type);
|
void updateIndex(Context context, boolean force, String type);
|
||||||
|
|
||||||
void cleanIndex(boolean force) throws IOException,
|
void cleanIndex(boolean force) throws IOException,
|
||||||
SQLException, SearchServiceException;
|
SQLException, SearchServiceException;
|
||||||
|
|
||||||
void cleanIndex(boolean force, int type) throws IOException,
|
|
||||||
SQLException, SearchServiceException;
|
|
||||||
|
|
||||||
void commit() throws SearchServiceException;
|
void commit() throws SearchServiceException;
|
||||||
|
|
||||||
void optimize() throws SearchServiceException;
|
void optimize() throws SearchServiceException;
|
||||||
|
@@ -32,6 +32,15 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public class SearchUtils {
|
public class SearchUtils {
|
||||||
|
|
||||||
|
public static final String AUTHORITY_SEPARATOR = "###";
|
||||||
|
public static final String LAST_INDEXED_FIELD = "SolrIndexer.lastIndexed";
|
||||||
|
public static final String RESOURCE_UNIQUE_ID = "search.uniqueid";
|
||||||
|
public static final String RESOURCE_TYPE_FIELD = "search.resourcetype";
|
||||||
|
public static final String RESOURCE_ID_FIELD = "search.resourceid";
|
||||||
|
public static final String NAMED_RESOURCE_TYPE = "namedresourcetype";
|
||||||
|
public static final String FILTER_SEPARATOR = "\n|||\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached search service
|
* Cached search service
|
||||||
**/
|
**/
|
||||||
@@ -161,5 +170,4 @@ public class SearchUtils {
|
|||||||
DiscoveryConfiguration configurationExtra = getDiscoveryConfigurationByName(confName);
|
DiscoveryConfiguration configurationExtra = getDiscoveryConfigurationByName(confName);
|
||||||
result.add(configurationExtra);
|
result.add(configurationExtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.commons.validator.routines.UrlValidator;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.solr.client.solrj.SolrClient;
|
||||||
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
|
import org.apache.solr.client.solrj.SolrRequest;
|
||||||
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
|
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
|
import org.dspace.services.ConfigurationService;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.storage.rdbms.DatabaseUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bean containing the SolrClient for the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class SolrSearchCore {
|
||||||
|
|
||||||
|
private final Logger log = Logger.getLogger(SolrSearchCore.class);
|
||||||
|
@Autowired
|
||||||
|
protected IndexingService indexingService;
|
||||||
|
@Autowired
|
||||||
|
protected ConfigurationService configurationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SolrServer for processing indexing events.
|
||||||
|
*/
|
||||||
|
protected SolrClient solr = null;
|
||||||
|
|
||||||
|
public SolrClient getSolr() {
|
||||||
|
if (solr == null) {
|
||||||
|
initSolr();
|
||||||
|
}
|
||||||
|
return solr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the solr search core
|
||||||
|
*/
|
||||||
|
protected void initSolr() {
|
||||||
|
if (solr == null) {
|
||||||
|
String solrService = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.search.server");
|
||||||
|
|
||||||
|
UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
|
||||||
|
if (urlValidator.isValid(solrService) || configurationService
|
||||||
|
.getBooleanProperty("discovery.solr.url.validation.enabled", true)) {
|
||||||
|
try {
|
||||||
|
log.debug("Solr URL: " + solrService);
|
||||||
|
HttpSolrClient solrServer = new HttpSolrClient.Builder(solrService).build();
|
||||||
|
|
||||||
|
solrServer.setBaseURL(solrService);
|
||||||
|
solrServer.setUseMultiPartPost(true);
|
||||||
|
// Dummy/test query to search for Item (type=2) of ID=1
|
||||||
|
SolrQuery solrQuery = new SolrQuery()
|
||||||
|
.setQuery(SearchUtils.RESOURCE_TYPE_FIELD + ":" + IndexableItem.TYPE +
|
||||||
|
" AND " + SearchUtils.RESOURCE_ID_FIELD + ":1");
|
||||||
|
// Only return obj identifier fields in result doc
|
||||||
|
solrQuery.setFields(SearchUtils.RESOURCE_TYPE_FIELD, SearchUtils.RESOURCE_ID_FIELD);
|
||||||
|
solrServer.query(solrQuery, SolrRequest.METHOD.POST);
|
||||||
|
|
||||||
|
// As long as Solr initialized, check with DatabaseUtils to see
|
||||||
|
// if a reindex is in order. If so, reindex everything
|
||||||
|
DatabaseUtils.checkReindexDiscovery(indexingService);
|
||||||
|
|
||||||
|
solr = solrServer;
|
||||||
|
} catch (SolrServerException | IOException e) {
|
||||||
|
log.error("Error while initializing solr server", e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("Error while initializing solr, invalid url: " + solrService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -14,6 +14,7 @@ import org.dspace.content.Bitstream;
|
|||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This plugin adds three fields to the solr index to make a facet with/without
|
* This plugin adds three fields to the solr index to make a facet with/without
|
||||||
@@ -29,9 +30,9 @@ import org.dspace.core.Context;
|
|||||||
public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin {
|
public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, IndexableObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, IndexableObject indexableObject, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (indexableObject instanceof IndexableItem) {
|
||||||
Item item = (Item) dso;
|
Item item = ((IndexableItem) indexableObject).getIndexedObject();
|
||||||
boolean hasOriginalBundleWithContent = hasOriginalBundleWithContent(item);
|
boolean hasOriginalBundleWithContent = hasOriginalBundleWithContent(item);
|
||||||
|
|
||||||
// _keyword and _filter because
|
// _keyword and _filter because
|
||||||
|
@@ -14,6 +14,7 @@ import org.dspace.content.Bitstream;
|
|||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -40,9 +41,9 @@ public class SolrServiceFileInfoPlugin implements SolrServiceIndexPlugin {
|
|||||||
private static final String SOLR_FIELD_NAME_FOR_DESCRIPTIONS = "original_bundle_descriptions";
|
private static final String SOLR_FIELD_NAME_FOR_DESCRIPTIONS = "original_bundle_descriptions";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, IndexableObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, IndexableObject indexableObject, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (indexableObject instanceof IndexableItem) {
|
||||||
Item item = (Item) dso;
|
Item item = ((IndexableItem) indexableObject).getIndexedObject();
|
||||||
List<Bundle> bundles = item.getBundles();
|
List<Bundle> bundles = item.getBundles();
|
||||||
if (bundles != null) {
|
if (bundles != null) {
|
||||||
for (Bundle bundle : bundles) {
|
for (Bundle bundle : bundles) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@ import org.dspace.content.authority.service.ChoiceAuthorityService;
|
|||||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.sort.OrderFormat;
|
import org.dspace.sort.OrderFormat;
|
||||||
import org.dspace.sort.SortException;
|
import org.dspace.sort.SortException;
|
||||||
@@ -56,12 +57,12 @@ public class SolrServiceMetadataBrowseIndexingPlugin implements SolrServiceIndex
|
|||||||
protected ChoiceAuthorityService choiceAuthorityService;
|
protected ChoiceAuthorityService choiceAuthorityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, IndexableObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, IndexableObject indexableObject, SolrInputDocument document) {
|
||||||
// Only works for Items
|
// Only works for Items
|
||||||
if (!(dso instanceof Item)) {
|
if (!(indexableObject instanceof IndexableItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Item item = (Item) dso;
|
Item item = ((IndexableItem) indexableObject).getIndexedObject();
|
||||||
|
|
||||||
// Get the currently configured browse indexes
|
// Get the currently configured browse indexes
|
||||||
BrowseIndex[] bis;
|
BrowseIndex[] bis;
|
||||||
@@ -206,9 +207,9 @@ public class SolrServiceMetadataBrowseIndexingPlugin implements SolrServiceIndex
|
|||||||
bi.getDataType());
|
bi.getDataType());
|
||||||
distFValues
|
distFValues
|
||||||
.add(nLabel
|
.add(nLabel
|
||||||
+ SolrServiceImpl.FILTER_SEPARATOR
|
+ SearchUtils.FILTER_SEPARATOR
|
||||||
+ preferedLabel
|
+ preferedLabel
|
||||||
+ SolrServiceImpl.AUTHORITY_SEPARATOR
|
+ SearchUtils.AUTHORITY_SEPARATOR
|
||||||
+ values.get(x).getAuthority());
|
+ values.get(x).getAuthority());
|
||||||
distValuesForAC.add(preferedLabel);
|
distValuesForAC.add(preferedLabel);
|
||||||
}
|
}
|
||||||
@@ -222,9 +223,9 @@ public class SolrServiceMetadataBrowseIndexingPlugin implements SolrServiceIndex
|
|||||||
bi.getDataType());
|
bi.getDataType());
|
||||||
distFValues
|
distFValues
|
||||||
.add(nVal
|
.add(nVal
|
||||||
+ SolrServiceImpl.FILTER_SEPARATOR
|
+ SearchUtils.FILTER_SEPARATOR
|
||||||
+ var
|
+ var
|
||||||
+ SolrServiceImpl.AUTHORITY_SEPARATOR
|
+ SearchUtils.AUTHORITY_SEPARATOR
|
||||||
+ values.get(x).getAuthority());
|
+ values.get(x).getAuthority());
|
||||||
distValuesForAC.add(var);
|
distValuesForAC.add(var);
|
||||||
}
|
}
|
||||||
@@ -241,7 +242,7 @@ public class SolrServiceMetadataBrowseIndexingPlugin implements SolrServiceIndex
|
|||||||
bi.getDataType());
|
bi.getDataType());
|
||||||
distFValues
|
distFValues
|
||||||
.add(nVal
|
.add(nVal
|
||||||
+ SolrServiceImpl.FILTER_SEPARATOR
|
+ SearchUtils.FILTER_SEPARATOR
|
||||||
+ values.get(x).getValue());
|
+ values.get(x).getValue());
|
||||||
distFVal.add(values.get(x).getValue());
|
distFVal.add(values.get(x).getValue());
|
||||||
distValuesForAC.add(values.get(x).getValue());
|
distValuesForAC.add(values.get(x).getValue());
|
||||||
|
@@ -24,6 +24,7 @@ import org.dspace.content.service.CommunityService;
|
|||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
@@ -56,8 +57,8 @@ public class SolrServiceResourceRestrictionPlugin implements SolrServiceIndexPlu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, IndexableObject idxObj, SolrInputDocument document) {
|
public void additionalIndex(Context context, IndexableObject idxObj, SolrInputDocument document) {
|
||||||
if (idxObj instanceof DSpaceObject) {
|
if (idxObj instanceof IndexableDSpaceObject) {
|
||||||
DSpaceObject dso = (DSpaceObject) idxObj;
|
DSpaceObject dso = ((IndexableDSpaceObject) idxObj).getIndexedObject();
|
||||||
try {
|
try {
|
||||||
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ);
|
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ);
|
||||||
for (ResourcePolicy resourcePolicy : policies) {
|
for (ResourcePolicy resourcePolicy : policies) {
|
||||||
|
@@ -14,6 +14,7 @@ import org.dspace.content.Item;
|
|||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,9 +30,9 @@ public class SolrServiceSpellIndexingPlugin implements SolrServiceIndexPlugin {
|
|||||||
protected ItemService itemService;
|
protected ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, IndexableObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, IndexableObject indexableObject, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (indexableObject instanceof IndexableItem) {
|
||||||
Item item = (Item) dso;
|
Item item = ((IndexableItem) indexableObject).getIndexedObject();
|
||||||
List<MetadataValue> dcValues = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
List<MetadataValue> dcValues = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType());
|
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType());
|
||||||
for (MetadataValue dcValue : dcValues) {
|
for (MetadataValue dcValue : dcValues) {
|
||||||
|
@@ -13,8 +13,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,8 +45,8 @@ public class DiscoveryConfigurationService {
|
|||||||
String name;
|
String name;
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
name = "site";
|
name = "site";
|
||||||
} else if (dso instanceof DSpaceObject) {
|
} else if (dso instanceof IndexableDSpaceObject) {
|
||||||
name = ((DSpaceObject) dso).getHandle();
|
name = ((IndexableDSpaceObject) dso).getIndexedObject().getHandle();
|
||||||
} else {
|
} else {
|
||||||
name = dso.getUniqueIndexID();
|
name = dso.getUniqueIndexID();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.factory.ClaimedTaskIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkflowItemIndexFactory;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving claimed tasks in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class ClaimedTaskIndexFactoryImpl extends IndexFactoryImpl<IndexableClaimedTask, ClaimedTask>
|
||||||
|
implements ClaimedTaskIndexFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected ClaimedTaskService claimedTaskService;
|
||||||
|
@Autowired
|
||||||
|
WorkflowItemIndexFactory indexableWorkflowItemService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableClaimedTask> findAll(Context context) throws SQLException {
|
||||||
|
final Iterator<ClaimedTask> claimedTasks = claimedTaskService.findAll(context).iterator();
|
||||||
|
return new Iterator<IndexableClaimedTask>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return claimedTasks.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableClaimedTask next() {
|
||||||
|
return new IndexableClaimedTask(claimedTasks.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableClaimedTask.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableClaimedTask indexableObject)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
final SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
final ClaimedTask claimedTask = indexableObject.getIndexedObject();
|
||||||
|
// Add submitter, locations and modification time
|
||||||
|
indexableWorkflowItemService.storeInprogressItemFields(context, doc, claimedTask.getWorkflowItem());
|
||||||
|
|
||||||
|
addFacetIndex(doc, "action", claimedTask.getActionID(), claimedTask.getActionID());
|
||||||
|
addFacetIndex(doc, "step", claimedTask.getStepID(), claimedTask.getStepID());
|
||||||
|
|
||||||
|
doc.addField("taskfor", "e" + claimedTask.getOwner().getID().toString());
|
||||||
|
|
||||||
|
String acvalue = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.facet.namedtype.workflow.claimed");
|
||||||
|
if (StringUtils.isBlank(acvalue)) {
|
||||||
|
acvalue = indexableObject.getTypeText();
|
||||||
|
}
|
||||||
|
addNamedResourceTypeIndex(doc, acvalue);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof ClaimedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, ClaimedTask object) {
|
||||||
|
return Arrays.asList(new IndexableClaimedTask(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableClaimedTask> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final ClaimedTask claimedTask = claimedTaskService.find(context, Integer.parseInt(id));
|
||||||
|
return claimedTask == null ? Optional.empty() : Optional.of(new IndexableClaimedTask(claimedTask));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,158 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
|
import org.dspace.content.service.CollectionService;
|
||||||
|
import org.dspace.content.service.CommunityService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.factory.CollectionIndexFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving collections in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class CollectionIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<IndexableCollection, Collection>
|
||||||
|
implements CollectionIndexFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CollectionService collectionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CommunityService communityService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableCollection> findAll(Context context) throws SQLException {
|
||||||
|
Iterator<Collection> collections = collectionService.findAll(context).iterator();
|
||||||
|
|
||||||
|
return new Iterator<IndexableCollection>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return collections.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableCollection next() {
|
||||||
|
return new IndexableCollection(collections.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableCollection.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a solr document for a DSpace Collection.
|
||||||
|
*
|
||||||
|
* @param context The relevant DSpace Context.
|
||||||
|
* @param indexableCollection indexableCollection to be indexed
|
||||||
|
* @throws SQLException sql exception
|
||||||
|
* @throws IOException IO exception
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableCollection indexableCollection)
|
||||||
|
throws IOException, SQLException {
|
||||||
|
// Create Lucene Document and add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
SolrInputDocument doc = super.buildDocument(context, indexableCollection);
|
||||||
|
|
||||||
|
final Collection collection = indexableCollection.getIndexedObject();
|
||||||
|
|
||||||
|
// Retrieve configuration
|
||||||
|
DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(collection);
|
||||||
|
DiscoveryHitHighlightingConfiguration highlightingConfiguration = discoveryConfiguration
|
||||||
|
.getHitHighlightingConfiguration();
|
||||||
|
List<String> highlightedMetadataFields = new ArrayList<>();
|
||||||
|
if (highlightingConfiguration != null) {
|
||||||
|
for (DiscoveryHitHighlightFieldConfiguration configuration : highlightingConfiguration
|
||||||
|
.getMetadataFields()) {
|
||||||
|
highlightedMetadataFields.add(configuration.getField());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add collection metadata
|
||||||
|
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||||
|
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||||
|
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||||
|
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||||
|
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||||
|
String rights_license = collectionService.getMetadata(collection, "license");
|
||||||
|
String title = collectionService.getMetadata(collection, "name");
|
||||||
|
|
||||||
|
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(collection.getType());
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description",
|
||||||
|
description);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.abstract",
|
||||||
|
description_abstract);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields,
|
||||||
|
"dc.description.tableofcontents", description_table);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.provenance", provenance);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights", rights);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights.license",
|
||||||
|
rights_license);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, Collection object) {
|
||||||
|
return Arrays.asList(new IndexableCollection(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableCollection> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final Collection collection = (collectionService.find(context, UUID.fromString(id)));
|
||||||
|
return collection == null ? Optional.empty() : Optional.of(new IndexableCollection(collection));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLocations(Context context, IndexableCollection indexableCollection) throws SQLException {
|
||||||
|
return getCollectionLocations(context, indexableCollection.getIndexedObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getCollectionLocations(Context context, Collection collection) throws SQLException {
|
||||||
|
List<String> locations = new ArrayList<>();
|
||||||
|
// build list of community ids
|
||||||
|
List<Community> communities = ContentServiceFactory.getInstance().getCommunityService().
|
||||||
|
getAllParents(context, collection);
|
||||||
|
|
||||||
|
// now put those into strings
|
||||||
|
for (Community community : communities) {
|
||||||
|
locations.add("m" + community.getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,131 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.content.service.CommunityService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.factory.CommunityIndexFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving communities in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class CommunityIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<IndexableCommunity, Community>
|
||||||
|
implements CommunityIndexFactory {
|
||||||
|
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected CommunityService communityService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableCommunity> findAll(Context context) throws SQLException {
|
||||||
|
Iterator<Community> communities = communityService.findAll(context).iterator();
|
||||||
|
|
||||||
|
return new Iterator<IndexableCommunity>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return communities.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableCommunity next() {
|
||||||
|
return new IndexableCommunity(communities.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableCommunity.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableCommunity indexableObject)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
final Community community = indexableObject.getIndexedObject();
|
||||||
|
|
||||||
|
// Retrieve configuration
|
||||||
|
DiscoveryConfiguration discoveryConfiguration = SearchUtils.getDiscoveryConfiguration(community);
|
||||||
|
DiscoveryHitHighlightingConfiguration highlightingConfiguration = discoveryConfiguration
|
||||||
|
.getHitHighlightingConfiguration();
|
||||||
|
List<String> highlightedMetadataFields = new ArrayList<String>();
|
||||||
|
if (highlightingConfiguration != null) {
|
||||||
|
for (DiscoveryHitHighlightFieldConfiguration configuration : highlightingConfiguration
|
||||||
|
.getMetadataFields()) {
|
||||||
|
highlightedMetadataFields.add(configuration.getField());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add community metadata
|
||||||
|
String description = communityService.getMetadata(community, "introductory_text");
|
||||||
|
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||||
|
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||||
|
String rights = communityService.getMetadata(community, "copyright_text");
|
||||||
|
String title = communityService.getMetadata(community, "name");
|
||||||
|
|
||||||
|
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(community.getType());
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description",
|
||||||
|
description);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.description.abstract",
|
||||||
|
description_abstract);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields,
|
||||||
|
"dc.description.tableofcontents", description_table);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.rights", rights);
|
||||||
|
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof Community;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, Community object) {
|
||||||
|
return Arrays.asList(new IndexableCommunity(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableCommunity> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final Community community = communityService.find(context, UUID.fromString(id));
|
||||||
|
return community == null ? Optional.empty() : Optional.of(new IndexableCommunity(community));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLocations(Context context, IndexableCommunity indexableDSpaceObject) throws SQLException {
|
||||||
|
final Community target = indexableDSpaceObject.getIndexedObject();
|
||||||
|
List<String> locations = new ArrayList<>();
|
||||||
|
// build list of community ids
|
||||||
|
List<Community> communities = target.getParentCommunities();
|
||||||
|
|
||||||
|
// now put those into strings
|
||||||
|
for (Community community : communities) {
|
||||||
|
locations.add("m" + community.getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.factory.DSpaceObjectIndexFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving DSpaceObjects in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class DSpaceObjectIndexFactoryImpl<T extends IndexableDSpaceObject, S extends DSpaceObject>
|
||||||
|
extends IndexFactoryImpl<T, S> implements DSpaceObjectIndexFactory<T, S> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, T indexableObject) throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
final DSpaceObject dso = indexableObject.getIndexedObject();
|
||||||
|
|
||||||
|
// want to be able to search for handle, so use keyword
|
||||||
|
// (not tokenized, but it is indexed)
|
||||||
|
if (dso.getHandle() != null) {
|
||||||
|
// want to be able to search for handle, so use keyword
|
||||||
|
// (not tokenized, but it is indexed)
|
||||||
|
doc.addField("handle", dso.getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> locations = getLocations(context, indexableObject);
|
||||||
|
storeCommunityCollectionLocations(doc, locations);
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the metadata value of the community/collection to the solr document
|
||||||
|
* IF needed highlighting is added !
|
||||||
|
*
|
||||||
|
* @param doc the solr document
|
||||||
|
* @param highlightedMetadataFields the list of metadata fields that CAN be highlighted
|
||||||
|
* @param toIgnoreMetadataFields the list of metadata fields to skip adding to Solr
|
||||||
|
* @param metadataField the metadata field added
|
||||||
|
* @param value the value (can be NULL !)
|
||||||
|
*/
|
||||||
|
protected void addContainerMetadataField(SolrInputDocument doc, List<String> highlightedMetadataFields,
|
||||||
|
List<String> toIgnoreMetadataFields, String metadataField, String value) {
|
||||||
|
if ((toIgnoreMetadataFields == null || !toIgnoreMetadataFields.contains(metadataField))
|
||||||
|
&& StringUtils.isNotBlank(value)) {
|
||||||
|
doc.addField(metadataField, value);
|
||||||
|
if (highlightedMetadataFields.contains(metadataField)) {
|
||||||
|
doc.addField(metadataField + "_hl", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeCommunityCollectionLocations(SolrInputDocument doc, List<String> locations) {
|
||||||
|
if (locations != null) {
|
||||||
|
for (String location : locations) {
|
||||||
|
doc.addField("location", location);
|
||||||
|
if (location.startsWith("m")) {
|
||||||
|
doc.addField("location.comm", location.substring(1));
|
||||||
|
} else {
|
||||||
|
doc.addField("location.coll", location.substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,193 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.client.solrj.SolrClient;
|
||||||
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
|
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
|
||||||
|
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
|
import org.apache.solr.handler.extraction.ExtractingParams;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.FullTextContentStreams;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.SolrSearchCore;
|
||||||
|
import org.dspace.discovery.SolrServiceIndexPlugin;
|
||||||
|
import org.dspace.discovery.indexobject.factory.IndexFactory;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.util.SolrUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basis factory interface implementation for indexing/retrieving any IndexableObject in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class IndexFactoryImpl<T extends IndexableObject, S> implements IndexFactory<T, S> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected List<SolrServiceIndexPlugin> solrServiceIndexPlugins;
|
||||||
|
@Autowired
|
||||||
|
protected SolrSearchCore solrSearchCore;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, T indexableObject) throws SQLException, IOException {
|
||||||
|
SolrInputDocument doc = new SolrInputDocument();
|
||||||
|
// want to be able to check when last updated
|
||||||
|
// (not tokenized, but it is indexed)
|
||||||
|
doc.addField(SearchUtils.LAST_INDEXED_FIELD, SolrUtils.getDateFormatter().format(new Date()));
|
||||||
|
|
||||||
|
// New fields to weaken the dependence on handles, and allow for faster
|
||||||
|
// list display
|
||||||
|
doc.addField(SearchUtils.RESOURCE_UNIQUE_ID, indexableObject.getType() + "-" + indexableObject.getID());
|
||||||
|
doc.addField(SearchUtils.RESOURCE_TYPE_FIELD, indexableObject.getType());
|
||||||
|
doc.addField(SearchUtils.RESOURCE_ID_FIELD, indexableObject.getID().toString());
|
||||||
|
|
||||||
|
//Do any additional indexing, depends on the plugins
|
||||||
|
for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins) {
|
||||||
|
solrServiceIndexPlugin.additionalIndex(context, indexableObject, doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeDocument(Context context, T indexableObject, SolrInputDocument solrInputDocument)
|
||||||
|
throws SQLException, IOException, SolrServerException {
|
||||||
|
writeDocument(solrInputDocument, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the document to the index under the appropriate unique identifier.
|
||||||
|
*
|
||||||
|
* @param doc the solr document to be written to the server
|
||||||
|
* @param streams list of bitstream content streams DiscoverQueryBuilderTest.java:285
|
||||||
|
* @throws IOException A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
*/
|
||||||
|
protected void writeDocument(SolrInputDocument doc, FullTextContentStreams streams)
|
||||||
|
throws IOException, SolrServerException {
|
||||||
|
final SolrClient solr = solrSearchCore.getSolr();
|
||||||
|
if (solr != null) {
|
||||||
|
if (streams != null && !streams.isEmpty()) {
|
||||||
|
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
|
||||||
|
req.addContentStream(streams);
|
||||||
|
|
||||||
|
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||||
|
|
||||||
|
//req.setParam(ExtractingParams.EXTRACT_ONLY, "true");
|
||||||
|
for (String name : doc.getFieldNames()) {
|
||||||
|
for (Object val : doc.getFieldValues(name)) {
|
||||||
|
params.add(ExtractingParams.LITERALS_PREFIX + name, val.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.setParams(params);
|
||||||
|
req.setParam(ExtractingParams.UNKNOWN_FIELD_PREFIX, "attr_");
|
||||||
|
req.setParam(ExtractingParams.MAP_PREFIX + "content", "fulltext");
|
||||||
|
req.setParam(ExtractingParams.EXTRACT_FORMAT, "text");
|
||||||
|
req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
|
||||||
|
req.process(solr);
|
||||||
|
} else {
|
||||||
|
solr.add(doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index the provided value as use for a sidebar facet
|
||||||
|
* @param document The solr document
|
||||||
|
* @param field The facet field name
|
||||||
|
* @param authority The authority linked to the field
|
||||||
|
* @param fvalue The display value for the facet
|
||||||
|
*/
|
||||||
|
protected void addFacetIndex(SolrInputDocument document, String field, String authority, String fvalue) {
|
||||||
|
addFacetIndex(document, field, fvalue, authority, fvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index the provided value as use for a sidebar facet
|
||||||
|
* @param document The solr document
|
||||||
|
* @param field The facet field name
|
||||||
|
* @param sortValue The value on which we should sort our facet fields when retrieving
|
||||||
|
* @param authority The authority linked to the field
|
||||||
|
* @param fvalue The display value for the facet
|
||||||
|
*/
|
||||||
|
protected void addFacetIndex(SolrInputDocument document, String field, String sortValue, String authority,
|
||||||
|
String fvalue) {
|
||||||
|
// the separator for the filter can be eventually configured
|
||||||
|
String separator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.solr.facets.split.char");
|
||||||
|
if (separator == null) {
|
||||||
|
separator = SearchUtils.FILTER_SEPARATOR;
|
||||||
|
}
|
||||||
|
String acvalue = sortValue + separator + fvalue + SearchUtils.AUTHORITY_SEPARATOR + authority;
|
||||||
|
document.addField(field + "_filter", acvalue);
|
||||||
|
// build the solr field used for the keyword search
|
||||||
|
document.addField(field + "_keyword", fvalue);
|
||||||
|
// build the solr fields used for the autocomplete
|
||||||
|
document.addField(field + "_ac", fvalue.toLowerCase() + separator + fvalue);
|
||||||
|
if (StringUtils.isNotBlank(authority)) {
|
||||||
|
document.addField(field + "_acid", fvalue.toLowerCase() + separator + fvalue
|
||||||
|
+ SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
document.addField(field + "_authority", authority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the necessary fields to the SOLR document to support a Discover Facet on resourcetypename (archived item,
|
||||||
|
* workspace item, workflow item, etc)
|
||||||
|
*
|
||||||
|
* @param document the solr document
|
||||||
|
* @param filterValue the filter value (i.e. <sort_value>\n|||\n<display_value>###<authority_value>
|
||||||
|
*/
|
||||||
|
protected void addNamedResourceTypeIndex(SolrInputDocument document, String filterValue) {
|
||||||
|
|
||||||
|
// the separator for the filter can be eventually configured
|
||||||
|
String separator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.solr.facets.split.char");
|
||||||
|
if (separator == null) {
|
||||||
|
separator = SearchUtils.FILTER_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// split the authority part from the sort/display
|
||||||
|
String[] avalues = filterValue.split(SearchUtils.AUTHORITY_SEPARATOR);
|
||||||
|
|
||||||
|
String sortValue = avalues[0];
|
||||||
|
String authorityValue = avalues.length == 2 ? avalues[1] : filterValue;
|
||||||
|
|
||||||
|
// get the display value
|
||||||
|
int idxSeparator = sortValue.indexOf(separator);
|
||||||
|
String displayValue = idxSeparator != -1 ? sortValue.substring(idxSeparator + separator.length())
|
||||||
|
: sortValue;
|
||||||
|
|
||||||
|
addFacetIndex(document, SearchUtils.NAMED_RESOURCE_TYPE, sortValue, authorityValue, displayValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(T indexableObject) throws IOException, SolrServerException {
|
||||||
|
solrSearchCore.getSolr().deleteById(indexableObject.getUniqueIndexID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String indexableObjectIdentifier) throws IOException, SolrServerException {
|
||||||
|
solrSearchCore.getSolr().deleteById(indexableObjectIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteAll() throws IOException, SolrServerException {
|
||||||
|
solrSearchCore.getSolr().deleteByQuery(SearchUtils.RESOURCE_TYPE_FIELD + ":" + getType());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClaimedTask implementation for the IndexableObject
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableClaimedTask implements IndexableObject<ClaimedTask, Integer> {
|
||||||
|
|
||||||
|
private ClaimedTask claimedTask;
|
||||||
|
public static final String TYPE = ClaimedTask.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableClaimedTask(ClaimedTask claimedTask) {
|
||||||
|
this.claimedTask = claimedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClaimedTask getIndexedObject() {
|
||||||
|
return claimedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndexedObject(ClaimedTask claimedTask) {
|
||||||
|
this.claimedTask = claimedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getID() {
|
||||||
|
return claimedTask.getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "CLAIMEDTASK";
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection implementation for the IndexableObject
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableCollection extends IndexableDSpaceObject<Collection> {
|
||||||
|
|
||||||
|
public static final String TYPE = Collection.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableCollection(Collection dso) {
|
||||||
|
super(dso);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return Constants.typeText[Constants.COLLECTION];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Community implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableCommunity extends IndexableDSpaceObject<Community> {
|
||||||
|
|
||||||
|
public static final String TYPE = Community.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableCommunity(Community dso) {
|
||||||
|
super(dso);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return Constants.typeText[Constants.COMMUNITY];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DSpaceObject implementation for the IndexableObject, contains methods used by all DSpaceObject methods
|
||||||
|
* All DSpaceObjects that will be indexed in discovery should inherit from this class & have their own implementation
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class IndexableDSpaceObject<T extends DSpaceObject> implements IndexableObject<T, UUID> {
|
||||||
|
|
||||||
|
private T dso;
|
||||||
|
|
||||||
|
public IndexableDSpaceObject(T dso) {
|
||||||
|
this.dso = dso;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T getIndexedObject() {
|
||||||
|
return dso;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndexedObject(T dso) {
|
||||||
|
this.dso = dso;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getID() {
|
||||||
|
return dso.getID();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InProgressSubmission implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class IndexableInProgressSubmission<T extends InProgressSubmission>
|
||||||
|
implements IndexableObject<T, Integer> {
|
||||||
|
|
||||||
|
protected T inProgressSubmission;
|
||||||
|
|
||||||
|
public IndexableInProgressSubmission(T inProgressSubmission) {
|
||||||
|
this.inProgressSubmission = inProgressSubmission;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T getIndexedObject() {
|
||||||
|
return inProgressSubmission;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndexedObject(T inProgressSubmission) {
|
||||||
|
this.inProgressSubmission = inProgressSubmission;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableItem extends IndexableDSpaceObject<Item> {
|
||||||
|
|
||||||
|
public static final String TYPE = Item.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableItem(Item dso) {
|
||||||
|
super(dso);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getLastModified() {
|
||||||
|
return getIndexedObject().getLastModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return Constants.typeText[Constants.ITEM];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PoolTask implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexablePoolTask implements IndexableObject<PoolTask, Integer> {
|
||||||
|
|
||||||
|
public static final String TYPE = PoolTask.class.getSimpleName();
|
||||||
|
|
||||||
|
private PoolTask poolTask;
|
||||||
|
|
||||||
|
public IndexablePoolTask(PoolTask poolTask) {
|
||||||
|
this.poolTask = poolTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolTask getIndexedObject() {
|
||||||
|
return poolTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIndexedObject(PoolTask poolTask) {
|
||||||
|
this.poolTask = poolTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "POOLTASK";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getID() {
|
||||||
|
return poolTask.getID();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workflow item implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableWorkflowItem extends IndexableInProgressSubmission<XmlWorkflowItem> {
|
||||||
|
|
||||||
|
public static final String TYPE = XmlWorkflowItem.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableWorkflowItem(XmlWorkflowItem inProgressSubmission) {
|
||||||
|
super(inProgressSubmission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "WORKFLOWITEM";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getID() {
|
||||||
|
return getIndexedObject().getID();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workspace item implementation for the IndexableObject
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexableWorkspaceItem extends IndexableInProgressSubmission<WorkspaceItem> {
|
||||||
|
|
||||||
|
public static final String TYPE = WorkspaceItem.class.getSimpleName();
|
||||||
|
|
||||||
|
public IndexableWorkspaceItem(WorkspaceItem inProgressSubmission) {
|
||||||
|
super(inProgressSubmission);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getID() {
|
||||||
|
return getIndexedObject().getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeText() {
|
||||||
|
return "WORKSPACEITEM";
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.factory.CollectionIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.InprogressSubmissionIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.ItemIndexFactory;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.util.SolrUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving InProgressSubmissions in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class InprogressSubmissionIndexFactoryImpl
|
||||||
|
<T extends IndexableInProgressSubmission, S extends InProgressSubmission> extends IndexFactoryImpl<T, S>
|
||||||
|
implements InprogressSubmissionIndexFactory<T, S> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CollectionIndexFactory indexableCollectionService;
|
||||||
|
@Autowired
|
||||||
|
protected ItemIndexFactory indexableItemService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, T indexableObject) throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
// Add submitter, locations and modification time
|
||||||
|
storeInprogressItemFields(context, doc, indexableObject.getIndexedObject());
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInprogressItemFields(Context context, SolrInputDocument doc,
|
||||||
|
InProgressSubmission inProgressSubmission) throws SQLException {
|
||||||
|
final Item item = inProgressSubmission.getItem();
|
||||||
|
doc.addField("lastModified", SolrUtils.getDateFormatter().format(item.getLastModified()));
|
||||||
|
EPerson submitter = inProgressSubmission.getSubmitter();
|
||||||
|
if (submitter != null) {
|
||||||
|
addFacetIndex(doc, "submitter", submitter.getID().toString(),
|
||||||
|
submitter.getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.addField("inprogress.item", new IndexableItem(inProgressSubmission.getItem()).getUniqueIndexID());
|
||||||
|
|
||||||
|
// get the location string (for searching by collection & community)
|
||||||
|
List<String> locations = indexableCollectionService.
|
||||||
|
getCollectionLocations(context, inProgressSubmission.getCollection());
|
||||||
|
indexableCollectionService.storeCommunityCollectionLocations(doc, locations);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,733 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.MetadataField;
|
||||||
|
import org.dspace.content.MetadataSchema;
|
||||||
|
import org.dspace.content.MetadataValue;
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.content.authority.Choices;
|
||||||
|
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||||
|
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||||
|
import org.dspace.content.service.ItemService;
|
||||||
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.LogManager;
|
||||||
|
import org.dspace.discovery.FullTextContentStreams;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoverySearchFilter;
|
||||||
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
import org.dspace.discovery.configuration.DiscoverySortConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.DiscoverySortFieldConfiguration;
|
||||||
|
import org.dspace.discovery.configuration.HierarchicalSidebarFacetConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.factory.ItemIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkflowItemIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkspaceItemIndexFactory;
|
||||||
|
import org.dspace.eperson.EPerson;
|
||||||
|
import org.dspace.handle.service.HandleService;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.util.MultiFormatDateParser;
|
||||||
|
import org.dspace.util.SolrUtils;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving items in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class ItemIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<IndexableItem, Item>
|
||||||
|
implements ItemIndexFactory {
|
||||||
|
|
||||||
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemIndexFactoryImpl.class);
|
||||||
|
public static final String VARIANTS_STORE_SEPARATOR = "###";
|
||||||
|
public static final String STORE_SEPARATOR = "\n|||\n";
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected HandleService handleService;
|
||||||
|
@Autowired
|
||||||
|
protected ItemService itemService;
|
||||||
|
@Autowired(required = true)
|
||||||
|
protected ChoiceAuthorityService choiceAuthorityService;
|
||||||
|
@Autowired
|
||||||
|
protected MetadataAuthorityService metadataAuthorityService;
|
||||||
|
@Autowired
|
||||||
|
protected WorkspaceItemService workspaceItemService;
|
||||||
|
@Autowired
|
||||||
|
protected XmlWorkflowItemService xmlWorkflowItemService;
|
||||||
|
@Autowired
|
||||||
|
protected WorkflowItemIndexFactory workflowItemIndexFactory;
|
||||||
|
@Autowired
|
||||||
|
protected WorkspaceItemIndexFactory workspaceItemIndexFactory;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableItem> findAll(Context context) throws SQLException {
|
||||||
|
Iterator<Item> items = itemService.findAllUnfiltered(context);
|
||||||
|
return new Iterator<IndexableItem>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return items.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableItem next() {
|
||||||
|
return new IndexableItem(items.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableItem.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a Solr document for a DSpace Item and write the index
|
||||||
|
*
|
||||||
|
* @param context Users Context
|
||||||
|
* @param indexableItem The IndexableItem Item to be indexed
|
||||||
|
* @throws SQLException if database error
|
||||||
|
* @throws IOException if IO error
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableItem indexableItem)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
SolrInputDocument doc = super.buildDocument(context, indexableItem);
|
||||||
|
|
||||||
|
final Item item = indexableItem.getIndexedObject();
|
||||||
|
|
||||||
|
doc.addField("archived", item.isArchived());
|
||||||
|
doc.addField("withdrawn", item.isWithdrawn());
|
||||||
|
doc.addField("discoverable", item.isDiscoverable());
|
||||||
|
doc.addField("lastModified", SolrUtils.getDateFormatter().format(item.getLastModified()));
|
||||||
|
|
||||||
|
EPerson submitter = item.getSubmitter();
|
||||||
|
if (submitter != null) {
|
||||||
|
addFacetIndex(doc, "submitter", submitter.getID().toString(),
|
||||||
|
submitter.getFullName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the item metadata
|
||||||
|
List<DiscoveryConfiguration> discoveryConfigurations = SearchUtils.getAllDiscoveryConfigurations(item);
|
||||||
|
addDiscoveryFields(doc, context, indexableItem.getIndexedObject(), discoveryConfigurations);
|
||||||
|
|
||||||
|
//mandatory facet to show status on mydspace
|
||||||
|
final String typeText = StringUtils.deleteWhitespace(indexableItem.getTypeText().toLowerCase());
|
||||||
|
String acvalue = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(
|
||||||
|
"discovery.facet.namedtype." + typeText,
|
||||||
|
typeText + SearchUtils.AUTHORITY_SEPARATOR + typeText);
|
||||||
|
if (StringUtils.isNotBlank(acvalue)) {
|
||||||
|
addNamedResourceTypeIndex(doc, acvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the index and close the inputstreamreaders
|
||||||
|
try {
|
||||||
|
log.info("Wrote Item: " + item.getID() + " to Index");
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
log.error("Error while writing item to discovery index: " + item.getID() + " message:"
|
||||||
|
+ e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDiscoveryFields(SolrInputDocument doc, Context context, Item item,
|
||||||
|
List<DiscoveryConfiguration> discoveryConfigurations)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
//Keep a list of our sort values which we added, sort values can only be added once
|
||||||
|
List<String> sortFieldsAdded = new ArrayList<>();
|
||||||
|
Map<String, List<DiscoverySearchFilter>> searchFilters = null;
|
||||||
|
Set<String> hitHighlightingFields = new HashSet<>();
|
||||||
|
try {
|
||||||
|
//A map used to save each sidebarFacet config by the metadata fields
|
||||||
|
searchFilters = new HashMap<>();
|
||||||
|
Map<String, DiscoverySortFieldConfiguration> sortFields = new HashMap<>();
|
||||||
|
Map<String, DiscoveryRecentSubmissionsConfiguration> recentSubmissionsConfigurationMap = new
|
||||||
|
HashMap<>();
|
||||||
|
Set<String> moreLikeThisFields = new HashSet<>();
|
||||||
|
// some configuration are returned multiple times, skip them to save CPU cycles
|
||||||
|
Set<String> appliedConf = new HashSet<>();
|
||||||
|
// it is common to have search filter shared between multiple configurations
|
||||||
|
Set<String> appliedDiscoverySearchFilter = new HashSet<>();
|
||||||
|
|
||||||
|
for (DiscoveryConfiguration discoveryConfiguration : discoveryConfigurations) {
|
||||||
|
if (appliedConf.contains(discoveryConfiguration.getId())) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
appliedConf.add(discoveryConfiguration.getId());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < discoveryConfiguration.getSearchFilters().size(); i++) {
|
||||||
|
if (appliedDiscoverySearchFilter
|
||||||
|
.contains(discoveryConfiguration.getSearchFilters().get(i).getIndexFieldName())) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
appliedDiscoverySearchFilter
|
||||||
|
.add(discoveryConfiguration.getSearchFilters().get(i).getIndexFieldName());
|
||||||
|
}
|
||||||
|
List<MetadataValue> metadataValueList = new LinkedList<>();
|
||||||
|
boolean shouldExposeMinMax = false;
|
||||||
|
DiscoverySearchFilter discoverySearchFilter = discoveryConfiguration.getSearchFilters().get(i);
|
||||||
|
if (StringUtils.equalsIgnoreCase(discoverySearchFilter.getFilterType(), "facet")) {
|
||||||
|
if (((DiscoverySearchFilterFacet) discoverySearchFilter).exposeMinAndMaxValue()) {
|
||||||
|
shouldExposeMinMax = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int j = 0; j < discoverySearchFilter.getMetadataFields().size(); j++) {
|
||||||
|
String metadataField = discoverySearchFilter.getMetadataFields().get(j);
|
||||||
|
List<DiscoverySearchFilter> resultingList;
|
||||||
|
if (searchFilters.get(metadataField) != null) {
|
||||||
|
resultingList = searchFilters.get(metadataField);
|
||||||
|
} else {
|
||||||
|
//New metadata field, create a new list for it
|
||||||
|
resultingList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (shouldExposeMinMax) {
|
||||||
|
String[] splittedMetadataField = metadataField.split("\\.");
|
||||||
|
String schema = splittedMetadataField[0];
|
||||||
|
String element = splittedMetadataField.length > 1 ? splittedMetadataField[1] : null;
|
||||||
|
String qualifier = splittedMetadataField.length > 2 ? splittedMetadataField[2] : null;
|
||||||
|
|
||||||
|
metadataValueList.addAll(itemService.getMetadata(item, schema,
|
||||||
|
element, qualifier, Item.ANY));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
resultingList.add(discoverySearchFilter);
|
||||||
|
|
||||||
|
searchFilters.put(metadataField, resultingList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!metadataValueList.isEmpty() && shouldExposeMinMax) {
|
||||||
|
metadataValueList.sort((mdv1, mdv2) -> mdv1.getValue().compareTo(mdv2.getValue()));
|
||||||
|
MetadataValue firstMetadataValue = metadataValueList.get(0);
|
||||||
|
MetadataValue lastMetadataValue = metadataValueList.get(metadataValueList.size() - 1);
|
||||||
|
|
||||||
|
doc.addField(discoverySearchFilter.getIndexFieldName() + "_min", firstMetadataValue.getValue());
|
||||||
|
doc.addField(discoverySearchFilter.getIndexFieldName()
|
||||||
|
+ "_min_sort", firstMetadataValue.getValue());
|
||||||
|
doc.addField(discoverySearchFilter.getIndexFieldName() + "_max", lastMetadataValue.getValue());
|
||||||
|
doc.addField(discoverySearchFilter.getIndexFieldName()
|
||||||
|
+ "_max_sort", lastMetadataValue.getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscoverySortConfiguration sortConfiguration = discoveryConfiguration.getSearchSortConfiguration();
|
||||||
|
if (sortConfiguration != null) {
|
||||||
|
for (DiscoverySortFieldConfiguration discoverySortConfiguration : sortConfiguration
|
||||||
|
.getSortFields()) {
|
||||||
|
sortFields.put(discoverySortConfiguration.getMetadataField(), discoverySortConfiguration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscoveryRecentSubmissionsConfiguration recentSubmissionConfiguration = discoveryConfiguration
|
||||||
|
.getRecentSubmissionConfiguration();
|
||||||
|
if (recentSubmissionConfiguration != null) {
|
||||||
|
recentSubmissionsConfigurationMap
|
||||||
|
.put(recentSubmissionConfiguration.getMetadataSortField(), recentSubmissionConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscoveryHitHighlightingConfiguration hitHighlightingConfiguration = discoveryConfiguration
|
||||||
|
.getHitHighlightingConfiguration();
|
||||||
|
if (hitHighlightingConfiguration != null) {
|
||||||
|
List<DiscoveryHitHighlightFieldConfiguration> fieldConfigurations = hitHighlightingConfiguration
|
||||||
|
.getMetadataFields();
|
||||||
|
for (DiscoveryHitHighlightFieldConfiguration fieldConfiguration : fieldConfigurations) {
|
||||||
|
hitHighlightingFields.add(fieldConfiguration.getField());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DiscoveryMoreLikeThisConfiguration moreLikeThisConfiguration = discoveryConfiguration
|
||||||
|
.getMoreLikeThisConfiguration();
|
||||||
|
if (moreLikeThisConfiguration != null) {
|
||||||
|
for (String metadataField : moreLikeThisConfiguration.getSimilarityMetadataFields()) {
|
||||||
|
moreLikeThisFields.add(metadataField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<String> toProjectionFields = new ArrayList<>();
|
||||||
|
String[] projectionFields = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getArrayProperty("discovery.index.projection");
|
||||||
|
if (projectionFields != null) {
|
||||||
|
for (String field : projectionFields) {
|
||||||
|
toProjectionFields.add(field.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType());
|
||||||
|
List<MetadataValue> mydc = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||||
|
for (MetadataValue meta : mydc) {
|
||||||
|
MetadataField metadataField = meta.getMetadataField();
|
||||||
|
MetadataSchema metadataSchema = metadataField.getMetadataSchema();
|
||||||
|
String field = metadataSchema.getName() + "." + metadataField.getElement();
|
||||||
|
String unqualifiedField = field;
|
||||||
|
|
||||||
|
String value = meta.getValue();
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadataField.getQualifier() != null && !metadataField.getQualifier().trim().equals("")) {
|
||||||
|
field += "." + metadataField.getQualifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
//We are not indexing provenance, this is useless
|
||||||
|
if (toIgnoreMetadataFields != null && (toIgnoreMetadataFields.contains(field) || toIgnoreMetadataFields
|
||||||
|
.contains(unqualifiedField + "." + Item.ANY))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String authority = null;
|
||||||
|
String preferedLabel = null;
|
||||||
|
List<String> variants = null;
|
||||||
|
boolean isAuthorityControlled = metadataAuthorityService
|
||||||
|
.isAuthorityControlled(metadataField);
|
||||||
|
|
||||||
|
int minConfidence = isAuthorityControlled ? metadataAuthorityService
|
||||||
|
.getMinConfidence(metadataField) : Choices.CF_ACCEPTED;
|
||||||
|
|
||||||
|
if (isAuthorityControlled && meta.getAuthority() != null
|
||||||
|
&& meta.getConfidence() >= minConfidence) {
|
||||||
|
boolean ignoreAuthority =
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore." + field,
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore",
|
||||||
|
new Boolean(false)),
|
||||||
|
true);
|
||||||
|
if (!ignoreAuthority) {
|
||||||
|
authority = meta.getAuthority();
|
||||||
|
|
||||||
|
boolean ignorePrefered =
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore-prefered." + field,
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore-prefered",
|
||||||
|
new Boolean(false)),
|
||||||
|
true);
|
||||||
|
if (!ignorePrefered) {
|
||||||
|
|
||||||
|
preferedLabel = choiceAuthorityService
|
||||||
|
.getLabel(meta, meta.getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ignoreVariants =
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore-variants." + field,
|
||||||
|
DSpaceServicesFactory
|
||||||
|
.getInstance()
|
||||||
|
.getConfigurationService()
|
||||||
|
.getPropertyAsType("discovery.index.authority.ignore-variants",
|
||||||
|
new Boolean(false)),
|
||||||
|
true);
|
||||||
|
if (!ignoreVariants) {
|
||||||
|
variants = choiceAuthorityService
|
||||||
|
.getVariants(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((searchFilters.get(field) != null || searchFilters
|
||||||
|
.get(unqualifiedField + "." + Item.ANY) != null)) {
|
||||||
|
List<DiscoverySearchFilter> searchFilterConfigs = searchFilters.get(field);
|
||||||
|
if (searchFilterConfigs == null) {
|
||||||
|
searchFilterConfigs = searchFilters.get(unqualifiedField + "." + Item.ANY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DiscoverySearchFilter searchFilter : searchFilterConfigs) {
|
||||||
|
Date date = null;
|
||||||
|
String separator = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.solr.facets.split.char");
|
||||||
|
if (separator == null) {
|
||||||
|
separator = SearchUtils.FILTER_SEPARATOR;
|
||||||
|
}
|
||||||
|
if (searchFilter.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
||||||
|
//For our search filters that are dates we format them properly
|
||||||
|
date = MultiFormatDateParser.parse(value);
|
||||||
|
if (date != null) {
|
||||||
|
//TODO: make this date format configurable !
|
||||||
|
value = DateFormatUtils.formatUTC(date, "yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doc.addField(searchFilter.getIndexFieldName(), value);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_keyword", value);
|
||||||
|
|
||||||
|
if (authority != null && preferedLabel == null) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_keyword", value + SearchUtils.AUTHORITY_SEPARATOR
|
||||||
|
+ authority);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_authority", authority);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_acid", value.toLowerCase()
|
||||||
|
+ separator + value
|
||||||
|
+ SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preferedLabel != null) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName(),
|
||||||
|
preferedLabel);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_keyword", preferedLabel);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_keyword", preferedLabel
|
||||||
|
+ SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_authority", authority);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_acid", preferedLabel.toLowerCase()
|
||||||
|
+ separator + preferedLabel
|
||||||
|
+ SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
}
|
||||||
|
if (variants != null) {
|
||||||
|
for (String var : variants) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_keyword", var);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_acid", var.toLowerCase()
|
||||||
|
+ separator + var
|
||||||
|
+ SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add a dynamic fields for auto complete in search
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_ac",
|
||||||
|
value.toLowerCase() + separator + value);
|
||||||
|
if (preferedLabel != null) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_ac", preferedLabel.toLowerCase()
|
||||||
|
+ separator + preferedLabel);
|
||||||
|
}
|
||||||
|
if (variants != null) {
|
||||||
|
for (String var : variants) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName()
|
||||||
|
+ "_ac", var.toLowerCase() + separator
|
||||||
|
+ var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchFilter.getFilterType().equals(DiscoverySearchFilterFacet.FILTER_TYPE_FACET)) {
|
||||||
|
if (searchFilter.getType().equals(DiscoveryConfigurationParameters.TYPE_TEXT)) {
|
||||||
|
//Add a special filter
|
||||||
|
//We use a separator to split up the lowercase and regular case, this is needed to
|
||||||
|
// get our filters in regular case
|
||||||
|
//Solr has issues with facet prefix and cases
|
||||||
|
if (authority != null) {
|
||||||
|
String facetValue = preferedLabel != null ? preferedLabel : value;
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_filter", facetValue
|
||||||
|
.toLowerCase() + separator + facetValue + SearchUtils.AUTHORITY_SEPARATOR
|
||||||
|
+ authority);
|
||||||
|
} else {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_filter",
|
||||||
|
value.toLowerCase() + separator + value);
|
||||||
|
}
|
||||||
|
} else if (searchFilter.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
||||||
|
if (date != null) {
|
||||||
|
String indexField = searchFilter.getIndexFieldName() + ".year";
|
||||||
|
String yearUTC = DateFormatUtils.formatUTC(date, "yyyy");
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_keyword", yearUTC);
|
||||||
|
// add the year to the autocomplete index
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_ac", yearUTC);
|
||||||
|
doc.addField(indexField, yearUTC);
|
||||||
|
|
||||||
|
if (yearUTC.startsWith("0")) {
|
||||||
|
doc.addField(
|
||||||
|
searchFilter.getIndexFieldName()
|
||||||
|
+ "_keyword",
|
||||||
|
yearUTC.replaceFirst("0*", ""));
|
||||||
|
// add date without starting zeros for autocomplete e filtering
|
||||||
|
doc.addField(
|
||||||
|
searchFilter.getIndexFieldName()
|
||||||
|
+ "_ac",
|
||||||
|
yearUTC.replaceFirst("0*", ""));
|
||||||
|
doc.addField(
|
||||||
|
searchFilter.getIndexFieldName()
|
||||||
|
+ "_ac",
|
||||||
|
value.replaceFirst("0*", ""));
|
||||||
|
doc.addField(
|
||||||
|
searchFilter.getIndexFieldName()
|
||||||
|
+ "_keyword",
|
||||||
|
value.replaceFirst("0*", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Also save a sort value of this year, this is required for determining the upper
|
||||||
|
// & lower bound year of our facet
|
||||||
|
if (doc.getField(indexField + "_sort") == null) {
|
||||||
|
//We can only add one year so take the first one
|
||||||
|
doc.addField(indexField + "_sort", yearUTC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (searchFilter.getType()
|
||||||
|
.equals(DiscoveryConfigurationParameters.TYPE_HIERARCHICAL)) {
|
||||||
|
HierarchicalSidebarFacetConfiguration hierarchicalSidebarFacetConfiguration =
|
||||||
|
(HierarchicalSidebarFacetConfiguration) searchFilter;
|
||||||
|
String[] subValues = value.split(hierarchicalSidebarFacetConfiguration.getSplitter());
|
||||||
|
if (hierarchicalSidebarFacetConfiguration
|
||||||
|
.isSkipFirstNodeLevel() && 1 < subValues.length) {
|
||||||
|
//Remove the first element of our array
|
||||||
|
subValues = (String[]) ArrayUtils.subarray(subValues, 1, subValues.length);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < subValues.length; i++) {
|
||||||
|
StringBuilder valueBuilder = new StringBuilder();
|
||||||
|
for (int j = 0; j <= i; j++) {
|
||||||
|
valueBuilder.append(subValues[j]);
|
||||||
|
if (j < i) {
|
||||||
|
valueBuilder.append(hierarchicalSidebarFacetConfiguration.getSplitter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String indexValue = valueBuilder.toString().trim();
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_tax_" + i + "_filter",
|
||||||
|
indexValue.toLowerCase() + separator + indexValue);
|
||||||
|
//We add the field x times that it has occurred
|
||||||
|
for (int j = i; j < subValues.length; j++) {
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_filter",
|
||||||
|
indexValue.toLowerCase() + separator + indexValue);
|
||||||
|
doc.addField(searchFilter.getIndexFieldName() + "_keyword", indexValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((sortFields.get(field) != null || recentSubmissionsConfigurationMap
|
||||||
|
.get(field) != null) && !sortFieldsAdded.contains(field)) {
|
||||||
|
//Only add sort value once
|
||||||
|
String type;
|
||||||
|
if (sortFields.get(field) != null) {
|
||||||
|
type = sortFields.get(field).getType();
|
||||||
|
} else {
|
||||||
|
type = recentSubmissionsConfigurationMap.get(field).getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
||||||
|
Date date = MultiFormatDateParser.parse(value);
|
||||||
|
if (date != null) {
|
||||||
|
String stringDate = SolrUtils.getDateFormatter().format(date);
|
||||||
|
doc.addField(field + "_dt", stringDate);
|
||||||
|
} else {
|
||||||
|
log.warn("Error while indexing sort date field, item: " + item
|
||||||
|
.getHandle() + " metadata field: " + field + " date value: " + date);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
doc.addField(field + "_sort", value);
|
||||||
|
}
|
||||||
|
sortFieldsAdded.add(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitHighlightingFields.contains(field) || hitHighlightingFields
|
||||||
|
.contains("*") || hitHighlightingFields.contains(unqualifiedField + "." + Item.ANY)) {
|
||||||
|
if (authority != null) {
|
||||||
|
doc.addField(field + "_hl", value + SearchUtils.AUTHORITY_SEPARATOR + authority);
|
||||||
|
} else {
|
||||||
|
doc.addField(field + "_hl", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moreLikeThisFields.contains(field) || moreLikeThisFields
|
||||||
|
.contains(unqualifiedField + "." + Item.ANY)) {
|
||||||
|
doc.addField(field + "_mlt", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.addField(field, value);
|
||||||
|
if (authority != null) {
|
||||||
|
doc.addField(field + "_authority", authority);
|
||||||
|
}
|
||||||
|
if (toProjectionFields.contains(field) || toProjectionFields
|
||||||
|
.contains(unqualifiedField + "." + Item.ANY)) {
|
||||||
|
StringBuffer variantsToStore = new StringBuffer();
|
||||||
|
if (variants != null) {
|
||||||
|
for (String var : variants) {
|
||||||
|
variantsToStore.append(VARIANTS_STORE_SEPARATOR);
|
||||||
|
variantsToStore.append(var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doc.addField(
|
||||||
|
field + "_stored",
|
||||||
|
value + STORE_SEPARATOR + preferedLabel
|
||||||
|
+ STORE_SEPARATOR
|
||||||
|
+ (variantsToStore.length() > VARIANTS_STORE_SEPARATOR
|
||||||
|
.length() ? variantsToStore
|
||||||
|
.substring(VARIANTS_STORE_SEPARATOR
|
||||||
|
.length()) : "null")
|
||||||
|
+ STORE_SEPARATOR + authority
|
||||||
|
+ STORE_SEPARATOR + meta.getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.getLanguage() != null && !meta.getLanguage().trim().equals("")) {
|
||||||
|
String langField = field + "." + meta.getLanguage();
|
||||||
|
doc.addField(langField, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LogManager.getHeader(context, "item_metadata_discovery_error",
|
||||||
|
"Item identifier: " + item.getID()), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.debug(" Added Metadata");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
List<MetadataValue> values = itemService.getMetadataByMetadataString(item, "dc.relation.ispartof");
|
||||||
|
|
||||||
|
if (values != null && values.size() > 0 && values.get(0) != null && values.get(0).getValue() != null) {
|
||||||
|
// group on parent
|
||||||
|
String handlePrefix = handleService.getCanonicalPrefix();
|
||||||
|
|
||||||
|
doc.addField("publication_grp", values.get(0).getValue().replaceFirst(handlePrefix, ""));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// group on self
|
||||||
|
doc.addField("publication_grp", item.getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LogManager.getHeader(context, "item_publication_group_discovery_error",
|
||||||
|
"Item identifier: " + item.getID()), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.debug(" Added Grouping");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeDocument(Context context, IndexableItem indexableObject, SolrInputDocument solrInputDocument)
|
||||||
|
throws SQLException, IOException, SolrServerException {
|
||||||
|
writeDocument(solrInputDocument, new FullTextContentStreams(context, indexableObject.getIndexedObject()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLocations(Context context, IndexableItem indexableDSpaceObject)
|
||||||
|
throws SQLException {
|
||||||
|
final Item item = indexableDSpaceObject.getIndexedObject();
|
||||||
|
List<String> locations = new ArrayList<>();
|
||||||
|
|
||||||
|
// build list of community ids
|
||||||
|
List<Community> communities = itemService.getCommunities(context, item);
|
||||||
|
|
||||||
|
// build list of collection ids
|
||||||
|
List<Collection> collections = item.getCollections();
|
||||||
|
|
||||||
|
// now put those into strings
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < communities.size(); i++) {
|
||||||
|
locations.add("m" + communities.get(i).getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < collections.size(); i++) {
|
||||||
|
locations.add("l" + collections.get(i).getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(IndexableItem indexableObject) throws IOException, SolrServerException {
|
||||||
|
super.delete(indexableObject);
|
||||||
|
deleteInProgressData(indexableObject.getUniqueIndexID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteInProgressData(String indexableObjectIdentifier) throws SolrServerException, IOException {
|
||||||
|
// Also delete any possible workflowItem / workspaceItem / tasks related to this item
|
||||||
|
String query = "inprogress.item:\"" + indexableObjectIdentifier + "\"";
|
||||||
|
log.debug("Try to delete all in progress submission [DELETEBYQUERY]:" + query);
|
||||||
|
solrSearchCore.getSolr().deleteByQuery(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String indexableObjectIdentifier) throws IOException, SolrServerException {
|
||||||
|
super.delete(indexableObjectIdentifier);
|
||||||
|
deleteInProgressData(indexableObjectIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, Item object) throws SQLException {
|
||||||
|
List<IndexableObject> results = new ArrayList<>();
|
||||||
|
if (object.isArchived() || object.isWithdrawn()) {
|
||||||
|
// We only want to index an item as an item if it is not in workflow
|
||||||
|
results.addAll(Arrays.asList(new IndexableItem(object)));
|
||||||
|
} else {
|
||||||
|
// Check if we have a workflow / workspace item
|
||||||
|
final WorkspaceItem workspaceItem = workspaceItemService.findByItem(context, object);
|
||||||
|
if (workspaceItem != null) {
|
||||||
|
results.addAll(workspaceItemIndexFactory.getIndexableObjects(context, workspaceItem));
|
||||||
|
} else {
|
||||||
|
// Check if we a workflow item
|
||||||
|
final XmlWorkflowItem xmlWorkflowItem = xmlWorkflowItemService.findByItem(context, object);
|
||||||
|
if (xmlWorkflowItem != null) {
|
||||||
|
results.addAll(workflowItemIndexFactory.getIndexableObjects(context, xmlWorkflowItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableItem> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final Item item = itemService.find(context, UUID.fromString(id));
|
||||||
|
return item == null ? Optional.empty() : Optional.of(new IndexableItem(item));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.factory.PoolTaskIndexFactory;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkflowItemIndexFactory;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving pooled tasks in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class PoolTaskIndexFactoryImpl extends IndexFactoryImpl<IndexablePoolTask, PoolTask>
|
||||||
|
implements PoolTaskIndexFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected PoolTaskService poolTaskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WorkflowItemIndexFactory indexableWorkflowItemService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexablePoolTask> findAll(Context context) throws SQLException {
|
||||||
|
final Iterator<PoolTask> pooledTasks = poolTaskService.findAll(context).iterator();
|
||||||
|
return new Iterator<IndexablePoolTask>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return pooledTasks.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexablePoolTask next() {
|
||||||
|
return new IndexablePoolTask(pooledTasks.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexablePoolTask.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexablePoolTask indexableObject)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
final SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
final PoolTask poolTask = indexableObject.getIndexedObject();
|
||||||
|
// Add submitter, locations and modification time
|
||||||
|
indexableWorkflowItemService.storeInprogressItemFields(context, doc, poolTask.getWorkflowItem());
|
||||||
|
|
||||||
|
addFacetIndex(doc, "action", poolTask.getActionID(), poolTask.getActionID());
|
||||||
|
addFacetIndex(doc, "step", poolTask.getStepID(), poolTask.getStepID());
|
||||||
|
if (poolTask.getEperson() != null) {
|
||||||
|
doc.addField("taskfor", "e" + poolTask.getEperson().getID().toString());
|
||||||
|
}
|
||||||
|
if (poolTask.getGroup() != null) {
|
||||||
|
doc.addField("taskfor", "g" + poolTask.getGroup().getID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
String acvalue = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.facet.namedtype.workflow.pooled");
|
||||||
|
if (StringUtils.isBlank(acvalue)) {
|
||||||
|
acvalue = indexableObject.getTypeText();
|
||||||
|
}
|
||||||
|
addNamedResourceTypeIndex(doc, acvalue);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof PoolTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, PoolTask object) {
|
||||||
|
return Arrays.asList(new IndexablePoolTask(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexablePoolTask> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final PoolTask poolTask = poolTaskService.find(context, Integer.parseInt(id));
|
||||||
|
return poolTask == null ? Optional.empty() : Optional.of(new IndexablePoolTask(poolTask));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,121 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkflowItemIndexFactory;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving workflow items in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class WorkflowItemIndexFactoryImpl
|
||||||
|
extends InprogressSubmissionIndexFactoryImpl<IndexableWorkflowItem, XmlWorkflowItem>
|
||||||
|
implements WorkflowItemIndexFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected XmlWorkflowItemService workflowItemService;
|
||||||
|
@Autowired
|
||||||
|
protected ClaimedTaskService claimedTaskService;
|
||||||
|
@Autowired
|
||||||
|
protected PoolTaskService poolTaskService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableWorkflowItem> findAll(Context context) throws SQLException {
|
||||||
|
final Iterator<XmlWorkflowItem> workflowItems = workflowItemService.findAll(context).iterator();
|
||||||
|
|
||||||
|
return new Iterator<IndexableWorkflowItem>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return workflowItems.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableWorkflowItem next() {
|
||||||
|
return new IndexableWorkflowItem(workflowItems.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableWorkflowItem.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableWorkflowItem indexableObject)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
final SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
final XmlWorkflowItem workflowItem = indexableObject.getIndexedObject();
|
||||||
|
final Item item = workflowItem.getItem();
|
||||||
|
// Add the item metadata as configured
|
||||||
|
List<DiscoveryConfiguration> discoveryConfigurations = SearchUtils
|
||||||
|
.getAllDiscoveryConfigurations(workflowItem);
|
||||||
|
indexableItemService.addDiscoveryFields(doc, context, item, discoveryConfigurations);
|
||||||
|
|
||||||
|
String acvalue = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.facet.namedtype.workflow.item");
|
||||||
|
if (StringUtils.isBlank(acvalue)) {
|
||||||
|
acvalue = indexableObject.getTypeText();
|
||||||
|
}
|
||||||
|
addNamedResourceTypeIndex(doc, acvalue);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof XmlWorkflowItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, XmlWorkflowItem object) throws SQLException {
|
||||||
|
List<IndexableObject> results = new ArrayList<>();
|
||||||
|
results.add(new IndexableWorkflowItem(object));
|
||||||
|
|
||||||
|
List<PoolTask> pools = poolTaskService.find(context, object);
|
||||||
|
for (PoolTask poolTask : pools) {
|
||||||
|
results.add(new IndexablePoolTask(poolTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ClaimedTask> claimedTasks = claimedTaskService.find(context, object);
|
||||||
|
for (ClaimedTask claimedTask : claimedTasks) {
|
||||||
|
results.add(new IndexableClaimedTask(claimedTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableWorkflowItem> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final XmlWorkflowItem xmlWorkflowItem = workflowItemService.find(context, Integer.parseInt(id));
|
||||||
|
return xmlWorkflowItem == null ? Optional.empty() : Optional.of(new IndexableWorkflowItem(xmlWorkflowItem));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.factory.WorkspaceItemIndexFactory;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory implementation for indexing/retrieving workspace items in the search core
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class WorkspaceItemIndexFactoryImpl
|
||||||
|
extends InprogressSubmissionIndexFactoryImpl<IndexableWorkspaceItem, WorkspaceItem>
|
||||||
|
implements WorkspaceItemIndexFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected WorkspaceItemService workspaceItemService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IndexableWorkspaceItem> findAll(Context context) throws SQLException {
|
||||||
|
final Iterator<WorkspaceItem> workspaceItems = workspaceItemService.findAll(context).iterator();
|
||||||
|
|
||||||
|
return new Iterator<IndexableWorkspaceItem>() {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return workspaceItems.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndexableWorkspaceItem next() {
|
||||||
|
return new IndexableWorkspaceItem(workspaceItems.next());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return IndexableWorkspaceItem.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SolrInputDocument buildDocument(Context context, IndexableWorkspaceItem indexableObject)
|
||||||
|
throws SQLException, IOException {
|
||||||
|
// Add the ID's, types and call the SolrServiceIndexPlugins
|
||||||
|
final SolrInputDocument doc = super.buildDocument(context, indexableObject);
|
||||||
|
|
||||||
|
// Add the object type
|
||||||
|
String acvalue = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
|
.getProperty("discovery.facet.namedtype.workspace");
|
||||||
|
if (StringUtils.isBlank(acvalue)) {
|
||||||
|
acvalue = indexableObject.getTypeText();
|
||||||
|
}
|
||||||
|
addNamedResourceTypeIndex(doc, acvalue);
|
||||||
|
final WorkspaceItem inProgressSubmission = indexableObject.getIndexedObject();
|
||||||
|
|
||||||
|
// Add the item metadata as configured
|
||||||
|
List<DiscoveryConfiguration> discoveryConfigurations = SearchUtils
|
||||||
|
.getAllDiscoveryConfigurations(inProgressSubmission);
|
||||||
|
indexableItemService.addDiscoveryFields(doc, context, inProgressSubmission.getItem(), discoveryConfigurations);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Object object) {
|
||||||
|
return object instanceof WorkspaceItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getIndexableObjects(Context context, WorkspaceItem object) {
|
||||||
|
return Arrays.asList(new IndexableWorkspaceItem(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<IndexableWorkspaceItem> findIndexableObject(Context context, String id) throws SQLException {
|
||||||
|
final WorkspaceItem workspaceItem = workspaceItemService.find(context, Integer.parseInt(id));
|
||||||
|
return workspaceItem == null ? Optional.empty() : Optional.of(new IndexableWorkspaceItem(workspaceItem));
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import org.dspace.discovery.indexobject.IndexableClaimedTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving claimed tasks in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface ClaimedTaskIndexFactory extends IndexFactory<IndexableClaimedTask, ClaimedTask> {
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving collections in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface CollectionIndexFactory extends DSpaceObjectIndexFactory<IndexableCollection, Collection> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of the identifiers of the owning communities from the provided collection prepended by "m"
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param collection DSpace collection
|
||||||
|
* @return A list of community identifiers with "m" prepended to every one
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
public List<String> getCollectionLocations(Context context, Collection collection) throws SQLException;
|
||||||
|
}
|
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableCommunity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving communities in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface CommunityIndexFactory extends DSpaceObjectIndexFactory<IndexableCommunity, Community> {
|
||||||
|
}
|
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving DSpaceObjects in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface DSpaceObjectIndexFactory<T extends IndexableDSpaceObject, S extends DSpaceObject>
|
||||||
|
extends IndexFactory<T, S> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of the identifiers from the parents for the provided IndexableObject,
|
||||||
|
* communities will be prepended by "m", collections b "c"
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @return A list of community identifiers with "m" prepended to every one
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
List<String> getLocations(Context context, T indexableDSpaceObject) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the provided locations in the solr document
|
||||||
|
* @param doc The solr input document
|
||||||
|
* @param locations The locations to be stored
|
||||||
|
*/
|
||||||
|
void storeCommunityCollectionLocations(SolrInputDocument doc, List<String> locations);
|
||||||
|
}
|
@@ -0,0 +1,108 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basis factory interface for indexing/retrieving any IndexableObject in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface IndexFactory<T extends IndexableObject, S> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all instances of a certain indexable object type
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @return An iterator containing all the objects to be indexed for the indexable object
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
Iterator<T> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the type of the indexable object
|
||||||
|
* @return a string containing the type
|
||||||
|
*/
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create solr document with all the shared fields initialized.
|
||||||
|
* @param indexableObject the indexableObject that we want to index
|
||||||
|
* @return initialized solr document
|
||||||
|
*/
|
||||||
|
SolrInputDocument buildDocument(Context context, T indexableObject) throws SQLException, IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the provided document to the solr core
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param indexableObject The indexable object that we want to store in the search core
|
||||||
|
* @param solrInputDocument Solr input document which will be written to our discovery search core
|
||||||
|
* @throws SQLException If database error
|
||||||
|
* @throws IOException If IO error
|
||||||
|
* @throws SolrServerException If the solr document could not be written to the search core
|
||||||
|
*/
|
||||||
|
void writeDocument(Context context, T indexableObject, SolrInputDocument solrInputDocument)
|
||||||
|
throws SQLException, IOException, SolrServerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the provided indexable object from the solr core
|
||||||
|
* @param indexableObject The indexable object that we want to remove from the search core
|
||||||
|
* @throws IOException If IO error
|
||||||
|
* @throws SolrServerException If the solr document could not be removed to the search core
|
||||||
|
*/
|
||||||
|
void delete(T indexableObject) throws IOException, SolrServerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the provided indexable object from the solr core
|
||||||
|
* @param indexableObjectIdentifier The identifier that we want to remove from the search core
|
||||||
|
* @throws IOException If IO error
|
||||||
|
* @throws SolrServerException If the solr document could not be removed to the search core
|
||||||
|
*/
|
||||||
|
void delete(String indexableObjectIdentifier) throws IOException, SolrServerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all indexable objects of the implementing type from the search core
|
||||||
|
* @throws IOException If IO error
|
||||||
|
* @throws SolrServerException If the solr document could not be removed to the search core
|
||||||
|
*/
|
||||||
|
void deleteAll() throws IOException, SolrServerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single indexable object using the provided identifier
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param id The identifier for which we want to retrieve our indexable object
|
||||||
|
* @return An indexable object
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
Optional<T> findIndexableObject(Context context, String id) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the class can handle the factory implementation
|
||||||
|
* @param object The object which we want to check
|
||||||
|
* @return True if the factory implementation can handle the given object. False if it doesn't.
|
||||||
|
*/
|
||||||
|
boolean supports(Object object);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all the indexable objects for the provided object
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param object The object we want to retrieve our indexable objects for
|
||||||
|
* @return A list of indexable objects
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
List getIndexableObjects(Context context, S object) throws SQLException;
|
||||||
|
}
|
@@ -0,0 +1,102 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract factory to get the IndexFactory objects
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public abstract class IndexObjectFactoryFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected WorkspaceItemService workspaceItemService;
|
||||||
|
@Autowired
|
||||||
|
protected XmlWorkflowItemService xmlWorkflowItemService;
|
||||||
|
@Autowired
|
||||||
|
protected ClaimedTaskService claimedTaskService;
|
||||||
|
@Autowired
|
||||||
|
protected PoolTaskService poolTaskService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of all the available implementations of the IndexableObjectService interface
|
||||||
|
*
|
||||||
|
* @return the list of IndexableObjectService
|
||||||
|
*/
|
||||||
|
public abstract List<IndexFactory> getIndexFactories();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the IndexFactory implementation for the given indexable object
|
||||||
|
* @param indexableObject the indexable object for which we need our factory
|
||||||
|
* @return An IndexFactory implementation
|
||||||
|
*/
|
||||||
|
public IndexFactory getIndexableObjectFactory(IndexableObject indexableObject) {
|
||||||
|
return getIndexableObjectFactory(indexableObject.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the IndexFactory implementation for the given indexable object unique identifier
|
||||||
|
* @param indexableObjectUniqueString the unique identifier of an indexable object
|
||||||
|
* @return An IndexFactory implementation
|
||||||
|
*/
|
||||||
|
public IndexFactory getIndexableObjectFactory(String indexableObjectUniqueString) {
|
||||||
|
// The unique identifier of an IndexableObject will always be {type}-{identifier}
|
||||||
|
return getIndexFactoryByType(StringUtils.substringBefore(indexableObjectUniqueString, "-"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the IndexFactory implementation for the given indexable object type
|
||||||
|
* @param indexableFactoryType the object type of the indexable object
|
||||||
|
* @return An IndexFactory implementation
|
||||||
|
*/
|
||||||
|
public IndexFactory getIndexFactoryByType(String indexableFactoryType) {
|
||||||
|
for (IndexFactory indexableObjectFactory : getIndexFactories()) {
|
||||||
|
if (indexableObjectFactory.getType().equals(indexableFactoryType)) {
|
||||||
|
return indexableObjectFactory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all the indexable objects for the provided object
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param object The object we want to retrieve our indexable objects for
|
||||||
|
* @return A list of indexable objects
|
||||||
|
*/
|
||||||
|
public List<IndexableObject> getIndexableObjects(Context context, Object object) throws SQLException {
|
||||||
|
for (IndexFactory indexableObjectFactory : getIndexFactories()) {
|
||||||
|
if (indexableObjectFactory.supports(object)) {
|
||||||
|
return indexableObjectFactory.getIndexableObjects(context, object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("The object: " + object.getClass().getName()
|
||||||
|
+ " cannot be indexed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an implementation instance for this factory
|
||||||
|
* @return an IndexObjectServiceFactory bean
|
||||||
|
*/
|
||||||
|
public static IndexObjectFactoryFactory getInstance() {
|
||||||
|
return DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
|
.getServiceByName("indexObjectFactoryFactory", IndexObjectFactoryFactory.class);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract factory implementation to get the IndexFactory objects
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public class IndexObjectFactoryFactoryImpl extends IndexObjectFactoryFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
List<IndexFactory> indexableObjectServices;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<IndexFactory> getIndexFactories() {
|
||||||
|
return indexableObjectServices;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.InProgressSubmission;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableInProgressSubmission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving InProgresssSubmission objects in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface InprogressSubmissionIndexFactory<T extends IndexableInProgressSubmission,
|
||||||
|
S extends InProgressSubmission>
|
||||||
|
extends IndexFactory<T, S> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store common fields between workspace / workflow items in the solr document
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param doc Solr input document which will be written to our discovery solr core
|
||||||
|
* @param inProgressSubmission the workspace / workflow item
|
||||||
|
* @throws SQLException If database error
|
||||||
|
*/
|
||||||
|
void storeInprogressItemFields(Context context, SolrInputDocument doc, InProgressSubmission inProgressSubmission)
|
||||||
|
throws SQLException;
|
||||||
|
}
|
@@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving items in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface ItemIndexFactory extends DSpaceObjectIndexFactory<IndexableItem, Item> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store item fields in the solr document
|
||||||
|
* @param doc Solr input document which will be written to our discovery solr core
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param item Item for which we want to index our fields in the provided solr document
|
||||||
|
* @param discoveryConfigurations The discovery configuration which holds information
|
||||||
|
* for which item fields we should index
|
||||||
|
* @throws SQLException If database error
|
||||||
|
* @throws IOException If IO error
|
||||||
|
*/
|
||||||
|
void addDiscoveryFields(SolrInputDocument doc, Context context, Item item,
|
||||||
|
List<DiscoveryConfiguration> discoveryConfigurations)
|
||||||
|
throws SQLException, IOException;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import org.dspace.discovery.indexobject.IndexablePoolTask;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving Pooltask objects in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface PoolTaskIndexFactory extends IndexFactory<IndexablePoolTask, PoolTask> {
|
||||||
|
}
|
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import org.dspace.discovery.indexobject.IndexableWorkflowItem;
|
||||||
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving workflow items objects in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface WorkflowItemIndexFactory
|
||||||
|
extends InprogressSubmissionIndexFactory<IndexableWorkflowItem, XmlWorkflowItem> {
|
||||||
|
}
|
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* 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.discovery.indexobject.factory;
|
||||||
|
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableWorkspaceItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory interface for indexing/retrieving workspace item objects in the search core
|
||||||
|
*
|
||||||
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
|
*/
|
||||||
|
public interface WorkspaceItemIndexFactory
|
||||||
|
extends InprogressSubmissionIndexFactory<IndexableWorkspaceItem, WorkspaceItem> {
|
||||||
|
}
|
@@ -132,7 +132,7 @@ public class OrcidV2AuthorDataProvider implements ExternalDataProvider {
|
|||||||
}
|
}
|
||||||
externalDataObject.setId(person.getName().getPath());
|
externalDataObject.setId(person.getName().getPath());
|
||||||
externalDataObject
|
externalDataObject
|
||||||
.addMetadata(new MetadataValueDTO("dc", "identifier", "orcid", null, person.getName().getPath()));
|
.addMetadata(new MetadataValueDTO("person", "identifier", "orcid", null, person.getName().getPath()));
|
||||||
externalDataObject
|
externalDataObject
|
||||||
.addMetadata(new MetadataValueDTO("dc", "identifier", "uri", null, orcidUrl + person.getName().getPath()));
|
.addMetadata(new MetadataValueDTO("dc", "identifier", "uri", null, orcidUrl + person.getName().getPath()));
|
||||||
if (!StringUtils.isBlank(lastName) && !StringUtils.isBlank(firstName)) {
|
if (!StringUtils.isBlank(lastName) && !StringUtils.isBlank(firstName)) {
|
||||||
|
@@ -31,6 +31,8 @@ import org.dspace.discovery.DiscoverResult;
|
|||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.SearchUtils;
|
import org.dspace.discovery.SearchUtils;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
||||||
|
import org.dspace.discovery.indexobject.IndexableItem;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
@@ -97,7 +99,7 @@ public class Harvest {
|
|||||||
boolean items, boolean collections, boolean withdrawn,
|
boolean items, boolean collections, boolean withdrawn,
|
||||||
boolean nonAnon) throws SQLException, ParseException {
|
boolean nonAnon) throws SQLException, ParseException {
|
||||||
DiscoverQuery discoverQuery = new DiscoverQuery();
|
DiscoverQuery discoverQuery = new DiscoverQuery();
|
||||||
discoverQuery.addFilterQueries("search.resourcetype:" + Constants.ITEM);
|
discoverQuery.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE);
|
||||||
|
|
||||||
if (scope != null) {
|
if (scope != null) {
|
||||||
if (scope instanceof Community) {
|
if (scope instanceof Community) {
|
||||||
@@ -143,13 +145,13 @@ public class Harvest {
|
|||||||
Iterator<IndexableObject> dsoIterator = discoverResult.getIndexableObjects().iterator();
|
Iterator<IndexableObject> dsoIterator = discoverResult.getIndexableObjects().iterator();
|
||||||
while (dsoIterator.hasNext() && ((limit == 0) || (itemCounter < limit))) {
|
while (dsoIterator.hasNext() && ((limit == 0) || (itemCounter < limit))) {
|
||||||
// the query is limited to ITEM
|
// the query is limited to ITEM
|
||||||
DSpaceObject dso = (DSpaceObject) dsoIterator.next();
|
IndexableDSpaceObject indexableDSpaceObject = (IndexableDSpaceObject) dsoIterator.next();
|
||||||
HarvestedItemInfo itemInfo = new HarvestedItemInfo();
|
HarvestedItemInfo itemInfo = new HarvestedItemInfo();
|
||||||
itemInfo.context = context;
|
itemInfo.context = context;
|
||||||
itemInfo.handle = dso.getHandle();
|
itemInfo.handle = indexableDSpaceObject.getIndexedObject().getHandle();
|
||||||
itemInfo.itemID = dso.getID();
|
itemInfo.itemID = indexableDSpaceObject.getID();
|
||||||
itemInfo.datestamp = ((Item) dso).getLastModified();
|
itemInfo.datestamp = ((IndexableItem) indexableDSpaceObject).getIndexedObject().getLastModified();
|
||||||
itemInfo.withdrawn = ((Item) dso).isWithdrawn();
|
itemInfo.withdrawn = ((IndexableItem) indexableDSpaceObject).getIndexedObject().isWithdrawn();
|
||||||
|
|
||||||
if (collections) {
|
if (collections) {
|
||||||
// Add collections data
|
// Add collections data
|
||||||
|
@@ -53,7 +53,9 @@ public class UploadConfiguration {
|
|||||||
|
|
||||||
public Boolean isRequired() {
|
public Boolean isRequired() {
|
||||||
if (required == null) {
|
if (required == null) {
|
||||||
required = configurationService.getBooleanProperty("webui.submit.upload.required");
|
//defaults to true
|
||||||
|
//don't store a local copy of the configuration property
|
||||||
|
return configurationService.getBooleanProperty("webui.submit.upload.required", true);
|
||||||
}
|
}
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
@@ -8,13 +8,12 @@
|
|||||||
package org.dspace.workflow;
|
package org.dspace.workflow;
|
||||||
|
|
||||||
import org.dspace.content.InProgressSubmission;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.core.ReloadableEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing a workflowitem, each workflowItem implementation must implement this interface.
|
* Interface representing a workflowitem, each workflowItem implementation must implement this interface.
|
||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkflowItem extends InProgressSubmission<Integer>, ReloadableEntity<Integer> {
|
public interface WorkflowItem extends InProgressSubmission {
|
||||||
public int getState();
|
public int getState();
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface WorkflowItemService<T extends WorkflowItem> extends InProgressSubmissionService<T, Integer> {
|
public interface WorkflowItemService<T extends WorkflowItem> extends InProgressSubmissionService<T> {
|
||||||
|
|
||||||
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
@@ -7,8 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.workflowbasic;
|
package org.dspace.workflowbasic;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -23,7 +21,6 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
@@ -152,7 +149,7 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EPerson getSubmitter() throws SQLException {
|
public EPerson getSubmitter() {
|
||||||
return item.getSubmitter();
|
return item.getSubmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,10 +182,4 @@ public class BasicWorkflowItem implements WorkflowItem {
|
|||||||
public void setPublishedBefore(boolean b) {
|
public void setPublishedBefore(boolean b) {
|
||||||
this.publishedBefore = b;
|
this.publishedBefore = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return Constants.WORKFLOWITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -53,11 +52,6 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return Constants.WORKFLOWITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BasicWorkflowItem create(Context context, Item item, Collection collection)
|
public BasicWorkflowItem create(Context context, Item item, Collection collection)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
@@ -90,14 +84,6 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BasicWorkflowItem findIndexableObject(Context context, Integer id) throws SQLException {
|
|
||||||
if (id != null) {
|
|
||||||
return find(context, id);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BasicWorkflowItem> findAll(Context context) throws SQLException {
|
public List<BasicWorkflowItem> findAll(Context context) throws SQLException {
|
||||||
return workflowItemDAO.findAll(context, BasicWorkflowItem.class);
|
return workflowItemDAO.findAll(context, BasicWorkflowItem.class);
|
||||||
|
@@ -13,14 +13,15 @@ import java.util.List;
|
|||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
|
||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
|
||||||
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.WorkflowItemRole;
|
import org.dspace.xmlworkflow.storedcomponents.WorkflowItemRole;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.service.CollectionRoleService;
|
import org.dspace.xmlworkflow.storedcomponents.service.CollectionRoleService;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService;
|
import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService;
|
||||||
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The role that is responsible for a certain step
|
* The role that is responsible for a certain step
|
||||||
@@ -32,38 +33,36 @@ import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public class Role {
|
public class Role implements BeanNameAware {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupService groupService;
|
||||||
|
@Autowired
|
||||||
|
private CollectionRoleService collectionRoleService;
|
||||||
|
@Autowired
|
||||||
|
private WorkflowItemRoleService workflowItemRoleService;
|
||||||
|
|
||||||
private GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
|
||||||
private CollectionRoleService collectionRoleService = XmlWorkflowServiceFactory.getInstance()
|
|
||||||
.getCollectionRoleService();
|
|
||||||
private WorkflowItemRoleService workflowItemRoleService = XmlWorkflowServiceFactory.getInstance()
|
|
||||||
.getWorkflowItemRoleService();
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private boolean isInternal;
|
private boolean isInternal = false;
|
||||||
private Scope scope;
|
private Scope scope = Scope.COLLECTION;
|
||||||
|
|
||||||
public static enum Scope {
|
@Override
|
||||||
|
public void setBeanName(String s) {
|
||||||
|
this.id = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Scope {
|
||||||
REPOSITORY,
|
REPOSITORY,
|
||||||
COLLECTION,
|
COLLECTION,
|
||||||
ITEM
|
ITEM
|
||||||
}
|
}
|
||||||
|
|
||||||
public Role(String id, String name, String description, boolean isInternal, Scope scope) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.isInternal = isInternal;
|
|
||||||
this.scope = scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -118,4 +117,41 @@ public class Role {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name specified in the name attribute of a role will be used to lookup the in DSpace.
|
||||||
|
* The lookup will depend on the scope specified in the "scope" attribute:
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
@Required
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the description of the role
|
||||||
|
* @param description the description
|
||||||
|
*/
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the scope attribute, depending on the scope the users will be retrieved in the following manner:
|
||||||
|
* * collection: The collection value specifies that the group will be configured at the level of the collection.
|
||||||
|
* * repository: The repository scope uses groups that are defined at repository level in DSpace.
|
||||||
|
* item: The item scope assumes that a different action in the workflow will assign a number of EPersons or
|
||||||
|
* Groups to a specific workflow-item in order to perform a step.
|
||||||
|
* @param scope the scope parameter
|
||||||
|
*/
|
||||||
|
public void setScope(Scope scope) {
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional attribute which isn't really used at the moment, false by default
|
||||||
|
* @param internal if the role is internal
|
||||||
|
*/
|
||||||
|
public void setInternal(boolean internal) {
|
||||||
|
isInternal = internal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,8 +13,8 @@ import java.io.StringWriter;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -236,13 +236,13 @@ public class WorkflowUtils extends Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static HashMap<String, Role> getCollectionRoles(Collection thisCollection)
|
public static Map<String, Role> getCollectionRoles(Collection thisCollection)
|
||||||
throws IOException, WorkflowConfigurationException, SQLException {
|
throws IOException, WorkflowConfigurationException, SQLException {
|
||||||
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
||||||
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
||||||
if (workflow != null) {
|
if (workflow != null) {
|
||||||
//Make sure we find one
|
//Make sure we find one
|
||||||
HashMap<String, Role> allRoles = workflow.getRoles();
|
Map<String, Role> allRoles = workflow.getRoles();
|
||||||
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
||||||
for (String roleId : allRoles.keySet()) {
|
for (String roleId : allRoles.keySet()) {
|
||||||
Role role = allRoles.get(roleId);
|
Role role = allRoles.get(roleId);
|
||||||
@@ -257,13 +257,13 @@ public class WorkflowUtils extends Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static HashMap<String, Role> getCollectionAndRepositoryRoles(Collection thisCollection)
|
public static Map<String, Role> getCollectionAndRepositoryRoles(Collection thisCollection)
|
||||||
throws IOException, WorkflowConfigurationException, SQLException {
|
throws IOException, WorkflowConfigurationException, SQLException {
|
||||||
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
||||||
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
||||||
if (workflow != null) {
|
if (workflow != null) {
|
||||||
//Make sure we find one
|
//Make sure we find one
|
||||||
HashMap<String, Role> allRoles = workflow.getRoles();
|
Map<String, Role> allRoles = workflow.getRoles();
|
||||||
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
||||||
for (String roleId : allRoles.keySet()) {
|
for (String roleId : allRoles.keySet()) {
|
||||||
Role role = allRoles.get(roleId);
|
Role role = allRoles.get(roleId);
|
||||||
@@ -279,13 +279,13 @@ public class WorkflowUtils extends Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static HashMap<String, Role> getAllExternalRoles(Collection thisCollection)
|
public static Map<String, Role> getAllExternalRoles(Collection thisCollection)
|
||||||
throws IOException, WorkflowConfigurationException, SQLException {
|
throws IOException, WorkflowConfigurationException, SQLException {
|
||||||
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
Workflow workflow = xmlWorkflowFactory.getWorkflow(thisCollection);
|
||||||
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
LinkedHashMap<String, Role> result = new LinkedHashMap<String, Role>();
|
||||||
if (workflow != null) {
|
if (workflow != null) {
|
||||||
//Make sure we find one
|
//Make sure we find one
|
||||||
HashMap<String, Role> allRoles = workflow.getRoles();
|
Map<String, Role> allRoles = workflow.getRoles();
|
||||||
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
//We have retrieved all our roles, not get the ones which can be configured by the collection
|
||||||
for (String roleId : allRoles.keySet()) {
|
for (String roleId : allRoles.keySet()) {
|
||||||
Role role = allRoles.get(roleId);
|
Role role = allRoles.get(roleId);
|
||||||
|
@@ -7,31 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow;
|
package org.dspace.xmlworkflow;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.apache.xpath.XPathAPI;
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.services.ConfigurationService;
|
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
|
||||||
import org.dspace.xmlworkflow.state.Workflow;
|
import org.dspace.xmlworkflow.state.Workflow;
|
||||||
import org.dspace.xmlworkflow.state.actions.UserSelectionActionConfig;
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The workflowfactory is responsible for parsing the
|
* The workflowfactory is responsible for parsing the
|
||||||
@@ -45,239 +26,28 @@ import org.w3c.dom.NodeList;
|
|||||||
*/
|
*/
|
||||||
public class XmlWorkflowFactoryImpl implements XmlWorkflowFactory {
|
public class XmlWorkflowFactoryImpl implements XmlWorkflowFactory {
|
||||||
|
|
||||||
private Logger log = org.apache.logging.log4j.LogManager.getLogger(XmlWorkflowFactoryImpl.class);
|
public static final String LEGACY_WORKFLOW_NAME = "defaultWorkflow";
|
||||||
|
|
||||||
@Autowired(required = true)
|
private Map<String, Workflow> workflowMapping;
|
||||||
protected ConfigurationService configurationService;
|
|
||||||
protected HashMap<String, Workflow> workflowCache;
|
|
||||||
protected String path;
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
protected void init() {
|
|
||||||
path = configurationService
|
|
||||||
.getProperty("dspace.dir") + File.separator + "config" + File.separator + "workflow.xml";
|
|
||||||
}
|
|
||||||
// private static String pathActions = ConfigurationManager.getProperty("dspace.dir")+"/config/workflow-actions.xml";
|
|
||||||
|
|
||||||
protected XmlWorkflowFactoryImpl() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Workflow getWorkflow(Collection collection) throws IOException, WorkflowConfigurationException {
|
public Workflow getWorkflow(Collection collection) throws WorkflowConfigurationException {
|
||||||
//Initialize our cache if we have none
|
|
||||||
if (workflowCache == null) {
|
|
||||||
workflowCache = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to retrieve our workflow object
|
// Attempt to retrieve our workflow object
|
||||||
if (workflowCache.get(collection.getHandle()) == null) {
|
if (workflowMapping.get(collection.getHandle()) == null) {
|
||||||
try {
|
final Workflow defaultWorkflow = workflowMapping.get(LEGACY_WORKFLOW_NAME);
|
||||||
// No workflow cache found for the collection, check if we have a workflowId for this collection
|
if (defaultWorkflow != null) {
|
||||||
File xmlFile = new File(path);
|
return defaultWorkflow;
|
||||||
Document input = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile);
|
|
||||||
Node mainNode = input.getFirstChild();
|
|
||||||
Node workflowMap = XPathAPI.selectSingleNode(mainNode,
|
|
||||||
"//workflow-map/name-map[@collection='" + collection
|
|
||||||
.getHandle() + "']");
|
|
||||||
if (workflowMap == null) {
|
|
||||||
//No workflowId found for this collection, so retrieve & use the default workflow
|
|
||||||
if (workflowCache.get("default") == null) {
|
|
||||||
String workflowID = XPathAPI
|
|
||||||
.selectSingleNode(mainNode, "//workflow-map/name-map[@collection='default']")
|
|
||||||
.getAttributes().getNamedItem("workflow").getTextContent();
|
|
||||||
if (workflowID == null) {
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"No mapping is present for collection with handle:" + collection.getHandle());
|
|
||||||
}
|
}
|
||||||
Node workflowNode = XPathAPI.selectSingleNode(mainNode, "//workflow[@id='" + workflowID + "']");
|
|
||||||
Workflow wf = new Workflow(workflowID, getRoles(workflowNode));
|
|
||||||
Step step = createFirstStep(wf, workflowNode);
|
|
||||||
wf.setFirstStep(step);
|
|
||||||
workflowCache.put("default", wf);
|
|
||||||
workflowCache.put(collection.getHandle(), wf);
|
|
||||||
return wf;
|
|
||||||
} else {
|
} else {
|
||||||
return workflowCache.get("default");
|
return workflowMapping.get(collection.getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
//We have a workflowID so retrieve it & resolve it to a workflow, also store it in our cache
|
|
||||||
String workflowID = workflowMap.getAttributes().getNamedItem("workflow").getTextContent();
|
|
||||||
|
|
||||||
Node workflowNode = XPathAPI.selectSingleNode(mainNode, "//workflow[@id='" + workflowID + "']");
|
|
||||||
Workflow wf = new Workflow(workflowID, getRoles(workflowNode));
|
|
||||||
Step step = createFirstStep(wf, workflowNode);
|
|
||||||
wf.setFirstStep(step);
|
|
||||||
workflowCache.put(collection.getHandle(), wf);
|
|
||||||
return wf;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error while retrieving workflow for collection: " + collection.getHandle(), e);
|
|
||||||
throw new WorkflowConfigurationException(
|
throw new WorkflowConfigurationException(
|
||||||
"Error while retrieving workflow for the following collection: " + collection.getHandle());
|
"Error while retrieving workflow for the following collection: " + collection.getHandle());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return workflowCache.get(collection.getHandle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Step createFirstStep(Workflow workflow, Node workflowNode)
|
@Required
|
||||||
throws TransformerException, WorkflowConfigurationException {
|
public void setWorkflowMapping(Map<String, Workflow> workflowMapping) {
|
||||||
String firstStepID = workflowNode.getAttributes().getNamedItem("start").getTextContent();
|
this.workflowMapping = workflowMapping;
|
||||||
Node stepNode = XPathAPI.selectSingleNode(workflowNode, "step[@id='" + firstStepID + "']");
|
|
||||||
if (stepNode == null) {
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"First step does not exist for workflow: " + workflowNode.getAttributes().getNamedItem("id")
|
|
||||||
.getTextContent());
|
|
||||||
}
|
|
||||||
Node roleNode = stepNode.getAttributes().getNamedItem("role");
|
|
||||||
Role role = null;
|
|
||||||
if (roleNode != null) {
|
|
||||||
role = workflow.getRoles().get(roleNode.getTextContent());
|
|
||||||
}
|
|
||||||
String userSelectionActionID = stepNode.getAttributes().getNamedItem("userSelectionMethod").getTextContent();
|
|
||||||
UserSelectionActionConfig userSelection = createUserAssignmentActionConfig(userSelectionActionID);
|
|
||||||
return new Step(firstStepID, workflow, role, userSelection, getStepActionConfigs(stepNode),
|
|
||||||
getStepOutcomes(stepNode), getNbRequiredUser(stepNode));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected Map<Integer, String> getStepOutcomes(Node stepNode)
|
|
||||||
throws TransformerException, WorkflowConfigurationException {
|
|
||||||
try {
|
|
||||||
NodeList outcomesNodeList = XPathAPI.selectNodeList(stepNode, "outcomes/step");
|
|
||||||
Map<Integer, String> outcomes = new HashMap<Integer, String>();
|
|
||||||
//Add our outcome, should it be null it will be interpreted as the end of the line (last step)
|
|
||||||
for (int i = 0; i < outcomesNodeList.getLength(); i++) {
|
|
||||||
Node outcomeNode = outcomesNodeList.item(i);
|
|
||||||
int index = Integer.parseInt(outcomeNode.getAttributes().getNamedItem("status").getTextContent());
|
|
||||||
if (index < 0) {
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"Outcome configuration error for step: " + stepNode.getAttributes().getNamedItem("id")
|
|
||||||
.getTextContent());
|
|
||||||
}
|
|
||||||
outcomes.put(index, outcomeNode.getTextContent());
|
|
||||||
}
|
|
||||||
return outcomes;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(
|
|
||||||
"Outcome configuration error for step: " + stepNode.getAttributes().getNamedItem("id").getTextContent(),
|
|
||||||
e);
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"Outcome configuration error for step: " + stepNode.getAttributes().getNamedItem("id")
|
|
||||||
.getTextContent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getNbRequiredUser(Node stepnode) {
|
|
||||||
if (stepnode.getAttributes().getNamedItem("requiredUsers") != null) {
|
|
||||||
return Integer.parseInt(stepnode.getAttributes().getNamedItem("requiredUsers").getTextContent());
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> getStepActionConfigs(Node stepNode) throws TransformerException {
|
|
||||||
NodeList actionConfigNodes = XPathAPI.selectNodeList(stepNode, "actions/action");
|
|
||||||
List<String> actionConfigIDs = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < actionConfigNodes.getLength(); i++) {
|
|
||||||
actionConfigIDs.add(actionConfigNodes.item(i).getAttributes().getNamedItem("id").getTextContent());
|
|
||||||
}
|
|
||||||
return actionConfigIDs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Step createStep(Workflow workflow, String stepID) throws WorkflowConfigurationException, IOException {
|
|
||||||
try {
|
|
||||||
File xmlFile = new File(path);
|
|
||||||
Document input = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile);
|
|
||||||
Node mainNode = input.getFirstChild();
|
|
||||||
Node stepNode = XPathAPI
|
|
||||||
.selectSingleNode(mainNode, "//workflow[@id='" + workflow.getID() + "']/step[@id='" + stepID + "']");
|
|
||||||
|
|
||||||
if (stepNode == null) {
|
|
||||||
throw new WorkflowConfigurationException("Step does not exist for workflow: " + workflow.getID());
|
|
||||||
}
|
|
||||||
Node roleNode = stepNode.getAttributes().getNamedItem("role");
|
|
||||||
Role role = null;
|
|
||||||
if (roleNode != null) {
|
|
||||||
role = workflow.getRoles().get(roleNode.getTextContent());
|
|
||||||
}
|
|
||||||
String userSelectionActionID = stepNode.getAttributes().getNamedItem("userSelectionMethod")
|
|
||||||
.getTextContent();
|
|
||||||
UserSelectionActionConfig userSelection = createUserAssignmentActionConfig(userSelectionActionID);
|
|
||||||
return new Step(stepID, workflow, role, userSelection, getStepActionConfigs(stepNode),
|
|
||||||
getStepOutcomes(stepNode), getNbRequiredUser(stepNode));
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error while creating step with :" + stepID, e);
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"Step: " + stepID + " does not exist for workflow: " + workflow.getID());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected UserSelectionActionConfig createUserAssignmentActionConfig(String userSelectionActionID) {
|
|
||||||
return DSpaceServicesFactory.getInstance().getServiceManager()
|
|
||||||
.getServiceByName(userSelectionActionID, UserSelectionActionConfig.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkflowActionConfig createWorkflowActionConfig(String actionID) {
|
|
||||||
return DSpaceServicesFactory.getInstance().getServiceManager()
|
|
||||||
.getServiceByName(actionID, WorkflowActionConfig.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LinkedHashMap<String, Role> getRoles(Node workflowNode) throws WorkflowConfigurationException {
|
|
||||||
NodeList roleNodes = null;
|
|
||||||
try {
|
|
||||||
roleNodes = XPathAPI.selectNodeList(workflowNode, "roles/role");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Error while resolving nodes", e);
|
|
||||||
throw new WorkflowConfigurationException("Error while retrieving roles");
|
|
||||||
}
|
|
||||||
LinkedHashMap<String, Role> roles = new LinkedHashMap<String, Role>();
|
|
||||||
for (int i = 0; i < roleNodes.getLength(); i++) {
|
|
||||||
String roleID = roleNodes.item(i).getAttributes().getNamedItem("id").getTextContent();
|
|
||||||
String roleName = roleNodes.item(i).getAttributes().getNamedItem("name").getTextContent();
|
|
||||||
Node descriptionNode = roleNodes.item(i).getAttributes().getNamedItem("description");
|
|
||||||
String roleDescription = null;
|
|
||||||
if (descriptionNode != null) {
|
|
||||||
roleDescription = descriptionNode.getTextContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
Node scopeNode = roleNodes.item(i).getAttributes().getNamedItem("scope");
|
|
||||||
String roleScope = null;
|
|
||||||
if (scopeNode != null) {
|
|
||||||
roleScope = scopeNode.getTextContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
Node internalNode = roleNodes.item(i).getAttributes().getNamedItem("internal");
|
|
||||||
String roleInternal;
|
|
||||||
boolean internal = false;
|
|
||||||
if (internalNode != null) {
|
|
||||||
roleInternal = internalNode.getTextContent();
|
|
||||||
internal = Boolean.parseBoolean(roleInternal);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Role.Scope scope;
|
|
||||||
if (roleScope == null || roleScope.equalsIgnoreCase("collection")) {
|
|
||||||
scope = Role.Scope.COLLECTION;
|
|
||||||
} else if (roleScope.equalsIgnoreCase("item")) {
|
|
||||||
scope = Role.Scope.ITEM;
|
|
||||||
} else if (roleScope.equalsIgnoreCase("repository")) {
|
|
||||||
scope = Role.Scope.REPOSITORY;
|
|
||||||
} else {
|
|
||||||
throw new WorkflowConfigurationException(
|
|
||||||
"An invalid role scope has been specified it must either be item or collection.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Role role = new Role(roleID, roleName, roleDescription, internal, scope);
|
|
||||||
roles.put(roleID, role);
|
|
||||||
}
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@@ -7,14 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.factory;
|
package org.dspace.xmlworkflow.factory;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
|
||||||
import org.dspace.xmlworkflow.state.Workflow;
|
import org.dspace.xmlworkflow.state.Workflow;
|
||||||
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The xmlworkflowfactory is responsible for parsing the
|
* The xmlworkflowfactory is responsible for parsing the
|
||||||
@@ -28,11 +23,13 @@ import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
|||||||
*/
|
*/
|
||||||
public interface XmlWorkflowFactory {
|
public interface XmlWorkflowFactory {
|
||||||
|
|
||||||
public final String LEGACY_WORKFLOW_NAME = "default";
|
|
||||||
|
|
||||||
public Workflow getWorkflow(Collection collection) throws IOException, WorkflowConfigurationException, SQLException;
|
/**
|
||||||
|
* Retrieve the workflow configuration for a single collection
|
||||||
public Step createStep(Workflow workflow, String stepID) throws WorkflowConfigurationException, IOException;
|
*
|
||||||
|
* @param collection the collection for which we want our workflow
|
||||||
public WorkflowActionConfig createWorkflowActionConfig(String actionID);
|
* @return the workflow configuration
|
||||||
|
* @throws WorkflowConfigurationException occurs if there is a configuration error in the workflow
|
||||||
|
*/
|
||||||
|
public Workflow getWorkflow(Collection collection) throws WorkflowConfigurationException;
|
||||||
}
|
}
|
||||||
|
@@ -7,22 +7,22 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.state;
|
package org.dspace.xmlworkflow.state;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.workflow.WorkflowException;
|
|
||||||
import org.dspace.xmlworkflow.Role;
|
import org.dspace.xmlworkflow.Role;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
|
||||||
import org.dspace.xmlworkflow.state.actions.UserSelectionActionConfig;
|
import org.dspace.xmlworkflow.state.actions.UserSelectionActionConfig;
|
||||||
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
import org.dspace.xmlworkflow.state.actions.WorkflowActionConfig;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.service.InProgressUserService;
|
import org.dspace.xmlworkflow.storedcomponents.service.InProgressUserService;
|
||||||
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that contains all the data of an xlworkflow step
|
* A class that contains all the data of an xlworkflow step
|
||||||
@@ -32,47 +32,37 @@ import org.dspace.xmlworkflow.storedcomponents.service.InProgressUserService;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public class Step {
|
public class Step implements BeanNameAware {
|
||||||
|
|
||||||
|
|
||||||
protected InProgressUserService inProgressUserService = XmlWorkflowServiceFactory.getInstance()
|
|
||||||
.getInProgressUserService();
|
|
||||||
protected XmlWorkflowFactory xmlWorkflowFactory = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory();
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected InProgressUserService inProgressUserService;
|
||||||
|
|
||||||
private UserSelectionActionConfig userSelectionMethod;
|
private UserSelectionActionConfig userSelectionMethod;
|
||||||
private HashMap<String, WorkflowActionConfig> actionConfigsMap;
|
private List<WorkflowActionConfig> actions;
|
||||||
private List<String> actionConfigsList;
|
private Map<Integer, Step> outcomes = new HashMap<>();
|
||||||
private Map<Integer, String> outcomes;
|
|
||||||
private String id;
|
private String id;
|
||||||
private Role role;
|
private Role role;
|
||||||
private Workflow workflow;
|
private Workflow workflow;
|
||||||
private int requiredUsers;
|
private int requiredUsers = 1;
|
||||||
|
|
||||||
public Step(String id, Workflow workflow, Role role, UserSelectionActionConfig userSelectionMethod,
|
|
||||||
List<String> actionConfigsList, Map<Integer, String> outcomes, int requiredUsers) {
|
|
||||||
this.actionConfigsMap = new HashMap<>();
|
|
||||||
this.outcomes = outcomes;
|
|
||||||
this.userSelectionMethod = userSelectionMethod;
|
|
||||||
this.role = role;
|
|
||||||
this.actionConfigsList = actionConfigsList;
|
|
||||||
this.id = id;
|
|
||||||
userSelectionMethod.setStep(this);
|
|
||||||
this.requiredUsers = requiredUsers;
|
|
||||||
this.workflow = workflow;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an WorkflowActionConfiguration object for the provided action identifier
|
||||||
|
* @param actionID the action id for which we want our action config
|
||||||
|
* @return The corresponding WorkflowActionConfiguration
|
||||||
|
* @throws WorkflowConfigurationException occurs if the provided action isn't part of the step
|
||||||
|
*/
|
||||||
|
public WorkflowActionConfig getActionConfig(String actionID) throws WorkflowConfigurationException {
|
||||||
|
// First check the userSelectionMethod as this is not a regular "action"
|
||||||
|
if (userSelectionMethod != null && StringUtils.equals(userSelectionMethod.getId(), actionID)) {
|
||||||
|
return userSelectionMethod;
|
||||||
}
|
}
|
||||||
|
for (WorkflowActionConfig actionConfig : actions) {
|
||||||
public WorkflowActionConfig getActionConfig(String actionID) {
|
if (StringUtils.equals(actionConfig.getId(), actionID)) {
|
||||||
if (actionConfigsMap.get(actionID) != null) {
|
return actionConfig;
|
||||||
return actionConfigsMap.get(actionID);
|
|
||||||
} else {
|
|
||||||
WorkflowActionConfig action = xmlWorkflowFactory.createWorkflowActionConfig(actionID);
|
|
||||||
action.setStep(this);
|
|
||||||
actionConfigsMap.put(actionID, action);
|
|
||||||
return action;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new WorkflowConfigurationException("Action configuration not found for: " + actionID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean that returns whether or not the actions in this step have a ui
|
* Boolean that returns whether or not the actions in this step have a ui
|
||||||
@@ -80,8 +70,7 @@ public class Step {
|
|||||||
* @return a boolean
|
* @return a boolean
|
||||||
*/
|
*/
|
||||||
public boolean hasUI() {
|
public boolean hasUI() {
|
||||||
for (String actionConfigId : actionConfigsList) {
|
for (WorkflowActionConfig actionConfig : actions) {
|
||||||
WorkflowActionConfig actionConfig = getActionConfig(actionConfigId);
|
|
||||||
if (actionConfig.requiresUI()) {
|
if (actionConfig.requiresUI()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -89,8 +78,12 @@ public class Step {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNextStepID(int outcome)
|
/**
|
||||||
throws WorkflowException, IOException, WorkflowConfigurationException, SQLException {
|
* Get the next step based on out the outcome
|
||||||
|
* @param outcome the outcome of the previous step
|
||||||
|
* @return the next stepp or NULL if there is no step configured for this outcome
|
||||||
|
*/
|
||||||
|
public Step getNextStep(int outcome) {
|
||||||
return outcomes.get(outcome);
|
return outcomes.get(outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,9 +102,9 @@ public class Step {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WorkflowActionConfig getNextAction(WorkflowActionConfig currentAction) {
|
public WorkflowActionConfig getNextAction(WorkflowActionConfig currentAction) {
|
||||||
int index = actionConfigsList.indexOf(currentAction.getId());
|
int index = actions.indexOf(currentAction);
|
||||||
if (index < actionConfigsList.size() - 1) {
|
if (index < actions.size() - 1) {
|
||||||
return getActionConfig(actionConfigsList.get(index + 1));
|
return actions.get(index + 1);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -125,7 +118,6 @@ public class Step {
|
|||||||
return workflow;
|
return workflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if enough users have finished this step for it to continue
|
* Check if enough users have finished this step for it to continue
|
||||||
*
|
*
|
||||||
@@ -146,6 +138,78 @@ public class Step {
|
|||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public boolean skipStep() {
|
/**
|
||||||
// }
|
* Set the user selection configuration, this is required as every step requires one
|
||||||
|
* @param userSelectionMethod the user selection method configuration
|
||||||
|
*/
|
||||||
|
@Required
|
||||||
|
public void setUserSelectionMethod(UserSelectionActionConfig userSelectionMethod) {
|
||||||
|
this.userSelectionMethod = userSelectionMethod;
|
||||||
|
userSelectionMethod.setStep(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the outcomes as a map, if no outcomes are configured this step will be last step in the workflow
|
||||||
|
* @param outcomes the map containing the outcomes.
|
||||||
|
*/
|
||||||
|
public void setOutcomes(Map<Integer, Step> outcomes) {
|
||||||
|
this.outcomes = outcomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the processing actions for the step. Processing actions contain the logic required to execute the required
|
||||||
|
* operations in each step.
|
||||||
|
* @return the actions configured for this step
|
||||||
|
*/
|
||||||
|
public List<WorkflowActionConfig> getActions() {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the processing actions for the step. Processing actions contain the logic required to execute the required
|
||||||
|
* operations in each step.
|
||||||
|
* @param actions the list of actions
|
||||||
|
*/
|
||||||
|
@Required
|
||||||
|
public void setActions(List<WorkflowActionConfig> actions) {
|
||||||
|
for (WorkflowActionConfig workflowActionConfig : actions) {
|
||||||
|
workflowActionConfig.setStep(this);
|
||||||
|
}
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the workflow this step belongs to
|
||||||
|
* @param workflow the workflow configuration
|
||||||
|
*/
|
||||||
|
protected void setWorkflow(Workflow workflow) {
|
||||||
|
this.workflow = workflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the name of the bean in the identifier
|
||||||
|
* @param s the bean name
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setBeanName(String s) {
|
||||||
|
id = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the number of required users that need to execute this step before it is completed,
|
||||||
|
* the default is a single user
|
||||||
|
* @param requiredUsers the number of required users
|
||||||
|
*/
|
||||||
|
public void setRequiredUsers(int requiredUsers) {
|
||||||
|
this.requiredUsers = requiredUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the role of which users role should execute this step
|
||||||
|
* @param role the role to be configured for this step
|
||||||
|
*/
|
||||||
|
public void setRole(Role role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,18 +7,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.state;
|
package org.dspace.xmlworkflow.state;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.workflow.WorkflowException;
|
|
||||||
import org.dspace.xmlworkflow.Role;
|
import org.dspace.xmlworkflow.Role;
|
||||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
||||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that contains all the steps and roles involved in a certain
|
* Class that contains all the steps and roles involved in a certain
|
||||||
@@ -29,21 +29,11 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public class Workflow {
|
public class Workflow implements BeanNameAware {
|
||||||
|
|
||||||
protected XmlWorkflowFactory xmlWorkflowFactory = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory();
|
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private Step firstStep;
|
private Step firstStep;
|
||||||
private HashMap<String, Step> steps;
|
private List<Step> steps;
|
||||||
private LinkedHashMap<String, Role> roles;
|
|
||||||
|
|
||||||
|
|
||||||
public Workflow(String workflowID, LinkedHashMap<String, Role> roles) {
|
|
||||||
this.id = workflowID;
|
|
||||||
this.roles = roles;
|
|
||||||
this.steps = new HashMap<String, Step>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Step getFirstStep() {
|
public Step getFirstStep() {
|
||||||
return firstStep;
|
return firstStep;
|
||||||
@@ -56,46 +46,72 @@ public class Workflow {
|
|||||||
/*
|
/*
|
||||||
* Return a step with a given id
|
* Return a step with a given id
|
||||||
*/
|
*/
|
||||||
public Step getStep(String stepID) throws WorkflowConfigurationException, IOException {
|
public Step getStep(String stepID) throws WorkflowConfigurationException {
|
||||||
if (steps.get(id) != null) {
|
for (Step step : steps) {
|
||||||
return steps.get(id);
|
if (step.getId().equals(stepID)) {
|
||||||
} else {
|
|
||||||
Step step = xmlWorkflowFactory.createStep(this, stepID);
|
|
||||||
if (step == null) {
|
|
||||||
throw new WorkflowConfigurationException("Step definition not found for: " + stepID);
|
|
||||||
}
|
|
||||||
steps.put(stepID, step);
|
|
||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new WorkflowConfigurationException("Step definition not found for: " + stepID);
|
||||||
|
}
|
||||||
|
|
||||||
public Step getNextStep(Context context, XmlWorkflowItem wfi, Step currentStep, int outcome)
|
public Step getNextStep(Context context, XmlWorkflowItem wfi, Step currentStep, int outcome)
|
||||||
throws IOException, WorkflowConfigurationException, WorkflowException, SQLException {
|
throws WorkflowConfigurationException, SQLException {
|
||||||
String nextStepID = currentStep.getNextStepID(outcome);
|
Step nextStep = currentStep.getNextStep(outcome);
|
||||||
if (nextStepID != null) {
|
if (nextStep != null) {
|
||||||
Step nextStep = getStep(nextStepID);
|
|
||||||
if (nextStep == null) {
|
|
||||||
throw new WorkflowException(
|
|
||||||
"Error while processing outcome, the following action was undefined: " + nextStepID);
|
|
||||||
}
|
|
||||||
if (nextStep.isValidStep(context, wfi)) {
|
if (nextStep.isValidStep(context, wfi)) {
|
||||||
return nextStep;
|
return nextStep;
|
||||||
} else {
|
} else {
|
||||||
return getNextStep(context, wfi, nextStep, 0);
|
return getNextStep(context, wfi, nextStep, ActionResult.OUTCOME_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//No next step, archive it
|
//No next step, archive it
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Required
|
||||||
public void setFirstStep(Step firstStep) {
|
public void setFirstStep(Step firstStep) {
|
||||||
|
firstStep.setWorkflow(this);
|
||||||
this.firstStep = firstStep;
|
this.firstStep = firstStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Role> getRoles() {
|
/**
|
||||||
|
* Get the steps that need to be executed in this workflow before the item is archived
|
||||||
|
* @return the workflow steps
|
||||||
|
*/
|
||||||
|
public List<Step> getSteps() {
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the steps that need to be executed in this workflow before the item is archived
|
||||||
|
* @param steps the workflow steps
|
||||||
|
*/
|
||||||
|
@Required
|
||||||
|
public void setSteps(List<Step> steps) {
|
||||||
|
for (Step step : steps) {
|
||||||
|
step.setWorkflow(this);
|
||||||
|
}
|
||||||
|
this.steps = steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the roles that are used in this workflow
|
||||||
|
* @return a map containing the roles, the role name will the key, the role itself the value
|
||||||
|
*/
|
||||||
|
public Map<String, Role> getRoles() {
|
||||||
|
Map<String, Role> roles = new HashMap<>();
|
||||||
|
for (Step step : steps) {
|
||||||
|
if (step.getRole() != null) {
|
||||||
|
roles.put(step.getRole().getName(), step.getRole());
|
||||||
|
}
|
||||||
|
}
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBeanName(String s) {
|
||||||
|
id = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,12 +19,14 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.service.EPersonService;
|
import org.dspace.eperson.service.EPersonService;
|
||||||
import org.dspace.workflow.WorkflowException;
|
import org.dspace.workflow.WorkflowException;
|
||||||
|
import org.dspace.xmlworkflow.Role;
|
||||||
import org.dspace.xmlworkflow.state.Step;
|
import org.dspace.xmlworkflow.state.Step;
|
||||||
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
import org.dspace.xmlworkflow.state.actions.ActionResult;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.WorkflowItemRole;
|
import org.dspace.xmlworkflow.storedcomponents.WorkflowItemRole;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService;
|
import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processing class for an action where an assigned user can
|
* Processing class for an action where an assigned user can
|
||||||
@@ -42,7 +44,7 @@ public class SelectReviewerAction extends ProcessingAction {
|
|||||||
|
|
||||||
public static final int RESULTS_PER_PAGE = 5;
|
public static final int RESULTS_PER_PAGE = 5;
|
||||||
|
|
||||||
private String roleId;
|
private Role role;
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
protected EPersonService ePersonService;
|
protected EPersonService ePersonService;
|
||||||
@@ -90,7 +92,7 @@ public class SelectReviewerAction extends ProcessingAction {
|
|||||||
//We have a reviewer, assign him, the workflowitemrole will be translated into a task in the autoassign
|
//We have a reviewer, assign him, the workflowitemrole will be translated into a task in the autoassign
|
||||||
WorkflowItemRole workflowItemRole = workflowItemRoleService.create(c);
|
WorkflowItemRole workflowItemRole = workflowItemRoleService.create(c);
|
||||||
workflowItemRole.setEPerson(reviewer);
|
workflowItemRole.setEPerson(reviewer);
|
||||||
workflowItemRole.setRoleId(getRoleId());
|
workflowItemRole.setRoleId(getRole().getId());
|
||||||
workflowItemRole.setWorkflowItem(wfi);
|
workflowItemRole.setWorkflowItem(wfi);
|
||||||
workflowItemRoleService.update(c, workflowItemRole);
|
workflowItemRoleService.update(c, workflowItemRole);
|
||||||
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE);
|
||||||
@@ -100,11 +102,12 @@ public class SelectReviewerAction extends ProcessingAction {
|
|||||||
return new ActionResult(ActionResult.TYPE.TYPE_ERROR);
|
return new ActionResult(ActionResult.TYPE.TYPE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRoleId() {
|
public Role getRole() {
|
||||||
return roleId;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoleId(String roleId) {
|
@Required
|
||||||
this.roleId = roleId;
|
public void setRole(Role role) {
|
||||||
|
this.role = role;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,10 +18,8 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +32,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_claimtask")
|
@Table(name = "cwf_claimtask")
|
||||||
public class ClaimedTask implements ReloadableEntity<Integer>, IndexableObject<Integer> {
|
public class ClaimedTask implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "claimtask_id")
|
@Column(name = "claimtask_id")
|
||||||
@@ -116,10 +114,4 @@ public class ClaimedTask implements ReloadableEntity<Integer>, IndexableObject<I
|
|||||||
public String getWorkflowID() {
|
public String getWorkflowID() {
|
||||||
return workflowId;
|
return workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return Constants.CLAIMEDTASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.dao.ClaimedTaskDAO;
|
import org.dspace.xmlworkflow.storedcomponents.dao.ClaimedTaskDAO;
|
||||||
@@ -37,11 +36,6 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return Constants.CLAIMEDTASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimedTask create(Context context) throws SQLException, AuthorizeException {
|
public ClaimedTask create(Context context) throws SQLException, AuthorizeException {
|
||||||
return claimedTaskDAO.create(context, new ClaimedTask());
|
return claimedTaskDAO.create(context, new ClaimedTask());
|
||||||
@@ -53,11 +47,8 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimedTask findIndexableObject(Context context, Integer id) throws SQLException {
|
public List<ClaimedTask> findAll(Context context) throws SQLException {
|
||||||
if (id == null) {
|
return claimedTaskDAO.findAll(context, ClaimedTask.class);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return find(context, id.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,10 +19,8 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ import org.dspace.eperson.Group;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_pooltask")
|
@Table(name = "cwf_pooltask")
|
||||||
public class PoolTask implements ReloadableEntity<Integer>, IndexableObject<Integer> {
|
public class PoolTask implements ReloadableEntity<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "pooltask_id")
|
@Column(name = "pooltask_id")
|
||||||
@@ -131,10 +129,4 @@ public class PoolTask implements ReloadableEntity<Integer>, IndexableObject<Inte
|
|||||||
public String getActionID() {
|
public String getActionID() {
|
||||||
return this.actionId;
|
return this.actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return Constants.POOLTASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
@@ -49,8 +48,8 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
public List<PoolTask> findAll(Context context) throws SQLException {
|
||||||
return Constants.POOLTASK;
|
return poolTaskDAO.findAll(context, PoolTask.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,14 +140,6 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
return poolTaskDAO.findByID(context, PoolTask.class, id);
|
return poolTaskDAO.findByID(context, PoolTask.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PoolTask findIndexableObject(Context context, Integer id) throws SQLException {
|
|
||||||
if (id == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return find(context, id.intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Context context, PoolTask poolTask) throws SQLException, AuthorizeException {
|
public void update(Context context, PoolTask poolTask) throws SQLException, AuthorizeException {
|
||||||
update(context, Collections.singletonList(poolTask));
|
update(context, Collections.singletonList(poolTask));
|
||||||
|
@@ -7,8 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.xmlworkflow.storedcomponents;
|
package org.dspace.xmlworkflow.storedcomponents;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -23,10 +21,7 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
|
||||||
import org.dspace.discovery.IndexableObject;
|
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
|
|
||||||
@@ -40,7 +35,7 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_workflowitem")
|
@Table(name = "cwf_workflowitem")
|
||||||
public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>, IndexableObject<Integer> {
|
public class XmlWorkflowItem implements WorkflowItem {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workflowitem_id")
|
@Column(name = "workflowitem_id")
|
||||||
@@ -103,7 +98,7 @@ public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EPerson getSubmitter() throws SQLException {
|
public EPerson getSubmitter() {
|
||||||
return item.getSubmitter();
|
return item.getSubmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,10 +138,4 @@ public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>,
|
|||||||
// simplified
|
// simplified
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getType() {
|
|
||||||
return Constants.WORKFLOWITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -63,11 +62,6 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSupportsIndexableObjectTypeConstant() {
|
|
||||||
return Constants.WORKFLOWITEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlWorkflowItem create(Context context, Item item, Collection collection)
|
public XmlWorkflowItem create(Context context, Item item, Collection collection)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
@@ -95,14 +89,6 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XmlWorkflowItem findIndexableObject(Context context, Integer id) throws SQLException {
|
|
||||||
if (id != null) {
|
|
||||||
return find(context, id);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<XmlWorkflowItem> findAll(Context context) throws SQLException {
|
public List<XmlWorkflowItem> findAll(Context context) throws SQLException {
|
||||||
return xmlWorkflowItemDAO.findAll(context, XmlWorkflowItem.class);
|
return xmlWorkflowItemDAO.findAll(context, XmlWorkflowItem.class);
|
||||||
|
@@ -11,7 +11,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -25,8 +24,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask> {
|
||||||
IndexableObjectService<ClaimedTask, Integer> {
|
|
||||||
|
|
||||||
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
||||||
|
|
||||||
@@ -49,4 +47,6 @@ public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
|||||||
|
|
||||||
public void deleteByWorkflowItem(Context context, XmlWorkflowItem workflowItem)
|
public void deleteByWorkflowItem(Context context, XmlWorkflowItem workflowItem)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
List<ClaimedTask> findAll(Context context) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.IndexableObjectService;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -26,7 +25,10 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, IndexableObjectService<PoolTask, Integer> {
|
public interface PoolTaskService extends DSpaceCRUDService<PoolTask> {
|
||||||
|
|
||||||
|
public List<PoolTask> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
@@ -0,0 +1,17 @@
|
|||||||
|
--
|
||||||
|
-- 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/
|
||||||
|
--
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- DS-4239 Migrate the workflow.xml to spring
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- This script will rename the default workflow "default" name
|
||||||
|
-- to the new "defaultWorkflow" identifier
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
UPDATE cwf_pooltask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
||||||
|
UPDATE cwf_claimtask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
@@ -0,0 +1,17 @@
|
|||||||
|
--
|
||||||
|
-- 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/
|
||||||
|
--
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- DS-4239 Migrate the workflow.xml to spring
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- This script will rename the default workflow "default" name
|
||||||
|
-- to the new "defaultWorkflow" identifier
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
UPDATE cwf_pooltask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
||||||
|
UPDATE cwf_claimtask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
@@ -0,0 +1,17 @@
|
|||||||
|
--
|
||||||
|
-- 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/
|
||||||
|
--
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- DS-4239 Migrate the workflow.xml to spring
|
||||||
|
---------------------------------------------------------------
|
||||||
|
-- This script will rename the default workflow "default" name
|
||||||
|
-- to the new "defaultWorkflow" identifier
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
UPDATE cwf_pooltask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
||||||
|
UPDATE cwf_claimtask SET workflow_id='defaultWorkflow' WHERE workflow_id='default';
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<context:annotation-config/> <!-- allows us to use spring annotations in beans -->
|
<context:annotation-config/> <!-- allows us to use spring annotations in beans -->
|
||||||
|
|
||||||
<bean class="org.dspace.discovery.MockSolrServiceImpl" id="org.dspace.discovery.SearchService"/>
|
<bean class="org.dspace.discovery.SolrServiceImpl" id="org.dspace.discovery.SearchService"/>
|
||||||
|
|
||||||
<alias name="org.dspace.discovery.SearchService" alias="org.dspace.discovery.IndexingService"/>
|
<alias name="org.dspace.discovery.SearchService" alias="org.dspace.discovery.IndexingService"/>
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@
|
|||||||
<bean class="org.dspace.authority.MockAuthoritySolrServiceImpl" id="org.dspace.authority.AuthoritySearchService"/>
|
<bean class="org.dspace.authority.MockAuthoritySolrServiceImpl" id="org.dspace.authority.AuthoritySearchService"/>
|
||||||
<alias name="org.dspace.authority.AuthoritySearchService" alias="org.dspace.authority.indexer.AuthorityIndexingService"/>
|
<alias name="org.dspace.authority.AuthoritySearchService" alias="org.dspace.authority.indexer.AuthorityIndexingService"/>
|
||||||
|
|
||||||
|
<bean id="org.dspace.discovery.SolrSearchCore" class="org.dspace.discovery.MockSolrSearchCore" autowire-candidate="true"/>
|
||||||
|
|
||||||
<!--<bean class="org.dspace.discovery.SolrServiceIndexOutputPlugin" id="solrServiceIndexOutputPlugin"/>-->
|
<!--<bean class="org.dspace.discovery.SolrServiceIndexOutputPlugin" id="solrServiceIndexOutputPlugin"/>-->
|
||||||
|
|
||||||
<!-- Statistics services are both lazy loaded (by name), as you are likely just using ONE of them and not both -->
|
<!-- Statistics services are both lazy loaded (by name), as you are likely just using ONE of them and not both -->
|
||||||
|
@@ -0,0 +1,190 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||||
|
|
||||||
|
<bean name="xmlWorkflowFactory" class="org.dspace.xmlworkflow.XmlWorkflowFactoryImpl">
|
||||||
|
<property name="workflowMapping">
|
||||||
|
<util:map>
|
||||||
|
<entry key="defaultWorkflow"
|
||||||
|
value-ref="defaultWorkflow"/>
|
||||||
|
<entry key="123456789/4" value-ref="selectSingleReviewer"/>
|
||||||
|
<!-- <entry key="123456789/5" value-ref="scoreReview"/>-->
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!--Standard DSpace workflow-->
|
||||||
|
<bean name="defaultWorkflow" class="org.dspace.xmlworkflow.state.Workflow">
|
||||||
|
<property name="firstStep" ref="reviewstep"/>
|
||||||
|
<property name="steps">
|
||||||
|
<util:list>
|
||||||
|
<ref bean="reviewstep"/>
|
||||||
|
<ref bean="editstep"/>
|
||||||
|
<ref bean="finaleditstep"/>
|
||||||
|
</util:list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="reviewstep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="claimaction"/>
|
||||||
|
<property name="role" ref="reviewer"/>
|
||||||
|
<property name="outcomes">
|
||||||
|
<util:map>
|
||||||
|
<entry key="#{ T(org.dspace.xmlworkflow.state.actions.ActionResult).OUTCOME_COMPLETE}"
|
||||||
|
value-ref="editstep"/>
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
<property name="actions">
|
||||||
|
<util:list>
|
||||||
|
<ref bean="reviewaction"/>
|
||||||
|
</util:list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="reviewer" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).COLLECTION}"/>
|
||||||
|
<property name="name" value="Reviewer"/>
|
||||||
|
<property name="description"
|
||||||
|
value="The people responsible for this step are able to edit the metadata of incoming submissions, and then accept or reject them."/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="editstep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="claimaction"/>
|
||||||
|
<property name="role" ref="editor" />
|
||||||
|
<property name="outcomes">
|
||||||
|
<util:map>
|
||||||
|
<entry key="#{ T(org.dspace.xmlworkflow.state.actions.ActionResult).OUTCOME_COMPLETE}"
|
||||||
|
value-ref="finaleditstep"/>
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="editaction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="editor" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).COLLECTION}"/>
|
||||||
|
<property name="name" value="Editor"/>
|
||||||
|
<property name="description"
|
||||||
|
value="The people responsible for this step are able to edit the metadata of incoming submissions, and then accept or reject them."/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="finaleditstep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="claimaction"/>
|
||||||
|
<property name="role" ref="finaleditor" />
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="finaleditaction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="finaleditor" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).COLLECTION}"/>
|
||||||
|
<property name="name" value="Final Editor"/>
|
||||||
|
<property name="description"
|
||||||
|
value="The people responsible for this step are able to edit the metadata of incoming submissions, but will not be able to reject them."/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!--Workflow where a reviewManager can select a single review who will then either accept/reject the item-->
|
||||||
|
<bean name="selectSingleReviewer" class="org.dspace.xmlworkflow.state.Workflow">
|
||||||
|
<property name="firstStep" ref="selectReviewerStep"/>
|
||||||
|
<property name="steps">
|
||||||
|
<util:list>
|
||||||
|
<ref bean="selectReviewerStep"/>
|
||||||
|
<ref bean="singleUserReviewStep"/>
|
||||||
|
</util:list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="selectReviewerStep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="claimaction"/>
|
||||||
|
<property name="role" ref="reviewmanagers">
|
||||||
|
</property>
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="selectrevieweraction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<property name="outcomes">
|
||||||
|
<util:map>
|
||||||
|
<entry key="#{ T(org.dspace.xmlworkflow.state.actions.ActionResult).OUTCOME_COMPLETE}"
|
||||||
|
value-ref="singleUserReviewStep"/>
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="reviewmanagers" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).REPOSITORY}"/>
|
||||||
|
<property name="name" value="ReviewManagers"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="singleUserReviewStep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="autoassignAction"/>
|
||||||
|
<property name="role" ref="scoreAssignedReviewer">
|
||||||
|
</property>
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="singleuserreviewaction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<property name="outcomes">
|
||||||
|
<util:map>
|
||||||
|
<entry key="#{ T(org.dspace.xmlworkflow.state.actions.processingaction.SingleUserReviewAction).OUTCOME_REJECT}"
|
||||||
|
value-ref="selectReviewerStep"/>
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="scoreAssignedReviewer" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).ITEM}"/>
|
||||||
|
<property name="name" value="Reviewer"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<!--Workflow where a number of users will perform reviews on an item and depending on the scores the item will be archived/rejected-->
|
||||||
|
<bean name="scoreReview" class="org.dspace.xmlworkflow.state.Workflow">
|
||||||
|
<property name="firstStep" ref="scoreReviewStep"/>
|
||||||
|
<property name="steps">
|
||||||
|
<util:list>
|
||||||
|
<ref bean="scoreReviewStep"/>
|
||||||
|
<ref bean="evaluationStep"/>
|
||||||
|
</util:list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="scoreReviewStep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="claimaction"/>
|
||||||
|
<property name="role" ref="scoreReviewers"/>
|
||||||
|
<property name="outcomes">
|
||||||
|
<util:map>
|
||||||
|
<entry key="#{ T(org.dspace.xmlworkflow.state.actions.ActionResult).OUTCOME_COMPLETE}"
|
||||||
|
value-ref="evaluationStep"/>
|
||||||
|
</util:map>
|
||||||
|
</property>
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="scorereviewaction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<property name="requiredUsers" value="2"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="evaluationStep" class="org.dspace.xmlworkflow.state.Step">
|
||||||
|
<property name="userSelectionMethod" ref="noUserSelectionAction"/>
|
||||||
|
<property name="actions">
|
||||||
|
<list>
|
||||||
|
<ref bean="evaluationaction"/>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="scoreReviewers" class="org.dspace.xmlworkflow.Role">
|
||||||
|
<property name="scope" value="#{ T(org.dspace.xmlworkflow.Role.Scope).COLLECTION}"/>
|
||||||
|
<property name="name" value="ScoreReviewers"/>
|
||||||
|
</bean>
|
||||||
|
</beans>
|
@@ -138,7 +138,6 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
||||||
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -181,7 +180,6 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("unknown");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(400));
|
|
||||||
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
||||||
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
||||||
|
|
||||||
@@ -342,9 +340,6 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("application/postscript");
|
||||||
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(100));
|
|
||||||
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
|
||||||
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(300));
|
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
@@ -362,9 +357,6 @@ public class GoogleBitstreamComparatorTest extends AbstractUnitTest {
|
|||||||
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
when(bitstreamFormat1.getMIMEType()).thenReturn("text/richtext");
|
||||||
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
when(bitstreamFormat2.getMIMEType()).thenReturn("application/msword");
|
||||||
when(bitstreamFormat3.getMIMEType()).thenReturn("audio/x-wav");
|
when(bitstreamFormat3.getMIMEType()).thenReturn("audio/x-wav");
|
||||||
when(bitstream1.getSizeBytes()).thenReturn(Long.valueOf(300));
|
|
||||||
when(bitstream2.getSizeBytes()).thenReturn(Long.valueOf(200));
|
|
||||||
when(bitstream3.getSizeBytes()).thenReturn(Long.valueOf(100));
|
|
||||||
|
|
||||||
List<Bitstream> toSort = bundle.getBitstreams();
|
List<Bitstream> toSort = bundle.getBitstreams();
|
||||||
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
Collections.sort(toSort, new GoogleBitstreamComparator(context, settings));
|
||||||
|
@@ -68,7 +68,6 @@ public class EntityServiceImplTest {
|
|||||||
// Mock the state of objects utilized in findByItemId() to meet the success criteria of an invocation
|
// Mock the state of objects utilized in findByItemId() to meet the success criteria of an invocation
|
||||||
when(itemService.find(any(), any())).thenReturn(item);
|
when(itemService.find(any(), any())).thenReturn(item);
|
||||||
when(item.getName()).thenReturn("ItemName");
|
when(item.getName()).thenReturn("ItemName");
|
||||||
when(relationshipService.findByItem(any(), any())).thenReturn(relationshipList);
|
|
||||||
|
|
||||||
// The returned Entity's item should match the mocked item's name
|
// The returned Entity's item should match the mocked item's name
|
||||||
assertEquals("TestFindByItem 0", "ItemName",
|
assertEquals("TestFindByItem 0", "ItemName",
|
||||||
@@ -86,10 +85,6 @@ public class EntityServiceImplTest {
|
|||||||
list.add(metadataValue);
|
list.add(metadataValue);
|
||||||
EntityType entityType = entityTypeService.findByEntityType(context, "testType");
|
EntityType entityType = entityTypeService.findByEntityType(context, "testType");
|
||||||
|
|
||||||
// Mock the state of objects utilized in getType() to meet the success criteria of an invocation
|
|
||||||
when(metadataValue.getValue()).thenReturn("testType");
|
|
||||||
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(list);
|
|
||||||
|
|
||||||
// The returned EntityType should equal our defined entityType case
|
// The returned EntityType should equal our defined entityType case
|
||||||
assertEquals("TestGetType 0", entityType, entityService.getType(context, entity));
|
assertEquals("TestGetType 0", entityType, entityService.getType(context, entity));
|
||||||
}
|
}
|
||||||
@@ -146,10 +141,6 @@ public class EntityServiceImplTest {
|
|||||||
relationshipList.add(relationship);
|
relationshipList.add(relationship);
|
||||||
|
|
||||||
// Mock the state of objects utilized in getRelationsByType() to meet the success criteria of an invocation
|
// Mock the state of objects utilized in getRelationsByType() to meet the success criteria of an invocation
|
||||||
when(relationshipService.findAll(context, -1, -1)).thenReturn(relationshipList);
|
|
||||||
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
|
||||||
when(relationshipService.findByTypeName(context, "leftwardType", -1, -1)).thenReturn(relationshipList);
|
when(relationshipService.findByTypeName(context, "leftwardType", -1, -1)).thenReturn(relationshipList);
|
||||||
|
|
||||||
// The relation(s) reported from our defined type should match our relationshipList
|
// The relation(s) reported from our defined type should match our relationshipList
|
||||||
@@ -176,17 +167,7 @@ public class EntityServiceImplTest {
|
|||||||
|
|
||||||
// Mock the state of objects utilized in getAllRelationshipTypes()
|
// Mock the state of objects utilized in getAllRelationshipTypes()
|
||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(metadataValue.getValue()).thenReturn("testType");
|
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(list);
|
|
||||||
when(relationshipTypeDAO.findAll(context, RelationshipType.class, -1, -1)).thenReturn(relationshipTypeList);
|
|
||||||
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
|
||||||
when(relationshipType.getLeftType()).thenReturn(leftType);
|
|
||||||
when(relationshipType.getRightType()).thenReturn(rightType);
|
|
||||||
when(entityTypeService.findByEntityType(context, "value")).thenReturn(leftType);
|
|
||||||
when(leftType.getID()).thenReturn(0);
|
|
||||||
when(rightType.getID()).thenReturn(1);
|
|
||||||
when(entityService.getType(context, entity)).thenReturn(leftType); // Mock
|
|
||||||
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), -1, -1))
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), -1, -1))
|
||||||
.thenReturn(relationshipTypeList);
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
@@ -214,11 +195,7 @@ public class EntityServiceImplTest {
|
|||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(entityType.getID()).thenReturn(0);
|
|
||||||
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
|
||||||
when(relationshipType.getLeftType()).thenReturn(entityType);
|
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
|
||||||
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), true, -1, -1))
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), true, -1, -1))
|
||||||
.thenReturn(relationshipTypeList);
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
@@ -246,11 +223,7 @@ public class EntityServiceImplTest {
|
|||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
when(itemService.getMetadata(item, "relationship", "type", null, Item.ANY, false)).thenReturn(metsList);
|
||||||
when(entity.getItem()).thenReturn(item);
|
when(entity.getItem()).thenReturn(item);
|
||||||
when(entityType.getID()).thenReturn(0);
|
|
||||||
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(relationshipTypeList);
|
|
||||||
when(relationshipType.getRightType()).thenReturn(entityType);
|
|
||||||
when(entityService.getType(context, entity)).thenReturn(entityType);
|
when(entityService.getType(context, entity)).thenReturn(entityType);
|
||||||
when(entityTypeService.findByEntityType(any(), any())).thenReturn(entityType);
|
|
||||||
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), false, -1, -1))
|
when(relationshipTypeService.findByEntityType(context, entityService.getType(context, entity), false, -1, -1))
|
||||||
.thenReturn(relationshipTypeList);
|
.thenReturn(relationshipTypeList);
|
||||||
|
|
||||||
@@ -269,9 +242,6 @@ public class EntityServiceImplTest {
|
|||||||
|
|
||||||
// Mock the state of objects utilized in getRelationshipTypesByTypeName()
|
// Mock the state of objects utilized in getRelationshipTypesByTypeName()
|
||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(relationshipTypeService.findAll(context, -1, -1)).thenReturn(list);
|
|
||||||
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
|
||||||
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
|
||||||
when(relationshipTypeService.findByLeftwardOrRightwardTypeName(context, "leftwardType", -1, -1))
|
when(relationshipTypeService.findByLeftwardOrRightwardTypeName(context, "leftwardType", -1, -1))
|
||||||
.thenReturn(list);
|
.thenReturn(list);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user