mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
Merged dspace/master into dspace/configurable_entities
This commit is contained in:
@@ -20,11 +20,13 @@ import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
|
|||||||
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
||||||
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
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.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.handle.service.HandleService;
|
import org.dspace.handle.service.HandleService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -118,7 +120,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,
|
IndexableObject scope, List<IndexableObject> 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 +134,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)
|
IndexableObject scope, List<IndexableObject> 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 +146,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, IndexableObject scope,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels) {
|
List<IndexableObject> 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";
|
||||||
|
@@ -52,6 +52,7 @@ import org.dspace.content.service.ItemService;
|
|||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
@@ -179,12 +180,12 @@ public class SyndicationFeed {
|
|||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @param context context
|
* @param context context
|
||||||
* @param dso DSpaceObject
|
* @param dso the scope
|
||||||
* @param items array of objects
|
* @param items array of objects
|
||||||
* @param labels label map
|
* @param labels label map
|
||||||
*/
|
*/
|
||||||
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
public void populate(HttpServletRequest request, Context context, IndexableObject dso,
|
||||||
List<? extends DSpaceObject> items, Map<String, String> labels) {
|
List<IndexableObject> items, Map<String, String> labels) {
|
||||||
String logoURL = null;
|
String logoURL = null;
|
||||||
String objectURL = null;
|
String objectURL = null;
|
||||||
String defaultTitle = null;
|
String defaultTitle = null;
|
||||||
@@ -208,6 +209,7 @@ public class SyndicationFeed {
|
|||||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||||
podcastFeed = true;
|
podcastFeed = true;
|
||||||
}
|
}
|
||||||
|
objectURL = resolveURL(request, col);
|
||||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||||
Community comm = (Community) dso;
|
Community comm = (Community) dso;
|
||||||
defaultTitle = comm.getName();
|
defaultTitle = comm.getName();
|
||||||
@@ -217,8 +219,9 @@ public class SyndicationFeed {
|
|||||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||||
podcastFeed = true;
|
podcastFeed = true;
|
||||||
}
|
}
|
||||||
|
objectURL = resolveURL(request, comm);
|
||||||
}
|
}
|
||||||
objectURL = resolveURL(request, dso);
|
|
||||||
if (logo != null) {
|
if (logo != null) {
|
||||||
logoURL = urlOfBitstream(request, logo);
|
logoURL = urlOfBitstream(request, logo);
|
||||||
}
|
}
|
||||||
@@ -247,11 +250,11 @@ 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 (IndexableObject idxObj : items) {
|
||||||
if (itemDSO.getType() != Constants.ITEM) {
|
if (idxObj.getType() != Constants.ITEM) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Item item = (Item) itemDSO;
|
Item item = (Item) idxObj;
|
||||||
boolean hasDate = false;
|
boolean hasDate = false;
|
||||||
SyndEntry entry = new SyndEntryImpl();
|
SyndEntry entry = new SyndEntryImpl();
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
|
@@ -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();
|
||||||
|
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +84,7 @@ public interface OpenSearchService {
|
|||||||
* @param totalResults - the hit count
|
* @param totalResults - the hit count
|
||||||
* @param start - start result index
|
* @param start - start result index
|
||||||
* @param pageSize - page size
|
* @param pageSize - page size
|
||||||
* @param scope - search scope, null or community/collection handle
|
* @param scope - search scope, null or the community/collection
|
||||||
* @param results the retreived DSpace objects satisfying search
|
* @param results the retreived DSpace objects satisfying search
|
||||||
* @param labels labels to apply - format specific
|
* @param labels labels to apply - format specific
|
||||||
* @return formatted search results
|
* @return formatted search results
|
||||||
@@ -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,
|
IndexableObject scope, List<IndexableObject> results,
|
||||||
Map<String, String> labels) throws IOException;
|
Map<String, String> labels) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +104,7 @@ public interface OpenSearchService {
|
|||||||
* @param totalResults - the hit count
|
* @param totalResults - the hit count
|
||||||
* @param start - start result index
|
* @param start - start result index
|
||||||
* @param pageSize - page size
|
* @param pageSize - page size
|
||||||
* @param scope - search scope, null or community/collection handle
|
* @param scope - search scope, null or the community/collection
|
||||||
* @param results the retreived DSpace objects satisfying search
|
* @param results the retreived DSpace objects satisfying search
|
||||||
* @param labels labels to apply - format specific
|
* @param labels labels to apply - format specific
|
||||||
* @return formatted search results
|
* @return formatted search results
|
||||||
@@ -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)
|
IndexableObject scope, List<IndexableObject> 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;
|
||||||
}
|
}
|
||||||
|
@@ -131,8 +131,7 @@ public class ResourcePolicyDAOImpl extends AbstractHibernateDAO<ResourcePolicy>
|
|||||||
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.actionId), action),
|
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.actionId), action),
|
||||||
criteriaBuilder
|
criteriaBuilder
|
||||||
.or(criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.eperson), e),
|
.or(criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.eperson), e),
|
||||||
criteriaBuilder
|
(resourcePolicyRoot.get(ResourcePolicy_.epersonGroup).in(groups)))
|
||||||
.in(resourcePolicyRoot.get(ResourcePolicy_.epersonGroup).in(groups)))
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return list(context, criteriaQuery, false, ResourcePolicy.class, 1, -1);
|
return list(context, criteriaQuery, false, ResourcePolicy.class, 1, -1);
|
||||||
@@ -201,4 +200,35 @@ 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);
|
||||||
|
if (rpType != null) {
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.and(criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.dSpaceObject), dso),
|
||||||
|
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.actionId), action),
|
||||||
|
criteriaBuilder.or(
|
||||||
|
criteriaBuilder.notEqual(resourcePolicyRoot.get(ResourcePolicy_.rptype),
|
||||||
|
rpType),
|
||||||
|
criteriaBuilder.isNull(resourcePolicyRoot.get(ResourcePolicy_.rptype))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
criteriaQuery.where(
|
||||||
|
criteriaBuilder.and(
|
||||||
|
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.dSpaceObject), dso),
|
||||||
|
criteriaBuilder.equal(resourcePolicyRoot.get(ResourcePolicy_.actionId), action),
|
||||||
|
criteriaBuilder.isNotNull(resourcePolicyRoot.get(ResourcePolicy_.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;
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.sort.SortException;
|
import org.dspace.sort.SortException;
|
||||||
import org.dspace.sort.SortOption;
|
import org.dspace.sort.SortOption;
|
||||||
|
|
||||||
@@ -114,6 +115,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 +134,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(IndexableObject dso)
|
||||||
throws BrowseException {
|
throws BrowseException {
|
||||||
if (dso instanceof Collection) {
|
if (dso instanceof Collection) {
|
||||||
this.collection = (Collection) dso;
|
this.collection = (Collection) dso;
|
||||||
@@ -582,4 +585,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;
|
||||||
@@ -29,6 +28,7 @@ import org.dspace.discovery.DiscoverQuery.SORT_ORDER;
|
|||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
import org.dspace.discovery.DiscoverResult.FacetResult;
|
import org.dspace.discovery.DiscoverResult.FacetResult;
|
||||||
import org.dspace.discovery.DiscoverResult.SearchDocument;
|
import org.dspace.discovery.DiscoverResult.SearchDocument;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.discovery.SearchService;
|
import org.dspace.discovery.SearchService;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
@@ -308,7 +308,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 (IndexableObject<UUID> solrDoc : resp.getIndexableObjects()) {
|
||||||
// FIXME introduce project, don't retrieve Item immediately when
|
// FIXME introduce project, don't retrieve Item immediately when
|
||||||
// processing the query...
|
// processing the query...
|
||||||
Item item = (Item) solrDoc;
|
Item item = (Item) solrDoc;
|
||||||
@@ -332,7 +332,7 @@ public class SolrBrowseDAO implements BrowseDAO {
|
|||||||
}
|
}
|
||||||
if (resp.getTotalSearchResults() > 0) {
|
if (resp.getTotalSearchResults() > 0) {
|
||||||
SearchDocument doc = resp.getSearchDocument(
|
SearchDocument doc = resp.getSearchDocument(
|
||||||
resp.getDspaceObjects().get(0)).get(0);
|
resp.getIndexableObjects().get(0)).get(0);
|
||||||
return (String) doc.getSearchFieldValues(column).get(0);
|
return (String) doc.getSearchFieldValues(column).get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -12,6 +12,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -31,6 +32,7 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
@@ -53,7 +55,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "collection")
|
@Table(name = "collection")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
||||||
|
|
||||||
@Column(name = "collection_id", insertable = false, updatable = false)
|
@Column(name = "collection_id", insertable = false, updatable = false)
|
||||||
private Integer legacyId;
|
private Integer legacyId;
|
||||||
|
@@ -277,6 +277,15 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
return collectionDAO.findByID(context, Collection.class, id);
|
return collectionDAO.findByID(context, Collection.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
||||||
|
* and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public Collection findIndexableObject(Context context, UUID id) throws SQLException {
|
||||||
|
return collectionDAO.findByID(context, Collection.class, id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMetadata(Context context, Collection collection, String field, String value)
|
public void setMetadata(Context context, Collection collection, String field, String value)
|
||||||
throws MissingResourceException, SQLException {
|
throws MissingResourceException, SQLException {
|
||||||
@@ -783,6 +792,15 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
return Constants.COLLECTION;
|
return Constants.COLLECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
||||||
|
* IndexableObjectService interface and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
|
return getSupportsTypeConstant();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
public List<Collection> findAuthorized(Context context, Community community, int actionID) throws SQLException {
|
||||||
List<Collection> myResults = new ArrayList<>();
|
List<Collection> myResults = new ArrayList<>();
|
||||||
|
@@ -11,6 +11,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Cacheable;
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
@@ -31,6 +32,7 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
@@ -49,7 +51,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Table(name = "community")
|
@Table(name = "community")
|
||||||
@Cacheable
|
@Cacheable
|
||||||
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
|
||||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
||||||
/**
|
/**
|
||||||
* log4j category
|
* log4j category
|
||||||
*/
|
*/
|
||||||
|
@@ -137,6 +137,15 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
return communityDAO.findByID(context, Community.class, id);
|
return communityDAO.findByID(context, Community.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
||||||
|
* and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public Community findIndexableObject(Context context, UUID id) throws SQLException {
|
||||||
|
return find(context, id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Community> findAll(Context context) throws SQLException {
|
public List<Community> findAll(Context context) throws SQLException {
|
||||||
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
|
||||||
@@ -511,6 +520,14 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
|||||||
return Constants.COMMUNITY;
|
return Constants.COMMUNITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
||||||
|
* IndexableObjectService interface and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
|
return getSupportsTypeConstant();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method to remove the community and all its children from the
|
* Internal method to remove the community and all its children from the
|
||||||
|
@@ -11,6 +11,7 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -26,7 +27,6 @@ import javax.persistence.Transient;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
import org.dspace.handle.Handle;
|
import org.dspace.handle.Handle;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
@@ -37,8 +37,7 @@ import org.hibernate.annotations.GenericGenerator;
|
|||||||
@Entity
|
@Entity
|
||||||
@Inheritance(strategy = InheritanceType.JOINED)
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
@Table(name = "dspaceobject")
|
@Table(name = "dspaceobject")
|
||||||
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID>,
|
public abstract class DSpaceObject implements Serializable, ReloadableEntity<java.util.UUID> {
|
||||||
BrowsableObject<UUID> {
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "system-uuid")
|
@GeneratedValue(generator = "system-uuid")
|
||||||
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
|
||||||
|
@@ -10,7 +10,7 @@ package org.dspace.content;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +20,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmission<ID extends Serializable> extends BrowsableObject<ID> {
|
public interface InProgressSubmission<ID extends Serializable> extends IndexableObject<ID> {
|
||||||
/**
|
/**
|
||||||
* Get the internal ID of this submission
|
* Get the internal ID of this submission
|
||||||
*
|
*
|
||||||
|
@@ -13,6 +13,7 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -34,6 +35,7 @@ import org.dspace.content.factory.ContentServiceFactory;
|
|||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "item")
|
@Table(name = "item")
|
||||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport {
|
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport, IndexableObject<UUID> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* log4j logger
|
* log4j logger
|
||||||
|
@@ -172,6 +172,15 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the find method needed to avoid ambiguity between the IndexableObjectService interface
|
||||||
|
* and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public Item findIndexableObject(Context context, UUID id) throws SQLException {
|
||||||
|
return find(context, id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException {
|
public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException {
|
||||||
if (workspaceItem.getItem() != null) {
|
if (workspaceItem.getItem() != null) {
|
||||||
@@ -658,6 +667,15 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
return Constants.ITEM;
|
return Constants.ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
/**
|
||||||
|
* This method is an alias of the getSupportsTypeConstant method needed to avoid ambiguity between the
|
||||||
|
* IndexableObjectService interface and the DSpaceObjectService interface
|
||||||
|
*/
|
||||||
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
|
return getSupportsTypeConstant();
|
||||||
|
}
|
||||||
|
|
||||||
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
protected void rawDelete(Context context, Item item) throws AuthorizeException, SQLException, IOException {
|
||||||
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
||||||
|
|
||||||
|
@@ -27,10 +27,10 @@ import javax.persistence.SequenceGenerator;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
@@ -45,7 +45,7 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "workspaceitem")
|
@Table(name = "workspaceitem")
|
||||||
public class WorkspaceItem
|
public class WorkspaceItem
|
||||||
implements InProgressSubmission<Integer>, Serializable, ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
implements InProgressSubmission<Integer>, Serializable, ReloadableEntity<Integer>, IndexableObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
@Column(name = "workspace_item_id", unique = true, nullable = false)
|
||||||
|
@@ -61,12 +61,12 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsTypeConstant() {
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
return Constants.WORKSPACEITEM;
|
return Constants.WORKSPACEITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItem find(Context context, Integer id) throws SQLException {
|
public WorkspaceItem find(Context context, int id) throws SQLException {
|
||||||
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id);
|
||||||
|
|
||||||
if (workspaceItem == null) {
|
if (workspaceItem == null) {
|
||||||
@@ -83,6 +83,14 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
|||||||
return workspaceItem;
|
return workspaceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkspaceItem findIndexableObject(Context context, Integer id) throws SQLException {
|
||||||
|
if (id != null) {
|
||||||
|
return find(context, id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
|
@@ -10,13 +10,11 @@ package org.dspace.content.factory;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.InProgressSubmission;
|
import org.dspace.content.InProgressSubmission;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.BrowsableObjectService;
|
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -25,6 +23,7 @@ import org.dspace.content.service.DSpaceObjectService;
|
|||||||
import org.dspace.content.service.EntityService;
|
import org.dspace.content.service.EntityService;
|
||||||
import org.dspace.content.service.EntityTypeService;
|
import org.dspace.content.service.EntityTypeService;
|
||||||
import org.dspace.content.service.InProgressSubmissionService;
|
import org.dspace.content.service.InProgressSubmissionService;
|
||||||
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -35,6 +34,7 @@ import org.dspace.content.service.RelationshipTypeService;
|
|||||||
import org.dspace.content.service.SiteService;
|
import org.dspace.content.service.SiteService;
|
||||||
import org.dspace.content.service.SupervisedItemService;
|
import org.dspace.content.service.SupervisedItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||||
|
|
||||||
@@ -46,7 +46,12 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
|||||||
*/
|
*/
|
||||||
public abstract class ContentServiceFactory {
|
public abstract class ContentServiceFactory {
|
||||||
|
|
||||||
public abstract List<BrowsableObjectService> getBrowsableDSpaceObjectServices();
|
/**
|
||||||
|
* Return the list of all the available implementations of the IndexableObjectService interface
|
||||||
|
*
|
||||||
|
* @return the list of IndexableObjectService
|
||||||
|
*/
|
||||||
|
public abstract List<IndexableObjectService> getIndexableObjectServices();
|
||||||
|
|
||||||
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
public abstract List<DSpaceObjectService<? extends DSpaceObject>> getDSpaceObjectServices();
|
||||||
|
|
||||||
@@ -115,15 +120,15 @@ public abstract class ContentServiceFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends BrowsableObject<PK>, PK extends Serializable> BrowsableObjectService<T, PK>
|
public <T extends IndexableObject<PK>, PK extends Serializable> IndexableObjectService<T, PK>
|
||||||
getBrowsableDSpaceObjectService(int type) {
|
getIndexableObjectService(int type) {
|
||||||
for (int i = 0; i < getBrowsableDSpaceObjectServices().size(); i++) {
|
for (int i = 0; i < getIndexableObjectServices().size(); i++) {
|
||||||
BrowsableObjectService objectService = getBrowsableDSpaceObjectServices().get(i);
|
IndexableObjectService objectService = getIndexableObjectServices().get(i);
|
||||||
if (objectService.getSupportsTypeConstant() == type) {
|
if (objectService.getSupportsIndexableObjectTypeConstant() == type) {
|
||||||
return (BrowsableObjectService<T, PK>) objectService;
|
return (IndexableObjectService<T, PK>) objectService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException("Unknown Browsable DSpace type: " + type);
|
throw new UnsupportedOperationException("Unknown Findable Object type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
public DSpaceObjectLegacySupportService<? extends DSpaceObject> getDSpaceLegacyObjectService(int type) {
|
||||||
|
@@ -12,7 +12,6 @@ import java.util.List;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.service.BitstreamFormatService;
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.BrowsableObjectService;
|
|
||||||
import org.dspace.content.service.BundleService;
|
import org.dspace.content.service.BundleService;
|
||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -20,6 +19,7 @@ import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
|||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
import org.dspace.content.service.EntityService;
|
import org.dspace.content.service.EntityService;
|
||||||
import org.dspace.content.service.EntityTypeService;
|
import org.dspace.content.service.EntityTypeService;
|
||||||
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.content.service.InstallItemService;
|
import org.dspace.content.service.InstallItemService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -83,8 +83,8 @@ public class ContentServiceFactoryImpl extends ContentServiceFactory {
|
|||||||
private EntityService entityService;
|
private EntityService entityService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BrowsableObjectService> getBrowsableDSpaceObjectServices() {
|
public List<IndexableObjectService> getIndexableObjectServices() {
|
||||||
return new DSpace().getServiceManager().getServicesByType(BrowsableObjectService.class);
|
return new DSpace().getServiceManager().getServicesByType(IndexableObjectService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.content.service;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.core.Context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service interface class for any BrowsableDSpaceObject.
|
|
||||||
* All BrowsableObject service classes should implement this class since it offers some basic methods which all
|
|
||||||
* BrowsableObjects are required to have.
|
|
||||||
*
|
|
||||||
* @param <T> class type
|
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
|
||||||
*/
|
|
||||||
public interface BrowsableObjectService<T extends BrowsableObject<PK>, PK extends Serializable> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic find for when the precise type of a BDSO is not known, just the
|
|
||||||
* a pair of type number and database ID.
|
|
||||||
*
|
|
||||||
* @param context - the context
|
|
||||||
* @param id - id within table of type'd objects
|
|
||||||
* @return the object found, or null if it does not exist.
|
|
||||||
* @throws SQLException only upon failure accessing the database.
|
|
||||||
*/
|
|
||||||
public T find(Context context, PK id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Constants which this service supports
|
|
||||||
*
|
|
||||||
* @return a org.dspace.core.Constants that represents a BrowsableDSpaceObject type
|
|
||||||
*/
|
|
||||||
public int getSupportsTypeConstant();
|
|
||||||
}
|
|
@@ -13,6 +13,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -30,7 +31,8 @@ import org.dspace.eperson.Group;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface CollectionService
|
public interface CollectionService
|
||||||
extends DSpaceObjectService<Collection>, DSpaceObjectLegacySupportService<Collection> {
|
extends DSpaceObjectService<Collection>, DSpaceObjectLegacySupportService<Collection>,
|
||||||
|
IndexableObjectService<Collection, UUID> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new collection with a new ID.
|
* Create a new collection with a new ID.
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.InputStream;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
@@ -27,7 +28,8 @@ import org.dspace.eperson.Group;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community> {
|
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community>,
|
||||||
|
IndexableObjectService<Community, UUID> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,7 +28,17 @@ import org.dspace.core.Context;
|
|||||||
* @param <T> class type
|
* @param <T> class type
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableObjectService<T, UUID> {
|
public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic find for when the precise type of an Entity is not known
|
||||||
|
*
|
||||||
|
* @param context - the context
|
||||||
|
* @param uuid - uuid within table of type'd dspace objects
|
||||||
|
* @return the dspace object found, or null if it does not exist.
|
||||||
|
* @throws SQLException only upon failure accessing the database.
|
||||||
|
*/
|
||||||
|
public T find(Context context, UUID uuid) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a proper name for the object. This may return <code>null</code>.
|
* Get a proper name for the object. This may return <code>null</code>.
|
||||||
@@ -40,17 +50,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableOb
|
|||||||
*/
|
*/
|
||||||
public abstract String getName(T dso);
|
public abstract String getName(T dso);
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic find for when the precise type of a BDSO is not known, just the
|
|
||||||
* a pair of type number and database ID.
|
|
||||||
*
|
|
||||||
* @param context - the context
|
|
||||||
* @param id - id within table of type'd objects
|
|
||||||
* @return the object found, or null if it does not exist.
|
|
||||||
* @throws SQLException only upon failure accessing the database.
|
|
||||||
*/
|
|
||||||
public T find(Context context, UUID id) throws SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to lookup all Identifiers of this DSpaceObject.
|
* Tries to lookup all Identifiers of this DSpaceObject.
|
||||||
*
|
*
|
||||||
@@ -371,7 +370,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableOb
|
|||||||
|
|
||||||
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
public void delete(Context context, T dso) throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
|
||||||
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
||||||
String value, String authority, int confidence, int index) throws SQLException;
|
String value, String authority, int confidence, int index) throws SQLException;
|
||||||
|
|
||||||
@@ -380,4 +378,11 @@ public interface DSpaceObjectService<T extends DSpaceObject> extends BrowsableOb
|
|||||||
|
|
||||||
void moveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to)
|
void moveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Constants which this service supports
|
||||||
|
*
|
||||||
|
* @return a org.dspace.core.Constants that represents a IndexableObject type
|
||||||
|
*/
|
||||||
|
public int getSupportsTypeConstant();
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ import org.dspace.core.Context;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface InProgressSubmissionService<T extends InProgressSubmission<ID>, ID extends Serializable>
|
public interface InProgressSubmissionService<T extends InProgressSubmission<ID>, ID extends Serializable>
|
||||||
extends BrowsableObjectService<T, ID> {
|
extends IndexableObjectService<T, ID> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes submission wrapper, doesn't delete item contents
|
* Deletes submission wrapper, doesn't delete item contents
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.content.service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base Service interface class for any IndexableObject. The name of the methods contains IndexableObject to avoid
|
||||||
|
* ambiguity reference as some implementation supports both this interface than the DSpaceObectService interface
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* class type of the indexable object
|
||||||
|
* @param <PK>
|
||||||
|
* class type of the primary key
|
||||||
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
|
*/
|
||||||
|
public interface IndexableObjectService<T extends IndexableObject<PK>, PK extends Serializable> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic find for when the precise type of an IndexableObject is not known
|
||||||
|
*
|
||||||
|
* @param context - the context
|
||||||
|
* @param id - id within table of type'd indexable objects
|
||||||
|
* @return the indexable object found, or null if it does not exist.
|
||||||
|
* @throws SQLException only upon failure accessing the database.
|
||||||
|
*/
|
||||||
|
public T findIndexableObject(Context context, PK id) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Constants which this service supports
|
||||||
|
*
|
||||||
|
* @return a org.dspace.core.Constants that represents a IndexableObject type
|
||||||
|
*/
|
||||||
|
public int getSupportsIndexableObjectTypeConstant();
|
||||||
|
}
|
@@ -39,7 +39,8 @@ import org.dspace.eperson.Group;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item> {
|
public interface ItemService
|
||||||
|
extends DSpaceObjectService<Item>, DSpaceObjectLegacySupportService<Item>, IndexableObjectService<Item, UUID> {
|
||||||
|
|
||||||
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException;
|
||||||
|
|
||||||
|
@@ -29,6 +29,17 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*/
|
*/
|
||||||
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem, Integer> {
|
public interface WorkspaceItemService extends InProgressSubmissionService<WorkspaceItem, Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a workspace item from the database. The item, collection and
|
||||||
|
* submitter are loaded into memory.
|
||||||
|
*
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param id ID of the workspace item
|
||||||
|
* @return the workspace item, or null if the ID is invalid.
|
||||||
|
* @throws SQLException if database error
|
||||||
|
*/
|
||||||
|
public WorkspaceItem find(Context context, int id) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new workspace item, with a new ID. An Item is also created. The
|
* Create a new workspace item, with a new ID. An Item is also created. The
|
||||||
* submitter is the current user in the context.
|
* submitter is the current user in the context.
|
||||||
|
@@ -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,22 @@ public class DiscoverQuery {
|
|||||||
return (int) (Math.ceil((float) (newestYear) / gap) * gap);
|
return (int) (Math.ceil((float) (newestYear) / gap) * gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of discovery configuration used by this query
|
||||||
|
*
|
||||||
|
* @return the discovery configuration name used
|
||||||
|
*/
|
||||||
|
public String getDiscoveryConfigurationName() {
|
||||||
|
return discoveryConfigurationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of discovery configuration to use to run this query
|
||||||
|
*
|
||||||
|
* @param discoveryConfigurationName
|
||||||
|
* the name of the discovery configuration to use to run this query
|
||||||
|
*/
|
||||||
|
public void setDiscoveryConfigurationName(String discoveryConfigurationName) {
|
||||||
|
this.discoveryConfigurationName = discoveryConfigurationName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,6 @@ 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.discovery.configuration.DiscoveryConfigurationParameters;
|
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
|
||||||
@@ -28,32 +27,31 @@ public class DiscoverResult {
|
|||||||
|
|
||||||
private long totalSearchResults;
|
private long totalSearchResults;
|
||||||
private int start;
|
private int start;
|
||||||
private List<DSpaceObject> dspaceObjects;
|
private List<IndexableObject> indexableObjects;
|
||||||
private Map<String, List<FacetResult>> facetResults;
|
private Map<String, List<FacetResult>> facetResults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 Indexable Object
|
||||||
*/
|
*/
|
||||||
private Map<String, List<SearchDocument>> searchDocuments;
|
private Map<String, List<SearchDocument>> searchDocuments;
|
||||||
private int maxResults = -1;
|
private int maxResults = -1;
|
||||||
private int searchTime;
|
private int searchTime;
|
||||||
private Map<String, DSpaceObjectHighlightResult> highlightedResults;
|
private Map<String, IndexableObjectHighlightResult> highlightedResults;
|
||||||
private String spellCheckQuery;
|
private String spellCheckQuery;
|
||||||
|
|
||||||
|
|
||||||
public DiscoverResult() {
|
public DiscoverResult() {
|
||||||
dspaceObjects = new ArrayList<DSpaceObject>();
|
indexableObjects = new ArrayList<IndexableObject>();
|
||||||
facetResults = new LinkedHashMap<String, List<FacetResult>>();
|
facetResults = 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, IndexableObjectHighlightResult>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addIndexableObject(IndexableObject idxObj) {
|
||||||
public void addDSpaceObject(DSpaceObject dso) {
|
this.indexableObjects.add(idxObj);
|
||||||
this.dspaceObjects.add(dso);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DSpaceObject> getDspaceObjects() {
|
public List<IndexableObject> getIndexableObjects() {
|
||||||
return dspaceObjects;
|
return indexableObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTotalSearchResults() {
|
public long getTotalSearchResults() {
|
||||||
@@ -107,19 +105,19 @@ public class DiscoverResult {
|
|||||||
|
|
||||||
public List<FacetResult> getFacetResult(DiscoverySearchFilterFacet field) {
|
public List<FacetResult> getFacetResult(DiscoverySearchFilterFacet field) {
|
||||||
List<DiscoverResult.FacetResult> facetValues = getFacetResult(field.getIndexFieldName());
|
List<DiscoverResult.FacetResult> facetValues = getFacetResult(field.getIndexFieldName());
|
||||||
//Check if we are dealing with a date, sometimes the facet values arrive as dates !
|
// Check if we are dealing with a date, sometimes the facet values arrive as dates !
|
||||||
if (facetValues.size() == 0 && field.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
if (facetValues.size() == 0 && field.getType().equals(DiscoveryConfigurationParameters.TYPE_DATE)) {
|
||||||
facetValues = getFacetResult(field.getIndexFieldName() + ".year");
|
facetValues = getFacetResult(field.getIndexFieldName() + ".year");
|
||||||
}
|
}
|
||||||
return ListUtils.emptyIfNull(facetValues);
|
return ListUtils.emptyIfNull(facetValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObjectHighlightResult getHighlightedResults(DSpaceObject dso) {
|
public IndexableObjectHighlightResult getHighlightedResults(IndexableObject dso) {
|
||||||
return highlightedResults.get(dso.getHandle());
|
return highlightedResults.get(dso.getUniqueIndexID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHighlightedResult(DSpaceObject dso, DSpaceObjectHighlightResult highlightedResult) {
|
public void addHighlightedResult(IndexableObject dso, IndexableObjectHighlightResult highlightedResult) {
|
||||||
this.highlightedResults.put(dso.getHandle(), highlightedResult);
|
this.highlightedResults.put(dso.getUniqueIndexID(), highlightedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class FacetResult {
|
public static final class FacetResult {
|
||||||
@@ -131,7 +129,7 @@ public class DiscoverResult {
|
|||||||
private String fieldType;
|
private String fieldType;
|
||||||
|
|
||||||
public FacetResult(String asFilterQuery, String displayedValue, String authorityKey, String sortValue,
|
public FacetResult(String asFilterQuery, String displayedValue, String authorityKey, String sortValue,
|
||||||
long count, String fieldType) {
|
long count, String fieldType) {
|
||||||
this.asFilterQuery = asFilterQuery;
|
this.asFilterQuery = asFilterQuery;
|
||||||
this.displayedValue = displayedValue;
|
this.displayedValue = displayedValue;
|
||||||
this.authorityKey = authorityKey;
|
this.authorityKey = authorityKey;
|
||||||
@@ -141,6 +139,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 +163,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() {
|
||||||
@@ -177,30 +179,51 @@ public class DiscoverResult {
|
|||||||
this.spellCheckQuery = spellCheckQuery;
|
this.spellCheckQuery = spellCheckQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class DSpaceObjectHighlightResult {
|
/**
|
||||||
private DSpaceObject dso;
|
* An utility class to represent the highlighting section of a Discovery Search
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static final class IndexableObjectHighlightResult {
|
||||||
|
private IndexableObject indexableObject;
|
||||||
private Map<String, List<String>> highlightResults;
|
private Map<String, List<String>> highlightResults;
|
||||||
|
|
||||||
public DSpaceObjectHighlightResult(DSpaceObject dso, Map<String, List<String>> highlightResults) {
|
public IndexableObjectHighlightResult(IndexableObject idxObj, Map<String, List<String>> highlightResults) {
|
||||||
this.dso = dso;
|
this.indexableObject = idxObj;
|
||||||
this.highlightResults = highlightResults;
|
this.highlightResults = highlightResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DSpaceObject getDso() {
|
/**
|
||||||
return dso;
|
* Return the indexable object that the highlighting snippets refer to
|
||||||
|
*
|
||||||
|
* @return the indexable object
|
||||||
|
*/
|
||||||
|
public IndexableObject getIndexableObject() {
|
||||||
|
return indexableObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The matching snippets for a specific metadata ignoring any authority value
|
||||||
|
*
|
||||||
|
* @param metadataKey
|
||||||
|
* the metadata where the snippets have been found
|
||||||
|
* @return the matching snippets
|
||||||
|
*/
|
||||||
public List<String> getHighlightResults(String metadataKey) {
|
public List<String> getHighlightResults(String metadataKey) {
|
||||||
return highlightResults.get(metadataKey);
|
return highlightResults.get(metadataKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All the matching snippets in whatever metadata ignoring any authority value
|
||||||
|
*
|
||||||
|
* @return All the matching snippets
|
||||||
|
*/
|
||||||
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(IndexableObject dso, SearchDocument searchDocument) {
|
||||||
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
String dsoString = SearchDocument.getIndexableObjectStringRepresentation(dso);
|
||||||
List<SearchDocument> docs = searchDocuments.get(dsoString);
|
List<SearchDocument> docs = searchDocuments.get(dsoString);
|
||||||
if (docs == null) {
|
if (docs == null) {
|
||||||
docs = new ArrayList<SearchDocument>();
|
docs = new ArrayList<SearchDocument>();
|
||||||
@@ -212,11 +235,12 @@ 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 idxObj
|
||||||
|
* the indexable 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(IndexableObject idxObj) {
|
||||||
String dsoString = SearchDocument.getDspaceObjectStringRepresentation(dso);
|
String dsoString = SearchDocument.getIndexableObjectStringRepresentation(idxObj);
|
||||||
List<SearchDocument> result = searchDocuments.get(dsoString);
|
List<SearchDocument> result = searchDocuments.get(dsoString);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return new ArrayList<SearchDocument>();
|
return new ArrayList<SearchDocument>();
|
||||||
@@ -256,8 +280,8 @@ public class DiscoverResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDspaceObjectStringRepresentation(DSpaceObject dso) {
|
public static String getIndexableObjectStringRepresentation(IndexableObject idxObj) {
|
||||||
return dso.getType() + ":" + dso.getID();
|
return idxObj.getType() + ":" + idxObj.getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ 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.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
|
||||||
@@ -46,8 +45,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, IndexableObject 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 +54,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 +92,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 {
|
IndexableObject 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);
|
||||||
@@ -105,9 +106,9 @@ public class FacetYearRange {
|
|||||||
yearRangeQuery.addSearchField(dateFacet);
|
yearRangeQuery.addSearchField(dateFacet);
|
||||||
DiscoverResult lastYearResult = searchService.search(context, scope, yearRangeQuery);
|
DiscoverResult lastYearResult = searchService.search(context, scope, yearRangeQuery);
|
||||||
|
|
||||||
if (0 < lastYearResult.getDspaceObjects().size()) {
|
if (0 < lastYearResult.getIndexableObjects().size()) {
|
||||||
List<DiscoverResult.SearchDocument> searchDocuments = lastYearResult
|
List<DiscoverResult.SearchDocument> searchDocuments = lastYearResult
|
||||||
.getSearchDocument(lastYearResult.getDspaceObjects().get(0));
|
.getSearchDocument(lastYearResult.getIndexableObjects().get(0));
|
||||||
if (0 < searchDocuments.size() && 0 < searchDocuments.get(0).getSearchFieldValues(dateFacet).size()) {
|
if (0 < searchDocuments.size() && 0 < searchDocuments.get(0).getSearchFieldValues(dateFacet).size()) {
|
||||||
oldestYear = Integer.parseInt(searchDocuments.get(0).getSearchFieldValues(dateFacet).get(0));
|
oldestYear = Integer.parseInt(searchDocuments.get(0).getSearchFieldValues(dateFacet).get(0));
|
||||||
}
|
}
|
||||||
@@ -115,9 +116,9 @@ public class FacetYearRange {
|
|||||||
//Now get the first year
|
//Now get the first year
|
||||||
yearRangeQuery.setSortField(dateFacet + "_sort", DiscoverQuery.SORT_ORDER.desc);
|
yearRangeQuery.setSortField(dateFacet + "_sort", DiscoverQuery.SORT_ORDER.desc);
|
||||||
DiscoverResult firstYearResult = searchService.search(context, scope, yearRangeQuery);
|
DiscoverResult firstYearResult = searchService.search(context, scope, yearRangeQuery);
|
||||||
if (0 < firstYearResult.getDspaceObjects().size()) {
|
if (0 < firstYearResult.getIndexableObjects().size()) {
|
||||||
List<DiscoverResult.SearchDocument> searchDocuments = firstYearResult
|
List<DiscoverResult.SearchDocument> searchDocuments = firstYearResult
|
||||||
.getSearchDocument(firstYearResult.getDspaceObjects().get(0));
|
.getSearchDocument(firstYearResult.getIndexableObjects().get(0));
|
||||||
if (0 < searchDocuments.size() && 0 < searchDocuments.get(0).getSearchFieldValues(dateFacet).size()) {
|
if (0 < searchDocuments.size() && 0 < searchDocuments.get(0).getSearchFieldValues(dateFacet).size()) {
|
||||||
newestYear = Integer.parseInt(searchDocuments.get(0).getSearchFieldValues(dateFacet).get(0));
|
newestYear = Integer.parseInt(searchDocuments.get(0).getSearchFieldValues(dateFacet).get(0));
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ package org.dspace.discovery;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.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;
|
||||||
@@ -19,7 +20,6 @@ import org.apache.commons.cli.PosixParser;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
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;
|
||||||
@@ -59,7 +59,7 @@ public class IndexClient {
|
|||||||
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>] or nothing to " +
|
||||||
"update/clean an existing index.";
|
"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;
|
||||||
@@ -72,10 +72,10 @@ public class IndexClient {
|
|||||||
.create("r"));
|
.create("r"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
.withArgName("handle to add or update")
|
.withArgName("handle or uuid to add or update")
|
||||||
.hasArg(true)
|
.hasArg(true)
|
||||||
.withDescription(
|
.withDescription(
|
||||||
"add or update an Item, Collection or Community based on its handle")
|
"add or update an Item, Collection or Community based on its handle or uuid")
|
||||||
.create("i"));
|
.create("i"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
@@ -151,17 +151,36 @@ public class IndexClient {
|
|||||||
} else if (line.hasOption('s')) {
|
} else if (line.hasOption('s')) {
|
||||||
checkRebuildSpellCheck(line, indexer);
|
checkRebuildSpellCheck(line, indexer);
|
||||||
} else if (line.hasOption('i')) {
|
} else if (line.hasOption('i')) {
|
||||||
final String handle = line.getOptionValue('i');
|
final String param = line.getOptionValue('i');
|
||||||
final DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService()
|
UUID uuid = null;
|
||||||
.resolveToObject(context, handle);
|
try {
|
||||||
if (dso == null) {
|
uuid = UUID.fromString(param);
|
||||||
throw new IllegalArgumentException("Cannot resolve " + handle + " to a DSpace object");
|
} catch (Exception e) {
|
||||||
|
// nothing to do, it should be an handle
|
||||||
}
|
}
|
||||||
log.info("Forcibly Indexing " + handle);
|
IndexableObject dso = null;
|
||||||
|
if (uuid != null) {
|
||||||
|
dso = ContentServiceFactory.getInstance().getItemService().find(context, uuid);
|
||||||
|
if (dso == null) {
|
||||||
|
// it could be a community
|
||||||
|
dso = ContentServiceFactory.getInstance().getCommunityService().find(context, uuid);
|
||||||
|
if (dso == null) {
|
||||||
|
// it could be a collection
|
||||||
|
dso = ContentServiceFactory.getInstance().getCollectionService().find(context, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dso = (IndexableObject) HandleServiceFactory.getInstance()
|
||||||
|
.getHandleService().resolveToObject(context, param);
|
||||||
|
}
|
||||||
|
if (dso == null) {
|
||||||
|
throw new IllegalArgumentException("Cannot resolve " + param + " to a DSpace object");
|
||||||
|
}
|
||||||
|
log.info("Indexing " + param + " force " + line.hasOption("f"));
|
||||||
final long startTimeMillis = System.currentTimeMillis();
|
final long startTimeMillis = System.currentTimeMillis();
|
||||||
final long count = indexAll(indexer, ContentServiceFactory.getInstance().getItemService(), context, dso);
|
final long count = indexAll(indexer, ContentServiceFactory.getInstance().getItemService(), context, dso);
|
||||||
final long seconds = (System.currentTimeMillis() - startTimeMillis) / 1000;
|
final long seconds = (System.currentTimeMillis() - startTimeMillis) / 1000;
|
||||||
log.info("Indexed " + count + " DSpace object" + (count > 1 ? "s" : "") + " in " + seconds + " seconds");
|
log.info("Indexed " + count + " object" + (count > 1 ? "s" : "") + " in " + seconds + " seconds");
|
||||||
} else {
|
} else {
|
||||||
log.info("Updating and Cleaning Index");
|
log.info("Updating and Cleaning Index");
|
||||||
indexer.cleanIndex(line.hasOption("f"));
|
indexer.cleanIndex(line.hasOption("f"));
|
||||||
@@ -186,7 +205,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 IndexableObject dso)
|
||||||
throws IOException, SearchServiceException, SQLException {
|
throws IOException, SearchServiceException, SQLException {
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
|
@@ -33,10 +33,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<IndexableObject> 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 +58,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<IndexableObject>();
|
||||||
handlesToDelete = new HashSet<String>();
|
uniqueIdsToDelete = new HashSet<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int st = event.getSubjectType();
|
int st = event.getSubjectType();
|
||||||
@@ -107,7 +107,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((IndexableObject)subject);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -120,17 +120,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((IndexableObject)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 +151,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 (IndexableObject iu : objectsToUpdate) {
|
||||||
/* we let all types through here and
|
/* we let all types through here and
|
||||||
* allow the search indexer to make
|
* allow the search indexer to make
|
||||||
* decisions on indexing and/or removal
|
* decisions on indexing and/or removal
|
||||||
*/
|
*/
|
||||||
DSpaceObject iu = ctx.reloadEntity(o);
|
iu = ctx.reloadEntity(iu);
|
||||||
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 +190,7 @@ public class IndexEventConsumer implements Consumer {
|
|||||||
|
|
||||||
// "free" the resources
|
// "free" the resources
|
||||||
objectsToUpdate = null;
|
objectsToUpdate = null;
|
||||||
handlesToDelete = null;
|
uniqueIdsToDelete = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -5,21 +5,22 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.browse;
|
package org.dspace.discovery;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the basic interface that a data model entity need to implement to support browsing/retrieval
|
* This is the basic interface that a data model entity need to implement to be indexable in Discover
|
||||||
*
|
*
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*
|
*
|
||||||
* @param <PK>
|
* @param <PK>
|
||||||
* the Class of the primary key
|
* the Class of the primary key
|
||||||
*/
|
*/
|
||||||
public interface BrowsableObject<PK extends Serializable> {
|
public interface IndexableObject<PK extends Serializable> extends ReloadableEntity<PK> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -27,12 +28,6 @@ public interface BrowsableObject<PK extends Serializable> {
|
|||||||
*/
|
*/
|
||||||
public int getType();
|
public int getType();
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the primary key of the Entity instance
|
|
||||||
*/
|
|
||||||
public PK getID();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return an unique id to index
|
* @return an unique id to index
|
@@ -10,11 +10,10 @@ package org.dspace.discovery;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface used for indexing dspaceobject into discovery
|
* Interface used for indexing IndexableObject 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 +21,28 @@ import org.dspace.core.Context;
|
|||||||
*/
|
*/
|
||||||
public interface IndexingService {
|
public interface IndexingService {
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso)
|
void indexContent(Context context, IndexableObject dso)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso,
|
void indexContent(Context context, IndexableObject dso,
|
||||||
boolean force) throws SQLException;
|
boolean force) throws SQLException;
|
||||||
|
|
||||||
void indexContent(Context context, DSpaceObject dso,
|
void indexContent(Context context, IndexableObject 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, IndexableObject dso)
|
||||||
throws SQLException, IOException;
|
throws SQLException, IOException;
|
||||||
|
|
||||||
void unIndexContent(Context context, DSpaceObject dso, boolean commit)
|
void unIndexContent(Context context, IndexableObject 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, IndexableObject dso)
|
||||||
throws SQLException, IOException;
|
throws SQLException, IOException;
|
||||||
|
|
||||||
void createIndex(Context context) throws SQLException, IOException;
|
void createIndex(Context context) throws SQLException, IOException;
|
||||||
@@ -52,9 +51,14 @@ public interface IndexingService {
|
|||||||
|
|
||||||
void updateIndex(Context context, boolean force);
|
void updateIndex(Context context, boolean force);
|
||||||
|
|
||||||
|
void updateIndex(Context context, 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,9 @@
|
|||||||
*/
|
*/
|
||||||
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.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 +48,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, IndexableObject dso, DiscoverQuery query)
|
||||||
throws SearchServiceException;
|
throws SearchServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,19 +72,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, IndexableObject dso, DiscoverQuery query, boolean includeWithdrawn)
|
||||||
throws SearchServiceException;
|
throws SearchServiceException;
|
||||||
|
|
||||||
|
List<IndexableObject> 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 +128,9 @@ public interface SearchService {
|
|||||||
*/
|
*/
|
||||||
String escapeQueryChars(String query);
|
String escapeQueryChars(String query);
|
||||||
|
|
||||||
FacetYearRange getFacetYearRange(Context context, DSpaceObject scope, DiscoverySearchFilterFacet facet,
|
FacetYearRange getFacetYearRange(Context context, IndexableObject 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,43 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the discovery configuration to use in a specific scope for the king of search identified by the prefix. A
|
||||||
|
* null prefix mean the normal query, other predefined values are workspace or workflow
|
||||||
|
*
|
||||||
|
* @param prefix
|
||||||
|
* the namespace of the configuration to lookup if any
|
||||||
|
* @param dso
|
||||||
|
* the DSpaceObject
|
||||||
|
* @return the discovery configuration for the specified scope
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the discovery configuration identified by the specified name
|
||||||
|
*
|
||||||
|
* @param configurationName the configuration name assigned to the bean in the
|
||||||
|
* discovery.xml
|
||||||
|
* @return the discovery configuration
|
||||||
|
*/
|
||||||
|
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 +109,57 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the discovery configuration applicable to the provided workspace item
|
||||||
|
* @param witem a workspace item
|
||||||
|
* @return a list of discovery configuration
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the discovery configuration applicable to the provided workflow item
|
||||||
|
* @param witem a workflow item
|
||||||
|
* @return a list of discovery configuration
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@ import java.util.List;
|
|||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
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 +29,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, IndexableObject 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);
|
||||||
|
@@ -12,7 +12,6 @@ import java.util.List;
|
|||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
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 +40,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, IndexableObject 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,6 @@
|
|||||||
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.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +19,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, IndexableObject dso, SolrInputDocument document) {
|
||||||
System.out.println("Currently indexing: " + dso.getHandle());
|
System.out.println("Currently indexing: " + dso.getUniqueIndexID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
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.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,5 +19,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, IndexableObject dso, SolrInputDocument document);
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
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 +56,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, IndexableObject dso, SolrInputDocument document) {
|
||||||
// Only works for Items
|
// Only works for Items
|
||||||
if (!(dso instanceof Item)) {
|
if (!(dso instanceof Item)) {
|
||||||
return;
|
return;
|
||||||
|
@@ -11,6 +11,7 @@ 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;
|
||||||
@@ -54,34 +55,44 @@ 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, IndexableObject idxObj, SolrInputDocument document) {
|
||||||
try {
|
if (idxObj instanceof DSpaceObject) {
|
||||||
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ);
|
DSpaceObject dso = (DSpaceObject) idxObj;
|
||||||
for (ResourcePolicy resourcePolicy : policies) {
|
try {
|
||||||
String fieldValue;
|
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ);
|
||||||
if (resourcePolicy.getGroup() != null) {
|
for (ResourcePolicy resourcePolicy : policies) {
|
||||||
//We have a group add it to the value
|
String fieldValue;
|
||||||
fieldValue = "g" + resourcePolicy.getGroup().getID();
|
if (resourcePolicy.getGroup() != null) {
|
||||||
} else {
|
//We have a group add it to the value
|
||||||
//We have an eperson add it to the value
|
fieldValue = "g" + resourcePolicy.getGroup().getID();
|
||||||
fieldValue = "e" + resourcePolicy.getEPerson().getID();
|
} else {
|
||||||
|
//We have an eperson add it to the value
|
||||||
|
fieldValue = "e" + resourcePolicy.getEPerson().getID();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addField("read", fieldValue);
|
||||||
|
|
||||||
|
//remove the policy from the cache to save memory
|
||||||
|
context.uncacheEntity(resourcePolicy);
|
||||||
}
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
document.addField("read", fieldValue);
|
log.error(LogManager.getHeader(context, "Error while indexing resource policies",
|
||||||
|
"DSpace object: (id " + dso.getID() + " type " + dso.getType() + ")"));
|
||||||
//remove the policy from the cache to save memory
|
|
||||||
context.uncacheEntity(resourcePolicy);
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
|
||||||
log.error(LogManager.getHeader(context, "Error while indexing resource policies",
|
|
||||||
"DSpace object: (id " + dso.getID() + " type " + dso.getType() + ")"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void additionalSearchParameters(Context context, DiscoverQuery discoveryQuery, SolrQuery solrQuery) {
|
public void additionalSearchParameters(Context context, DiscoverQuery discoveryQuery, SolrQuery solrQuery) {
|
||||||
try {
|
try {
|
||||||
|
// skip workspace and workflow queries as security for it them is builtin in the SolrServiceImpl
|
||||||
|
if (StringUtils.startsWith(discoveryQuery.getDiscoveryConfigurationName(),
|
||||||
|
SolrServiceImpl.DISCOVER_WORKSPACE_CONFIGURATION_NAME)
|
||||||
|
|| StringUtils.startsWith(discoveryQuery.getDiscoveryConfigurationName(),
|
||||||
|
SolrServiceImpl.DISCOVER_WORKFLOW_CONFIGURATION_NAME)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!authorizeService.isAdmin(context)) {
|
if (!authorizeService.isAdmin(context)) {
|
||||||
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
|
||||||
|
@@ -10,7 +10,6 @@ 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.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 +29,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, IndexableObject 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);
|
||||||
|
@@ -13,6 +13,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,12 +40,14 @@ public class DiscoveryConfigurationService {
|
|||||||
this.toIgnoreMetadataFields = toIgnoreMetadataFields;
|
this.toIgnoreMetadataFields = toIgnoreMetadataFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso) {
|
public DiscoveryConfiguration getDiscoveryConfiguration(IndexableObject dso) {
|
||||||
String name;
|
String name;
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
name = "site";
|
name = "site";
|
||||||
|
} else if (dso instanceof DSpaceObject) {
|
||||||
|
name = ((DSpaceObject) dso).getHandle();
|
||||||
} else {
|
} else {
|
||||||
name = dso.getHandle();
|
name = dso.getUniqueIndexID();
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDiscoveryConfiguration(name);
|
return getDiscoveryConfiguration(name);
|
||||||
@@ -64,7 +67,7 @@ public class DiscoveryConfigurationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DiscoveryConfiguration getDiscoveryConfigurationByNameOrDso(final String configurationName,
|
public DiscoveryConfiguration getDiscoveryConfigurationByNameOrDso(final String configurationName,
|
||||||
final DSpaceObject dso) {
|
final IndexableObject 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 {
|
||||||
|
@@ -28,6 +28,7 @@ import org.dspace.core.Constants;
|
|||||||
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;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.SearchUtils;
|
import org.dspace.discovery.SearchUtils;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
@@ -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<IndexableObject> dsoIterator = discoverResult.getIndexableObjects().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();
|
||||||
|
@@ -30,6 +30,16 @@ public interface WorkflowItemService<T extends WorkflowItem> extends InProgressS
|
|||||||
|
|
||||||
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
public T create(Context context, Item item, Collection collection) throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a workflow item from the database.
|
||||||
|
*
|
||||||
|
* @param context The relevant DSpace Context.
|
||||||
|
* @param id ID of the workflow item
|
||||||
|
* @return the workflow item, or null if the ID is invalid.
|
||||||
|
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||||
|
*/
|
||||||
|
public T find(Context context, int id) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return all workflowitems
|
* return all workflowitems
|
||||||
*
|
*
|
||||||
|
@@ -54,7 +54,7 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsTypeConstant() {
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
return Constants.WORKFLOWITEM;
|
return Constants.WORKFLOWITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BasicWorkflowItem find(Context context, Integer id) throws SQLException {
|
public BasicWorkflowItem find(Context context, int id) throws SQLException {
|
||||||
BasicWorkflowItem workflowItem = workflowItemDAO.findByID(context, BasicWorkflowItem.class, id);
|
BasicWorkflowItem workflowItem = workflowItemDAO.findByID(context, BasicWorkflowItem.class, id);
|
||||||
|
|
||||||
if (workflowItem == null) {
|
if (workflowItem == null) {
|
||||||
@@ -90,6 +90,14 @@ public class BasicWorkflowItemServiceImpl implements BasicWorkflowItemService {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BasicWorkflowItem findIndexableObject(Context context, Integer id) throws SQLException {
|
||||||
|
if (id != null) {
|
||||||
|
return find(context, id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BasicWorkflowItem> findAll(Context context) throws SQLException {
|
public List<BasicWorkflowItem> findAll(Context context) throws SQLException {
|
||||||
return workflowItemDAO.findAll(context, BasicWorkflowItem.class);
|
return workflowItemDAO.findAll(context, BasicWorkflowItem.class);
|
||||||
|
@@ -18,10 +18,10 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,7 @@ import org.dspace.eperson.EPerson;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_claimtask")
|
@Table(name = "cwf_claimtask")
|
||||||
public class ClaimedTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
public class ClaimedTask implements ReloadableEntity<Integer>, IndexableObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "claimtask_id")
|
@Column(name = "claimtask_id")
|
||||||
|
@@ -38,7 +38,7 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsTypeConstant() {
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
return Constants.CLAIMEDTASK;
|
return Constants.CLAIMEDTASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClaimedTask find(Context context, Integer id) throws SQLException {
|
public ClaimedTask findIndexableObject(Context context, Integer id) throws SQLException {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -19,10 +19,10 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.Group;
|
import org.dspace.eperson.Group;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ import org.dspace.eperson.Group;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_pooltask")
|
@Table(name = "cwf_pooltask")
|
||||||
public class PoolTask implements ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
public class PoolTask implements ReloadableEntity<Integer>, IndexableObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "pooltask_id")
|
@Column(name = "pooltask_id")
|
||||||
|
@@ -49,7 +49,7 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsTypeConstant() {
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
return Constants.POOLTASK;
|
return Constants.POOLTASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ public class PoolTaskServiceImpl implements PoolTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PoolTask find(Context context, Integer id) throws SQLException {
|
public PoolTask findIndexableObject(Context context, Integer id) throws SQLException {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -21,12 +21,12 @@ import javax.persistence.OneToOne;
|
|||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
import org.dspace.workflow.WorkflowItem;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ import org.dspace.workflow.WorkflowItem;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "cwf_workflowitem")
|
@Table(name = "cwf_workflowitem")
|
||||||
public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>, BrowsableObject<Integer> {
|
public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity<Integer>, IndexableObject<Integer> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "workflowitem_id")
|
@Column(name = "workflowitem_id")
|
||||||
|
@@ -64,7 +64,7 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSupportsTypeConstant() {
|
public int getSupportsIndexableObjectTypeConstant() {
|
||||||
return Constants.WORKFLOWITEM;
|
return Constants.WORKFLOWITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,10 +78,9 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XmlWorkflowItem find(Context context, Integer id) throws SQLException {
|
public XmlWorkflowItem find(Context context, int id) throws SQLException {
|
||||||
XmlWorkflowItem workflowItem = xmlWorkflowItemDAO.findByID(context, XmlWorkflowItem.class, id);
|
XmlWorkflowItem workflowItem = xmlWorkflowItemDAO.findByID(context, XmlWorkflowItem.class, id);
|
||||||
|
|
||||||
|
|
||||||
if (workflowItem == null) {
|
if (workflowItem == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug(LogManager.getHeader(context, "find_workflow_item",
|
log.debug(LogManager.getHeader(context, "find_workflow_item",
|
||||||
@@ -96,6 +95,14 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
|||||||
return workflowItem;
|
return workflowItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlWorkflowItem findIndexableObject(Context context, Integer id) throws SQLException {
|
||||||
|
if (id != null) {
|
||||||
|
return find(context, id);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<XmlWorkflowItem> findAll(Context context) throws SQLException {
|
public List<XmlWorkflowItem> findAll(Context context) throws SQLException {
|
||||||
return xmlWorkflowItemDAO.findAll(context, XmlWorkflowItem.class);
|
return xmlWorkflowItemDAO.findAll(context, XmlWorkflowItem.class);
|
||||||
|
@@ -11,7 +11,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.BrowsableObjectService;
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -26,7 +26,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
public interface ClaimedTaskService extends DSpaceCRUDService<ClaimedTask>,
|
||||||
BrowsableObjectService<ClaimedTask, Integer> {
|
IndexableObjectService<ClaimedTask, Integer> {
|
||||||
|
|
||||||
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
public List<ClaimedTask> findByWorkflowItem(Context context, XmlWorkflowItem workflowItem) throws SQLException;
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.service.BrowsableObjectService;
|
import org.dspace.content.service.IndexableObjectService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.service.DSpaceCRUDService;
|
import org.dspace.service.DSpaceCRUDService;
|
||||||
@@ -26,7 +26,7 @@ import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
|||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, BrowsableObjectService<PoolTask, Integer> {
|
public interface PoolTaskService extends DSpaceCRUDService<PoolTask>, IndexableObjectService<PoolTask, Integer> {
|
||||||
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
public List<PoolTask> findByEperson(Context context, EPerson ePerson)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
|
||||||
|
@@ -117,7 +117,6 @@ public class AuthenticationRestController implements InitializingBean {
|
|||||||
|
|
||||||
context = ContextUtil.obtainContext(request);
|
context = ContextUtil.obtainContext(request);
|
||||||
|
|
||||||
|
|
||||||
if (context == null || context.getCurrentUser() == null) {
|
if (context == null || context.getCurrentUser() == null) {
|
||||||
// Note that the actual HTTP status in this case is set by
|
// Note that the actual HTTP status in this case is set by
|
||||||
// org.dspace.app.rest.security.StatelessLoginFilter.unsuccessfulAuthentication()
|
// org.dspace.app.rest.security.StatelessLoginFilter.unsuccessfulAuthentication()
|
||||||
@@ -128,4 +127,5 @@ public class AuthenticationRestController implements InitializingBean {
|
|||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
||||||
@@ -101,20 +101,20 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
public FacetsResource getFacets(@RequestParam(name = "query", required = false) String query,
|
public FacetsResource getFacets(@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,
|
@RequestParam(name = "configuration", required = false) String configuration,
|
||||||
List<SearchFilter> searchFilters,
|
List<SearchFilter> searchFilters,
|
||||||
Pageable page) throws Exception {
|
Pageable page) throws Exception {
|
||||||
|
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Searching with scope: " + StringUtils.trimToEmpty(dsoScope)
|
log.trace("Searching with scope: " + StringUtils.trimToEmpty(dsoScope)
|
||||||
+ ", configuration name: " + StringUtils.trimToEmpty(configurationName)
|
+ ", configuration name: " + StringUtils.trimToEmpty(configuration)
|
||||||
+ ", dsoType: " + StringUtils.trimToEmpty(dsoType)
|
+ ", dsoType: " + StringUtils.trimToEmpty(dsoType)
|
||||||
+ ", query: " + StringUtils.trimToEmpty(query)
|
+ ", query: " + StringUtils.trimToEmpty(query)
|
||||||
+ ", filters: " + Objects.toString(searchFilters));
|
+ ", filters: " + Objects.toString(searchFilters));
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchResultsRest searchResultsRest = discoveryRestRepository
|
SearchResultsRest searchResultsRest = discoveryRestRepository
|
||||||
.getAllFacets(query, dsoType, dsoScope, configurationName, searchFilters);
|
.getAllFacets(query, dsoType, dsoScope, configuration, searchFilters);
|
||||||
|
|
||||||
FacetsResource facetsResource = new FacetsResource(searchResultsRest, page);
|
FacetsResource facetsResource = new FacetsResource(searchResultsRest, page);
|
||||||
halLinkService.addLinks(facetsResource, page);
|
halLinkService.addLinks(facetsResource, page);
|
||||||
@@ -129,12 +129,12 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
@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
|
@RequestParam(name = "configuration", required = false) String
|
||||||
configurationName,
|
configuration,
|
||||||
List<SearchFilter> searchFilters,
|
List<SearchFilter> searchFilters,
|
||||||
Pageable page) throws Exception {
|
Pageable page) throws Exception {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Searching with scope: " + StringUtils.trimToEmpty(dsoScope)
|
log.trace("Searching with scope: " + StringUtils.trimToEmpty(dsoScope)
|
||||||
+ ", configuration name: " + StringUtils.trimToEmpty(configurationName)
|
+ ", configuration name: " + StringUtils.trimToEmpty(configuration)
|
||||||
+ ", dsoType: " + StringUtils.trimToEmpty(dsoType)
|
+ ", dsoType: " + StringUtils.trimToEmpty(dsoType)
|
||||||
+ ", query: " + StringUtils.trimToEmpty(query)
|
+ ", query: " + StringUtils.trimToEmpty(query)
|
||||||
+ ", filters: " + Objects.toString(searchFilters)
|
+ ", filters: " + Objects.toString(searchFilters)
|
||||||
@@ -144,7 +144,7 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
//Get the Search results in JSON format
|
//Get the Search results in JSON format
|
||||||
SearchResultsRest searchResultsRest = null;
|
SearchResultsRest searchResultsRest = null;
|
||||||
searchResultsRest = discoveryRestRepository
|
searchResultsRest = discoveryRestRepository
|
||||||
.getSearchObjects(query, dsoType, dsoScope, configurationName, searchFilters, page);
|
.getSearchObjects(query, dsoType, dsoScope, configuration, searchFilters, page);
|
||||||
|
|
||||||
//Convert the Search JSON results to paginated HAL resources
|
//Convert the Search JSON results to paginated HAL resources
|
||||||
SearchResultsResource searchResultsResource = new SearchResultsResource(searchResultsRest, utils, page);
|
SearchResultsResource searchResultsResource = new SearchResultsResource(searchResultsRest, utils, page);
|
||||||
@@ -155,15 +155,15 @@ public class DiscoveryRestController implements InitializingBean {
|
|||||||
@RequestMapping(method = RequestMethod.GET, value = "/facets")
|
@RequestMapping(method = RequestMethod.GET, value = "/facets")
|
||||||
public FacetConfigurationResource getFacetsConfiguration(
|
public FacetConfigurationResource getFacetsConfiguration(
|
||||||
@RequestParam(name = "scope", required = false) String dsoScope,
|
@RequestParam(name = "scope", required = false) String dsoScope,
|
||||||
@RequestParam(name = "configuration", required = false) String configurationName,
|
@RequestParam(name = "configuration", required = false) String configuration,
|
||||||
Pageable pageable) throws Exception {
|
Pageable pageable) throws Exception {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Retrieving facet configuration for scope " + StringUtils.trimToEmpty(dsoScope)
|
log.trace("Retrieving facet configuration for scope " + StringUtils.trimToEmpty(dsoScope)
|
||||||
+ " and configuration name " + StringUtils.trimToEmpty(configurationName));
|
+ " and configuration name " + StringUtils.trimToEmpty(configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
FacetConfigurationRest facetConfigurationRest = discoveryRestRepository
|
FacetConfigurationRest facetConfigurationRest = discoveryRestRepository
|
||||||
.getFacetsConfiguration(dsoScope, configurationName);
|
.getFacetsConfiguration(dsoScope, configuration);
|
||||||
FacetConfigurationResource facetConfigurationResource = new FacetConfigurationResource(facetConfigurationRest);
|
FacetConfigurationResource facetConfigurationResource = new FacetConfigurationResource(facetConfigurationRest);
|
||||||
|
|
||||||
halLinkService.addLinks(facetConfigurationResource, pageable);
|
halLinkService.addLinks(facetConfigurationResource, pageable);
|
||||||
@@ -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
|
||||||
|
configuration,
|
||||||
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, configuration, searchFilters, page);
|
||||||
|
|
||||||
FacetResultsResource facetResultsResource = new FacetResultsResource(facetResultsRest);
|
FacetResultsResource facetResultsResource = new FacetResultsResource(facetResultsRest);
|
||||||
|
|
||||||
|
@@ -12,6 +12,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -22,7 +24,6 @@ import javax.xml.transform.dom.DOMSource;
|
|||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.app.rest.utils.ScopeResolver;
|
import org.dspace.app.rest.utils.ScopeResolver;
|
||||||
import org.dspace.app.util.SyndicationFeed;
|
import org.dspace.app.util.SyndicationFeed;
|
||||||
@@ -30,7 +31,6 @@ 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.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;
|
||||||
import org.dspace.content.service.CommunityService;
|
import org.dspace.content.service.CommunityService;
|
||||||
@@ -38,17 +38,16 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.discovery.DiscoverQuery;
|
import org.dspace.discovery.DiscoverQuery;
|
||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.discovery.SearchServiceException;
|
import org.dspace.discovery.SearchServiceException;
|
||||||
import org.dspace.discovery.SearchUtils;
|
import org.dspace.discovery.SearchUtils;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilter;
|
import org.dspace.discovery.configuration.DiscoverySearchFilter;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +112,7 @@ public class OpenSearchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// then the rest - we are processing the query
|
// then the rest - we are processing the query
|
||||||
DSpaceObject container = null;
|
IndexableObject<UUID> container = null;
|
||||||
|
|
||||||
// support pagination parameters
|
// support pagination parameters
|
||||||
DiscoverQuery queryArgs = new DiscoverQuery();
|
DiscoverQuery queryArgs = new DiscoverQuery();
|
||||||
@@ -140,7 +139,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<IndexableObject> dsoResults = qResults.getIndexableObjects();
|
||||||
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);
|
||||||
|
@@ -42,7 +42,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
*/
|
*/
|
||||||
public abstract class AInprogressItemConverter<T extends InProgressSubmission<ID>,
|
public abstract class AInprogressItemConverter<T extends InProgressSubmission<ID>,
|
||||||
R extends AInprogressSubmissionRest<ID>, ID extends Serializable>
|
R extends AInprogressSubmissionRest<ID>, ID extends Serializable>
|
||||||
extends BrowsableDSpaceObjectConverter<T, R> {
|
implements IndexableObjectConverter<T, R> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AInprogressItemConverter.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AInprogressItemConverter.class);
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class AuthorityEntryRestConverter extends DSpaceConverter<Choice, AuthorityEntryRest> {
|
public class AuthorityEntryRestConverter implements DSpaceConverter<Choice, AuthorityEntryRest> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthorityEntryRest fromModel(Choice choice) {
|
public AuthorityEntryRest fromModel(Choice choice) {
|
||||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class AuthorityRestConverter extends DSpaceConverter<ChoiceAuthority, AuthorityRest> {
|
public class AuthorityRestConverter implements DSpaceConverter<ChoiceAuthority, AuthorityRest> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthorityRest fromModel(ChoiceAuthority step) {
|
public AuthorityRest fromModel(ChoiceAuthority step) {
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.BitstreamFormatRest;
|
import org.dspace.app.rest.model.BitstreamFormatRest;
|
||||||
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,9 +18,9 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BitstreamFormatConverter extends DSpaceConverter<org.dspace.content.BitstreamFormat, BitstreamFormatRest> {
|
public class BitstreamFormatConverter implements DSpaceConverter<BitstreamFormat, BitstreamFormatRest> {
|
||||||
@Override
|
@Override
|
||||||
public BitstreamFormatRest fromModel(org.dspace.content.BitstreamFormat obj) {
|
public BitstreamFormatRest fromModel(BitstreamFormat obj) {
|
||||||
BitstreamFormatRest bf = new BitstreamFormatRest();
|
BitstreamFormatRest bf = new BitstreamFormatRest();
|
||||||
bf.setDescription(obj.getDescription());
|
bf.setDescription(obj.getDescription());
|
||||||
bf.setExtensions(bf.getExtensions());
|
bf.setExtensions(bf.getExtensions());
|
||||||
@@ -31,7 +32,7 @@ public class BitstreamFormatConverter extends DSpaceConverter<org.dspace.content
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.dspace.content.BitstreamFormat toModel(BitstreamFormatRest obj) {
|
public BitstreamFormat toModel(BitstreamFormatRest obj) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BrowseIndexConverter extends DSpaceConverter<BrowseIndex, BrowseIndexRest> {
|
public class BrowseIndexConverter implements DSpaceConverter<BrowseIndex, BrowseIndexRest> {
|
||||||
@Override
|
@Override
|
||||||
public BrowseIndexRest fromModel(BrowseIndex obj) {
|
public BrowseIndexRest fromModel(BrowseIndex obj) {
|
||||||
BrowseIndexRest bir = new BrowseIndexRest();
|
BrowseIndexRest bir = new BrowseIndexRest();
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.ClaimedTaskRest;
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
import org.dspace.xmlworkflow.storedcomponents.ClaimedTask;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ClaimedTaskConverter
|
public class ClaimedTaskConverter
|
||||||
extends BrowsableDSpaceObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
implements IndexableObjectConverter<ClaimedTask, org.dspace.app.rest.model.ClaimedTaskRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkflowItemConverter workflowItemConverter;
|
private WorkflowItemConverter workflowItemConverter;
|
||||||
@@ -49,7 +49,7 @@ public class ClaimedTaskConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(IndexableObject object) {
|
||||||
return object instanceof ClaimedTask;
|
return object instanceof ClaimedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.service.CollectionService;
|
import org.dspace.content.service.CollectionService;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.services.RequestService;
|
import org.dspace.services.RequestService;
|
||||||
import org.dspace.services.model.Request;
|
import org.dspace.services.model.Request;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -37,7 +38,8 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class CollectionConverter
|
public class CollectionConverter
|
||||||
extends DSpaceObjectConverter<org.dspace.content.Collection, org.dspace.app.rest.model.CollectionRest> {
|
extends DSpaceObjectConverter<org.dspace.content.Collection, org.dspace.app.rest.model.CollectionRest>
|
||||||
|
implements IndexableObjectConverter<Collection, CollectionRest> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CollectionConverter.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CollectionConverter.class);
|
||||||
|
|
||||||
@@ -110,4 +112,9 @@ public class CollectionConverter
|
|||||||
protected Class<org.dspace.content.Collection> getModelClass() {
|
protected Class<org.dspace.content.Collection> getModelClass() {
|
||||||
return org.dspace.content.Collection.class;
|
return org.dspace.content.Collection.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(IndexableObject idxo) {
|
||||||
|
return idxo instanceof Collection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ import org.dspace.app.rest.model.CommunityRest;
|
|||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class CommunityConverter
|
public class CommunityConverter
|
||||||
extends DSpaceObjectConverter<org.dspace.content.Community, org.dspace.app.rest.model.CommunityRest> {
|
extends DSpaceObjectConverter<org.dspace.content.Community, org.dspace.app.rest.model.CommunityRest>
|
||||||
|
implements IndexableObjectConverter<Community, CommunityRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BitstreamConverter bitstreamConverter;
|
private BitstreamConverter bitstreamConverter;
|
||||||
|
|
||||||
@@ -77,4 +80,9 @@ public class CommunityConverter
|
|||||||
protected Class<org.dspace.content.Community> getModelClass() {
|
protected Class<org.dspace.content.Community> getModelClass() {
|
||||||
return org.dspace.content.Community.class;
|
return org.dspace.content.Community.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(IndexableObject idxo) {
|
||||||
|
return idxo instanceof Community;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,9 +9,9 @@ package org.dspace.app.rest.converter;
|
|||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
|
||||||
public abstract class DSpaceConverter<M, R> implements Converter<M, R> {
|
public interface DSpaceConverter<M, R> extends Converter<M, R> {
|
||||||
@Override
|
@Override
|
||||||
public R convert(M source) {
|
public default R convert(M source) {
|
||||||
return fromModel(source);
|
return fromModel(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -20,8 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends org.dspace.app.rest.model
|
public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends org.dspace.app.rest.model
|
||||||
.DSpaceObjectRest>
|
.DSpaceObjectRest> implements DSpaceConverter<M, R> {
|
||||||
extends BrowsableDSpaceObjectConverter<M, R> {
|
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private MetadataConverter metadataConverter;
|
private MetadataConverter metadataConverter;
|
||||||
@@ -43,7 +41,7 @@ public abstract class DSpaceObjectConverter<M extends DSpaceObject, R extends or
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(DSpaceObject object) {
|
||||||
return object != null && object.getClass().equals(getModelClass());
|
return object != null && object.getClass().equals(getModelClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ public class DiscoverFacetConfigurationConverter {
|
|||||||
DiscoveryConfiguration configuration) {
|
DiscoveryConfiguration configuration) {
|
||||||
FacetConfigurationRest facetConfigurationRest = new FacetConfigurationRest();
|
FacetConfigurationRest facetConfigurationRest = new FacetConfigurationRest();
|
||||||
|
|
||||||
facetConfigurationRest.setConfigurationName(configurationName);
|
facetConfigurationRest.setConfiguration(configurationName);
|
||||||
facetConfigurationRest.setScope(scope);
|
facetConfigurationRest.setScope(scope);
|
||||||
|
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
|
@@ -19,6 +19,7 @@ import org.dspace.core.Context;
|
|||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
import org.dspace.discovery.configuration.DiscoveryConfiguration;
|
||||||
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
import org.dspace.discovery.configuration.DiscoverySearchFilterFacet;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -27,8 +28,11 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class DiscoverFacetResultsConverter {
|
public class DiscoverFacetResultsConverter {
|
||||||
|
@Autowired
|
||||||
|
private DiscoverFacetValueConverter facetValueConverter;
|
||||||
|
|
||||||
private DiscoverFacetValueConverter facetValueConverter = new DiscoverFacetValueConverter();
|
@Autowired
|
||||||
|
private SearchFilterToAppliedFilterConverter searchFilterToAppliedFilterConverter;
|
||||||
|
|
||||||
public FacetResultsRest convert(Context context, String facetName, String prefix, String query, String dsoType,
|
public FacetResultsRest convert(Context context, String facetName, String prefix, String query, String dsoType,
|
||||||
String dsoScope, List<SearchFilter> searchFilters, DiscoverResult searchResult,
|
String dsoScope, List<SearchFilter> searchFilters, DiscoverResult searchResult,
|
||||||
@@ -80,8 +84,6 @@ public class DiscoverFacetResultsConverter {
|
|||||||
|
|
||||||
facetResultsRest.setSearchFilters(searchFilters);
|
facetResultsRest.setSearchFilters(searchFilters);
|
||||||
|
|
||||||
SearchFilterToAppliedFilterConverter searchFilterToAppliedFilterConverter = new
|
|
||||||
SearchFilterToAppliedFilterConverter();
|
|
||||||
for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(searchFilters)) {
|
for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(searchFilters)) {
|
||||||
facetResultsRest
|
facetResultsRest
|
||||||
.addAppliedFilter(searchFilterToAppliedFilterConverter.convertSearchFilter(context, searchFilter));
|
.addAppliedFilter(searchFilterToAppliedFilterConverter.convertSearchFilter(context, searchFilter));
|
||||||
|
@@ -9,10 +9,12 @@ package org.dspace.app.rest.converter;
|
|||||||
|
|
||||||
import org.dspace.app.rest.model.SearchFacetValueRest;
|
import org.dspace.app.rest.model.SearchFacetValueRest;
|
||||||
import org.dspace.discovery.DiscoverResult;
|
import org.dspace.discovery.DiscoverResult;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class' purpose is to convert a DiscoverResult.FacetResult object into a SearchFacetValueRest object
|
* This class' purpose is to convert a DiscoverResult.FacetResult object into a SearchFacetValueRest object
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class DiscoverFacetValueConverter {
|
public class DiscoverFacetValueConverter {
|
||||||
|
|
||||||
public SearchFacetValueRest convert(final DiscoverResult.FacetResult value) {
|
public SearchFacetValueRest convert(final DiscoverResult.FacetResult value) {
|
||||||
|
@@ -50,61 +50,71 @@ public class DiscoverFacetsConverter {
|
|||||||
return searchResultsRest;
|
return searchResultsRest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private void addFacetValues(Context context, final DiscoverResult searchResult,
|
* Fill the facet values information in the SearchResultsRest using the information in the api DiscoverResult object
|
||||||
final SearchResultsRest searchResultsRest,
|
* according to the configuration applied to the discovery query
|
||||||
final DiscoveryConfiguration configuration) {
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace context
|
||||||
|
* @param searchResult
|
||||||
|
* The DiscoverResult containing the discovery result
|
||||||
|
* @param resultsRest
|
||||||
|
* The SearchResultsRest that need to be filled in
|
||||||
|
* @param configuration
|
||||||
|
* The DiscoveryConfiguration applied to the query
|
||||||
|
*/
|
||||||
|
public void addFacetValues(Context context, final DiscoverResult searchResult, final SearchResultsRest resultsRest,
|
||||||
|
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());
|
||||||
|
facetEntry.setFacetType(field.getType());
|
||||||
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
|
||||||
//more results available.
|
// are
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(facetEntry.getFacetType())) {
|
|
||||||
facetEntry.setFacetType(value.getFieldType());
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
private void handleExposeMinMaxValues(Context context,DiscoverySearchFilterFacet field,
|
* The DiscoverySearchFilterFacet field to search for this value in solr
|
||||||
SearchFacetEntryRest facetEntry) {
|
* @param facetEntry
|
||||||
|
* The SearchFacetEntryRest facetEntry for which this needs to be filled in
|
||||||
|
*/
|
||||||
|
private void handleExposeMinMaxValues(Context context, DiscoverySearchFilterFacet field,
|
||||||
|
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,13 +125,12 @@ 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,
|
||||||
final SearchResultsRest resultsRest) {
|
final SearchResultsRest resultsRest) {
|
||||||
resultsRest.setQuery(query);
|
resultsRest.setQuery(query);
|
||||||
resultsRest.setConfigurationName(configurationName);
|
resultsRest.setConfiguration(configurationName);
|
||||||
resultsRest.setDsoType(dsoType);
|
resultsRest.setDsoType(dsoType);
|
||||||
resultsRest.setSort(SearchResultsRest.Sorting.fromPage(page));
|
resultsRest.setSort(SearchResultsRest.Sorting.fromPage(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.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.IndexableObject;
|
||||||
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<IndexableObjectConverter> 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,
|
||||||
@@ -69,77 +61,19 @@ 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 (IndexableObject dspaceObject : CollectionUtils.emptyIfNull(searchResult.getIndexableObjects())) {
|
||||||
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.setIndexableObject(convertDSpaceObject(dspaceObject));
|
||||||
|
|
||||||
//Add hit highlighting for this DSO if present
|
//Add hit highlighting for this DSO if present
|
||||||
DiscoverResult.DSpaceObjectHighlightResult highlightedResults = searchResult
|
DiscoverResult.IndexableObjectHighlightResult highlightedResults = searchResult
|
||||||
.getHighlightedResults(dspaceObject);
|
.getHighlightedResults(dspaceObject);
|
||||||
if (highlightedResults != null && MapUtils.isNotEmpty(highlightedResults.getHighlightResults())) {
|
if (highlightedResults != null && MapUtils.isNotEmpty(highlightedResults.getHighlightResults())) {
|
||||||
for (Map.Entry<String, List<String>> metadataHighlight : highlightedResults.getHighlightResults()
|
for (Map.Entry<String, List<String>> metadataHighlight : highlightedResults.getHighlightResults()
|
||||||
@@ -152,10 +86,10 @@ public class DiscoverResultConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DSpaceObjectRest convertDSpaceObject(final DSpaceObject dspaceObject) {
|
private RestAddressableModel convertDSpaceObject(final IndexableObject dspaceObject) {
|
||||||
for (DSpaceObjectConverter converter : converters) {
|
for (IndexableObjectConverter<IndexableObject, RestAddressableModel> converter : converters) {
|
||||||
if (converter.supportsModel(dspaceObject)) {
|
if (converter.supportsModel(dspaceObject)) {
|
||||||
return converter.fromModel(dspaceObject);
|
return converter.convert(dspaceObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -166,7 +100,7 @@ public class DiscoverResultConverter {
|
|||||||
final List<SearchFilter> searchFilters, final Pageable page,
|
final List<SearchFilter> searchFilters, final Pageable page,
|
||||||
final SearchResultsRest resultsRest) {
|
final SearchResultsRest resultsRest) {
|
||||||
resultsRest.setQuery(query);
|
resultsRest.setQuery(query);
|
||||||
resultsRest.setConfigurationName(configurationName);
|
resultsRest.setConfiguration(configurationName);
|
||||||
resultsRest.setDsoType(dsoType);
|
resultsRest.setDsoType(dsoType);
|
||||||
|
|
||||||
resultsRest.setScope(scope);
|
resultsRest.setScope(scope);
|
||||||
@@ -178,12 +112,9 @@ public class DiscoverResultConverter {
|
|||||||
SearchQueryConverter searchQueryConverter = new SearchQueryConverter();
|
SearchQueryConverter searchQueryConverter = new SearchQueryConverter();
|
||||||
List<SearchFilter> transformedFilters = searchQueryConverter.convert(searchFilters);
|
List<SearchFilter> transformedFilters = searchQueryConverter.convert(searchFilters);
|
||||||
|
|
||||||
SearchFilterToAppliedFilterConverter 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* representation of an EntityType and vice versa
|
* representation of an EntityType and vice versa
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class EntityTypeConverter extends DSpaceConverter<org.dspace.content.EntityType, EntityTypeRest> {
|
public class EntityTypeConverter implements DSpaceConverter<org.dspace.content.EntityType, EntityTypeRest> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method converts the EntityType model object that is passed along in the params to the
|
* This method converts the EntityType model object that is passed along in the params to the
|
||||||
|
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* representation about the filter query that has to be used for the given EntityType
|
* representation about the filter query that has to be used for the given EntityType
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class FilteredDiscoveryPageConverter extends DSpaceConverter<org.dspace.content.EntityType,
|
public class FilteredDiscoveryPageConverter implements DSpaceConverter<org.dspace.content.EntityType,
|
||||||
FilteredDiscoveryPageRest> {
|
FilteredDiscoveryPageRest> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityTypeToFilterQueryService entityTypeToFilterQueryService;
|
private EntityTypeToFilterQueryService entityTypeToFilterQueryService;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the base converter from/to objects in the DSpace API data model and
|
* This is the base converter from/to objects in the DSpace API data model and
|
||||||
@@ -17,15 +17,15 @@ import org.dspace.browse.BrowsableObject;
|
|||||||
* @param <R> the Class in the DSpace REST data model
|
* @param <R> the Class in the DSpace REST data model
|
||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
public abstract class BrowsableDSpaceObjectConverter<M extends BrowsableObject,
|
public interface IndexableObjectConverter<M extends IndexableObject,
|
||||||
R extends org.dspace.app.rest.model.RestAddressableModel> extends DSpaceConverter<M, R> {
|
R extends org.dspace.app.rest.model.RestAddressableModel> extends DSpaceConverter<M, R> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param bdso
|
* @param idxo
|
||||||
* the browsableDSpaceObject to check
|
* the IndexableObject to check
|
||||||
* @return true if the actual converter implementation is able to manage the supplied BrowsableDSpaceObject
|
* @return true if the actual converter implementation is able to manage the supplied IndexableObject
|
||||||
*/
|
*/
|
||||||
public abstract boolean supportsModel(BrowsableObject bdso);
|
public boolean supportsModel(IndexableObject idxo);
|
||||||
|
|
||||||
}
|
}
|
@@ -25,6 +25,7 @@ import org.dspace.content.Relationship;
|
|||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.RelationshipService;
|
import org.dspace.content.service.RelationshipService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -35,7 +36,10 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item, org.dspace.app.rest.model.ItemRest> {
|
public class ItemConverter
|
||||||
|
extends DSpaceObjectConverter<org.dspace.content.Item, org.dspace.app.rest.model.ItemRest>
|
||||||
|
implements IndexableObjectConverter<Item, ItemRest> {
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private CollectionConverter collectionConverter;
|
private CollectionConverter collectionConverter;
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
@@ -120,4 +124,8 @@ public class ItemConverter extends DSpaceObjectConverter<org.dspace.content.Item
|
|||||||
return Item.class;
|
return Item.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsModel(IndexableObject idxo) {
|
||||||
|
return idxo instanceof Item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class MetadataFieldConverter extends DSpaceConverter<org.dspace.content.MetadataField, MetadataFieldRest> {
|
public class MetadataFieldConverter implements DSpaceConverter<org.dspace.content.MetadataField, MetadataFieldRest> {
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private MetadataSchemaConverter metadataSchemaConverter;
|
private MetadataSchemaConverter metadataSchemaConverter;
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class MetadataSchemaConverter extends DSpaceConverter<org.dspace.content.MetadataSchema, MetadataSchemaRest> {
|
public class MetadataSchemaConverter implements DSpaceConverter<org.dspace.content.MetadataSchema, MetadataSchemaRest> {
|
||||||
@Override
|
@Override
|
||||||
public MetadataSchemaRest fromModel(org.dspace.content.MetadataSchema obj) {
|
public MetadataSchemaRest fromModel(org.dspace.content.MetadataSchema obj) {
|
||||||
MetadataSchemaRest schema = new MetadataSchemaRest();
|
MetadataSchemaRest schema = new MetadataSchemaRest();
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
package org.dspace.app.rest.converter;
|
package org.dspace.app.rest.converter;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.PoolTaskRest;
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
import org.dspace.xmlworkflow.storedcomponents.PoolTask;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class PoolTaskConverter
|
public class PoolTaskConverter
|
||||||
extends BrowsableDSpaceObjectConverter<PoolTask, org.dspace.app.rest.model.PoolTaskRest> {
|
implements IndexableObjectConverter<PoolTask, org.dspace.app.rest.model.PoolTaskRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkflowItemConverter workflowItemConverter;
|
private WorkflowItemConverter workflowItemConverter;
|
||||||
@@ -57,7 +57,7 @@ public class PoolTaskConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(IndexableObject object) {
|
||||||
return object instanceof PoolTask;
|
return object instanceof PoolTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
|||||||
* representation of an Relationship and vice versa
|
* representation of an Relationship and vice versa
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class RelationshipConverter extends DSpaceConverter<Relationship, RelationshipRest> {
|
public class RelationshipConverter implements DSpaceConverter<Relationship, RelationshipRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RelationshipTypeConverter relationshipTypeConverter;
|
private RelationshipTypeConverter relationshipTypeConverter;
|
||||||
|
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* representation of an RelationshipType and vice versa
|
* representation of an RelationshipType and vice versa
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class RelationshipTypeConverter extends DSpaceConverter<RelationshipType, RelationshipTypeRest> {
|
public class RelationshipTypeConverter implements DSpaceConverter<RelationshipType, RelationshipTypeRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityTypeConverter entityTypeConverter;
|
private EntityTypeConverter entityTypeConverter;
|
||||||
|
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ResourcePolicyConverter extends DSpaceConverter<ResourcePolicy, ResourcePolicyRest> {
|
public class ResourcePolicyConverter implements DSpaceConverter<ResourcePolicy, ResourcePolicyRest> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ResourcePolicyService resourcePolicyService;
|
ResourcePolicyService resourcePolicyService;
|
||||||
|
@@ -13,18 +13,28 @@ 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
|
||||||
private AuthorityValueService authorityValueService;
|
private AuthorityValueService authorityValueService;
|
||||||
|
|
||||||
public SearchResultsRest.AppliedFilter convertSearchFilter(Context context, SearchFilter searchFilter) {
|
public SearchResultsRest.AppliedFilter convertSearchFilter(Context context, SearchFilter searchFilter) {
|
||||||
|
|
||||||
AuthorityValue authorityValue = null;
|
AuthorityValue authorityValue = null;
|
||||||
if (searchFilter.hasAuthorityOperator()) {
|
if (searchFilter.hasAuthorityOperator()) {
|
||||||
|
// FIXME this is obviously wrong as it assumes that the authorityValueService is able to retrieve the label
|
||||||
|
// for each Authority. Indeed, the AuthorityValueService regardless to his name is specific of the
|
||||||
|
// "SOLRAuthority" implementation and should not have a prominent role.
|
||||||
|
// Moreover, it is not possible to discover which authority is responsible for the value selected in the
|
||||||
|
// facet as the authority is bind at the metadata level and so a facet could contains values from multiple
|
||||||
|
// authorities
|
||||||
|
// https://jira.duraspace.org/browse/DS-4209
|
||||||
authorityValue = authorityValueService.findByUID(context, searchFilter.getValue());
|
authorityValue = authorityValueService.findByUID(context, searchFilter.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SubmissionDefinitionConverter extends DSpaceConverter<SubmissionConfig, SubmissionDefinitionRest> {
|
public class SubmissionDefinitionConverter implements DSpaceConverter<SubmissionConfig, SubmissionDefinitionRest> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager
|
private static final Logger log = org.apache.logging.log4j.LogManager
|
||||||
.getLogger(SubmissionDefinitionConverter.class);
|
.getLogger(SubmissionDefinitionConverter.class);
|
||||||
|
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SubmissionFormConverter extends DSpaceConverter<DCInputSet, SubmissionFormRest> {
|
public class SubmissionFormConverter implements DSpaceConverter<DCInputSet, SubmissionFormRest> {
|
||||||
|
|
||||||
private static final String INPUT_TYPE_ONEBOX = "onebox";
|
private static final String INPUT_TYPE_ONEBOX = "onebox";
|
||||||
private static final String INPUT_TYPE_NAME = "name";
|
private static final String INPUT_TYPE_NAME = "name";
|
||||||
|
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SubmissionSectionConverter extends DSpaceConverter<SubmissionStepConfig, SubmissionSectionRest> {
|
public class SubmissionSectionConverter implements DSpaceConverter<SubmissionStepConfig, SubmissionSectionRest> {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionSectionConverter.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionSectionConverter.class);
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ package org.dspace.app.rest.converter;
|
|||||||
|
|
||||||
import org.dspace.app.rest.model.WorkflowItemRest;
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
import org.dspace.browse.BrowsableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public class WorkflowItemConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(IndexableObject object) {
|
||||||
return object instanceof XmlWorkflowItem;
|
return object instanceof XmlWorkflowItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,8 @@ package org.dspace.app.rest.converter;
|
|||||||
|
|
||||||
import org.dspace.app.rest.model.WorkspaceItemRest;
|
import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||||
import org.dspace.browse.BrowsableObject;
|
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ public class WorkspaceItemConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsModel(BrowsableObject object) {
|
public boolean supportsModel(IndexableObject object) {
|
||||||
return object instanceof WorkspaceItem;
|
return object instanceof WorkspaceItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ public abstract class DiscoveryRestHalLinkFactory<T> extends HalLinkFactory<T, D
|
|||||||
try {
|
try {
|
||||||
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn()
|
UriComponentsBuilder uriBuilder = uriBuilder(getMethodOn()
|
||||||
.getSearchObjects(data.getQuery(), data.getDsoType(),
|
.getSearchObjects(data.getQuery(), data.getDsoType(),
|
||||||
data.getScope(), data.getConfigurationName(),
|
data.getScope(), data.getConfiguration(),
|
||||||
null, null));
|
null, null));
|
||||||
|
|
||||||
return addFilterParams(uriBuilder, data);
|
return addFilterParams(uriBuilder, data);
|
||||||
@@ -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.getConfiguration(), 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.getConfiguration(), null, null));
|
||||||
data.getConfigurationName(), null, null));
|
|
||||||
|
|
||||||
uriBuilder = addSortingParms(uriBuilder, data);
|
uriBuilder = addSortingParms(uriBuilder, data);
|
||||||
|
|
||||||
@@ -75,7 +72,7 @@ public abstract class DiscoveryRestHalLinkFactory<T> extends HalLinkFactory<T, D
|
|||||||
for (SearchResultsRest.AppliedFilter filter : data.getAppliedFilters()) {
|
for (SearchResultsRest.AppliedFilter filter : data.getAppliedFilters()) {
|
||||||
//TODO Make sure the filter format is defined in only one place
|
//TODO Make sure the filter format is defined in only one place
|
||||||
uriComponentsBuilder
|
uriComponentsBuilder
|
||||||
.queryParam("f." + filter.getFilter(), filter.getValue() + "," + filter.getOperator());
|
.queryParam("f." + filter.getFilter(), filter.getValue() + "," + filter.getOperator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ public class FacetConfigurationResourceHalLinkFactory extends DiscoveryRestHalLi
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
list.add(buildLink(Link.REL_SELF, getMethodOn()
|
list.add(buildLink(Link.REL_SELF, getMethodOn()
|
||||||
.getFacetsConfiguration(data.getScope(), data.getConfigurationName(), page)));
|
.getFacetsConfiguration(data.getScope(), data.getConfiguration(), page)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ public class SearchConfigurationResourceHalLinkFactory
|
|||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
||||||
list.add(buildLink(Link.REL_SELF, getMethodOn()
|
list.add(buildLink(Link.REL_SELF, getMethodOn()
|
||||||
.getSearchConfiguration(data.getScope(), data.getConfigurationName())));
|
.getSearchConfiguration(data.getScope(), data.getConfiguration())));
|
||||||
|
|
||||||
list.add(buildLink("objects", getMethodOn().getSearchObjects(null, null, null, null, null, null)));
|
list.add(buildLink("objects", getMethodOn().getSearchObjects(null, null, null, null, null, null)));
|
||||||
list.add(buildLink("facets", getMethodOn().getFacets(null, null, null, null, null, null)));
|
list.add(buildLink("facets", getMethodOn().getFacets(null, null, null, null, null, null)));
|
||||||
|
@@ -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.getConfiguration();
|
||||||
|
|
||||||
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,9 @@ 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.getIndexableObject() != null) {
|
||||||
list.add(utils.linkToSingleResource(data.getDspaceObject(), SearchResultEntryResource.DSPACE_OBJECT_LINK));
|
list.add(utils.linkToSingleResource(data.getIndexableObject(),
|
||||||
|
SearchResultEntryResource.INDEXABLE_OBJECT_LINK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user