1 |
34342
|
nikon.gasp
|
package eu.dnetlib.validator.service.impl;
|
2 |
21870
|
nikon.gasp
|
|
3 |
|
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
4 |
|
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler;
|
5 |
|
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
|
6 |
41622
|
nikon.gasp
|
import org.apache.log4j.Logger;
|
7 |
21870
|
nikon.gasp
|
|
8 |
|
|
public class NotificationListener extends
|
9 |
41622
|
nikon.gasp
|
BlackboardNotificationHandler<BlackboardServerHandler> {
|
10 |
21870
|
nikon.gasp
|
|
11 |
41622
|
nikon.gasp
|
private static Logger logger = Logger.getLogger(NotificationListener.class);
|
12 |
|
|
private ValidatorManager valManager;
|
13 |
|
|
|
14 |
|
|
@Override
|
15 |
|
|
protected void processJob(BlackboardJob job) {
|
16 |
|
|
super.processJob(job);
|
17 |
|
|
|
18 |
|
|
logger.debug("New Job!");
|
19 |
34342
|
nikon.gasp
|
// String validationSet = job.getParameters().get("validationSet");
|
20 |
|
|
// String validationType = job.getParameters().get("validationType");
|
21 |
41622
|
nikon.gasp
|
String type = job.getParameters().get("type"); //OAI
|
22 |
|
|
String mdstoreId = job.getParameters().get("mdstoreId");
|
23 |
|
|
String guidelines = job.getParameters().get("guidelines");
|
24 |
|
|
String groupBy = job.getParameters().get("groupBy");
|
25 |
|
|
String records = job.getParameters().get("records");
|
26 |
|
|
String outputEpr = job.getParameters().get("outputEpr");
|
27 |
|
|
if (outputEpr == null) {
|
28 |
|
|
outputEpr = "false";
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
String blacklistGuidelines = job.getParameters().get("blacklistGuidelines");
|
32 |
|
|
if (blacklistGuidelines == null)
|
33 |
|
|
blacklistGuidelines = guidelines;
|
34 |
|
|
|
35 |
|
|
String blacklistedRecords = job.getParameters().get("blacklistedRecords");
|
36 |
|
|
if (blacklistedRecords == null) {
|
37 |
|
|
blacklistedRecords = "false";
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
String submissionDate = job.getParameters().get("submissionDate");
|
41 |
|
|
|
42 |
|
|
String jobStatusUpdateInterval = job.getParameters().get("jobStatusUpdateInterval");
|
43 |
|
|
|
44 |
|
|
//the datasource id
|
45 |
|
|
String datasourceId = job.getParameters().get("datasourceId");
|
46 |
|
|
|
47 |
|
|
//the datasource baseUrl, optional for type=OAI, mandatory for type=DNET
|
48 |
|
|
String baseUrl = job.getParameters().get("baseUrl");
|
49 |
|
|
|
50 |
|
|
//the namespace prefix of the datasource, optional
|
51 |
|
|
String datasourceNamespacePrefix = job.getParameters().get("datasourceNamespacePrefix");
|
52 |
|
|
|
53 |
|
|
//the datasource name, optional
|
54 |
|
|
String datasourceName = job.getParameters().get("datasourceName");
|
55 |
|
|
|
56 |
|
|
//json map of other parameters that may be of interest, optional
|
57 |
|
|
String extra_param = job.getParameters().get("extra_param");
|
58 |
|
|
|
59 |
|
|
try {
|
60 |
|
|
int workers = 1;
|
61 |
|
|
int recordsInt = 0;
|
62 |
|
|
int jobStatusUpdateIntervalInt = 100;
|
63 |
|
|
if (records == null || records.equalsIgnoreCase("all"))
|
64 |
|
|
recordsInt = -1;
|
65 |
|
|
else
|
66 |
|
|
recordsInt = Integer.parseInt(records);
|
67 |
|
|
if (recordsInt > -1 && recordsInt < 100)
|
68 |
|
|
workers = 1;
|
69 |
|
|
else
|
70 |
|
|
workers = 4;
|
71 |
|
|
|
72 |
|
|
if (job.getParameters().get("workers") != null)
|
73 |
|
|
workers = Integer.parseInt(job.getParameters().get("workers"));
|
74 |
|
|
|
75 |
|
|
if (jobStatusUpdateInterval != null)
|
76 |
|
|
jobStatusUpdateIntervalInt = Integer.parseInt(jobStatusUpdateInterval);
|
77 |
|
|
|
78 |
|
|
if (recordsInt != 0) {
|
79 |
|
|
logger.debug("New Job of type: " + type + " - workers: " + workers + " - recordsInt: " + recordsInt);
|
80 |
|
|
logger.debug("workers: " + workers);
|
81 |
|
|
logger.debug("recordsInt: " + recordsInt);
|
82 |
|
|
logger.debug("jobStatusUpdateInterval: " + jobStatusUpdateIntervalInt);
|
83 |
|
|
if (job.getAction().equalsIgnoreCase("VALIDATE")) {
|
84 |
|
|
if (type.equalsIgnoreCase("OAI")) {
|
85 |
|
|
logger.debug("type is oai");
|
86 |
|
|
|
87 |
|
|
} else if (type.equalsIgnoreCase("DNET")) {
|
88 |
|
|
logger.debug("type is dnet");
|
89 |
|
|
logger.debug("groupBy: " + groupBy);
|
90 |
38323
|
nikon.gasp
|
// this.getBlackboardHandler().ongoing(job);
|
91 |
41622
|
nikon.gasp
|
valManager.beginDataJobForWorkflow(mdstoreId, guidelines, groupBy, recordsInt, workers, job, this, jobStatusUpdateIntervalInt, Boolean.parseBoolean(outputEpr), Boolean.parseBoolean(blacklistedRecords), blacklistGuidelines);
|
92 |
|
|
}
|
93 |
|
|
} else {
|
94 |
|
|
throw new Exception("Unknown action");
|
95 |
|
|
}
|
96 |
|
|
} else {
|
97 |
|
|
throw new Exception("There are no records in the MDStore.");
|
98 |
|
|
}
|
99 |
|
|
} catch (Exception e) {
|
100 |
|
|
logger.error("Failed to begin the workflow for the job received", e);
|
101 |
|
|
getBlackboardHandler().failed(job, e);
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
21870
|
nikon.gasp
|
|
105 |
41622
|
nikon.gasp
|
public ValidatorManager getValManager() {
|
106 |
|
|
return valManager;
|
107 |
|
|
}
|
108 |
21870
|
nikon.gasp
|
|
109 |
41622
|
nikon.gasp
|
public void setValManager(ValidatorManager valManager) {
|
110 |
|
|
this.valManager = valManager;
|
111 |
|
|
}
|
112 |
30052
|
antonis.le
|
}
|