1
|
package eu.dnetlib.oai;
|
2
|
|
3
|
import javax.annotation.Resource;
|
4
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5
|
|
6
|
import eu.dnetlib.data.information.oai.publisher.info.MDFInfo;
|
7
|
import eu.dnetlib.data.oai.store.conf.OAISetHelper;
|
8
|
import eu.dnetlib.data.oai.store.conf.OAISetsCounter;
|
9
|
import eu.dnetlib.data.oai.store.mongo.MongoPublisherStore;
|
10
|
import eu.dnetlib.data.oai.store.mongo.MongoPublisherStoreDAO;
|
11
|
import eu.dnetlib.data.oai.store.sync.OAIStoreSynchronizer;
|
12
|
import eu.dnetlib.enabling.resultset.client.IterableResultSetClient;
|
13
|
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
|
14
|
import eu.dnetlib.enabling.tools.AbstractBaseService;
|
15
|
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
import org.springframework.beans.factory.annotation.Required;
|
18
|
|
19
|
public class OAIStoreServiceImpl extends AbstractBaseService implements OAIStoreService {
|
20
|
|
21
|
/**
|
22
|
* notification handler.
|
23
|
*/
|
24
|
private NotificationHandler notificationHandler;
|
25
|
|
26
|
@Resource
|
27
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
28
|
@Resource
|
29
|
private OAIStoreSynchronizer synchronizer;
|
30
|
@Resource(name = "oaiSetsCounter")
|
31
|
private OAISetsCounter setsCounter;
|
32
|
@Autowired
|
33
|
private OAISetHelper oaiSetHelper;
|
34
|
|
35
|
@Resource
|
36
|
private ResultSetClientFactory resultSetClientFactory;
|
37
|
|
38
|
@Override
|
39
|
public void feed(final W3CEndpointReference recordsEpr, final MDFInfo mdfInfo, final String dbName) {
|
40
|
this.feed(recordsEpr, mdfInfo, "", dbName);
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public void feed(final W3CEndpointReference recordsEpr, final MDFInfo mdfInfo, final String recordSource, final String dbName) {
|
45
|
IterableResultSetClient rsClient = resultSetClientFactory.getClient(recordsEpr);
|
46
|
this.synchronizer.synchronize(rsClient, 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
|
oaiSetHelper.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
|
MongoPublisherStore s = this.mongoPublisherStoreDAO.getStore(mdfInfo.getSourceFormatName(), mdfInfo.getSourceFormatInterpretation(),
|
72
|
mdfInfo.getSourceFormatLayout(), 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 notificationHandler;
|
83
|
}
|
84
|
|
85
|
@Required
|
86
|
public void setNotificationHandler(final NotificationHandler notificationHandler) {
|
87
|
this.notificationHandler = notificationHandler;
|
88
|
}
|
89
|
|
90
|
public OAIStoreSynchronizer getSynchronizer() {
|
91
|
return synchronizer;
|
92
|
}
|
93
|
|
94
|
public void setSynchronizer(final OAIStoreSynchronizer synchronizer) {
|
95
|
this.synchronizer = synchronizer;
|
96
|
}
|
97
|
|
98
|
public OAISetsCounter getSetsCounter() {
|
99
|
return setsCounter;
|
100
|
}
|
101
|
|
102
|
public void setSetsCounter(final OAISetsCounter setsCounter) {
|
103
|
this.setsCounter = setsCounter;
|
104
|
}
|
105
|
|
106
|
public OAISetHelper getOaiSetHelper() {
|
107
|
return oaiSetHelper;
|
108
|
}
|
109
|
|
110
|
public void setOaiSetHelper(final OAISetHelper oaiSetHelper) {
|
111
|
this.oaiSetHelper = oaiSetHelper;
|
112
|
}
|
113
|
|
114
|
public MongoPublisherStoreDAO getMongoPublisherStoreDAO() {
|
115
|
return mongoPublisherStoreDAO;
|
116
|
}
|
117
|
|
118
|
public void setMongoPublisherStoreDAO(final MongoPublisherStoreDAO mongoPublisherStoreDAO) {
|
119
|
this.mongoPublisherStoreDAO = mongoPublisherStoreDAO;
|
120
|
}
|
121
|
|
122
|
public ResultSetClientFactory getResultSetClientFactory() {
|
123
|
return resultSetClientFactory;
|
124
|
}
|
125
|
|
126
|
public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
|
127
|
this.resultSetClientFactory = resultSetClientFactory;
|
128
|
}
|
129
|
|
130
|
}
|