1
|
package eu.dnetlib.oai;
|
2
|
|
3
|
import javax.annotation.Resource;
|
4
|
|
5
|
import eu.dnetlib.enabling.resultset.client.ResultSetClient;
|
6
|
import eu.dnetlib.enabling.tools.AbstractBaseService;
|
7
|
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
|
8
|
import eu.dnetlib.oai.mongo.MongoPublisherStore;
|
9
|
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO;
|
10
|
import eu.dnetlib.oai.sets.OAISetsCounter;
|
11
|
import eu.dnetlib.oai.sync.OAIStoreSynchronizer;
|
12
|
import eu.dnetlib.oai.utils.OAIHelper;
|
13
|
import eu.dnetlib.rmi.common.ResultSet;
|
14
|
import eu.dnetlib.rmi.provision.MDFInfo;
|
15
|
import eu.dnetlib.rmi.provision.OAIStoreService;
|
16
|
import eu.dnetlib.utils.MetadataReference;
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
import org.springframework.beans.factory.annotation.Required;
|
19
|
|
20
|
public class OAIStoreServiceImpl extends AbstractBaseService implements OAIStoreService {
|
21
|
|
22
|
/**
|
23
|
* notification handler.
|
24
|
*/
|
25
|
private NotificationHandler notificationHandler;
|
26
|
|
27
|
@Autowired
|
28
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
29
|
@Autowired
|
30
|
private OAIStoreSynchronizer synchronizer;
|
31
|
@Resource(name = "oaiSetsCounter")
|
32
|
private OAISetsCounter setsCounter;
|
33
|
@Autowired
|
34
|
private OAIHelper oaiHelper;
|
35
|
@Autowired
|
36
|
private ResultSetClient resultSetClient;
|
37
|
|
38
|
@Override
|
39
|
public void feed(final ResultSet<String> recordsEpr, final MetadataReference mdfInfo, final String dbName) {
|
40
|
this.feed(recordsEpr, mdfInfo, "", dbName);
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public void feed(final ResultSet<String> recordsEpr, final MetadataReference mdfInfo, final String recordSource, final String dbName) {
|
45
|
final Iterable<String> iter = this.resultSetClient.iter(recordsEpr, String.class);
|
46
|
this.synchronizer.synchronize(iter, mdfInfo, recordSource, dbName, false, null, null);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public void updateSetCounts(final String dbName) {
|
51
|
this.setsCounter.updateCounts("", dbName, null, null);
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public void updateSetCounts(final MDFInfo mdfInfo, final String dbName) {
|
56
|
this.setsCounter.updateCounts(mdfInfo, dbName, null, null);
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public void refreshConfiguration(final String dbName) {
|
61
|
this.oaiHelper.loadConfiguration(dbName);
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public void ensureIndexes(final String dbName) {
|
66
|
this.mongoPublisherStoreDAO.ensureIndex(dbName);
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public void ensureIndexes(final MDFInfo mdfInfo, final String dbName) {
|
71
|
final MongoPublisherStore s = this.mongoPublisherStoreDAO.getStore(mdfInfo.getSourceFormat(), mdfInfo.getSourceInterpretation(),
|
72
|
mdfInfo.getSourceLayout(), dbName);
|
73
|
s.ensureIndices();
|
74
|
}
|
75
|
|
76
|
@Override
|
77
|
public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
|
78
|
getNotificationHandler().notified(subscriptionId, topic, isId, message);
|
79
|
}
|
80
|
|
81
|
public NotificationHandler getNotificationHandler() {
|
82
|
return this.notificationHandler;
|
83
|
}
|
84
|
|
85
|
@Required
|
86
|
public void setNotificationHandler(final NotificationHandler notificationHandler) {
|
87
|
this.notificationHandler = notificationHandler;
|
88
|
}
|
89
|
|
90
|
public OAIStoreSynchronizer getSynchronizer() {
|
91
|
return this.synchronizer;
|
92
|
}
|
93
|
|
94
|
public void setSynchronizer(final OAIStoreSynchronizer synchronizer) {
|
95
|
this.synchronizer = synchronizer;
|
96
|
}
|
97
|
|
98
|
public OAISetsCounter getSetsCounter() {
|
99
|
return this.setsCounter;
|
100
|
}
|
101
|
|
102
|
public void setSetsCounter(final OAISetsCounter setsCounter) {
|
103
|
this.setsCounter = setsCounter;
|
104
|
}
|
105
|
|
106
|
public OAIHelper getOaiSetHelper() {
|
107
|
return this.oaiHelper;
|
108
|
}
|
109
|
|
110
|
public void setOaiSetHelper(final OAIHelper oaiHelper) {
|
111
|
this.oaiHelper = oaiHelper;
|
112
|
}
|
113
|
|
114
|
public MongoPublisherStoreDAO getMongoPublisherStoreDAO() {
|
115
|
return this.mongoPublisherStoreDAO;
|
116
|
}
|
117
|
|
118
|
public void setMongoPublisherStoreDAO(final MongoPublisherStoreDAO mongoPublisherStoreDAO) {
|
119
|
this.mongoPublisherStoreDAO = mongoPublisherStoreDAO;
|
120
|
}
|
121
|
|
122
|
}
|