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.conf.OAISetHelper;
|
9
|
import eu.dnetlib.oai.conf.OAISetsCounter;
|
10
|
import eu.dnetlib.oai.mongo.MongoPublisherStore;
|
11
|
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO;
|
12
|
import eu.dnetlib.oai.sync.OAIStoreSynchronizer;
|
13
|
import eu.dnetlib.rmi.common.ResultSet;
|
14
|
import eu.dnetlib.rmi.provision.MDFInfo;
|
15
|
import eu.dnetlib.rmi.provision.OAIStoreService;
|
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
|
@Autowired
|
27
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
28
|
@Autowired
|
29
|
private OAIStoreSynchronizer synchronizer;
|
30
|
@Resource(name = "oaiSetsCounter")
|
31
|
private OAISetsCounter setsCounter;
|
32
|
@Autowired
|
33
|
private OAISetHelper oaiSetHelper;
|
34
|
@Autowired
|
35
|
private ResultSetClient resultSetClient;
|
36
|
|
37
|
@Override
|
38
|
public void feed(final ResultSet<String> recordsEpr, final MDFInfo mdfInfo, final String dbName) {
|
39
|
this.feed(recordsEpr, mdfInfo, "", dbName);
|
40
|
}
|
41
|
|
42
|
@Override
|
43
|
public void feed(final ResultSet<String> recordsEpr, final MDFInfo mdfInfo, final String recordSource, final String dbName) {
|
44
|
final Iterable<String> iter = this.resultSetClient.iter(recordsEpr, String.class);
|
45
|
this.synchronizer.synchronize(iter, mdfInfo, recordSource, dbName, false, null, null);
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public void updateSetCounts(final String dbName) {
|
50
|
this.setsCounter.updateCounts("", dbName, null, null);
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public void updateSetCounts(final MDFInfo mdfInfo, final String dbName) {
|
55
|
this.setsCounter.updateCounts(mdfInfo, dbName, null, null);
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public void refreshConfiguration(final String dbName) {
|
60
|
this.oaiSetHelper.loadConfiguration(dbName);
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public void ensureIndexes(final String dbName) {
|
65
|
this.mongoPublisherStoreDAO.ensureIndex(dbName);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public void ensureIndexes(final MDFInfo mdfInfo, final String dbName) {
|
70
|
final MongoPublisherStore s = this.mongoPublisherStoreDAO.getStore(mdfInfo.getSourceFormatName(), mdfInfo.getSourceFormatInterpretation(),
|
71
|
mdfInfo.getSourceFormatLayout(), dbName);
|
72
|
s.ensureIndices();
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
|
77
|
getNotificationHandler().notified(subscriptionId, topic, isId, message);
|
78
|
}
|
79
|
|
80
|
public NotificationHandler getNotificationHandler() {
|
81
|
return this.notificationHandler;
|
82
|
}
|
83
|
|
84
|
@Required
|
85
|
public void setNotificationHandler(final NotificationHandler notificationHandler) {
|
86
|
this.notificationHandler = notificationHandler;
|
87
|
}
|
88
|
|
89
|
public OAIStoreSynchronizer getSynchronizer() {
|
90
|
return this.synchronizer;
|
91
|
}
|
92
|
|
93
|
public void setSynchronizer(final OAIStoreSynchronizer synchronizer) {
|
94
|
this.synchronizer = synchronizer;
|
95
|
}
|
96
|
|
97
|
public OAISetsCounter getSetsCounter() {
|
98
|
return this.setsCounter;
|
99
|
}
|
100
|
|
101
|
public void setSetsCounter(final OAISetsCounter setsCounter) {
|
102
|
this.setsCounter = setsCounter;
|
103
|
}
|
104
|
|
105
|
public OAISetHelper getOaiSetHelper() {
|
106
|
return this.oaiSetHelper;
|
107
|
}
|
108
|
|
109
|
public void setOaiSetHelper(final OAISetHelper oaiSetHelper) {
|
110
|
this.oaiSetHelper = oaiSetHelper;
|
111
|
}
|
112
|
|
113
|
public MongoPublisherStoreDAO getMongoPublisherStoreDAO() {
|
114
|
return this.mongoPublisherStoreDAO;
|
115
|
}
|
116
|
|
117
|
public void setMongoPublisherStoreDAO(final MongoPublisherStoreDAO mongoPublisherStoreDAO) {
|
118
|
this.mongoPublisherStoreDAO = mongoPublisherStoreDAO;
|
119
|
}
|
120
|
|
121
|
}
|