1
|
package eu.dnetlib.msro.oai.workflows.nodes;
|
2
|
|
3
|
import org.apache.commons.lang.StringUtils;
|
4
|
import org.apache.commons.logging.Log;
|
5
|
import org.apache.commons.logging.LogFactory;
|
6
|
|
7
|
import com.googlecode.sarasvati.NodeToken;
|
8
|
|
9
|
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
|
10
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
11
|
import eu.dnetlib.msro.oai.workflows.InaccurateProgressProvider;
|
12
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
13
|
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
|
14
|
import eu.dnetlib.msro.workflows.util.ProgressProvider;
|
15
|
|
16
|
public class OAICreateIndexJobNode extends BlackboardJobNode implements ProgressJobNode {
|
17
|
|
18
|
private static final Log log = LogFactory.getLog(OAICreateIndexJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
19
|
|
20
|
private String oaiStoreCollectionParam;
|
21
|
|
22
|
/**
|
23
|
* Name of the fields (comma separated) to be included in the same index. For several indexes separate the fieldNames with ;
|
24
|
* <p>
|
25
|
* Examples: field1,field2 -- one compound index on the given two fields field1,field2;field3,field4 -- two compound indices: one on
|
26
|
* field1 and field2, the other on field3 and field4
|
27
|
* </p>
|
28
|
* **/
|
29
|
private String fieldNames;
|
30
|
|
31
|
@Override
|
32
|
protected String getXqueryForServiceId(final NodeToken token) {
|
33
|
return "//RESOURCE_IDENTIFIER[../RESOURCE_TYPE/@value='OAIStoreServiceResourceType']/@value/string()";
|
34
|
}
|
35
|
|
36
|
@Override
|
37
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
|
38
|
|
39
|
job.setAction("CREATE_OAI_INDEX");
|
40
|
|
41
|
final String collection = token.getEnv().getAttribute(getOaiStoreCollectionParam());
|
42
|
|
43
|
if (StringUtils.isNotBlank(collection)) {
|
44
|
job.getParameters().put("collection", collection);
|
45
|
} else {
|
46
|
log.debug("collection not set");
|
47
|
}
|
48
|
if (StringUtils.isNotBlank(fieldNames)) {
|
49
|
job.getParameters().put("oai_index_fieldNames", fieldNames);
|
50
|
} else {
|
51
|
log.debug("fieldNames not set");
|
52
|
}
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public ProgressProvider getProgressProvider() {
|
57
|
return new InaccurateProgressProvider();
|
58
|
}
|
59
|
|
60
|
public String getFieldNames() {
|
61
|
return fieldNames;
|
62
|
}
|
63
|
|
64
|
public void setFieldNames(final String fieldNames) {
|
65
|
this.fieldNames = fieldNames;
|
66
|
}
|
67
|
|
68
|
public String getOaiStoreCollectionParam() {
|
69
|
return oaiStoreCollectionParam;
|
70
|
}
|
71
|
|
72
|
public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
|
73
|
this.oaiStoreCollectionParam = oaiStoreCollectionParam;
|
74
|
}
|
75
|
|
76
|
}
|