mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +00:00
fix duplicate method
This commit is contained in:
@@ -928,7 +928,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
discoverQuery.setDSpaceObjectFilter(IndexableCollection.TYPE);
|
discoverQuery.setDSpaceObjectFilter(IndexableCollection.TYPE);
|
||||||
discoverQuery.setStart(offset);
|
discoverQuery.setStart(offset);
|
||||||
discoverQuery.setMaxResults(limit);
|
discoverQuery.setMaxResults(limit);
|
||||||
DiscoverResult resp = retrieveCollectionsWithSubmit(context, discoverQuery,community, q);
|
DiscoverResult resp = retrieveCollectionsWithSubmit(context, discoverQuery, null, community, q);
|
||||||
for (IndexableObject solrCollections : resp.getIndexableObjects()) {
|
for (IndexableObject solrCollections : resp.getIndexableObjects()) {
|
||||||
Collection c = ((IndexableCollection) solrCollections).getIndexedObject();
|
Collection c = ((IndexableCollection) solrCollections).getIndexedObject();
|
||||||
collections.add(c);
|
collections.add(c);
|
||||||
@@ -943,56 +943,10 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
DiscoverQuery discoverQuery = new DiscoverQuery();
|
DiscoverQuery discoverQuery = new DiscoverQuery();
|
||||||
discoverQuery.setMaxResults(0);
|
discoverQuery.setMaxResults(0);
|
||||||
discoverQuery.setDSpaceObjectFilter(IndexableCollection.TYPE);
|
discoverQuery.setDSpaceObjectFilter(IndexableCollection.TYPE);
|
||||||
DiscoverResult resp = retrieveCollectionsWithSubmit(context, discoverQuery,community,q);
|
DiscoverResult resp = retrieveCollectionsWithSubmit(context, discoverQuery, null, community, q);
|
||||||
return (int)resp.getTotalSearchResults();
|
return (int)resp.getTotalSearchResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all Indexed Collections where the current user has submit rights. If the user is an Admin,
|
|
||||||
* this is all Indexed Collections. Otherwise, it includes those collections where
|
|
||||||
* an indexed "submit" policy lists either the eperson or one of the eperson's groups
|
|
||||||
*
|
|
||||||
* @param context DSpace context
|
|
||||||
* @param discoverQuery
|
|
||||||
* @param community parent community, could be null
|
|
||||||
* @param q limit the returned collection to those with metadata values matching the query
|
|
||||||
* terms. The terms are used to make also a prefix query on SOLR
|
|
||||||
* so it can be used to implement an autosuggest feature over the collection name
|
|
||||||
* @return discovery search result objects
|
|
||||||
* @throws SQLException if something goes wrong
|
|
||||||
* @throws SearchServiceException if search error
|
|
||||||
*/
|
|
||||||
private DiscoverResult retrieveCollectionsWithSubmit(Context context, DiscoverQuery discoverQuery,
|
|
||||||
Community community, String q) throws SQLException, SearchServiceException {
|
|
||||||
|
|
||||||
StringBuilder query = new StringBuilder();
|
|
||||||
EPerson currentUser = context.getCurrentUser();
|
|
||||||
if (!authorizeService.isAdmin(context)) {
|
|
||||||
String userId = "";
|
|
||||||
if (currentUser != null) {
|
|
||||||
userId = currentUser.getID().toString();
|
|
||||||
}
|
|
||||||
query.append("submit:(e").append(userId);
|
|
||||||
Set<Group> groups = groupService.allMemberGroupsSet(context, currentUser);
|
|
||||||
for (Group group : groups) {
|
|
||||||
query.append(" OR g").append(group.getID());
|
|
||||||
}
|
|
||||||
query.append(")");
|
|
||||||
discoverQuery.addFilterQueries(query.toString());
|
|
||||||
}
|
|
||||||
if (community != null) {
|
|
||||||
discoverQuery.addFilterQueries("location.comm:" + community.getID().toString());
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(q)) {
|
|
||||||
StringBuilder buildQuery = new StringBuilder();
|
|
||||||
String escapedQuery = ClientUtils.escapeQueryChars(q);
|
|
||||||
buildQuery.append(escapedQuery).append(" OR ").append(escapedQuery).append("*");
|
|
||||||
discoverQuery.setQuery(buildQuery.toString());
|
|
||||||
}
|
|
||||||
DiscoverResult resp = searchService.search(context, discoverQuery);
|
|
||||||
return resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all Indexed Collections where the current user has submit rights. If the user is an Admin,
|
* Finds all Indexed Collections where the current user has submit rights. If the user is an Admin,
|
||||||
* this is all Indexed Collections. Otherwise, it includes those collections where
|
* this is all Indexed Collections. Otherwise, it includes those collections where
|
||||||
|
Reference in New Issue
Block a user