mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 21:13:19 +00:00
DS-4166 Index workspace, workflow and tasks in SOLR
This commit is contained in:
@@ -22,6 +22,7 @@ import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
|||||||
import com.sun.syndication.io.FeedException;
|
import com.sun.syndication.io.FeedException;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.util.service.OpenSearchService;
|
import org.dspace.app.util.service.OpenSearchService;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
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;
|
||||||
@@ -118,7 +119,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
|||||||
@Override
|
@Override
|
||||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results,
|
DSpaceObject scope, List<BrowsableDSpaceObject> results,
|
||||||
Map<String, String> labels) throws IOException {
|
Map<String, String> labels) throws IOException {
|
||||||
try {
|
try {
|
||||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||||
@@ -132,7 +133,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
|||||||
@Override
|
@Override
|
||||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
DSpaceObject scope, List<BrowsableDSpaceObject> results, Map<String, String> labels)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try {
|
try {
|
||||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||||
@@ -144,8 +145,8 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize, DSpaceObject scope,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels) {
|
List<BrowsableDSpaceObject> results, Map<String, String> labels) {
|
||||||
// Encode results in requested format
|
// Encode results in requested format
|
||||||
if ("rss".equals(format)) {
|
if ("rss".equals(format)) {
|
||||||
format = "rss_2.0";
|
format = "rss_2.0";
|
||||||
|
@@ -37,6 +37,7 @@ import com.sun.syndication.io.SyndFeedOutput;
|
|||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
@@ -184,7 +185,7 @@ public class SyndicationFeed {
|
|||||||
* @param labels label map
|
* @param labels label map
|
||||||
*/
|
*/
|
||||||
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
||||||
List<? extends DSpaceObject> items, Map<String, String> labels) {
|
List<BrowsableDSpaceObject> items, Map<String, String> labels) {
|
||||||
String logoURL = null;
|
String logoURL = null;
|
||||||
String objectURL = null;
|
String objectURL = null;
|
||||||
String defaultTitle = null;
|
String defaultTitle = null;
|
||||||
@@ -247,7 +248,7 @@ public class SyndicationFeed {
|
|||||||
// add entries for items
|
// add entries for items
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
||||||
for (DSpaceObject itemDSO : items) {
|
for (BrowsableDSpaceObject itemDSO : items) {
|
||||||
if (itemDSO.getType() != Constants.ITEM) {
|
if (itemDSO.getType() != Constants.ITEM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -473,6 +473,26 @@ public class Util {
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split a list in an array of i sub-lists uniformly sized
|
||||||
|
*
|
||||||
|
* @param idsList the list to split
|
||||||
|
* @param i the number of sublists to return
|
||||||
|
*
|
||||||
|
* @return an array of sub-lists of fixed size
|
||||||
|
*/
|
||||||
|
public static <T> List<T>[] splitList(List<T> idsList, int i) {
|
||||||
|
int setmin = idsList.size() / i;
|
||||||
|
List<T>[] result = new List[i];
|
||||||
|
int offset = 0;
|
||||||
|
for (int idx = 0; idx < i - 1; idx++) {
|
||||||
|
result[idx] = idsList.subList(offset, offset + setmin);
|
||||||
|
offset += setmin;
|
||||||
|
}
|
||||||
|
result[i - 1] = idsList.subList(offset, idsList.size());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection)
|
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection)
|
||||||
throws DCInputsReaderException {
|
throws DCInputsReaderException {
|
||||||
DCInputsReader reader = new DCInputsReader();
|
DCInputsReader reader = new DCInputsReader();
|
||||||
|
@@ -12,6 +12,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@@ -91,7 +92,7 @@ public interface OpenSearchService {
|
|||||||
*/
|
*/
|
||||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results,
|
DSpaceObject scope, List<BrowsableDSpaceObject> results,
|
||||||
Map<String, String> labels) throws IOException;
|
Map<String, String> labels) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,7 +112,7 @@ public interface OpenSearchService {
|
|||||||
*/
|
*/
|
||||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
DSpaceObject scope, List<BrowsableDSpaceObject> results, Map<String, String> labels)
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
||||||
|
@@ -767,4 +767,10 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
|||||||
return policy;
|
return policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ResourcePolicy> getPoliciesActionFilterExceptRpType(Context c, DSpaceObject o, int actionID,
|
||||||
|
String rpType) throws SQLException {
|
||||||
|
return resourcePolicyService.findExceptRpType(c, o, actionID, rpType);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -307,4 +307,10 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ResourcePolicy> findExceptRpType(Context c, DSpaceObject o, int actionID, String rpType)
|
||||||
|
throws SQLException {
|
||||||
|
return resourcePolicyDAO.findByDSoAndActionExceptRpType(c, o, actionID, rpType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,4 +66,17 @@ public interface ResourcePolicyDAO extends GenericDAO<ResourcePolicy> {
|
|||||||
public void deleteByDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) throws SQLException;
|
public void deleteByDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) throws SQLException;
|
||||||
|
|
||||||
public void deleteByDsoAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException;
|
public void deleteByDsoAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of policies for an object that match the action except the record labeled with the rpType
|
||||||
|
*
|
||||||
|
* @param c context
|
||||||
|
* @param o DSpaceObject policies relate to
|
||||||
|
* @param actionID action (defined in class Constants)
|
||||||
|
* @param rpType the resource policy type
|
||||||
|
* @return list of resource policies
|
||||||
|
* @throws SQLException if there's a database problem
|
||||||
|
*/
|
||||||
|
public List<ResourcePolicy> findByDSoAndActionExceptRpType(Context c, DSpaceObject o, int actionID,
|
||||||
|
String rpType) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -201,4 +201,21 @@ public class ResourcePolicyDAOImpl extends AbstractHibernateDAO<ResourcePolicy>
|
|||||||
query.setParameter("rptype", type);
|
query.setParameter("rptype", type);
|
||||||
query.executeUpdate();
|
query.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ResourcePolicy> findByDSoAndActionExceptRpType(Context context, DSpaceObject dso, int action,
|
||||||
|
String rpType) throws SQLException {
|
||||||
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, ResourcePolicy.class);
|
||||||
|
|
||||||
|
Root<ResourcePolicy> resourcePolicyRoot = criteriaQuery.from(ResourcePolicy.class);
|
||||||
|
criteriaQuery.select(resourcePolicyRoot);
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.and(criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.dSpaceObject), dso),
|
||||||
|
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.actionId), action),
|
||||||
|
criteriaBuilder.notEqual(resourcePolicyRoot.get(ResourcePolicy_.rptype), rpType)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return list(context, criteriaQuery, false, ResourcePolicy.class, 1, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -312,6 +312,18 @@ public interface AuthorizeService {
|
|||||||
*/
|
*/
|
||||||
public List<ResourcePolicy> getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws SQLException;
|
public List<ResourcePolicy> getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of policies for an object that match the action except the record labeled with the rpType
|
||||||
|
*
|
||||||
|
* @param c context
|
||||||
|
* @param o DSpaceObject policies relate to
|
||||||
|
* @param actionID action (defined in class Constants)
|
||||||
|
* @param rpType the resource policy type
|
||||||
|
* @return list of resource policies
|
||||||
|
* @throws SQLException if there's a database problem
|
||||||
|
*/
|
||||||
|
public List<ResourcePolicy> getPoliciesActionFilterExceptRpType(Context c, DSpaceObject o, int actionID,
|
||||||
|
String rpType) throws SQLException;
|
||||||
/**
|
/**
|
||||||
* Add policies to an object to match those from a previous object
|
* Add policies to an object to match those from a previous object
|
||||||
*
|
*
|
||||||
|
@@ -76,4 +76,16 @@ public interface ResourcePolicyService extends DSpaceCRUDService<ResourcePolicy>
|
|||||||
public void removeDsoAndTypeNotEqualsToPolicies(Context c, DSpaceObject o, String type)
|
public void removeDsoAndTypeNotEqualsToPolicies(Context c, DSpaceObject o, String type)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of policies for an object that match the action except the record labeled with the rpType
|
||||||
|
*
|
||||||
|
* @param c context
|
||||||
|
* @param o DSpaceObject policies relate to
|
||||||
|
* @param actionID action (defined in class Constants)
|
||||||
|
* @param rpType the resource policy type
|
||||||
|
* @return list of resource policies
|
||||||
|
* @throws SQLException if there's a database problem
|
||||||
|
*/
|
||||||
|
public List<ResourcePolicy> findExceptRpType(Context c, DSpaceObject o, int actionID, String rpType)
|
||||||
|
throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -114,6 +114,8 @@ public class BrowserScope {
|
|||||||
|
|
||||||
private String authority = null;
|
private String authority = null;
|
||||||
|
|
||||||
|
private String userLocale = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new BrowserScope using the given Context
|
* Construct a new BrowserScope using the given Context
|
||||||
*
|
*
|
||||||
@@ -131,7 +133,7 @@ public class BrowserScope {
|
|||||||
* @param dso the container object; a Community or Collection
|
* @param dso the container object; a Community or Collection
|
||||||
* @throws BrowseException if browse error
|
* @throws BrowseException if browse error
|
||||||
*/
|
*/
|
||||||
public void setBrowseContainer(DSpaceObject dso)
|
public void setBrowseContainer(BrowsableDSpaceObject dso)
|
||||||
throws BrowseException {
|
throws BrowseException {
|
||||||
if (dso instanceof Collection) {
|
if (dso instanceof Collection) {
|
||||||
this.collection = (Collection) dso;
|
this.collection = (Collection) dso;
|
||||||
@@ -582,4 +584,12 @@ public class BrowserScope {
|
|||||||
public void setAuthorityValue(String value) {
|
public void setAuthorityValue(String value) {
|
||||||
authority = value;
|
authority = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUserLocale(String userLocale) {
|
||||||
|
this.userLocale = userLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserLocale() {
|
||||||
|
return userLocale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.logging.log4j.Logger;
|
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.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -308,7 +307,7 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
DiscoverResult resp = getSolrResponse();
|
DiscoverResult resp = getSolrResponse();
|
||||||
|
|
||||||
List<Item> bitems = new ArrayList<>();
|
List<Item> bitems = new ArrayList<>();
|
||||||
for (DSpaceObject solrDoc : resp.getDspaceObjects()) {
|
for (BrowsableDSpaceObject<UUID> solrDoc : resp.getDspaceObjects()) {
|
||||||
// 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 = (Item) solrDoc;
|
||||||
|
@@ -69,6 +69,8 @@ public class DiscoverQuery {
|
|||||||
**/
|
**/
|
||||||
private Map<String, List<String>> properties;
|
private Map<String, List<String>> properties;
|
||||||
|
|
||||||
|
private String discoveryConfigurationName;
|
||||||
|
|
||||||
public DiscoverQuery() {
|
public DiscoverQuery() {
|
||||||
//Initialize all our lists
|
//Initialize all our lists
|
||||||
this.filterQueries = new ArrayList<String>();
|
this.filterQueries = new ArrayList<String>();
|
||||||
@@ -331,6 +333,7 @@ public class DiscoverQuery {
|
|||||||
// Example: 2001 and a gap from 10 we need the following result: 2010 - 2000 ; 2000 - 1990 hence the top
|
// Example: 2001 and a gap from 10 we need the following result: 2010 - 2000 ; 2000 - 1990 hence the top
|
||||||
// year
|
// year
|
||||||
int topYear = getTopYear(newestYear, gap);
|
int topYear = getTopYear(newestYear, gap);
|
||||||
|
|
||||||
if (gap == 1) {
|
if (gap == 1) {
|
||||||
//We need a list of our years
|
//We need a list of our years
|
||||||
//We have a date range add faceting for our field
|
//We have a date range add faceting for our field
|
||||||
@@ -376,4 +379,11 @@ public class DiscoverQuery {
|
|||||||
return (int) (Math.ceil((float) (newestYear) / gap) * gap);
|
return (int) (Math.ceil((float) (newestYear) / gap) * gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDiscoveryConfigurationName() {
|
||||||
|
return discoveryConfigurationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscoveryConfigurationName(String discoveryConfigurationName) {
|
||||||
|
this.discoveryConfigurationName = discoveryConfigurationName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.collections4.ListUtils;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
|
||||||
@@ -28,8 +28,11 @@ public class DiscoverResult {
|
|||||||
|
|
||||||
private long totalSearchResults;
|
private long totalSearchResults;
|
||||||
private int start;
|
private int start;
|
||||||
private List<DSpaceObject> dspaceObjects;
|
private List<BrowsableDSpaceObject> dspaceObjects;
|
||||||
private Map<String, List<FacetResult>> facetResults;
|
private Map<String, List<FacetResult>> facetResults;
|
||||||
|
private Map<String, List<FacetResult>> facetQueryResults;
|
||||||
|
private Map<String, List<FacetResult>> facetFieldResults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map that contains all the documents sougth after, the key is a string representation of the DSpace object
|
* A map that contains all the documents sougth after, the key is a string representation of the DSpace object
|
||||||
*/
|
*/
|
||||||
@@ -39,20 +42,20 @@ public class DiscoverResult {
|
|||||||
private Map<String, DSpaceObjectHighlightResult> highlightedResults;
|
private Map<String, DSpaceObjectHighlightResult> highlightedResults;
|
||||||
private String spellCheckQuery;
|
private String spellCheckQuery;
|
||||||
|
|
||||||
|
|
||||||
public DiscoverResult() {
|
public DiscoverResult() {
|
||||||
dspaceObjects = new ArrayList<DSpaceObject>();
|
dspaceObjects = new ArrayList<BrowsableDSpaceObject>();
|
||||||
facetResults = new LinkedHashMap<String, List<FacetResult>>();
|
facetResults = new LinkedHashMap<String, List<FacetResult>>();
|
||||||
|
facetQueryResults = new LinkedHashMap<String, List<FacetResult>>();
|
||||||
|
facetFieldResults = new LinkedHashMap<String, List<FacetResult>>();
|
||||||
searchDocuments = new LinkedHashMap<String, List<SearchDocument>>();
|
searchDocuments = new LinkedHashMap<String, List<SearchDocument>>();
|
||||||
highlightedResults = new HashMap<String, DSpaceObjectHighlightResult>();
|
highlightedResults = new HashMap<String, DSpaceObjectHighlightResult>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addDSpaceObject(BrowsableDSpaceObject dso) {
|
||||||
public void addDSpaceObject(DSpaceObject dso) {
|
|
||||||
this.dspaceObjects.add(dso);
|
this.dspaceObjects.add(dso);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DSpaceObject> getDspaceObjects() {
|
public List<BrowsableDSpaceObject> getDspaceObjects() {
|
||||||
return dspaceObjects;
|
return dspaceObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +104,40 @@ public class DiscoverResult {
|
|||||||
return facetResults;
|
return facetResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FacetResult> getFacetQueryResult(String facet) {
|
||||||
|
return facetQueryResults.get(facet) == null ? new ArrayList<FacetResult>() : facetQueryResults.get(facet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFacetQueryResult(String facetField, FacetResult... facetResults) {
|
||||||
|
List<FacetResult> facetValues = this.facetQueryResults.get(facetField);
|
||||||
|
if (facetValues == null) {
|
||||||
|
facetValues = new ArrayList<FacetResult>();
|
||||||
|
}
|
||||||
|
facetValues.addAll(Arrays.asList(facetResults));
|
||||||
|
this.facetQueryResults.put(facetField, facetValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<FacetResult>> getFacetQueryResults() {
|
||||||
|
return facetQueryResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FacetResult> getFacetFieldResult(String facet) {
|
||||||
|
return facetFieldResults.get(facet) == null ? new ArrayList<FacetResult>() : facetFieldResults.get(facet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFacetFieldResult(String facetField, FacetResult... facetResults) {
|
||||||
|
List<FacetResult> facetValues = this.facetFieldResults.get(facetField);
|
||||||
|
if (facetValues == null) {
|
||||||
|
facetValues = new ArrayList<FacetResult>();
|
||||||
|
}
|
||||||
|
facetValues.addAll(Arrays.asList(facetResults));
|
||||||
|
this.facetFieldResults.put(facetField, facetValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<FacetResult>> getFacetFieldResults() {
|
||||||
|
return facetFieldResults;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FacetResult> getFacetResult(String facet) {
|
public List<FacetResult> getFacetResult(String facet) {
|
||||||
return ListUtils.emptyIfNull(facetResults.get(facet));
|
return ListUtils.emptyIfNull(facetResults.get(facet));
|
||||||
}
|
}
|
||||||
@@ -114,12 +151,12 @@ public class DiscoverResult {
|
|||||||
return ListUtils.emptyIfNull(facetValues);
|
return ListUtils.emptyIfNull(facetValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectHighlightResult getHighlightedResults(DSpaceObject dso) {
|
public DSpaceObjectHighlightResult getHighlightedResults(BrowsableDSpaceObject dso) {
|
||||||
return highlightedResults.get(dso.getHandle());
|
return highlightedResults.get(dso.getUniqueIndexID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHighlightedResult(DSpaceObject dso, DSpaceObjectHighlightResult highlightedResult) {
|
public void addHighlightedResult(BrowsableDSpaceObject dso, DSpaceObjectHighlightResult highlightedResult) {
|
||||||
this.highlightedResults.put(dso.getHandle(), highlightedResult);
|
this.highlightedResults.put(dso.getUniqueIndexID(), highlightedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class FacetResult {
|
public static final class FacetResult {
|
||||||
@@ -141,6 +178,10 @@ public class DiscoverResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getAsFilterQuery() {
|
public String getAsFilterQuery() {
|
||||||
|
if (asFilterQuery == null) {
|
||||||
|
// missing facet filter query
|
||||||
|
return "[* TO *]";
|
||||||
|
}
|
||||||
return asFilterQuery;
|
return asFilterQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +202,7 @@ public class DiscoverResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFilterType() {
|
public String getFilterType() {
|
||||||
return authorityKey != null ? "authority" : "equals";
|
return authorityKey != null ? "authority" : asFilterQuery != null ? "equals" : "notequals";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFieldType() {
|
public String getFieldType() {
|
||||||
@@ -178,15 +219,18 @@ public class DiscoverResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final class DSpaceObjectHighlightResult {
|
public static final class DSpaceObjectHighlightResult {
|
||||||
private DSpaceObject dso;
|
private BrowsableDSpaceObject dso;
|
||||||
private Map<String, List<String>> highlightResults;
|
private Map<String, List<String>> highlightResults;
|
||||||
|
private Map<String, List<String[]>> highlightResultsWithAuthority;
|
||||||
|
|
||||||
public DSpaceObjectHighlightResult(DSpaceObject dso, Map<String, List<String>> highlightResults) {
|
public DSpaceObjectHighlightResult(BrowsableDSpaceObject dso, Map<String, List<String>> highlightResults,
|
||||||
|
Map<String, List<String[]>> highlightResultsWithAuthority) {
|
||||||
this.dso = dso;
|
this.dso = dso;
|
||||||
this.highlightResults = highlightResults;
|
this.highlightResults = highlightResults;
|
||||||
|
this.highlightResultsWithAuthority = highlightResultsWithAuthority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObject getDso() {
|
public BrowsableDSpaceObject getDso() {
|
||||||
return dso;
|
return dso;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,12 +238,16 @@ public class DiscoverResult {
|
|||||||
return highlightResults.get(metadataKey);
|
return highlightResults.get(metadataKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String[]> getHighlightResultsWithAuthority(String metadataKey) {
|
||||||
|
return highlightResultsWithAuthority.get(metadataKey);
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, List<String>> getHighlightResults() {
|
public Map<String, List<String>> getHighlightResults() {
|
||||||
return highlightResults;
|
return highlightResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSearchDocument(DSpaceObject dso, SearchDocument searchDocument) {
|
public void addSearchDocument(BrowsableDSpaceObject dso, SearchDocument searchDocument) {
|
||||||
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
||||||
List<SearchDocument> docs = searchDocuments.get(dsoString);
|
List<SearchDocument> docs = searchDocuments.get(dsoString);
|
||||||
if (docs == null) {
|
if (docs == null) {
|
||||||
@@ -212,10 +260,11 @@ public class DiscoverResult {
|
|||||||
/**
|
/**
|
||||||
* Returns all the sought after search document values
|
* Returns all the sought after search document values
|
||||||
*
|
*
|
||||||
* @param dso the dspace object we want our search documents for
|
* @param dso
|
||||||
|
* the dspace object we want our search documents for
|
||||||
* @return the search documents list
|
* @return the search documents list
|
||||||
*/
|
*/
|
||||||
public List<SearchDocument> getSearchDocument(DSpaceObject dso) {
|
public List<SearchDocument> getSearchDocument(BrowsableDSpaceObject dso) {
|
||||||
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
||||||
List<SearchDocument> result = searchDocuments.get(dsoString);
|
List<SearchDocument> result = searchDocuments.get(dsoString);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@@ -256,7 +305,7 @@ public class DiscoverResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDspaceObjectStringRepresentation(DSpaceObject dso) {
|
public static String getDspaceObjectStringRepresentation(BrowsableDSpaceObject dso) {
|
||||||
return dso.getType() + ":" + dso.getID();
|
return dso.getType() + ":" + dso.getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ public class FacetYearRange {
|
|||||||
return oldestYear != -1 && newestYear != -1;
|
return oldestYear != -1 && newestYear != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculateRange(Context context, List<String> filterQueries, DSpaceObject scope,
|
public void calculateRange(Context context, List<String> filterQueries, BrowsableDSpaceObject scope,
|
||||||
SearchService searchService) throws SearchServiceException {
|
SearchService searchService, DiscoverQuery parentQuery) throws SearchServiceException {
|
||||||
dateFacet = facet.getIndexFieldName() + ".year";
|
dateFacet = facet.getIndexFieldName() + ".year";
|
||||||
//Get a range query so we can create facet queries ranging from our first to our last date
|
//Get a range query so we can create facet queries ranging from our first to our last date
|
||||||
//Attempt to determine our oldest & newest year by checking for previously selected filters
|
//Attempt to determine our oldest & newest year by checking for previously selected filters
|
||||||
@@ -55,7 +55,7 @@ public class FacetYearRange {
|
|||||||
|
|
||||||
//Check if we have found a range, if not then retrieve our first & last year using Solr
|
//Check if we have found a range, if not then retrieve our first & last year using Solr
|
||||||
if (oldestYear == -1 && newestYear == -1) {
|
if (oldestYear == -1 && newestYear == -1) {
|
||||||
calculateNewRangeBasedOnSearchIndex(context, filterQueries, scope, searchService);
|
calculateNewRangeBasedOnSearchIndex(context, filterQueries, scope, searchService, parentQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +93,11 @@ public class FacetYearRange {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateNewRangeBasedOnSearchIndex(Context context, List<String> filterQueries, DSpaceObject scope,
|
private void calculateNewRangeBasedOnSearchIndex(Context context, List<String> filterQueries,
|
||||||
SearchService searchService) throws SearchServiceException {
|
BrowsableDSpaceObject scope, SearchService searchService,
|
||||||
|
DiscoverQuery parentQuery) throws SearchServiceException {
|
||||||
DiscoverQuery yearRangeQuery = new DiscoverQuery();
|
DiscoverQuery yearRangeQuery = new DiscoverQuery();
|
||||||
|
yearRangeQuery.setDiscoveryConfigurationName(parentQuery.getDiscoveryConfigurationName());
|
||||||
yearRangeQuery.setMaxResults(1);
|
yearRangeQuery.setMaxResults(1);
|
||||||
//Set our query to anything that has this value
|
//Set our query to anything that has this value
|
||||||
yearRangeQuery.addFieldPresentQueries(dateFacet);
|
yearRangeQuery.addFieldPresentQueries(dateFacet);
|
||||||
|
@@ -7,9 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.HelpFormatter;
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
@@ -17,12 +24,13 @@ import org.apache.commons.cli.OptionBuilder;
|
|||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
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.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
@@ -58,8 +66,8 @@ public class IndexClient {
|
|||||||
Context context = new Context(Context.Mode.READ_ONLY);
|
Context context = new Context(Context.Mode.READ_ONLY);
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
String usage = "org.dspace.discovery.IndexClient [-cbhf] | [-r <handle>] | [-i <handle>] or nothing to " +
|
String usage = "org.dspace.discovery.IndexClient [-cbhf] | [-r <handle>] | [-i <handle>] | [-item_uuid " +
|
||||||
"update/clean an existing index.";
|
"<uuid>] or nothing to update/clean an existing index.";
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
HelpFormatter formatter = new HelpFormatter();
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
CommandLine line = null;
|
CommandLine line = null;
|
||||||
@@ -71,6 +79,9 @@ public class IndexClient {
|
|||||||
"remove an Item, Collection or Community from index based on its handle")
|
"remove an Item, Collection or Community from index based on its handle")
|
||||||
.create("r"));
|
.create("r"));
|
||||||
|
|
||||||
|
options.addOption(OptionBuilder.withArgName("item uuid to index").hasArg(true)
|
||||||
|
.withDescription("add an Item based on its uuid").create("item_uuid"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
.withArgName("handle to add or update")
|
.withArgName("handle to add or update")
|
||||||
.hasArg(true)
|
.hasArg(true)
|
||||||
@@ -78,6 +89,11 @@ public class IndexClient {
|
|||||||
"add or update an Item, Collection or Community based on its handle")
|
"add or update an Item, Collection or Community based on its handle")
|
||||||
.create("i"));
|
.create("i"));
|
||||||
|
|
||||||
|
options.addOption(OptionBuilder.isRequired(false).hasArg(true)
|
||||||
|
.withDescription("update an Item, Collection or Community from index based on its handle, use with -f "
|
||||||
|
+ "to force clean")
|
||||||
|
.create("u"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
.isRequired(false)
|
.isRequired(false)
|
||||||
.withDescription(
|
.withDescription(
|
||||||
@@ -111,6 +127,8 @@ public class IndexClient {
|
|||||||
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
||||||
"optimize search core").create("o"));
|
"optimize search core").create("o"));
|
||||||
|
|
||||||
|
options.addOption("e", "readfile", true, "Read the identifier from a file");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
line = new PosixParser().parse(options, args);
|
line = new PosixParser().parse(options, args);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -150,10 +168,55 @@ public class IndexClient {
|
|||||||
indexer.optimize();
|
indexer.optimize();
|
||||||
} else if (line.hasOption('s')) {
|
} else if (line.hasOption('s')) {
|
||||||
checkRebuildSpellCheck(line, indexer);
|
checkRebuildSpellCheck(line, indexer);
|
||||||
|
} else if (line.hasOption("item_uuid")) {
|
||||||
|
String itemUUID = line.getOptionValue("item_uuid");
|
||||||
|
Item item = ContentServiceFactory.getInstance().getItemService().find(context, UUID.fromString(itemUUID));
|
||||||
|
indexer.indexContent(context, item, line.hasOption("f"));
|
||||||
|
} else if (line.hasOption("u")) {
|
||||||
|
String optionValue = line.getOptionValue("u");
|
||||||
|
String[] identifiers = optionValue.split("\\s*,\\s*");
|
||||||
|
for (String id : identifiers) {
|
||||||
|
if (id.startsWith(ConfigurationManager.getProperty("handle.prefix")) || id.startsWith("123456789/")) {
|
||||||
|
BrowsableDSpaceObject dso = (BrowsableDSpaceObject) HandleServiceFactory.getInstance()
|
||||||
|
.getHandleService().resolveToObject(context, id);
|
||||||
|
indexer.indexContent(context, dso, line.hasOption("f"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (line.hasOption('e')) {
|
||||||
|
try {
|
||||||
|
String filename = line.getOptionValue('e');
|
||||||
|
FileInputStream fstream = new FileInputStream(filename);
|
||||||
|
// Get the object of DataInputStream
|
||||||
|
DataInputStream in = new DataInputStream(fstream);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
String strLine;
|
||||||
|
// Read File Line By Line
|
||||||
|
|
||||||
|
UUID item_id = null;
|
||||||
|
List<UUID> ids = new ArrayList<UUID>();
|
||||||
|
|
||||||
|
while ((strLine = br.readLine()) != null) {
|
||||||
|
item_id = UUID.fromString(strLine.trim());
|
||||||
|
ids.add(item_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
int type = -1;
|
||||||
|
if (line.hasOption('t')) {
|
||||||
|
type = Integer.parseInt(line.getOptionValue("t"));
|
||||||
|
} else {
|
||||||
|
// force to item
|
||||||
|
type = Constants.ITEM;
|
||||||
|
}
|
||||||
|
indexer.updateIndex(context, ids, line.hasOption("f"), type);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error: " + e.getMessage());
|
||||||
|
}
|
||||||
} else if (line.hasOption('i')) {
|
} else if (line.hasOption('i')) {
|
||||||
final String handle = line.getOptionValue('i');
|
final String handle = line.getOptionValue('i');
|
||||||
final DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService()
|
final BrowsableDSpaceObject dso = (BrowsableDSpaceObject) HandleServiceFactory.getInstance()
|
||||||
.resolveToObject(context, handle);
|
.getHandleService().resolveToObject(context, handle);
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
throw new IllegalArgumentException("Cannot resolve " + handle + " to a DSpace object");
|
throw new IllegalArgumentException("Cannot resolve " + handle + " to a DSpace object");
|
||||||
}
|
}
|
||||||
@@ -186,7 +249,7 @@ public class IndexClient {
|
|||||||
private static long indexAll(final IndexingService indexingService,
|
private static long indexAll(final IndexingService indexingService,
|
||||||
final ItemService itemService,
|
final ItemService itemService,
|
||||||
final Context context,
|
final Context context,
|
||||||
final DSpaceObject dso)
|
final BrowsableDSpaceObject dso)
|
||||||
throws IOException, SearchServiceException, SQLException {
|
throws IOException, SearchServiceException, SQLException {
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Bundle;
|
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;
|
||||||
@@ -33,10 +34,10 @@ 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<DSpaceObject> objectsToUpdate = null;
|
private Set<BrowsableDSpaceObject> objectsToUpdate = null;
|
||||||
|
|
||||||
// handles to delete since IDs are not useful by now.
|
// unique search IDs to delete
|
||||||
private Set<String> handlesToDelete = null;
|
private Set<String> uniqueIdsToDelete = null;
|
||||||
|
|
||||||
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager()
|
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||||
.getServiceByName(IndexingService.class.getName(),
|
.getServiceByName(IndexingService.class.getName(),
|
||||||
@@ -58,8 +59,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<DSpaceObject>();
|
objectsToUpdate = new HashSet<BrowsableDSpaceObject>();
|
||||||
handlesToDelete = new HashSet<String>();
|
uniqueIdsToDelete = new HashSet<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int st = event.getSubjectType();
|
int st = event.getSubjectType();
|
||||||
@@ -107,7 +108,7 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
+ ", 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(subject);
|
objectsToUpdate.add((BrowsableDSpaceObject)subject);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -120,17 +121,17 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
+ ", 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(object);
|
objectsToUpdate.add((BrowsableDSpaceObject)object);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.DELETE:
|
case Event.DELETE:
|
||||||
String detail = event.getDetail();
|
if (event.getSubjectType() == -1 || event.getSubjectID() == null) {
|
||||||
if (detail == null) {
|
log.warn("got null subject type and/or ID on DELETE event, skipping it.");
|
||||||
log.warn("got null detail on DELETE event, skipping it.");
|
|
||||||
} else {
|
} else {
|
||||||
|
String detail = event.getSubjectType() + "-" + event.getSubjectID().toString();
|
||||||
log.debug("consume() adding event to delete queue: " + event.toString());
|
log.debug("consume() adding event to delete queue: " + event.toString());
|
||||||
handlesToDelete.add(detail);
|
uniqueIdsToDelete.add(detail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -151,37 +152,37 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
@Override
|
@Override
|
||||||
public void end(Context ctx) throws Exception {
|
public void end(Context ctx) throws Exception {
|
||||||
|
|
||||||
if (objectsToUpdate != null && handlesToDelete != null) {
|
if (objectsToUpdate != null && uniqueIdsToDelete != null) {
|
||||||
|
|
||||||
// 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 (DSpaceObject o : objectsToUpdate) {
|
for (BrowsableDSpaceObject 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
|
||||||
*/
|
*/
|
||||||
DSpaceObject iu = ctx.reloadEntity(o);
|
// iu = ctx.reloadEntity(o);
|
||||||
String hdl = iu.getHandle();
|
String uniqueIndexID = iu.getUniqueIndexID();
|
||||||
if (hdl != null && !handlesToDelete.contains(hdl)) {
|
if (uniqueIndexID != null && !uniqueIdsToDelete.contains(uniqueIndexID)) {
|
||||||
try {
|
try {
|
||||||
indexer.indexContent(ctx, iu, true);
|
indexer.indexContent(ctx, iu, true, true);
|
||||||
log.debug("Indexed "
|
log.debug("Indexed "
|
||||||
+ Constants.typeText[iu.getType()]
|
+ Constants.typeText[iu.getType()]
|
||||||
+ ", id=" + String.valueOf(iu.getID())
|
+ ", id=" + String.valueOf(iu.getID())
|
||||||
+ ", handle=" + hdl);
|
+ ", unique_id=" + uniqueIndexID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed while indexing object: ", e);
|
log.error("Failed while indexing object: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String hdl : handlesToDelete) {
|
for (String uid : uniqueIdsToDelete) {
|
||||||
try {
|
try {
|
||||||
indexer.unIndexContent(ctx, hdl, true);
|
indexer.unIndexContent(ctx, uid, true);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("UN-Indexed Item, handle=" + hdl);
|
log.debug("UN-Indexed Item, handle=" + uid);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed while UN-indexing object: " + hdl, e);
|
log.error("Failed while UN-indexing object: " + uid, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -190,7 +191,7 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
|
|
||||||
// "free" the resources
|
// "free" the resources
|
||||||
objectsToUpdate = null;
|
objectsToUpdate = null;
|
||||||
handlesToDelete = null;
|
uniqueIdsToDelete = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -9,12 +9,14 @@ package org.dspace.discovery;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used for indexing dspaceobject into discovery
|
* Interface used for indexing BrowsableDSpaceObject into discovery
|
||||||
*
|
*
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
@@ -22,28 +24,28 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public interface IndexingService {
|
public interface IndexingService {
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso)
|
void indexContent(Context context, BrowsableDSpaceObject dso)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso,
|
void indexContent(Context context, BrowsableDSpaceObject dso,
|
||||||
boolean force) throws SQLException;
|
boolean force) throws SQLException;
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso,
|
void indexContent(Context context, BrowsableDSpaceObject dso,
|
||||||
boolean force, boolean commit) throws SQLException, SearchServiceException;
|
boolean force, boolean commit) throws SQLException, SearchServiceException;
|
||||||
|
|
||||||
void unIndexContent(Context context, DSpaceObject dso)
|
void unIndexContent(Context context, BrowsableDSpaceObject dso)
|
||||||
throws SQLException, IOException;
|
throws SQLException, IOException;
|
||||||
|
|
||||||
void unIndexContent(Context context, DSpaceObject dso, boolean commit)
|
void unIndexContent(Context context, BrowsableDSpaceObject dso, boolean commit)
|
||||||
throws SQLException, IOException;
|
throws SQLException, IOException;
|
||||||
|
|
||||||
void unIndexContent(Context context, String handle)
|
void unIndexContent(Context context, String uniqueSearchID)
|
||||||
throws SQLException, IOException;
|
throws IOException;
|
||||||
|
|
||||||
void unIndexContent(Context context, String handle, boolean commit)
|
void unIndexContent(Context context, String uniqueSearchID, boolean commit)
|
||||||
throws SQLException, IOException;
|
throws IOException;
|
||||||
|
|
||||||
void reIndexContent(Context context, DSpaceObject dso)
|
void reIndexContent(Context context, BrowsableDSpaceObject dso)
|
||||||
throws SQLException, IOException;
|
throws SQLException, IOException;
|
||||||
|
|
||||||
void createIndex(Context context) throws SQLException, IOException;
|
void createIndex(Context context) throws SQLException, IOException;
|
||||||
@@ -52,9 +54,16 @@ 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, List<UUID> ids, boolean force, int 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;
|
||||||
|
@@ -7,11 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration;
|
import org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration;
|
||||||
@@ -50,7 +49,7 @@ public interface SearchService {
|
|||||||
* @return discovery search result object
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query)
|
DiscoverResult search(Context context, BrowsableDSpaceObject dso, DiscoverQuery query)
|
||||||
throws SearchServiceException;
|
throws SearchServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,19 +73,11 @@ public interface SearchService {
|
|||||||
* @return discovery search result object
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query, boolean includeWithdrawn)
|
DiscoverResult search(Context context, BrowsableDSpaceObject dso, DiscoverQuery query, boolean includeWithdrawn)
|
||||||
throws SearchServiceException;
|
throws SearchServiceException;
|
||||||
|
|
||||||
|
List<BrowsableDSpaceObject> search(Context context, String query, String orderfield, boolean ascending, int offset,
|
||||||
InputStream searchJSON(Context context, DiscoverQuery query, String jsonIdentifier) throws SearchServiceException;
|
int max, String... filterquery);
|
||||||
|
|
||||||
InputStream searchJSON(Context context, DiscoverQuery query, DSpaceObject dso, String jsonIdentifier)
|
|
||||||
throws SearchServiceException;
|
|
||||||
|
|
||||||
|
|
||||||
List<DSpaceObject> search(Context context, String query, String orderfield, boolean ascending, int offset, int max,
|
|
||||||
String... filterquery);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the given string field and value into a filter query
|
* Transforms the given string field and value into a filter query
|
||||||
@@ -138,8 +129,9 @@ public interface SearchService {
|
|||||||
*/
|
*/
|
||||||
String escapeQueryChars(String query);
|
String escapeQueryChars(String query);
|
||||||
|
|
||||||
FacetYearRange getFacetYearRange(Context context, DSpaceObject scope, DiscoverySearchFilterFacet facet,
|
FacetYearRange getFacetYearRange(Context context, BrowsableDSpaceObject scope, DiscoverySearchFilterFacet facet,
|
||||||
List<String> filterQueries) throws SearchServiceException;
|
List<String> filterQueries, DiscoverQuery parentQuery)
|
||||||
|
throws SearchServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns us either the highest or lowest value for the field that we give to it
|
* This method returns us either the highest or lowest value for the field that we give to it
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,10 +17,12 @@ import java.util.Map;
|
|||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfigurationService;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationService;
|
||||||
import org.dspace.kernel.ServiceManager;
|
import org.dspace.kernel.ServiceManager;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
import org.dspace.workflow.WorkflowItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Util methods used by discovery
|
* Util methods used by discovery
|
||||||
@@ -48,13 +51,26 @@ public class SearchUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DiscoveryConfiguration getDiscoveryConfiguration() {
|
public static DiscoveryConfiguration getDiscoveryConfiguration() {
|
||||||
return getDiscoveryConfiguration(null);
|
return getDiscoveryConfiguration(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso) {
|
public static DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso) {
|
||||||
|
return getDiscoveryConfiguration(null, dso);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DiscoveryConfiguration getDiscoveryConfiguration(String prefix, DSpaceObject dso) {
|
||||||
|
if (prefix != null) {
|
||||||
|
return getDiscoveryConfigurationByName(dso != null ? prefix + "." + dso.getHandle() : prefix);
|
||||||
|
} else {
|
||||||
|
return getDiscoveryConfigurationByName(dso != null ? dso.getHandle() : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DiscoveryConfiguration getDiscoveryConfigurationByName(
|
||||||
|
String configurationName) {
|
||||||
DiscoveryConfigurationService configurationService = getConfigurationService();
|
DiscoveryConfigurationService configurationService = getConfigurationService();
|
||||||
|
|
||||||
return configurationService.getDiscoveryConfiguration(dso);
|
return configurationService.getDiscoveryConfiguration(configurationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DiscoveryConfigurationService getConfigurationService() {
|
public static DiscoveryConfigurationService getConfigurationService() {
|
||||||
@@ -76,23 +92,45 @@ public class SearchUtils {
|
|||||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Item item) throws SQLException {
|
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Item item) throws SQLException {
|
||||||
|
List<Collection> collections = item.getCollections();
|
||||||
|
return getAllDiscoveryConfigurations(null, collections, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(WorkspaceItem witem) throws SQLException {
|
||||||
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
collections.add(witem.getCollection());
|
||||||
|
return getAllDiscoveryConfigurations("workspace", collections, witem.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(WorkflowItem witem) throws SQLException {
|
||||||
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
collections.add(witem.getCollection());
|
||||||
|
return getAllDiscoveryConfigurations("workflow", collections, witem.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(String prefix,
|
||||||
|
List<Collection> collections, Item item)
|
||||||
|
throws SQLException {
|
||||||
Map<String, DiscoveryConfiguration> result = new HashMap<String, DiscoveryConfiguration>();
|
Map<String, DiscoveryConfiguration> result = new HashMap<String, DiscoveryConfiguration>();
|
||||||
|
|
||||||
List<Collection> collections = item.getCollections();
|
|
||||||
for (Collection collection : collections) {
|
for (Collection collection : collections) {
|
||||||
DiscoveryConfiguration configuration = getDiscoveryConfiguration(collection);
|
DiscoveryConfiguration configuration = getDiscoveryConfiguration(prefix, collection);
|
||||||
if (!result.containsKey(configuration.getId())) {
|
if (!result.containsKey(configuration.getId())) {
|
||||||
result.put(configuration.getId(), configuration);
|
result.put(configuration.getId(), configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also add one for the default
|
//Also add one for the default
|
||||||
DiscoveryConfiguration configuration = getDiscoveryConfiguration(null);
|
addConfigurationIfExists(result, prefix);
|
||||||
if (!result.containsKey(configuration.getId())) {
|
|
||||||
result.put(configuration.getId(), configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Arrays.asList(result.values().toArray(new DiscoveryConfiguration[result.size()]));
|
return Arrays.asList(result.values().toArray(new DiscoveryConfiguration[result.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addConfigurationIfExists(Map<String, DiscoveryConfiguration> result, String confName) {
|
||||||
|
DiscoveryConfiguration configurationExtra = getDiscoveryConfigurationByName(confName);
|
||||||
|
if (!result.containsKey(configurationExtra.getId())) {
|
||||||
|
result.put(configurationExtra.getId(), configurationExtra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,9 @@ package org.dspace.discovery;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import org.dspace.core.Context;
|
|||||||
public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin {
|
public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (dso instanceof Item) {
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
boolean hasOriginalBundleWithContent = hasOriginalBundleWithContent(item);
|
boolean hasOriginalBundleWithContent = hasOriginalBundleWithContent(item);
|
||||||
|
@@ -10,9 +10,9 @@ package org.dspace.discovery;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ 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, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (dso instanceof Item) {
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
List<Bundle> bundles = item.getBundles();
|
List<Bundle> bundles = item.getBundles();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ import org.dspace.core.Context;
|
|||||||
public class SolrServiceIndexOutputPlugin implements SolrServiceIndexPlugin {
|
public class SolrServiceIndexOutputPlugin implements SolrServiceIndexPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document) {
|
||||||
System.out.println("Currently indexing: " + dso.getHandle());
|
System.out.println("Currently indexing: " + dso.getUniqueIndexID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.discovery;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,5 +20,5 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public interface SolrServiceIndexPlugin {
|
public interface SolrServiceIndexPlugin {
|
||||||
|
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document);
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document);
|
||||||
}
|
}
|
||||||
|
@@ -15,9 +15,9 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.browse.BrowseException;
|
import org.dspace.browse.BrowseException;
|
||||||
import org.dspace.browse.BrowseIndex;
|
import org.dspace.browse.BrowseIndex;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataValue;
|
import org.dspace.content.MetadataValue;
|
||||||
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||||
@@ -57,7 +57,7 @@ public class SolrServiceMetadataBrowseIndexingPlugin implements SolrServiceIndex
|
|||||||
protected ChoiceAuthorityService choiceAuthorityService;
|
protected ChoiceAuthorityService choiceAuthorityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document) {
|
||||||
// Only works for Items
|
// Only works for Items
|
||||||
if (!(dso instanceof Item)) {
|
if (!(dso instanceof Item)) {
|
||||||
return;
|
return;
|
||||||
|
@@ -11,12 +11,14 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
import org.dspace.authorize.service.ResourcePolicyService;
|
import org.dspace.authorize.service.ResourcePolicyService;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -54,9 +56,14 @@ public class SolrServiceResourceRestrictionPlugin implements SolrServiceIndexPlu
|
|||||||
protected ResourcePolicyService resourcePolicyService;
|
protected ResourcePolicyService resourcePolicyService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject bdso, SolrInputDocument document) {
|
||||||
|
if (!(bdso instanceof DSpaceObject)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DSpaceObject dso = (DSpaceObject) bdso;
|
||||||
try {
|
try {
|
||||||
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ);
|
List<ResourcePolicy> policies = authorizeService
|
||||||
|
.getPoliciesActionFilterExceptRpType(context, dso, Constants.READ, ResourcePolicy.TYPE_WORKFLOW);
|
||||||
for (ResourcePolicy resourcePolicy : policies) {
|
for (ResourcePolicy resourcePolicy : policies) {
|
||||||
String fieldValue;
|
String fieldValue;
|
||||||
if (resourcePolicy.getGroup() != null) {
|
if (resourcePolicy.getGroup() != null) {
|
||||||
@@ -82,7 +89,35 @@ public class SolrServiceResourceRestrictionPlugin implements SolrServiceIndexPlu
|
|||||||
@Override
|
@Override
|
||||||
public void additionalSearchParameters(Context context, DiscoverQuery discoveryQuery, SolrQuery solrQuery) {
|
public void additionalSearchParameters(Context context, DiscoverQuery discoveryQuery, SolrQuery solrQuery) {
|
||||||
try {
|
try {
|
||||||
if (!authorizeService.isAdmin(context)) {
|
if (context != null && !authorizeService.isAdmin(context)) {
|
||||||
|
|
||||||
|
boolean isInProgessSubmission = false;
|
||||||
|
EPerson currentUser = context.getCurrentUser();
|
||||||
|
// Retrieve all the groups the current user is a member of !
|
||||||
|
Set<Group> groups = groupService.allMemberGroupsSet(context, currentUser);
|
||||||
|
|
||||||
|
if (currentUser != null) {
|
||||||
|
if (StringUtils.isNotBlank(discoveryQuery.getDiscoveryConfigurationName())) {
|
||||||
|
if (discoveryQuery.getDiscoveryConfigurationName().startsWith("workspace")) {
|
||||||
|
// insert filter by submitter
|
||||||
|
solrQuery
|
||||||
|
.addFilterQuery("read:(e" + currentUser.getID() + " OR ws" + currentUser.getID() + ")");
|
||||||
|
isInProgessSubmission = true;
|
||||||
|
} else if (discoveryQuery.getDiscoveryConfigurationName().startsWith("workflow")) {
|
||||||
|
// insert filter by controllers
|
||||||
|
StringBuilder controllerQuery = new StringBuilder();
|
||||||
|
controllerQuery.append("read:(we" + currentUser.getID());
|
||||||
|
for (Group group : groups) {
|
||||||
|
controllerQuery.append(" OR wg").append(group.getID());
|
||||||
|
}
|
||||||
|
controllerQuery.append(")");
|
||||||
|
solrQuery.addFilterQuery(controllerQuery.toString());
|
||||||
|
isInProgessSubmission = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isInProgessSubmission) {
|
||||||
StringBuilder resourceQuery = new StringBuilder();
|
StringBuilder resourceQuery = new StringBuilder();
|
||||||
//Always add the anonymous group id to the query
|
//Always add the anonymous group id to the query
|
||||||
Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS);
|
Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS);
|
||||||
@@ -91,13 +126,12 @@ public class SolrServiceResourceRestrictionPlugin implements SolrServiceIndexPlu
|
|||||||
anonGroupId = anonymousGroup.getID().toString();
|
anonGroupId = anonymousGroup.getID().toString();
|
||||||
}
|
}
|
||||||
resourceQuery.append("read:(g" + anonGroupId);
|
resourceQuery.append("read:(g" + anonGroupId);
|
||||||
EPerson currentUser = context.getCurrentUser();
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
resourceQuery.append(" OR e").append(currentUser.getID());
|
resourceQuery.append(" OR e").append(currentUser.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve all the groups the current user is a member of !
|
//Retrieve all the groups the current user is a member of !
|
||||||
Set<Group> groups = groupService.allMemberGroupsSet(context, currentUser);
|
|
||||||
for (Group group : groups) {
|
for (Group group : groups) {
|
||||||
resourceQuery.append(" OR g").append(group.getID());
|
resourceQuery.append(" OR g").append(group.getID());
|
||||||
}
|
}
|
||||||
@@ -116,6 +150,7 @@ public class SolrServiceResourceRestrictionPlugin implements SolrServiceIndexPlu
|
|||||||
|
|
||||||
solrQuery.addFilterQuery(resourceQuery.toString());
|
solrQuery.addFilterQuery(resourceQuery.toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error(LogManager.getHeader(context, "Error while adding resource policy information to query", ""), e);
|
log.error(LogManager.getHeader(context, "Error while adding resource policy information to query", ""), e);
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.discovery;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Item;
|
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;
|
||||||
@@ -30,7 +30,7 @@ public class SolrServiceSpellIndexingPlugin implements SolrServiceIndexPlugin {
|
|||||||
protected ItemService itemService;
|
protected ItemService itemService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
|
public void additionalIndex(Context context, BrowsableDSpaceObject dso, SolrInputDocument document) {
|
||||||
if (dso instanceof Item) {
|
if (dso instanceof Item) {
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
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);
|
||||||
|
@@ -12,7 +12,7 @@ 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.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,9 +20,18 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
*/
|
*/
|
||||||
public class DiscoveryConfigurationService {
|
public class DiscoveryConfigurationService {
|
||||||
|
|
||||||
|
private Map<String, List<String>> extraConfigurationMapping = new HashMap<String, List<String>>();
|
||||||
private Map<String, DiscoveryConfiguration> map;
|
private Map<String, DiscoveryConfiguration> map;
|
||||||
private Map<Integer, List<String>> toIgnoreMetadataFields = new HashMap<>();
|
private Map<Integer, List<String>> toIgnoreMetadataFields = new HashMap<>();
|
||||||
|
|
||||||
|
public void setExtraConfigurationMapping(Map<String, List<String>> extraConfigurationMapping) {
|
||||||
|
this.extraConfigurationMapping = extraConfigurationMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> getExtraConfigurationMapping() {
|
||||||
|
return extraConfigurationMapping;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, DiscoveryConfiguration> getMap() {
|
public Map<String, DiscoveryConfiguration> getMap() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -39,7 +48,7 @@ public class DiscoveryConfigurationService {
|
|||||||
this.toIgnoreMetadataFields = toIgnoreMetadataFields;
|
this.toIgnoreMetadataFields = toIgnoreMetadataFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso) {
|
public DiscoveryConfiguration getDiscoveryConfiguration(BrowsableDSpaceObject dso) {
|
||||||
String name;
|
String name;
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
name = "site";
|
name = "site";
|
||||||
@@ -64,7 +73,7 @@ public class DiscoveryConfigurationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoveryConfiguration getDiscoveryConfigurationByNameOrDso(final String configurationName,
|
public DiscoveryConfiguration getDiscoveryConfigurationByNameOrDso(final String configurationName,
|
||||||
final DSpaceObject dso) {
|
final BrowsableDSpaceObject dso) {
|
||||||
if (StringUtils.isNotBlank(configurationName) && getMap().containsKey(configurationName)) {
|
if (StringUtils.isNotBlank(configurationName) && getMap().containsKey(configurationName)) {
|
||||||
return getMap().get(configurationName);
|
return getMap().get(configurationName);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -17,6 +17,7 @@ import java.util.List;
|
|||||||
import org.apache.logging.log4j.Logger;
|
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.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DCDate;
|
import org.dspace.content.DCDate;
|
||||||
@@ -139,9 +140,10 @@ public class Harvest {
|
|||||||
DiscoverResult discoverResult = SearchUtils.getSearchService().search(context, discoverQuery);
|
DiscoverResult discoverResult = SearchUtils.getSearchService().search(context, discoverQuery);
|
||||||
|
|
||||||
// Process results of query into HarvestedItemInfo objects
|
// Process results of query into HarvestedItemInfo objects
|
||||||
Iterator<DSpaceObject> dsoIterator = discoverResult.getDspaceObjects().iterator();
|
Iterator<BrowsableDSpaceObject> dsoIterator = discoverResult.getDspaceObjects().iterator();
|
||||||
while (dsoIterator.hasNext() && ((limit == 0) || (itemCounter < limit))) {
|
while (dsoIterator.hasNext() && ((limit == 0) || (itemCounter < limit))) {
|
||||||
DSpaceObject dso = dsoIterator.next();
|
// the query is limited to ITEM
|
||||||
|
DSpaceObject dso = (DSpaceObject) dsoIterator.next();
|
||||||
HarvestedItemInfo itemInfo = new HarvestedItemInfo();
|
HarvestedItemInfo itemInfo = new HarvestedItemInfo();
|
||||||
itemInfo.context = context;
|
itemInfo.context = context;
|
||||||
itemInfo.handle = dso.getHandle();
|
itemInfo.handle = dso.getHandle();
|
||||||
|
@@ -70,7 +70,7 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
@RequestMapping(method = RequestMethod.GET)
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
public SearchSupportResource getSearchSupport(@RequestParam(name = "scope", required = false) String dsoScope,
|
public SearchSupportResource getSearchSupport(@RequestParam(name = "scope", required = false) String dsoScope,
|
||||||
@RequestParam(name = "configuration", required = false) String
|
@RequestParam(name = "configuration", required = false) String
|
||||||
configurationName)
|
configuration)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
SearchSupportRest searchSupportRest = discoveryRestRepository.getSearchSupport();
|
SearchSupportRest searchSupportRest = discoveryRestRepository.getSearchSupport();
|
||||||
@@ -82,14 +82,14 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
@RequestMapping(method = RequestMethod.GET, value = "/search")
|
@RequestMapping(method = RequestMethod.GET, value = "/search")
|
||||||
public SearchConfigurationResource getSearchConfiguration(
|
public SearchConfigurationResource getSearchConfiguration(
|
||||||
@RequestParam(name = "scope", required = false) String dsoScope,
|
@RequestParam(name = "scope", required = false) String dsoScope,
|
||||||
@RequestParam(name = "configuration", required = false) String configurationName) throws Exception {
|
@RequestParam(name = "configuration", required = false) String configuration) throws Exception {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Retrieving search configuration for scope " + StringUtils.trimToEmpty(dsoScope)
|
log.trace("Retrieving search configuration for scope " + StringUtils.trimToEmpty(dsoScope)
|
||||||
+ " and configuration name " + StringUtils.trimToEmpty(configurationName));
|
+ " and configuration name " + StringUtils.trimToEmpty(configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchConfigurationRest searchConfigurationRest = discoveryRestRepository
|
SearchConfigurationRest searchConfigurationRest = discoveryRestRepository
|
||||||
.getSearchConfiguration(dsoScope, configurationName);
|
.getSearchConfiguration(dsoScope, configuration);
|
||||||
|
|
||||||
SearchConfigurationResource searchConfigurationResource = new SearchConfigurationResource(
|
SearchConfigurationResource searchConfigurationResource = new SearchConfigurationResource(
|
||||||
searchConfigurationRest);
|
searchConfigurationRest);
|
||||||
@@ -176,6 +176,8 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
@RequestParam(name = "query", required = false) String query,
|
@RequestParam(name = "query", required = false) String query,
|
||||||
@RequestParam(name = "dsoType", required = false) String dsoType,
|
@RequestParam(name = "dsoType", required = false) String dsoType,
|
||||||
@RequestParam(name = "scope", required = false) String dsoScope,
|
@RequestParam(name = "scope", required = false) String dsoScope,
|
||||||
|
@RequestParam(name = "configuration", required = false) String
|
||||||
|
configurationName,
|
||||||
List<SearchFilter> searchFilters,
|
List<SearchFilter> searchFilters,
|
||||||
Pageable page) throws Exception {
|
Pageable page) throws Exception {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
@@ -188,7 +190,7 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FacetResultsRest facetResultsRest = discoveryRestRepository
|
FacetResultsRest facetResultsRest = discoveryRestRepository
|
||||||
.getFacetObjects(facetName, prefix, query, dsoType, dsoScope, searchFilters, page);
|
.getFacetObjects(facetName, prefix, query, dsoType, dsoScope, configurationName, searchFilters, page);
|
||||||
|
|
||||||
FacetResultsResource facetResultsResource = new FacetResultsResource(facetResultsRest);
|
FacetResultsResource facetResultsResource = new FacetResultsResource(facetResultsRest);
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@ import org.dspace.app.util.factory.UtilServiceFactory;
|
|||||||
import org.dspace.app.util.service.OpenSearchService;
|
import org.dspace.app.util.service.OpenSearchService;
|
||||||
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.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.factory.ContentServiceFactory;
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
@@ -140,7 +141,7 @@ public class OpenSearchController {
|
|||||||
|
|
||||||
// format and return results
|
// format and return results
|
||||||
Map<String, String> labelMap = getLabels(request);
|
Map<String, String> labelMap = getLabels(request);
|
||||||
List<DSpaceObject> dsoResults = qResults.getDspaceObjects();
|
List<BrowsableDSpaceObject> dsoResults = qResults.getDspaceObjects();
|
||||||
Document resultsDoc = openSearchService.getResultsDoc(context, format, query,
|
Document resultsDoc = openSearchService.getResultsDoc(context, format, query,
|
||||||
(int) qResults.getTotalSearchResults(), qResults.getStart(),
|
(int) qResults.getTotalSearchResults(), qResults.getStart(),
|
||||||
qResults.getMaxResults(), container, dsoResults, labelMap);
|
qResults.getMaxResults(), container, dsoResults, labelMap);
|
||||||
|
@@ -431,47 +431,6 @@ public class RestResourceController implements InitializingBean {
|
|||||||
return ControllerUtils.toResponseEntity(HttpStatus.CREATED, null, result);
|
return ControllerUtils.toResponseEntity(HttpStatus.CREATED, null, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called in POST, with a x-www-form-urlencoded, execute an action on a resource
|
|
||||||
*
|
|
||||||
* Note that the regular expression in the request mapping accept a number as identifier;
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param apiCategory
|
|
||||||
* @param model
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
* @throws HttpRequestMethodNotSupportedException
|
|
||||||
*/
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT, headers =
|
|
||||||
"content-type=application/x-www-form-urlencoded")
|
|
||||||
public ResponseEntity<ResourceSupport> action(HttpServletRequest request, @PathVariable String apiCategory,
|
|
||||||
@PathVariable String model, @PathVariable Integer id)
|
|
||||||
throws HttpRequestMethodNotSupportedException {
|
|
||||||
checkModelPluralForm(apiCategory, model);
|
|
||||||
DSpaceRestRepository<RestAddressableModel, Integer> repository =
|
|
||||||
utils.getResourceRepository(apiCategory, model);
|
|
||||||
|
|
||||||
RestAddressableModel modelObject = null;
|
|
||||||
try {
|
|
||||||
modelObject = repository.action(request, id);
|
|
||||||
} catch (UnprocessableEntityException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return ControllerUtils.toEmptyResponse(HttpStatus.UNPROCESSABLE_ENTITY);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return ControllerUtils.toEmptyResponse(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modelObject != null) {
|
|
||||||
DSpaceResource result = repository.wrapResource(modelObject);
|
|
||||||
linkService.addLinks(result);
|
|
||||||
return ControllerUtils.toResponseEntity(HttpStatus.CREATED, null, result);
|
|
||||||
} else {
|
|
||||||
return ControllerUtils.toEmptyResponse(HttpStatus.NO_CONTENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in POST, multipart, upload to a specific rest resource the file passed as "file" request parameter
|
* Called in POST, multipart, upload to a specific rest resource the file passed as "file" request parameter
|
||||||
*
|
*
|
||||||
|
@@ -50,28 +50,28 @@ public class DiscoverFacetsConverter {
|
|||||||
return searchResultsRest;
|
return searchResultsRest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addFacetValues(Context context, final DiscoverResult searchResult, final SearchResultsRest resultsRest,
|
||||||
private void addFacetValues(Context context, final DiscoverResult searchResult,
|
|
||||||
final SearchResultsRest searchResultsRest,
|
|
||||||
final DiscoveryConfiguration configuration) {
|
final DiscoveryConfiguration configuration) {
|
||||||
|
|
||||||
List<DiscoverySearchFilterFacet> facets = configuration.getSidebarFacets();
|
List<DiscoverySearchFilterFacet> facets = configuration.getSidebarFacets();
|
||||||
for (DiscoverySearchFilterFacet field : CollectionUtils.emptyIfNull(facets)) {
|
for (DiscoverySearchFilterFacet field : CollectionUtils.emptyIfNull(facets)) {
|
||||||
|
|
||||||
List<DiscoverResult.FacetResult> facetValues = searchResult.getFacetResult(field);
|
List<DiscoverResult.FacetResult> facetValues = searchResult.getFacetResult(field);
|
||||||
|
|
||||||
SearchFacetEntryRest facetEntry = new SearchFacetEntryRest(field.getIndexFieldName());
|
SearchFacetEntryRest facetEntry = new SearchFacetEntryRest(field.getIndexFieldName());
|
||||||
int valueCount = 0;
|
int valueCount = 0;
|
||||||
|
facetEntry.setHasMore(false);
|
||||||
facetEntry.setFacetLimit(field.getFacetLimit());
|
facetEntry.setFacetLimit(field.getFacetLimit());
|
||||||
facetEntry.setExposeMinMax(field.exposeMinAndMaxValue());
|
|
||||||
if (field.exposeMinAndMaxValue()) {
|
if (field.exposeMinAndMaxValue()) {
|
||||||
handleExposeMinMaxValues(context, field, facetEntry);
|
handleExposeMinMaxValues(context, field, facetEntry);
|
||||||
}
|
}
|
||||||
|
facetEntry.setExposeMinMax(field.exposeMinAndMaxValue());
|
||||||
for (DiscoverResult.FacetResult value : CollectionUtils.emptyIfNull(facetValues)) {
|
for (DiscoverResult.FacetResult value : CollectionUtils.emptyIfNull(facetValues)) {
|
||||||
//The discover results contains max facetLimit + 1 values. If we reach the "+1", indicate that there are
|
// The discover results contains max facetLimit + 1 values. If we reach the "+1", indicate that there
|
||||||
|
// are
|
||||||
// more results available.
|
// more results available.
|
||||||
if (valueCount < field.getFacetLimit()) {
|
if (valueCount < field.getFacetLimit()) {
|
||||||
SearchFacetValueRest valueRest = facetValueConverter.convert(value);
|
SearchFacetValueRest valueRest = facetValueConverter.convert(value);
|
||||||
|
|
||||||
facetEntry.addValue(valueRest);
|
facetEntry.addValue(valueRest);
|
||||||
} else {
|
} else {
|
||||||
facetEntry.setHasMore(true);
|
facetEntry.setHasMore(true);
|
||||||
@@ -84,27 +84,27 @@ public class DiscoverFacetsConverter {
|
|||||||
valueCount++;
|
valueCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResultsRest.addFacetEntry(facetEntry);
|
resultsRest.addFacetEntry(facetEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will fill the facetEntry with the appropriate min and max values if they're not empty
|
* This method will fill the facetEntry with the appropriate min and max values if they're not empty
|
||||||
* @param context The relevant DSpace context
|
*
|
||||||
* @param field The DiscoverySearchFilterFacet field to search for this value in solr
|
* @param context
|
||||||
* @param facetEntry The SearchFacetEntryRest facetEntry for which this needs to be filled in
|
* The relevant DSpace context
|
||||||
|
* @param field
|
||||||
|
* The DiscoverySearchFilterFacet field to search for this value in solr
|
||||||
|
* @param facetEntry
|
||||||
|
* The SearchFacetEntryRest facetEntry for which this needs to be filled in
|
||||||
*/
|
*/
|
||||||
private void handleExposeMinMaxValues(Context context, DiscoverySearchFilterFacet field,
|
private void handleExposeMinMaxValues(Context context, DiscoverySearchFilterFacet field,
|
||||||
SearchFacetEntryRest facetEntry) {
|
SearchFacetEntryRest facetEntry) {
|
||||||
try {
|
try {
|
||||||
String minValue = searchService.calculateExtremeValue(context,
|
String minValue = searchService.calculateExtremeValue(context, field.getIndexFieldName() + "_min",
|
||||||
field.getIndexFieldName() + "_min",
|
field.getIndexFieldName() + "_min_sort", DiscoverQuery.SORT_ORDER.asc);
|
||||||
field.getIndexFieldName() + "_min_sort",
|
String maxValue = searchService.calculateExtremeValue(context, field.getIndexFieldName() + "_max",
|
||||||
DiscoverQuery.SORT_ORDER.asc);
|
field.getIndexFieldName() + "_max_sort", DiscoverQuery.SORT_ORDER.desc);
|
||||||
String maxValue = searchService.calculateExtremeValue(context,
|
|
||||||
field.getIndexFieldName() + "_max",
|
|
||||||
field.getIndexFieldName() + "_max_sort",
|
|
||||||
DiscoverQuery.SORT_ORDER.desc);
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(minValue) && StringUtils.isNotBlank(maxValue)) {
|
if (StringUtils.isNotBlank(minValue) && StringUtils.isNotBlank(maxValue)) {
|
||||||
facetEntry.setMinValue(minValue);
|
facetEntry.setMinValue(minValue);
|
||||||
@@ -115,7 +115,6 @@ public class DiscoverFacetsConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setRequestInformation(final Context context, final String query, final String dsoType,
|
private void setRequestInformation(final Context context, final String query, final String dsoType,
|
||||||
final String configurationName, final String scope,
|
final String configurationName, final String scope,
|
||||||
final List<SearchFilter> searchFilters, final Pageable page,
|
final List<SearchFilter> searchFilters, final Pageable page,
|
||||||
|
@@ -12,23 +12,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.rest.converter.query.SearchQueryConverter;
|
import org.dspace.app.rest.converter.query.SearchQueryConverter;
|
||||||
import org.dspace.app.rest.model.DSpaceObjectRest;
|
import org.dspace.app.rest.model.RestAddressableModel;
|
||||||
import org.dspace.app.rest.model.SearchFacetEntryRest;
|
|
||||||
import org.dspace.app.rest.model.SearchFacetValueRest;
|
|
||||||
import org.dspace.app.rest.model.SearchResultEntryRest;
|
import org.dspace.app.rest.model.SearchResultEntryRest;
|
||||||
import org.dspace.app.rest.model.SearchResultsRest;
|
import org.dspace.app.rest.model.SearchResultsRest;
|
||||||
import org.dspace.app.rest.parameter.SearchFilter;
|
import org.dspace.app.rest.parameter.SearchFilter;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.DiscoverQuery;
|
|
||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
import org.dspace.discovery.SearchService;
|
|
||||||
import org.dspace.discovery.SearchServiceException;
|
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
@@ -43,12 +36,11 @@ public class DiscoverResultConverter {
|
|||||||
private static final Logger log = Logger.getLogger(DiscoverResultConverter.class);
|
private static final Logger log = Logger.getLogger(DiscoverResultConverter.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<DSpaceObjectConverter> converters;
|
private List<BrowsableDSpaceObjectConverter> converters;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SearchService searchService;
|
private DiscoverFacetsConverter facetConverter;
|
||||||
|
@Autowired
|
||||||
private DiscoverFacetValueConverter facetValueConverter = new DiscoverFacetValueConverter();
|
private SearchFilterToAppliedFilterConverter searchFilterToAppliedFilterConverter;
|
||||||
|
|
||||||
public SearchResultsRest convert(final Context context, final String query, final String dsoType,
|
public SearchResultsRest convert(final Context context, final String query, final String dsoType,
|
||||||
final String configurationName, final String scope,
|
final String configurationName, final String scope,
|
||||||
@@ -70,73 +62,15 @@ public class DiscoverResultConverter {
|
|||||||
|
|
||||||
private void addFacetValues(Context context, final DiscoverResult searchResult, final SearchResultsRest resultsRest,
|
private void addFacetValues(Context context, final DiscoverResult searchResult, final SearchResultsRest resultsRest,
|
||||||
final DiscoveryConfiguration configuration) {
|
final DiscoveryConfiguration configuration) {
|
||||||
|
facetConverter.addFacetValues(context, searchResult, resultsRest, configuration);
|
||||||
List<DiscoverySearchFilterFacet> facets = configuration.getSidebarFacets();
|
|
||||||
for (DiscoverySearchFilterFacet field : CollectionUtils.emptyIfNull(facets)) {
|
|
||||||
List<DiscoverResult.FacetResult> facetValues = searchResult.getFacetResult(field);
|
|
||||||
|
|
||||||
SearchFacetEntryRest facetEntry = new SearchFacetEntryRest(field.getIndexFieldName());
|
|
||||||
int valueCount = 0;
|
|
||||||
facetEntry.setHasMore(false);
|
|
||||||
facetEntry.setFacetLimit(field.getFacetLimit());
|
|
||||||
if (field.exposeMinAndMaxValue()) {
|
|
||||||
handleExposeMinMaxValues(context,field,facetEntry);
|
|
||||||
}
|
|
||||||
facetEntry.setExposeMinMax(field.exposeMinAndMaxValue());
|
|
||||||
for (DiscoverResult.FacetResult value : CollectionUtils.emptyIfNull(facetValues)) {
|
|
||||||
//The discover results contains max facetLimit + 1 values. If we reach the "+1", indicate that there are
|
|
||||||
//more results available.
|
|
||||||
if (valueCount < field.getFacetLimit()) {
|
|
||||||
SearchFacetValueRest valueRest = facetValueConverter.convert(value);
|
|
||||||
|
|
||||||
facetEntry.addValue(valueRest);
|
|
||||||
} else {
|
|
||||||
facetEntry.setHasMore(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(facetEntry.getFacetType())) {
|
|
||||||
facetEntry.setFacetType(value.getFieldType());
|
|
||||||
}
|
|
||||||
|
|
||||||
valueCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
resultsRest.addFacetEntry(facetEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will fill the facetEntry with the appropriate min and max values if they're not empty
|
|
||||||
* @param context The relevant DSpace context
|
|
||||||
* @param field The DiscoverySearchFilterFacet field to search for this value in solr
|
|
||||||
* @param facetEntry The SearchFacetEntryRest facetEntry for which this needs to be filled in
|
|
||||||
*/
|
|
||||||
private void handleExposeMinMaxValues(Context context,DiscoverySearchFilterFacet field,
|
|
||||||
SearchFacetEntryRest facetEntry) {
|
|
||||||
try {
|
|
||||||
String minValue = searchService.calculateExtremeValue(context,
|
|
||||||
field.getIndexFieldName() + "_min",
|
|
||||||
field.getIndexFieldName() + "_min_sort",
|
|
||||||
DiscoverQuery.SORT_ORDER.asc);
|
|
||||||
String maxValue = searchService.calculateExtremeValue(context,
|
|
||||||
field.getIndexFieldName() + "_max",
|
|
||||||
field.getIndexFieldName() + "_max_sort",
|
|
||||||
DiscoverQuery.SORT_ORDER.desc);
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(minValue) && StringUtils.isNotBlank(maxValue)) {
|
|
||||||
facetEntry.setMinValue(minValue);
|
|
||||||
facetEntry.setMaxValue(maxValue);
|
|
||||||
}
|
|
||||||
} catch (SearchServiceException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void addSearchResults(final DiscoverResult searchResult, final SearchResultsRest resultsRest) {
|
private void addSearchResults(final DiscoverResult searchResult, final SearchResultsRest resultsRest) {
|
||||||
for (DSpaceObject dspaceObject : CollectionUtils.emptyIfNull(searchResult.getDspaceObjects())) {
|
for (BrowsableDSpaceObject dspaceObject : CollectionUtils.emptyIfNull(searchResult.getDspaceObjects())) {
|
||||||
SearchResultEntryRest resultEntry = new SearchResultEntryRest();
|
SearchResultEntryRest resultEntry = new SearchResultEntryRest();
|
||||||
|
|
||||||
//Convert the DSpace Object to its REST model
|
//Convert the DSpace Object to its REST model
|
||||||
resultEntry.setDspaceObject(convertDSpaceObject(dspaceObject));
|
resultEntry.setRObject(convertDSpaceObject(dspaceObject));
|
||||||
|
|
||||||
//Add hit highlighting for this DSO if present
|
//Add hit highlighting for this DSO if present
|
||||||
DiscoverResult.DSpaceObjectHighlightResult highlightedResults = searchResult
|
DiscoverResult.DSpaceObjectHighlightResult highlightedResults = searchResult
|
||||||
@@ -152,10 +86,10 @@ public class DiscoverResultConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DSpaceObjectRest convertDSpaceObject(final DSpaceObject dspaceObject) {
|
private RestAddressableModel convertDSpaceObject(final BrowsableDSpaceObject dspaceObject) {
|
||||||
for (DSpaceObjectConverter converter : converters) {
|
for (BrowsableDSpaceObjectConverter<BrowsableDSpaceObject, RestAddressableModel> converter : converters) {
|
||||||
if (converter.supportsModel(dspaceObject)) {
|
if (converter.supportsModel(dspaceObject)) {
|
||||||
return converter.fromModel(dspaceObject);
|
return converter.convert(dspaceObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -181,7 +115,6 @@ public class DiscoverResultConverter {
|
|||||||
SearchFilterToAppliedFilterConverter searchFilterToAppliedFilterConverter =
|
SearchFilterToAppliedFilterConverter searchFilterToAppliedFilterConverter =
|
||||||
new SearchFilterToAppliedFilterConverter();
|
new SearchFilterToAppliedFilterConverter();
|
||||||
for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(transformedFilters)) {
|
for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(transformedFilters)) {
|
||||||
|
|
||||||
resultsRest
|
resultsRest
|
||||||
.addAppliedFilter(searchFilterToAppliedFilterConverter.convertSearchFilter(context, searchFilter));
|
.addAppliedFilter(searchFilterToAppliedFilterConverter.convertSearchFilter(context, searchFilter));
|
||||||
}
|
}
|
||||||
|
@@ -13,10 +13,12 @@ import org.dspace.authority.AuthorityValue;
|
|||||||
import org.dspace.authority.service.AuthorityValueService;
|
import org.dspace.authority.service.AuthorityValueService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class' purpose is to convert the SearchFilter object into a SearchResultsRest.AppliedFilter object
|
* This class' purpose is to convert the SearchFilter object into a SearchResultsRest.AppliedFilter object
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class SearchFilterToAppliedFilterConverter {
|
public class SearchFilterToAppliedFilterConverter {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@@ -39,13 +39,11 @@ public abstract class DiscoveryRestHalLinkFactory<T> extends HalLinkFactory<T, D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UriComponentsBuilder buildFacetBaseLink(final FacetResultsRest data) throws Exception {
|
protected UriComponentsBuilder buildFacetBaseLink(final FacetResultsRest data) {
|
||||||
try {
|
try {
|
||||||
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn()
|
UriComponentsBuilder uriBuilder = uriBuilder(
|
||||||
.getFacetValues(data.getFacetEntry().getName(),
|
getMethodOn().getFacetValues(data.getFacetEntry().getName(), data.getPrefix(), data.getQuery(),
|
||||||
data.getPrefix(), data.getQuery(),
|
data.getDsoType(), data.getScope(), data.getConfigurationName(), null, null));
|
||||||
data.getDsoType(), data.getScope(),
|
|
||||||
null, null));
|
|
||||||
|
|
||||||
return addFilterParams(uriBuilder, data);
|
return addFilterParams(uriBuilder, data);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -56,9 +54,8 @@ public abstract class DiscoveryRestHalLinkFactory<T> extends HalLinkFactory<T, D
|
|||||||
|
|
||||||
protected UriComponentsBuilder buildSearchFacetsBaseLink(final SearchResultsRest data) {
|
protected UriComponentsBuilder buildSearchFacetsBaseLink(final SearchResultsRest data) {
|
||||||
try {
|
try {
|
||||||
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn()
|
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn().getFacets(data.getQuery(), data.getDsoType(),
|
||||||
.getFacets(data.getQuery(), data.getDsoType(), data.getScope(),
|
data.getScope(), data.getConfigurationName(), null, null));
|
||||||
data.getConfigurationName(), null, null));
|
|
||||||
|
|
||||||
uriBuilder = addSortingParms(uriBuilder, data);
|
uriBuilder = addSortingParms(uriBuilder, data);
|
||||||
|
|
||||||
|
@@ -40,10 +40,10 @@ public class SearchFacetEntryHalLinkFactory extends DiscoveryRestHalLinkFactory<
|
|||||||
String query = searchData == null ? null : searchData.getQuery();
|
String query = searchData == null ? null : searchData.getQuery();
|
||||||
String dsoType = searchData == null ? null : searchData.getDsoType();
|
String dsoType = searchData == null ? null : searchData.getDsoType();
|
||||||
String scope = searchData == null ? null : searchData.getScope();
|
String scope = searchData == null ? null : searchData.getScope();
|
||||||
|
String configuration = searchData == null ? null : searchData.getConfigurationName();
|
||||||
|
|
||||||
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn()
|
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn().getFacetValues(facetData.getName(), null, query,
|
||||||
.getFacetValues(facetData.getName(), null, query, dsoType,
|
dsoType, scope, configuration, null, null));
|
||||||
scope, null, null));
|
|
||||||
|
|
||||||
addFilterParams(uriBuilder, searchData);
|
addFilterParams(uriBuilder, searchData);
|
||||||
|
|
||||||
|
@@ -33,8 +33,8 @@ public class SearchResultEntryHalLinkFactory extends DiscoveryRestHalLinkFactory
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
SearchResultEntryRest data = halResource.getContent();
|
SearchResultEntryRest data = halResource.getContent();
|
||||||
|
|
||||||
if (data != null && data.getDspaceObject() != null) {
|
if (data != null && data.getRObject() != null) {
|
||||||
list.add(utils.linkToSingleResource(data.getDspaceObject(), SearchResultEntryResource.DSPACE_OBJECT_LINK));
|
list.add(utils.linkToSingleResource(data.getRObject(), SearchResultEntryResource.R_OBJECT_LINK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import org.dspace.app.rest.DiscoveryRestController;
|
import org.dspace.app.rest.DiscoveryRestController;
|
||||||
import org.dspace.app.rest.parameter.SearchFilter;
|
import org.dspace.app.rest.parameter.SearchFilter;
|
||||||
|
|
||||||
@@ -28,6 +29,9 @@ public abstract class DiscoveryResultsRest extends BaseObjectRest<String> {
|
|||||||
private SearchResultsRest.Sorting sort;
|
private SearchResultsRest.Sorting sort;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String dsoType;
|
private String dsoType;
|
||||||
|
@JsonIgnore
|
||||||
|
private List<SearchFilter> searchFilters;
|
||||||
|
private String configurationName;
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return CATEGORY;
|
return CATEGORY;
|
||||||
@@ -98,12 +102,10 @@ public abstract class DiscoveryResultsRest extends BaseObjectRest<String> {
|
|||||||
return configurationName;
|
return configurationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigurationName(final String configurationName) {
|
public void setConfigurationName(final String configuration) {
|
||||||
this.configurationName = configurationName;
|
this.configurationName = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String configurationName;
|
|
||||||
|
|
||||||
public void setSearchFilters(final List<SearchFilter> searchFilters) {
|
public void setSearchFilters(final List<SearchFilter> searchFilters) {
|
||||||
this.searchFilters = searchFilters;
|
this.searchFilters = searchFilters;
|
||||||
}
|
}
|
||||||
@@ -112,6 +114,5 @@ public abstract class DiscoveryResultsRest extends BaseObjectRest<String> {
|
|||||||
return searchFilters;
|
return searchFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
private List<SearchFilter> searchFilters;
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.model;
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +43,7 @@ public class ErrorRest {
|
|||||||
*/
|
*/
|
||||||
public List<String> getPaths() {
|
public List<String> getPaths() {
|
||||||
if (this.paths == null) {
|
if (this.paths == null) {
|
||||||
this.paths = new ArrayList<String>();
|
this.paths = new LinkedList<String>();
|
||||||
}
|
}
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import org.dspace.app.rest.DiscoveryRestController;
|
import org.dspace.app.rest.DiscoveryRestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,10 +25,9 @@ public class SearchResultEntryRest implements RestAddressableModel {
|
|||||||
|
|
||||||
private Map<String, List<String>> hitHighlights;
|
private Map<String, List<String>> hitHighlights;
|
||||||
|
|
||||||
|
private RestAddressableModel rObject;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private DSpaceObjectRest dspaceObject;
|
|
||||||
|
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return CATEGORY;
|
return CATEGORY;
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ public class SearchResultEntryRest implements RestAddressableModel {
|
|||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
public Class getController() {
|
public Class getController() {
|
||||||
return DiscoveryRestController.class;
|
return DiscoveryRestController.class;
|
||||||
}
|
}
|
||||||
@@ -55,11 +56,12 @@ public class SearchResultEntryRest implements RestAddressableModel {
|
|||||||
this.hitHighlights = hitHighlights;
|
this.hitHighlights = hitHighlights;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectRest getDspaceObject() {
|
@JsonIgnore
|
||||||
return dspaceObject;
|
public RestAddressableModel getRObject() {
|
||||||
|
return rObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDspaceObject(final DSpaceObjectRest dspaceObject) {
|
public void setRObject(final RestAddressableModel dspaceObject) {
|
||||||
this.dspaceObject = dspaceObject;
|
this.rObject = dspaceObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.model.hateoas;
|
package org.dspace.app.rest.model.hateoas;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.DSpaceObjectRest;
|
import org.dspace.app.rest.model.RestAddressableModel;
|
||||||
import org.dspace.app.rest.model.SearchResultEntryRest;
|
import org.dspace.app.rest.model.SearchResultEntryRest;
|
||||||
import org.dspace.app.rest.repository.DSpaceRestRepository;
|
import org.dspace.app.rest.repository.DSpaceRestRepository;
|
||||||
import org.dspace.app.rest.utils.Utils;
|
import org.dspace.app.rest.utils.Utils;
|
||||||
@@ -17,7 +17,7 @@ import org.dspace.app.rest.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class SearchResultEntryResource extends HALResource<SearchResultEntryRest> {
|
public class SearchResultEntryResource extends HALResource<SearchResultEntryRest> {
|
||||||
|
|
||||||
public static final String DSPACE_OBJECT_LINK = "dspaceObject";
|
public static final String R_OBJECT_LINK = "rObject";
|
||||||
|
|
||||||
public SearchResultEntryResource(final SearchResultEntryRest data, final Utils utils) {
|
public SearchResultEntryResource(final SearchResultEntryRest data, final Utils utils) {
|
||||||
super(data);
|
super(data);
|
||||||
@@ -27,12 +27,12 @@ public class SearchResultEntryResource extends HALResource<SearchResultEntryRest
|
|||||||
|
|
||||||
private void addEmbeds(final SearchResultEntryRest data, final Utils utils) {
|
private void addEmbeds(final SearchResultEntryRest data, final Utils utils) {
|
||||||
|
|
||||||
DSpaceObjectRest dspaceObject = data.getDspaceObject();
|
RestAddressableModel dspaceObject = data.getRObject();
|
||||||
|
|
||||||
if (dspaceObject != null) {
|
if (dspaceObject != null) {
|
||||||
DSpaceRestRepository resourceRepository = utils
|
DSpaceRestRepository resourceRepository = utils
|
||||||
.getResourceRepository(dspaceObject.getCategory(), dspaceObject.getType());
|
.getResourceRepository(dspaceObject.getCategory(), dspaceObject.getType());
|
||||||
embedResource(DSPACE_OBJECT_LINK, resourceRepository.wrapResource(dspaceObject));
|
embedResource(R_OBJECT_LINK, resourceRepository.wrapResource(dspaceObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,12 +20,12 @@ import org.dspace.app.rest.model.BrowseEntryRest;
|
|||||||
import org.dspace.app.rest.model.BrowseIndexRest;
|
import org.dspace.app.rest.model.BrowseIndexRest;
|
||||||
import org.dspace.app.rest.model.hateoas.BrowseEntryResource;
|
import org.dspace.app.rest.model.hateoas.BrowseEntryResource;
|
||||||
import org.dspace.app.rest.utils.ScopeResolver;
|
import org.dspace.app.rest.utils.ScopeResolver;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.browse.BrowseEngine;
|
import org.dspace.browse.BrowseEngine;
|
||||||
import org.dspace.browse.BrowseException;
|
import org.dspace.browse.BrowseException;
|
||||||
import org.dspace.browse.BrowseIndex;
|
import org.dspace.browse.BrowseIndex;
|
||||||
import org.dspace.browse.BrowseInfo;
|
import org.dspace.browse.BrowseInfo;
|
||||||
import org.dspace.browse.BrowserScope;
|
import org.dspace.browse.BrowserScope;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -73,7 +73,7 @@ public class BrowseEntryLinkRepository extends AbstractDSpaceRestRepository
|
|||||||
BrowseEngine be = new BrowseEngine(context);
|
BrowseEngine be = new BrowseEngine(context);
|
||||||
BrowserScope bs = new BrowserScope(context);
|
BrowserScope bs = new BrowserScope(context);
|
||||||
|
|
||||||
DSpaceObject scopeObj = scopeResolver.resolveScope(context, scope);
|
BrowsableDSpaceObject scopeObj = scopeResolver.resolveScope(context, scope);
|
||||||
|
|
||||||
// process the input, performing some inline validation
|
// process the input, performing some inline validation
|
||||||
final BrowseIndex bi;
|
final BrowseIndex bi;
|
||||||
|
@@ -8,7 +8,9 @@
|
|||||||
package org.dspace.app.rest.repository;
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -17,12 +19,12 @@ import org.dspace.app.rest.model.BrowseIndexRest;
|
|||||||
import org.dspace.app.rest.model.ItemRest;
|
import org.dspace.app.rest.model.ItemRest;
|
||||||
import org.dspace.app.rest.model.hateoas.ItemResource;
|
import org.dspace.app.rest.model.hateoas.ItemResource;
|
||||||
import org.dspace.app.rest.utils.ScopeResolver;
|
import org.dspace.app.rest.utils.ScopeResolver;
|
||||||
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.browse.BrowseEngine;
|
import org.dspace.browse.BrowseEngine;
|
||||||
import org.dspace.browse.BrowseException;
|
import org.dspace.browse.BrowseException;
|
||||||
import org.dspace.browse.BrowseIndex;
|
import org.dspace.browse.BrowseIndex;
|
||||||
import org.dspace.browse.BrowseInfo;
|
import org.dspace.browse.BrowseInfo;
|
||||||
import org.dspace.browse.BrowserScope;
|
import org.dspace.browse.BrowserScope;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.sort.SortException;
|
import org.dspace.sort.SortException;
|
||||||
@@ -73,7 +75,7 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
|
|||||||
BrowseEngine be = new BrowseEngine(context);
|
BrowseEngine be = new BrowseEngine(context);
|
||||||
BrowserScope bs = new BrowserScope(context);
|
BrowserScope bs = new BrowserScope(context);
|
||||||
|
|
||||||
DSpaceObject scopeObj = scopeResolver.resolveScope(context, scope);
|
BrowsableDSpaceObject scopeObj = scopeResolver.resolveScope(context, scope);
|
||||||
|
|
||||||
// process the input, performing some inline validation
|
// process the input, performing some inline validation
|
||||||
BrowseIndex bi = null;
|
BrowseIndex bi = null;
|
||||||
@@ -147,10 +149,13 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
|
|||||||
|
|
||||||
BrowseInfo binfo = be.browse(bs);
|
BrowseInfo binfo = be.browse(bs);
|
||||||
|
|
||||||
Pageable pageResultInfo = new PageRequest((binfo.getStart() - 1) / binfo.getResultsPerPage(),
|
Pageable pageResultInfo =
|
||||||
binfo.getResultsPerPage());
|
new PageRequest((binfo.getStart() - 1) / binfo.getResultsPerPage(), binfo.getResultsPerPage());
|
||||||
Page<ItemRest> page = new PageImpl<Item>(binfo.getBrowseItemResults(), pageResultInfo, binfo.getTotal())
|
List<Item> tmpResult = new ArrayList<Item>();
|
||||||
.map(converter);
|
for (BrowsableDSpaceObject bb : binfo.getBrowseItemResults()) {
|
||||||
|
tmpResult.add((Item) bb);
|
||||||
|
}
|
||||||
|
Page<ItemRest> page = new PageImpl<Item>(tmpResult, pageResultInfo, binfo.getTotal()).map(converter);
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.rest.Parameter;
|
|
||||||
import org.dspace.app.rest.SearchRestMethod;
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
import org.dspace.app.rest.converter.ClaimedTaskConverter;
|
import org.dspace.app.rest.converter.ClaimedTaskConverter;
|
||||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||||
@@ -47,6 +46,7 @@ import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +93,7 @@ public class ClaimedTaskRestRepository extends DSpaceRestRepository<ClaimedTaskR
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SearchRestMethod(name = "findByUser")
|
@SearchRestMethod(name = "findByUser")
|
||||||
public Page<ClaimedTaskRest> findByUser(@Parameter(value = "uuid") UUID userID, Pageable pageable) {
|
public Page<ClaimedTaskRest> findByUser(@Param(value = "uuid") UUID userID, Pageable pageable) {
|
||||||
List<ClaimedTask> tasks = null;
|
List<ClaimedTask> tasks = null;
|
||||||
try {
|
try {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
@@ -9,8 +9,6 @@ package org.dspace.app.rest.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ws.rs.BadRequestException;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.rest.converter.DiscoverConfigurationConverter;
|
import org.dspace.app.rest.converter.DiscoverConfigurationConverter;
|
||||||
@@ -28,7 +26,7 @@ import org.dspace.app.rest.model.SearchSupportRest;
|
|||||||
import org.dspace.app.rest.parameter.SearchFilter;
|
import org.dspace.app.rest.parameter.SearchFilter;
|
||||||
import org.dspace.app.rest.utils.DiscoverQueryBuilder;
|
import org.dspace.app.rest.utils.DiscoverQueryBuilder;
|
||||||
import org.dspace.app.rest.utils.ScopeResolver;
|
import org.dspace.app.rest.utils.ScopeResolver;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.DiscoverQuery;
|
import org.dspace.discovery.DiscoverQuery;
|
||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
@@ -81,32 +79,32 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DiscoverFacetsConverter discoverFacetsConverter;
|
private DiscoverFacetsConverter discoverFacetsConverter;
|
||||||
|
|
||||||
public SearchConfigurationRest getSearchConfiguration(final String dsoScope, final String configurationName) {
|
public SearchConfigurationRest getSearchConfiguration(final String dsoScope, final String configuration) {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
|
||||||
DSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
BrowsableDSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
||||||
DiscoveryConfiguration configuration = searchConfigurationService
|
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
|
||||||
.getDiscoveryConfigurationByNameOrDso(configurationName, scopeObject);
|
.getDiscoveryConfigurationByNameOrDso(configuration, scopeObject);
|
||||||
|
|
||||||
return discoverConfigurationConverter.convert(configuration);
|
return discoverConfigurationConverter.convert(discoveryConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchResultsRest getSearchObjects(final String query, final String dsoType, final String dsoScope,
|
public SearchResultsRest getSearchObjects(final String query, final String dsoType, final String dsoScope,
|
||||||
final String configurationName,
|
final String configuration,
|
||||||
final List<SearchFilter> searchFilters, final Pageable page)
|
final List<SearchFilter> searchFilters, final Pageable page)
|
||||||
throws InvalidRequestException, BadRequestException {
|
throws InvalidRequestException {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
|
||||||
DSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
BrowsableDSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
||||||
DiscoveryConfiguration configuration = searchConfigurationService
|
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
|
||||||
.getDiscoveryConfigurationByNameOrDso(configurationName, scopeObject);
|
.getDiscoveryConfigurationByNameOrDso(configuration, scopeObject);
|
||||||
|
|
||||||
DiscoverResult searchResult = null;
|
DiscoverResult searchResult = null;
|
||||||
DiscoverQuery discoverQuery = null;
|
DiscoverQuery discoverQuery = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
discoverQuery = queryBuilder
|
discoverQuery = queryBuilder
|
||||||
.buildQuery(context, scopeObject, configuration, query, searchFilters, dsoType, page);
|
.buildQuery(context, scopeObject, discoveryConfiguration, query, searchFilters, dsoType, page);
|
||||||
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
||||||
|
|
||||||
} catch (SearchServiceException e) {
|
} catch (SearchServiceException e) {
|
||||||
@@ -115,18 +113,18 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return discoverResultConverter
|
return discoverResultConverter
|
||||||
.convert(context, query, dsoType, configurationName, dsoScope, searchFilters, page, searchResult,
|
.convert(context, query, dsoType, configuration, dsoScope, searchFilters, page, searchResult,
|
||||||
configuration);
|
discoveryConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FacetConfigurationRest getFacetsConfiguration(final String dsoScope, final String configurationName) {
|
public FacetConfigurationRest getFacetsConfiguration(final String dsoScope, final String configuration) {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
|
||||||
DSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
BrowsableDSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
||||||
DiscoveryConfiguration configuration = searchConfigurationService
|
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
|
||||||
.getDiscoveryConfigurationByNameOrDso(configurationName, scopeObject);
|
.getDiscoveryConfigurationByNameOrDso(configuration, scopeObject);
|
||||||
|
|
||||||
return discoverFacetConfigurationConverter.convert(configurationName, dsoScope, configuration);
|
return discoverFacetConfigurationConverter.convert(configuration, dsoScope, discoveryConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchSupportRest getSearchSupport() {
|
public SearchSupportRest getSearchSupport() {
|
||||||
@@ -134,20 +132,19 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FacetResultsRest getFacetObjects(String facetName, String prefix, String query, String dsoType,
|
public FacetResultsRest getFacetObjects(String facetName, String prefix, String query, String dsoType,
|
||||||
String dsoScope, List<SearchFilter> searchFilters, Pageable page)
|
String dsoScope, final String configuration, List<SearchFilter> searchFilters, Pageable page)
|
||||||
throws InvalidRequestException {
|
throws InvalidRequestException {
|
||||||
|
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
|
||||||
DSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
BrowsableDSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
||||||
DiscoveryConfiguration configuration = searchConfigurationService
|
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
|
||||||
.getDiscoveryConfigurationByNameOrDso(facetName, scopeObject);
|
.getDiscoveryConfigurationByNameOrDso(configuration, scopeObject);
|
||||||
|
|
||||||
DiscoverResult searchResult = null;
|
DiscoverResult searchResult = null;
|
||||||
DiscoverQuery discoverQuery = null;
|
DiscoverQuery discoverQuery = null;
|
||||||
try {
|
try {
|
||||||
discoverQuery = queryBuilder
|
discoverQuery = queryBuilder.buildFacetQuery(context, scopeObject, discoveryConfiguration, prefix, query,
|
||||||
.buildFacetQuery(context, scopeObject, configuration, prefix, query,
|
|
||||||
searchFilters, dsoType, page, facetName);
|
searchFilters, dsoType, page, facetName);
|
||||||
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
||||||
|
|
||||||
@@ -156,36 +153,34 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository {
|
|||||||
//TODO TOM handle search exception
|
//TODO TOM handle search exception
|
||||||
}
|
}
|
||||||
|
|
||||||
FacetResultsRest facetResultsRest = discoverFacetResultsConverter
|
FacetResultsRest facetResultsRest = discoverFacetResultsConverter.convert(context, facetName, prefix, query,
|
||||||
.convert(context, facetName, prefix, query, dsoType, dsoScope, searchFilters,
|
dsoType, dsoScope, searchFilters, searchResult, discoveryConfiguration, page);
|
||||||
searchResult, configuration, page);
|
|
||||||
return facetResultsRest;
|
return facetResultsRest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchResultsRest getAllFacets(String query, String dsoType, String dsoScope, String configurationName,
|
public SearchResultsRest getAllFacets(String query, String dsoType, String dsoScope, String configuration,
|
||||||
List<SearchFilter> searchFilters) throws InvalidRequestException {
|
List<SearchFilter> searchFilters) throws InvalidRequestException {
|
||||||
|
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
Pageable page = new PageRequest(1, 1);
|
Pageable page = new PageRequest(1, 1);
|
||||||
DSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
BrowsableDSpaceObject scopeObject = scopeResolver.resolveScope(context, dsoScope);
|
||||||
DiscoveryConfiguration configuration = searchConfigurationService
|
DiscoveryConfiguration discoveryConfiguration = searchConfigurationService
|
||||||
.getDiscoveryConfigurationByNameOrDso(configurationName, scopeObject);
|
.getDiscoveryConfigurationByNameOrDso(configuration, scopeObject);
|
||||||
|
|
||||||
DiscoverResult searchResult = null;
|
DiscoverResult searchResult = null;
|
||||||
DiscoverQuery discoverQuery = null;
|
DiscoverQuery discoverQuery = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
discoverQuery = queryBuilder
|
discoverQuery = queryBuilder
|
||||||
.buildQuery(context, scopeObject, configuration, query, searchFilters, dsoType, page);
|
.buildQuery(context, scopeObject, discoveryConfiguration, query, searchFilters, dsoType, page);
|
||||||
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
searchResult = searchService.search(context, scopeObject, discoverQuery);
|
||||||
|
|
||||||
} catch (SearchServiceException e) {
|
} catch (SearchServiceException e) {
|
||||||
log.error("Error while searching with Discovery", e);
|
log.error("Error while searching with Discovery", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResultsRest searchResultsRest = discoverFacetsConverter
|
SearchResultsRest searchResultsRest = discoverFacetsConverter.convert(context, query, dsoType,
|
||||||
.convert(context, query, dsoType, configurationName, dsoScope, searchFilters, page, configuration,
|
configuration, dsoScope, searchFilters, page, discoveryConfiguration, searchResult);
|
||||||
searchResult);
|
|
||||||
|
|
||||||
return searchResultsRest;
|
return searchResultsRest;
|
||||||
|
|
||||||
|
@@ -7,7 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.repository;
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.RestModel;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.hateoas.HALResource;
|
import org.dspace.app.rest.model.hateoas.HALResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +16,7 @@ import org.dspace.app.rest.model.hateoas.HALResource;
|
|||||||
*
|
*
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
public interface LinkRestRepository<L extends RestModel> {
|
public interface LinkRestRepository<L extends Serializable> {
|
||||||
public abstract HALResource wrapResource(L model, String... rels);
|
public abstract HALResource wrapResource(L model, String... rels);
|
||||||
|
|
||||||
public default boolean isEmbeddableRelation(Object data, String name) {
|
public default boolean isEmbeddableRelation(Object data, String name) {
|
||||||
|
@@ -15,7 +15,6 @@ import javax.mail.MessagingException;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.rest.Parameter;
|
|
||||||
import org.dspace.app.rest.SearchRestMethod;
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
import org.dspace.app.rest.converter.PoolTaskConverter;
|
import org.dspace.app.rest.converter.PoolTaskConverter;
|
||||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||||
@@ -41,6 +40,7 @@ import org.dspace.xmlworkflow.storedcomponents.service.PoolTaskService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +87,7 @@ public class PoolTaskRestRepository extends DSpaceRestRepository<PoolTaskRest, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SearchRestMethod(name = "findByUser")
|
@SearchRestMethod(name = "findByUser")
|
||||||
public Page<PoolTaskRest> findByUser(@Parameter(value = "uuid") UUID userID, Pageable pageable) {
|
public Page<PoolTaskRest> findByUser(@Param(value = "uuid") UUID userID, Pageable pageable) {
|
||||||
List<PoolTask> tasks = null;
|
List<PoolTask> tasks = null;
|
||||||
try {
|
try {
|
||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
@@ -22,7 +22,7 @@ import org.dspace.app.rest.exception.InvalidSearchFacetException;
|
|||||||
import org.dspace.app.rest.exception.InvalidSearchFilterException;
|
import org.dspace.app.rest.exception.InvalidSearchFilterException;
|
||||||
import org.dspace.app.rest.exception.InvalidSortingException;
|
import org.dspace.app.rest.exception.InvalidSortingException;
|
||||||
import org.dspace.app.rest.parameter.SearchFilter;
|
import org.dspace.app.rest.parameter.SearchFilter;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
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;
|
||||||
@@ -67,7 +67,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
pageSizeLimit = configurationService.getIntProperty("rest.search.max.results", 100);
|
pageSizeLimit = configurationService.getIntProperty("rest.search.max.results", 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscoverQuery buildQuery(Context context, DSpaceObject scope,
|
public DiscoverQuery buildQuery(Context context, BrowsableDSpaceObject scope,
|
||||||
DiscoveryConfiguration discoveryConfiguration,
|
DiscoveryConfiguration discoveryConfiguration,
|
||||||
String query, List<SearchFilter> searchFilters,
|
String query, List<SearchFilter> searchFilters,
|
||||||
String dsoType, Pageable page)
|
String dsoType, Pageable page)
|
||||||
@@ -100,7 +100,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscoverQuery buildFacetQuery(Context context, DSpaceObject scope,
|
public DiscoverQuery buildFacetQuery(Context context, BrowsableDSpaceObject scope,
|
||||||
DiscoveryConfiguration discoveryConfiguration,
|
DiscoveryConfiguration discoveryConfiguration,
|
||||||
String prefix, String query, List<SearchFilter> searchFilters,
|
String prefix, String query, List<SearchFilter> searchFilters,
|
||||||
String dsoType, Pageable page, String facetName)
|
String dsoType, Pageable page, String facetName)
|
||||||
@@ -127,9 +127,9 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoverQuery addFacetingForFacets(Context context, DSpaceObject scope, String prefix,
|
private DiscoverQuery addFacetingForFacets(Context context, BrowsableDSpaceObject scope, String prefix,
|
||||||
DiscoverQuery queryArgs, DiscoveryConfiguration discoveryConfiguration,
|
DiscoverQuery queryArgs, DiscoveryConfiguration discoveryConfiguration, String facetName, Pageable page)
|
||||||
String facetName, Pageable page) throws InvalidSearchFacetException {
|
throws InvalidSearchFacetException {
|
||||||
|
|
||||||
DiscoverySearchFilterFacet facet = discoveryConfiguration.getSidebarFacet(facetName);
|
DiscoverySearchFilterFacet facet = discoveryConfiguration.getSidebarFacet(facetName);
|
||||||
if (facet != null) {
|
if (facet != null) {
|
||||||
@@ -145,12 +145,12 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
return queryArgs;
|
return queryArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillFacetIntoQueryArgs(Context context, DSpaceObject scope, String prefix, DiscoverQuery queryArgs,
|
private void fillFacetIntoQueryArgs(Context context, BrowsableDSpaceObject scope, String prefix,
|
||||||
DiscoverySearchFilterFacet facet, final int pageSize) {
|
DiscoverQuery queryArgs, DiscoverySearchFilterFacet facet, final int pageSize) {
|
||||||
if (facet.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
if (facet.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
||||||
try {
|
try {
|
||||||
FacetYearRange facetYearRange = searchService
|
FacetYearRange facetYearRange =
|
||||||
.getFacetYearRange(context, scope, facet, queryArgs.getFilterQueries());
|
searchService.getFacetYearRange(context, scope, facet, queryArgs.getFilterQueries(), queryArgs);
|
||||||
|
|
||||||
queryArgs.addYearRangeFacet(facet, facetYearRange);
|
queryArgs.addYearRangeFacet(facet, facetYearRange);
|
||||||
|
|
||||||
@@ -193,6 +193,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
|
|
||||||
private DiscoverQuery buildBaseQueryForConfiguration(DiscoveryConfiguration discoveryConfiguration) {
|
private DiscoverQuery buildBaseQueryForConfiguration(DiscoveryConfiguration discoveryConfiguration) {
|
||||||
DiscoverQuery queryArgs = new DiscoverQuery();
|
DiscoverQuery queryArgs = new DiscoverQuery();
|
||||||
|
queryArgs.setDiscoveryConfigurationName(discoveryConfiguration.getId());
|
||||||
queryArgs.addFilterQueries(discoveryConfiguration.getDefaultFilterQueries()
|
queryArgs.addFilterQueries(discoveryConfiguration.getDefaultFilterQueries()
|
||||||
.toArray(
|
.toArray(
|
||||||
new String[discoveryConfiguration.getDefaultFilterQueries()
|
new String[discoveryConfiguration.getDefaultFilterQueries()
|
||||||
@@ -309,7 +310,7 @@ public class DiscoverQueryBuilder implements InitializingBean {
|
|||||||
return filterQueries.toArray(new String[filterQueries.size()]);
|
return filterQueries.toArray(new String[filterQueries.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscoverQuery addFaceting(Context context, DSpaceObject scope, DiscoverQuery queryArgs,
|
private DiscoverQuery addFaceting(Context context, BrowsableDSpaceObject scope, DiscoverQuery queryArgs,
|
||||||
DiscoveryConfiguration discoveryConfiguration) {
|
DiscoveryConfiguration discoveryConfiguration) {
|
||||||
|
|
||||||
List<DiscoverySearchFilterFacet> facets = discoveryConfiguration.getSidebarFacets();
|
List<DiscoverySearchFilterFacet> facets = discoveryConfiguration.getSidebarFacets();
|
||||||
|
@@ -28,7 +28,7 @@ import org.dspace.app.rest.exception.InvalidSearchFacetException;
|
|||||||
import org.dspace.app.rest.exception.InvalidSearchFilterException;
|
import org.dspace.app.rest.exception.InvalidSearchFilterException;
|
||||||
import org.dspace.app.rest.exception.InvalidSortingException;
|
import org.dspace.app.rest.exception.InvalidSortingException;
|
||||||
import org.dspace.app.rest.parameter.SearchFilter;
|
import org.dspace.app.rest.parameter.SearchFilter;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.browse.BrowsableDSpaceObject;
|
||||||
import org.dspace.core.Constants;
|
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;
|
||||||
@@ -75,7 +75,7 @@ public class DiscoverQueryBuilderTest {
|
|||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DSpaceObject scope;
|
private BrowsableDSpaceObject scope;
|
||||||
|
|
||||||
private DiscoveryConfiguration discoveryConfiguration;
|
private DiscoveryConfiguration discoveryConfiguration;
|
||||||
private String query;
|
private String query;
|
||||||
@@ -92,30 +92,29 @@ public class DiscoverQueryBuilderTest {
|
|||||||
.then(invocation -> invocation.getArguments()[0] + "_sort");
|
.then(invocation -> invocation.getArguments()[0] + "_sort");
|
||||||
|
|
||||||
when(searchService
|
when(searchService
|
||||||
.getFacetYearRange(eq(context), any(DSpaceObject.class), any(DiscoverySearchFilterFacet.class), any()))
|
.getFacetYearRange(eq(context), any(BrowsableDSpaceObject.class), any(DiscoverySearchFilterFacet.class),
|
||||||
.then(invocation
|
any(), any(DiscoverQuery.class)))
|
||||||
-> new FacetYearRange((DiscoverySearchFilterFacet) invocation.getArguments()[2]));
|
.then(invocation -> new FacetYearRange((DiscoverySearchFilterFacet) invocation.getArguments()[2]));
|
||||||
|
|
||||||
when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class)))
|
when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class)))
|
||||||
.then(invocation -> new DiscoverFilterQuery((String) invocation.getArguments()[1],
|
.then(invocation -> new DiscoverFilterQuery((String) invocation.getArguments()[1],
|
||||||
invocation.getArguments()[1] + ":\"" + invocation
|
invocation.getArguments()[1] + ":\"" + invocation.getArguments()[3] + "\"",
|
||||||
.getArguments()[3] + "\"",
|
|
||||||
(String) invocation.getArguments()[3]));
|
(String) invocation.getArguments()[3]));
|
||||||
|
|
||||||
discoveryConfiguration = new DiscoveryConfiguration();
|
discoveryConfiguration = new DiscoveryConfiguration();
|
||||||
discoveryConfiguration.setDefaultFilterQueries(Arrays.asList("archived:true"));
|
discoveryConfiguration.setDefaultFilterQueries(Arrays.asList("archived:true"));
|
||||||
|
|
||||||
|
|
||||||
DiscoveryHitHighlightingConfiguration discoveryHitHighlightingConfiguration = new
|
DiscoveryHitHighlightingConfiguration discoveryHitHighlightingConfiguration =
|
||||||
DiscoveryHitHighlightingConfiguration();
|
new DiscoveryHitHighlightingConfiguration();
|
||||||
List<DiscoveryHitHighlightFieldConfiguration> discoveryHitHighlightFieldConfigurations = new LinkedList<>();
|
List<DiscoveryHitHighlightFieldConfiguration> discoveryHitHighlightFieldConfigurations = new LinkedList<>();
|
||||||
|
|
||||||
DiscoveryHitHighlightFieldConfiguration discoveryHitHighlightFieldConfiguration = new
|
DiscoveryHitHighlightFieldConfiguration discoveryHitHighlightFieldConfiguration =
|
||||||
DiscoveryHitHighlightFieldConfiguration();
|
new DiscoveryHitHighlightFieldConfiguration();
|
||||||
discoveryHitHighlightFieldConfiguration.setField("dc.title");
|
discoveryHitHighlightFieldConfiguration.setField("dc.title");
|
||||||
|
|
||||||
DiscoveryHitHighlightFieldConfiguration discoveryHitHighlightFieldConfiguration1 = new
|
DiscoveryHitHighlightFieldConfiguration discoveryHitHighlightFieldConfiguration1 =
|
||||||
DiscoveryHitHighlightFieldConfiguration();
|
new DiscoveryHitHighlightFieldConfiguration();
|
||||||
discoveryHitHighlightFieldConfiguration1.setField("fulltext");
|
discoveryHitHighlightFieldConfiguration1.setField("fulltext");
|
||||||
|
|
||||||
discoveryHitHighlightFieldConfigurations.add(discoveryHitHighlightFieldConfiguration1);
|
discoveryHitHighlightFieldConfigurations.add(discoveryHitHighlightFieldConfiguration1);
|
||||||
@@ -164,8 +163,8 @@ public class DiscoverQueryBuilderTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testBuildQuery() throws Exception {
|
public void testBuildQuery() throws Exception {
|
||||||
|
|
||||||
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, scope, discoveryConfiguration, query,
|
DiscoverQuery discoverQuery = queryBuilder
|
||||||
Arrays.asList(searchFilter), "item", page);
|
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "item", page);
|
||||||
|
|
||||||
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true", "subject:\"Java\""));
|
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true", "subject:\"Java\""));
|
||||||
assertThat(discoverQuery.getQuery(), is(query));
|
assertThat(discoverQuery.getQuery(), is(query));
|
||||||
@@ -177,24 +176,21 @@ public class DiscoverQueryBuilderTest {
|
|||||||
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
||||||
assertThat(discoverQuery.getFacetOffset(), is(0));
|
assertThat(discoverQuery.getFacetOffset(), is(0));
|
||||||
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(new ReflectionEquals(
|
||||||
new ReflectionEquals(new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
||||||
DiscoveryConfigurationParameters.SORT.COUNT)),
|
DiscoveryConfigurationParameters.SORT.COUNT)), new ReflectionEquals(
|
||||||
new ReflectionEquals(
|
|
||||||
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
||||||
DiscoveryConfigurationParameters.SORT.VALUE))
|
DiscoveryConfigurationParameters.SORT.VALUE))));
|
||||||
));
|
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getHitHighlightingFields(),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
containsInAnyOrder(new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))
|
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildQueryDefaults() throws Exception {
|
public void testBuildQueryDefaults() throws Exception {
|
||||||
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, null, discoveryConfiguration, null,
|
DiscoverQuery discoverQuery =
|
||||||
null, null, null);
|
queryBuilder.buildQuery(context, null, discoveryConfiguration, null, null, null, null);
|
||||||
|
|
||||||
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true"));
|
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true"));
|
||||||
assertThat(discoverQuery.getQuery(), isEmptyOrNullString());
|
assertThat(discoverQuery.getQuery(), isEmptyOrNullString());
|
||||||
@@ -208,26 +204,23 @@ public class DiscoverQueryBuilderTest {
|
|||||||
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
||||||
assertThat(discoverQuery.getFacetOffset(), is(0));
|
assertThat(discoverQuery.getFacetOffset(), is(0));
|
||||||
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(new ReflectionEquals(
|
||||||
new ReflectionEquals(new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
||||||
DiscoveryConfigurationParameters.SORT.COUNT)),
|
DiscoveryConfigurationParameters.SORT.COUNT)), new ReflectionEquals(
|
||||||
new ReflectionEquals(
|
|
||||||
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
||||||
DiscoveryConfigurationParameters.SORT.VALUE))
|
DiscoveryConfigurationParameters.SORT.VALUE))));
|
||||||
));
|
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getHitHighlightingFields(),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
containsInAnyOrder(new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))
|
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSortByScore() throws Exception {
|
public void testSortByScore() throws Exception {
|
||||||
page = new PageRequest(2, 10, Sort.Direction.ASC, "SCORE");
|
page = new PageRequest(2, 10, Sort.Direction.ASC, "SCORE");
|
||||||
|
|
||||||
DiscoverQuery discoverQuery = queryBuilder.buildQuery(context, null, discoveryConfiguration, null,
|
DiscoverQuery discoverQuery =
|
||||||
null, null, page);
|
queryBuilder.buildQuery(context, null, discoveryConfiguration, null, null, null, page);
|
||||||
|
|
||||||
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true"));
|
assertThat(discoverQuery.getFilterQueries(), containsInAnyOrder("archived:true"));
|
||||||
assertThat(discoverQuery.getQuery(), isEmptyOrNullString());
|
assertThat(discoverQuery.getQuery(), isEmptyOrNullString());
|
||||||
@@ -241,39 +234,36 @@ public class DiscoverQueryBuilderTest {
|
|||||||
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
assertThat(discoverQuery.getFacetMinCount(), is(1));
|
||||||
assertThat(discoverQuery.getFacetOffset(), is(0));
|
assertThat(discoverQuery.getFacetOffset(), is(0));
|
||||||
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
assertThat(discoverQuery.getFacetFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getFacetFields(), containsInAnyOrder(new ReflectionEquals(
|
||||||
new ReflectionEquals(new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
new DiscoverFacetField("subject", DiscoveryConfigurationParameters.TYPE_TEXT, 6,
|
||||||
DiscoveryConfigurationParameters.SORT.COUNT)),
|
DiscoveryConfigurationParameters.SORT.COUNT)), new ReflectionEquals(
|
||||||
new ReflectionEquals(
|
|
||||||
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
new DiscoverFacetField("hierarchy", DiscoveryConfigurationParameters.TYPE_HIERARCHICAL, 8,
|
||||||
DiscoveryConfigurationParameters.SORT.VALUE))
|
DiscoveryConfigurationParameters.SORT.VALUE))));
|
||||||
));
|
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
assertThat(discoverQuery.getHitHighlightingFields(), hasSize(2));
|
||||||
assertThat(discoverQuery.getHitHighlightingFields(), containsInAnyOrder(
|
assertThat(discoverQuery.getHitHighlightingFields(),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
containsInAnyOrder(new ReflectionEquals(new DiscoverHitHighlightingField("dc.title", 0, 3)),
|
||||||
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))
|
new ReflectionEquals(new DiscoverHitHighlightingField("fulltext", 0, 3))));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidDSpaceObjectTypeException.class)
|
@Test(expected = InvalidDSpaceObjectTypeException.class)
|
||||||
public void testInvalidDSOType() throws Exception {
|
public void testInvalidDSOType() throws Exception {
|
||||||
queryBuilder.buildQuery(context, scope, discoveryConfiguration, query,
|
queryBuilder
|
||||||
Arrays.asList(searchFilter), "TEST", page);
|
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "TEST", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidSortingException.class)
|
@Test(expected = InvalidSortingException.class)
|
||||||
public void testInvalidSortField() throws Exception {
|
public void testInvalidSortField() throws Exception {
|
||||||
page = new PageRequest(2, 10, Sort.Direction.ASC, "test");
|
page = new PageRequest(2, 10, Sort.Direction.ASC, "test");
|
||||||
queryBuilder.buildQuery(context, scope, discoveryConfiguration, query,
|
queryBuilder
|
||||||
Arrays.asList(searchFilter), "ITEM", page);
|
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidSearchFilterException.class)
|
@Test(expected = InvalidSearchFilterException.class)
|
||||||
public void testInvalidSearchFilter1() throws Exception {
|
public void testInvalidSearchFilter1() throws Exception {
|
||||||
searchFilter = new SearchFilter("test", "equals", "Smith, Donald");
|
searchFilter = new SearchFilter("test", "equals", "Smith, Donald");
|
||||||
|
|
||||||
queryBuilder.buildQuery(context, scope, discoveryConfiguration, query,
|
queryBuilder
|
||||||
Arrays.asList(searchFilter), "ITEM", page);
|
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidSearchFilterException.class)
|
@Test(expected = InvalidSearchFilterException.class)
|
||||||
@@ -281,8 +271,8 @@ public class DiscoverQueryBuilderTest {
|
|||||||
when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class)))
|
when(searchService.toFilterQuery(any(Context.class), any(String.class), any(String.class), any(String.class)))
|
||||||
.thenThrow(SQLException.class);
|
.thenThrow(SQLException.class);
|
||||||
|
|
||||||
queryBuilder.buildQuery(context, scope, discoveryConfiguration, query,
|
queryBuilder
|
||||||
Arrays.asList(searchFilter), "ITEM", page);
|
.buildQuery(context, scope, discoveryConfiguration, query, Arrays.asList(searchFilter), "ITEM", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -7,6 +7,11 @@
|
|||||||
##### Search Indexing #####
|
##### Search Indexing #####
|
||||||
discovery.search.server = ${solr.server}/search
|
discovery.search.server = ${solr.server}/search
|
||||||
|
|
||||||
|
### See SolrServiceImpl, default number of threads is 5;
|
||||||
|
### WARNING: before changing this value please check the configuration of the connection pool to the Database.
|
||||||
|
#discovery.indexer.items.threads = 9
|
||||||
|
discovery.indexer.items.threads = 5
|
||||||
|
|
||||||
#Enable the url validation of the search.server setting above.
|
#Enable the url validation of the search.server setting above.
|
||||||
#Defaults to true: validation is enabled
|
#Defaults to true: validation is enabled
|
||||||
#discovery.solr.url.validation.enabled = true
|
#discovery.solr.url.validation.enabled = true
|
||||||
@@ -14,11 +19,12 @@ discovery.search.server = ${solr.server}/search
|
|||||||
#Char used to ensure that the sidebar facets are case insensitive
|
#Char used to ensure that the sidebar facets are case insensitive
|
||||||
#discovery.solr.facets.split.char=\n|||\n
|
#discovery.solr.facets.split.char=\n|||\n
|
||||||
|
|
||||||
# index.ignore-variants = false
|
# discovery.index.ignore-variants = false
|
||||||
# index.ignore-authority = false
|
# discovery.index.ignore-authority = false
|
||||||
discovery.index.projection=dc.title,dc.contributor.*,dc.date.issued
|
discovery.index.projection=dc.title,dc.contributor.*,dc.date.issued
|
||||||
|
|
||||||
# ONLY-FOR-JSPUI:
|
discovery.facet.namedtype.item = 000item\n|||\nArchived###item
|
||||||
# 1) you need to set the DiscoverySearchRequestProcessor in the dspace.cfg
|
discovery.facet.namedtype.workspace = 001workspace\n|||\nWorkspace###workspace
|
||||||
# 2) to show facet on Site/Community/etc. you need to add a Site/Community/Collection
|
discovery.facet.namedtype.workflow.item = 002workflow\n|||\nWorkflow###workflow
|
||||||
# Processors plugin in the dspace.cfg
|
discovery.facet.namedtype.workflow.claimed = 003workflow\n|||\nValidation###validation
|
||||||
|
discovery.facet.namedtype.workflow.pooled = 004workflow\n|||\nWaiting for Controller###waitingforcontroller
|
||||||
|
@@ -50,6 +50,9 @@
|
|||||||
<!--Use site to override the default configuration for the home page & default discovery page-->
|
<!--Use site to override the default configuration for the home page & default discovery page-->
|
||||||
<entry key="site" value-ref="homepageConfiguration" />
|
<entry key="site" value-ref="homepageConfiguration" />
|
||||||
<!--<entry key="123456789/7621" value-ref="defaultConfiguration"/>-->
|
<!--<entry key="123456789/7621" value-ref="defaultConfiguration"/>-->
|
||||||
|
<!-- Used to show filters and results on MyDSpace -->
|
||||||
|
<entry key="workspace" value-ref="workspaceConfiguration" />
|
||||||
|
<entry key="workflow" value-ref="workflowConfiguration" />
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
<property name="toIgnoreMetadataFields">
|
<property name="toIgnoreMetadataFields">
|
||||||
@@ -134,13 +137,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</property>
|
</property>
|
||||||
<!--Any default filter queries, these filter queries will be used for all queries done by discovery for this configuration-->
|
<!--Any default filter queries, these filter queries will be used for all
|
||||||
<!--<property name="defaultFilterQueries">-->
|
queries done by discovery for this configuration -->
|
||||||
<!--<list>-->
|
<property name="defaultFilterQueries">
|
||||||
|
<list>
|
||||||
<!--Only find items-->
|
<!--Only find items-->
|
||||||
<!--<value>search.resourcetype:2</value>-->
|
<value>search.resourcetype:2</value>
|
||||||
<!--</list>-->
|
</list>
|
||||||
<!--</property>-->
|
</property>
|
||||||
<!--The configuration for the recent submissions-->
|
<!--The configuration for the recent submissions-->
|
||||||
<property name="recentSubmissionConfiguration">
|
<property name="recentSubmissionConfiguration">
|
||||||
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
||||||
@@ -247,6 +251,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</property>
|
</property>
|
||||||
|
<!--Any default filter queries, these filter queries will be used for all
|
||||||
|
queries done by discovery for this configuration-->
|
||||||
|
<property name="defaultFilterQueries">
|
||||||
|
<list>
|
||||||
|
<!--Only find items, communities and collections-->
|
||||||
|
<value>search.resourcetype:2</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
<!-- Limit recent submissions on homepage to only 5 (default is 20) -->
|
<!-- Limit recent submissions on homepage to only 5 (default is 20) -->
|
||||||
<property name="recentSubmissionConfiguration">
|
<property name="recentSubmissionConfiguration">
|
||||||
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
||||||
@@ -289,6 +301,219 @@
|
|||||||
<property name="spellCheckEnabled" value="true"/>
|
<property name="spellCheckEnabled" value="true"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<!--The workspace configuration settings for discovery -->
|
||||||
|
<bean id="workspaceConfiguration"
|
||||||
|
class="org.dspace.discovery.configuration.DiscoveryConfiguration"
|
||||||
|
scope="prototype">
|
||||||
|
<property name="id" value="workspace" />
|
||||||
|
<!--Which sidebar facets are to be displayed -->
|
||||||
|
<property name="sidebarFacets">
|
||||||
|
<list>
|
||||||
|
<ref bean="searchFilterObjectNamedType" />
|
||||||
|
<ref bean="searchFilterType" />
|
||||||
|
<ref bean="searchFilterIssued" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The search filters which can be used on the discovery search page -->
|
||||||
|
<property name="searchFilters">
|
||||||
|
<list>
|
||||||
|
<ref bean="searchFilterObjectNamedType" />
|
||||||
|
<ref bean="searchFilterType" />
|
||||||
|
<ref bean="searchFilterIssued" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The sort filters for the discovery search-->
|
||||||
|
<property name="searchSortConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoverySortConfiguration">
|
||||||
|
<!--<property name="defaultSort" ref="sortDateIssued"/>-->
|
||||||
|
<!--DefaultSortOrder can either be desc or asc (desc is default)-->
|
||||||
|
<property name="defaultSortOrder" value="desc"/>
|
||||||
|
<property name="sortFields">
|
||||||
|
<list>
|
||||||
|
<ref bean="sortTitle" />
|
||||||
|
<ref bean="sortDateIssued" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!--Any default filter queries, these filter queries will be used for all
|
||||||
|
queries done by discovery for this configuration -->
|
||||||
|
<property name="defaultFilterQueries">
|
||||||
|
<list>
|
||||||
|
<!--Only find items, workspace and accepted for workflow -->
|
||||||
|
<value>search.resourcetype:2 OR search.resourcetype:[8 TO 9]</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The configuration for the recent submissions-->
|
||||||
|
<property name="recentSubmissionConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
||||||
|
<property name="metadataSortField" value="dc.date.accessioned" />
|
||||||
|
<property name="type" value="date"/>
|
||||||
|
<property name="max" value="20"/>
|
||||||
|
<!-- If enabled the collection home page will not display metadata but show a pageable list of recent submissions -->
|
||||||
|
<property name="useAsHomePage" value="false"/>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!--Default result per page -->
|
||||||
|
<property name="defaultRpp" value="10" />
|
||||||
|
<property name="hitHighlightingConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.title"/>
|
||||||
|
<property name="snippets" value="5"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.contributor.author"/>
|
||||||
|
<property name="snippets" value="5"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.description.abstract"/>
|
||||||
|
<property name="maxSize" value="250"/>
|
||||||
|
<property name="snippets" value="2"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="fulltext"/>
|
||||||
|
<property name="maxSize" value="250"/>
|
||||||
|
<property name="snippets" value="2"/>
|
||||||
|
</bean>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<property name="moreLikeThisConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration">
|
||||||
|
<!--When altering this list also alter the "xmlui.Discovery.RelatedItems.help" key as it describes
|
||||||
|
the metadata fields below-->
|
||||||
|
<property name="similarityMetadataFields">
|
||||||
|
<list>
|
||||||
|
<value>dc.title</value>
|
||||||
|
<value>dc.contributor.author</value>
|
||||||
|
<value>dc.creator</value>
|
||||||
|
<value>dc.subject</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The minimum number of matching terms across the metadata fields above before an item is found as related -->
|
||||||
|
<property name="minTermFrequency" value="5"/>
|
||||||
|
<!--The maximum number of related items displayed-->
|
||||||
|
<property name="max" value="3"/>
|
||||||
|
<!--The minimum word length below which words will be ignored-->
|
||||||
|
<property name="minWordLength" value="5"/>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!-- When true a "did you mean" example will be displayed, value can be true or false -->
|
||||||
|
<property name="spellCheckEnabled" value="true"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!--The workflow configuration settings for discovery -->
|
||||||
|
<bean id="workflowConfiguration"
|
||||||
|
class="org.dspace.discovery.configuration.DiscoveryConfiguration"
|
||||||
|
scope="prototype">
|
||||||
|
<property name="id" value="workflow" />
|
||||||
|
<!--Which sidebar facets are to be displayed -->
|
||||||
|
<property name="sidebarFacets">
|
||||||
|
<list>
|
||||||
|
<ref bean="searchFilterObjectNamedType" />
|
||||||
|
<ref bean="searchFilterType" />
|
||||||
|
<ref bean="searchFilterIssued" />
|
||||||
|
<ref bean="searchFilterSubmitter" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The search filters which can be used on the discovery search page -->
|
||||||
|
<property name="searchFilters">
|
||||||
|
<list>
|
||||||
|
<ref bean="searchFilterObjectNamedType" />
|
||||||
|
<ref bean="searchFilterType" />
|
||||||
|
<ref bean="searchFilterIssued" />
|
||||||
|
<ref bean="searchFilterSubmitter" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The sort filters for the discovery search-->
|
||||||
|
<property name="searchSortConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoverySortConfiguration">
|
||||||
|
<!--<property name="defaultSort" ref="sortDateIssued"/>-->
|
||||||
|
<!--DefaultSortOrder can either be desc or asc (desc is default)-->
|
||||||
|
<property name="defaultSortOrder" value="desc"/>
|
||||||
|
<property name="sortFields">
|
||||||
|
<list>
|
||||||
|
<ref bean="sortTitle" />
|
||||||
|
<ref bean="sortDateIssued" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!--Any default filter queries, these filter queries will be used for all
|
||||||
|
queries done by discovery for this configuration -->
|
||||||
|
<property name="defaultFilterQueries">
|
||||||
|
<list>
|
||||||
|
<!--Only find PoolTask and ClaimedTask -->
|
||||||
|
<value>search.resourcetype:[10 TO 11]</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The configuration for the recent submissions-->
|
||||||
|
<property name="recentSubmissionConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryRecentSubmissionsConfiguration">
|
||||||
|
<property name="metadataSortField" value="dc.date.accessioned" />
|
||||||
|
<property name="type" value="date"/>
|
||||||
|
<property name="max" value="20"/>
|
||||||
|
<!-- If enabled the collection home page will not display metadata but show a pageable list of recent submissions -->
|
||||||
|
<property name="useAsHomePage" value="false"/>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!--Default result per page -->
|
||||||
|
<property name="defaultRpp" value="10" />
|
||||||
|
<property name="hitHighlightingConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightingConfiguration">
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.title"/>
|
||||||
|
<property name="snippets" value="5"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.contributor.author"/>
|
||||||
|
<property name="snippets" value="5"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="dc.description.abstract"/>
|
||||||
|
<property name="maxSize" value="250"/>
|
||||||
|
<property name="snippets" value="2"/>
|
||||||
|
</bean>
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryHitHighlightFieldConfiguration">
|
||||||
|
<property name="field" value="fulltext"/>
|
||||||
|
<property name="maxSize" value="250"/>
|
||||||
|
<property name="snippets" value="2"/>
|
||||||
|
</bean>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<property name="moreLikeThisConfiguration">
|
||||||
|
<bean class="org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration">
|
||||||
|
<!--When altering this list also alter the "xmlui.Discovery.RelatedItems.help" key as it describes
|
||||||
|
the metadata fields below-->
|
||||||
|
<property name="similarityMetadataFields">
|
||||||
|
<list>
|
||||||
|
<value>dc.title</value>
|
||||||
|
<value>dc.contributor.author</value>
|
||||||
|
<value>dc.creator</value>
|
||||||
|
<value>dc.subject</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<!--The minimum number of matching terms across the metadata fields above before an item is found as related -->
|
||||||
|
<property name="minTermFrequency" value="5"/>
|
||||||
|
<!--The maximum number of related items displayed-->
|
||||||
|
<property name="max" value="3"/>
|
||||||
|
<!--The minimum word length below which words will be ignored-->
|
||||||
|
<property name="minWordLength" value="5"/>
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
|
<!-- When true a "did you mean" example will be displayed, value can be true or false -->
|
||||||
|
<property name="spellCheckEnabled" value="true"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!--TagCloud configuration bean for homepage discovery configuration-->
|
<!--TagCloud configuration bean for homepage discovery configuration-->
|
||||||
<bean id="homepageTagCloudFacetConfiguration" class="org.dspace.discovery.configuration.TagCloudFacetConfiguration">
|
<bean id="homepageTagCloudFacetConfiguration" class="org.dspace.discovery.configuration.TagCloudFacetConfiguration">
|
||||||
<!-- Actual configuration of the tagcloud (colors, sorting, etc.) -->
|
<!-- Actual configuration of the tagcloud (colors, sorting, etc.) -->
|
||||||
@@ -468,6 +693,46 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="searchFilterType" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
|
||||||
|
<property name="indexFieldName" value="itemtype" />
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<value>dc.type</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="searchFilterObjectType"
|
||||||
|
class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
|
||||||
|
<property name="indexFieldName" value="resourcetype" />
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<value>placeholder.placeholder.placeholder</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="searchFilterObjectNamedType"
|
||||||
|
class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
|
||||||
|
<property name="indexFieldName" value="namedresourcetype" />
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<value>placeholder.placeholder.placeholder</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- Used only to READ "submitter" facets (managed programmatically at SolrServiceImpl) -->
|
||||||
|
<bean id="searchFilterSubmitter"
|
||||||
|
class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
|
||||||
|
<property name="indexFieldName" value="submitter" />
|
||||||
|
<property name="metadataFields">
|
||||||
|
<list>
|
||||||
|
<value>placeholder.placeholder.placeholder</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!--Sort properties-->
|
<!--Sort properties-->
|
||||||
<bean id="sortTitle" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
|
<bean id="sortTitle" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">
|
||||||
<property name="metadataField" value="dc.title"/>
|
<property name="metadataField" value="dc.title"/>
|
||||||
|
Reference in New Issue
Block a user