forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathCommunityUpdates.java
More file actions
48 lines (40 loc) · 1.65 KB
/
CommunityUpdates.java
File metadata and controls
48 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* 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.subscriptions.dSpaceObjectsUpdates;
import java.util.List;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.discovery.DiscoverQuery;
import org.dspace.discovery.DiscoverResult;
import org.dspace.discovery.IndexableObject;
import org.dspace.discovery.SearchService;
import org.dspace.discovery.SearchServiceException;
import org.dspace.subscriptions.service.DSpaceObjectUpdates;
/**
* Class which will be used to find
* all community objects updated related with subscribed DSO
*
* @author Alba Aliu
*/
public class CommunityUpdates implements DSpaceObjectUpdates {
private SearchService searchService;
@Override
public List<IndexableObject> findUpdates(Context context, DSpaceObject dSpaceObject, String frequency)
throws SearchServiceException {
DiscoverQuery discoverQuery = new DiscoverQuery();
discoverQuery.addFilterQueries("search.resourcetype:" + Item.class.getSimpleName());
discoverQuery.addFilterQueries("location.comm:(" + dSpaceObject.getID() + ")");
discoverQuery.addFilterQueries("lastModified_dt:" + this.findLastFrequency(frequency));
DiscoverResult discoverResult = searchService.search(context, discoverQuery);
return discoverResult.getIndexableObjects();
}
public CommunityUpdates(SearchService searchService) {
this.searchService = searchService;
}
}