1
|
package eu.dnetlib.validator.service.impl;
|
2
|
|
3
|
import eu.dnetlib.api.functionality.ValidatorService;
|
4
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
5
|
import eu.dnetlib.domain.ActionType;
|
6
|
import eu.dnetlib.domain.ResourceType;
|
7
|
import eu.dnetlib.domain.enabling.Notification;
|
8
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
9
|
import eu.dnetlib.domain.functionality.validator.RuleSet;
|
10
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
11
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler;
|
12
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
|
13
|
import eu.dnetlib.validator.engine.ValidatorException;
|
14
|
import gr.uoa.di.driver.app.DriverServiceImpl;
|
15
|
import gr.uoa.di.driver.enabling.issn.NotificationListener;
|
16
|
|
17
|
import java.util.List;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
|
21
|
public class ValidatorServiceImpl extends DriverServiceImpl implements
|
22
|
ValidatorService {
|
23
|
|
24
|
private BlackboardNotificationHandler<BlackboardServerHandler> blackboardNotificationHandler = null;
|
25
|
private Logger logger = Logger.getLogger(ValidatorServiceImpl.class);
|
26
|
|
27
|
private ValidatorManager valManager;
|
28
|
|
29
|
// do NOT call directly. It will be called by the
|
30
|
// InitializingServiceRegistrationManager
|
31
|
// after it sets the service EPR and id.
|
32
|
@Override
|
33
|
public void init() {
|
34
|
super.init();
|
35
|
if (this.blackboardNotificationHandler != null) {
|
36
|
this.subscribe(ActionType.UPDATE,
|
37
|
ResourceType.VALIDATORSERVICERESOURCETYPE, this.getServiceEPR()
|
38
|
.getParameter("serviceId"),
|
39
|
"RESOURCE_PROFILE/BODY/BLACKBOARD/LAST_REQUEST",
|
40
|
new NotificationListener() {
|
41
|
@Override
|
42
|
public void processNotification(Notification notification) {
|
43
|
blackboardNotificationHandler.notified(
|
44
|
notification.getSubscriptionId(),
|
45
|
notification.getTopic(),
|
46
|
notification.getIsId(),
|
47
|
notification.getMessage());
|
48
|
logger.debug(notification.getSubscriptionId());
|
49
|
logger.debug(notification.getTopic());
|
50
|
logger.debug(notification.getIsId());
|
51
|
logger.debug(notification.getMessage());
|
52
|
}
|
53
|
});
|
54
|
}
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public StoredJob getStoredJob(int jobId, String groupBy)
|
59
|
throws ValidatorServiceException {
|
60
|
try {
|
61
|
logger.info("received request for job " + jobId);
|
62
|
return valManager.getStoredJob(jobId, groupBy);
|
63
|
} catch (ValidatorException e) {
|
64
|
throw new ValidatorServiceException(e);
|
65
|
}
|
66
|
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public List<StoredJob> getStoredJobs(String userMail, String jobType,
|
71
|
Integer offset, Integer limit, String dateFrom, String dateTo)
|
72
|
throws ValidatorServiceException {
|
73
|
try {
|
74
|
logger.debug("received request for jobs of user " + userMail);
|
75
|
return valManager.getStoredJobs(userMail, jobType, offset, limit, dateFrom, dateTo);
|
76
|
} catch (ValidatorException e) {
|
77
|
throw new ValidatorServiceException(e);
|
78
|
}
|
79
|
}
|
80
|
|
81
|
@Override
|
82
|
public List<StoredJob> getStoredJobsNew(String userMail, String jobType,
|
83
|
Integer offset, Integer limit, String dateFrom, String dateTo, String jobStatus)
|
84
|
throws ValidatorServiceException {
|
85
|
try {
|
86
|
logger.debug("received request for jobs of user " + userMail);
|
87
|
return valManager.getStoredJobs(userMail, jobType, offset, limit, dateFrom, dateTo, jobStatus);
|
88
|
} catch (ValidatorException e) {
|
89
|
throw new ValidatorServiceException(e);
|
90
|
}
|
91
|
}
|
92
|
|
93
|
@Override
|
94
|
public int getStoredJobsTotalNumber(String userMail, String jobType)
|
95
|
throws ValidatorServiceException {
|
96
|
try {
|
97
|
logger.debug("received request for total number of jobs of user " + userMail);
|
98
|
return valManager.getStoredJobsTotalNumber(userMail, jobType);
|
99
|
} catch (ValidatorException e) {
|
100
|
throw new ValidatorServiceException(e);
|
101
|
}
|
102
|
}
|
103
|
|
104
|
@Override
|
105
|
public int getStoredJobsTotalNumberNew(String userMail, String jobType, String jobStatus)
|
106
|
throws ValidatorServiceException {
|
107
|
try {
|
108
|
logger.debug("received request for total number of jobs of user " + userMail);
|
109
|
return valManager.getStoredJobsTotalNumber(userMail, jobType, jobStatus);
|
110
|
} catch (ValidatorException e) {
|
111
|
throw new ValidatorServiceException(e);
|
112
|
}
|
113
|
}
|
114
|
|
115
|
@Override
|
116
|
public List<RuleSet> getRuleSets() throws ValidatorServiceException {
|
117
|
try {
|
118
|
logger.info("received request for rulesets ");
|
119
|
return valManager.getRuleSets();
|
120
|
} catch (ValidatorException e) {
|
121
|
throw new ValidatorServiceException(e);
|
122
|
}
|
123
|
}
|
124
|
|
125
|
@Override
|
126
|
public void submitValidationJob(JobForValidation job)
|
127
|
throws ValidatorServiceException {
|
128
|
try {
|
129
|
logger.info("received request to submit job");
|
130
|
this.valManager.submitJob(job);
|
131
|
} catch (ValidatorException e) {
|
132
|
throw new ValidatorServiceException(e);
|
133
|
}
|
134
|
}
|
135
|
|
136
|
public BlackboardNotificationHandler<BlackboardServerHandler> getBlackboardNotificationHandler() {
|
137
|
return blackboardNotificationHandler;
|
138
|
}
|
139
|
|
140
|
public ValidatorManager getValManager() {
|
141
|
return valManager;
|
142
|
}
|
143
|
|
144
|
public void setValManager(ValidatorManager valManager) {
|
145
|
this.valManager = valManager;
|
146
|
}
|
147
|
|
148
|
public void setBlackboardNotificationHandler(
|
149
|
BlackboardNotificationHandler<BlackboardServerHandler> blackboardNotificationHandler) {
|
150
|
this.blackboardNotificationHandler = blackboardNotificationHandler;
|
151
|
}
|
152
|
|
153
|
}
|