Project

General

Profile

« Previous | Next » 

Revision 45256

codebase used to migrate to java8 the production system

View differences:

modules/dnet-oai-common-workflows/trunk/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-oai-common-workflows/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-oai-common-workflows"}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAISetsCountJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.lang.StringUtils;
4

  
5
import com.googlecode.sarasvati.NodeToken;
6

  
7
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
8

  
9
public class OAISetsCountJobNode extends AbstractOAIJobNode {
10

  
11
	private String configuredOnly;
12
	private String oaiStoreCollectionParam;
13
	// overrides the value in the env param oaiStoreCollectionParam
14
	private String oaiStoreCollection;
15

  
16
	@Override
17
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
18
		job.setAction("COUNT_SETS");
19
		job.getParameters().put("configuredOnly", configuredOnly);
20
		job.getParameters().put("collection", getCollectionName(token));
21
		job.getParameters().put("oai_dbName", token.getEnv().getAttribute("oai_dbName"));
22
	}
23

  
24
	private String getCollectionName(final NodeToken token) {
25
		if (StringUtils.isNotBlank(oaiStoreCollection)) return oaiStoreCollection;
26
		else {
27
			String collName = token.getEnv().getAttribute(getOaiStoreCollectionParam());
28
			if (collName == null) {
29
				collName = "";
30
			}
31
			return collName;
32
		}
33
	}
34

  
35
	public String getConfiguredOnly() {
36
		return configuredOnly;
37
	}
38

  
39
	public void setConfiguredOnly(final String configuredOnly) {
40
		this.configuredOnly = configuredOnly;
41
	}
42

  
43
	public String getOaiStoreCollectionParam() {
44
		return oaiStoreCollectionParam;
45
	}
46

  
47
	public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
48
		this.oaiStoreCollectionParam = oaiStoreCollectionParam;
49
	}
50

  
51
	public String getOaiStoreCollection() {
52
		return oaiStoreCollection;
53
	}
54

  
55
	public void setOaiStoreCollection(final String oaiStoreCollection) {
56
		this.oaiStoreCollection = oaiStoreCollection;
57
	}
58

  
59
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/PrepareOaiDataJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import javax.annotation.Resource;
4

  
5
import org.apache.commons.logging.Log;
6
import org.apache.commons.logging.LogFactory;
7

  
8
import com.googlecode.sarasvati.Arc;
9
import com.googlecode.sarasvati.NodeToken;
10

  
11
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
12
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
13
import eu.dnetlib.miscutils.datetime.DateUtils;
14
import eu.dnetlib.msro.rmi.MSROException;
15
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
16

  
17
/**
18
 * The Class PrepareOaiDataJobNode.
19
 */
20
public class PrepareOaiDataJobNode extends SimpleJobNode {
21

  
22
	/** The Constant log. */
23
	private static final Log log = LogFactory.getLog(PrepareOaiDataJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
24

  
25
	/** The service locator. */
26
	@Resource
27
	private UniqueServiceLocator serviceLocator;
28

  
29
	/** Target mongo oai store collection name. **/
30
	private String oaiStoreCollectionParam;
31

  
32
	/** Target mongo database name. **/
33
	private String oaiDBName;
34
	/** Name of the env property where to put the value of oaiDBName. **/
35
	private String oaiDBNameParam;
36

  
37
	private String formatParam = "oai_format";
38

  
39
	private String layoutParam = "oai_layout";
40

  
41
	private String interpretationParam = "oai_interpretation";
42

  
43
	private boolean skipDuplicates = false;
44
	private String duplicateXPath;
45

  
46
	/*
47
	 * (non-Javadoc)
48
	 * 
49
	 * @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
50
	 */
51
	@Override
52
	protected String execute(final NodeToken token) throws Exception {
53

  
54
		log.info("start preparing job");
55

  
56
		// set the target mongo collection name
57
		String format = token.getEnv().getAttribute(getFormatParam());
58
		String interpretation = token.getEnv().getAttribute(getInterpretationParam());
59
		String layout = token.getEnv().getAttribute(getLayoutParam());
60
		token.getEnv().setAttribute(getOaiStoreCollectionParam(), format + "-" + layout + "-" + interpretation);
61

  
62
		String configurationProfile = getConfigurationProfile();
63
		token.getEnv().setAttribute("oaiConfiguration", configurationProfile);
64
		token.getEnv().setAttribute("oai.feed.date", DateUtils.now_ISO8601());
65

  
66
		token.getEnv().setAttribute(getOaiDBNameParam(), getOaiDBName());
67

  
68
		// services.publisher.oai.
69
		// duplicates
70
		token.getEnv().setAttribute("services.publisher.oai.skipDuplicates", skipDuplicates);
71
		token.getEnv().setAttribute("services.publisher.oai.duplicateXPath", duplicateXPath);
72

  
73
		return Arc.DEFAULT_ARC;
74
	}
75

  
76
	/**
77
	 * Gets the configuration profile.
78
	 * 
79
	 * @return the configuration profile
80
	 * @throws MSROException
81
	 *             the MSRO exception
82
	 */
83
	private String getConfigurationProfile() throws MSROException {
84
		try {
85
			return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
86
					"//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'OAIPublisherConfigurationDSResourceType']");
87
		} catch (Exception e) {
88
			throw new MSROException("Cannot find OAI configuration profile", e);
89
		}
90
	}
91

  
92
	/**
93
	 * Gets the oai store collection param.
94
	 * 
95
	 * @return the oai store collection param
96
	 */
97
	public String getOaiStoreCollectionParam() {
98
		return oaiStoreCollectionParam;
99
	}
100

  
101
	/**
102
	 * Sets the oai store collection param.
103
	 * 
104
	 * @param oaiStoreCollectionParam
105
	 *            the new oai store collection param
106
	 */
107
	public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
108
		this.oaiStoreCollectionParam = oaiStoreCollectionParam;
109
	}
110

  
111
	public String getOaiDBName() {
112
		return oaiDBName;
113
	}
114

  
115
	public void setOaiDBName(final String oaiDBName) {
116
		this.oaiDBName = oaiDBName;
117
	}
118

  
119
	public String getOaiDBNameParam() {
120
		return oaiDBNameParam;
121
	}
122

  
123
	public void setOaiDBNameParam(final String oaiDBNameParam) {
124
		this.oaiDBNameParam = oaiDBNameParam;
125
	}
126

  
127
	public String getFormatParam() {
128
		return formatParam;
129
	}
130

  
131
	public void setFormatParam(final String formatParam) {
132
		this.formatParam = formatParam;
133
	}
134

  
135
	public String getLayoutParam() {
136
		return layoutParam;
137
	}
138

  
139
	public void setLayoutParam(final String layoutParam) {
140
		this.layoutParam = layoutParam;
141
	}
142

  
143
	public String getInterpretationParam() {
144
		return interpretationParam;
145
	}
146

  
147
	public void setInterpretationParam(final String interpretationParam) {
148
		this.interpretationParam = interpretationParam;
149
	}
150

  
151
	public boolean isSkipDuplicates() {
152
		return skipDuplicates;
153
	}
154

  
155
	public void setSkipDuplicates(final boolean skipDuplicates) {
156
		this.skipDuplicates = skipDuplicates;
157
	}
158

  
159
	public String getDuplicateXPath() {
160
		return duplicateXPath;
161
	}
162

  
163
	public void setDuplicateXPath(final String duplicateXPath) {
164
		this.duplicateXPath = duplicateXPath;
165
	}
166

  
167
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/SyncOAIStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Required;
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.workflows.nodes.ProgressJobNode;
12
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory;
13
import eu.dnetlib.msro.workflows.util.ProgressProvider;
14
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
15

  
16
public class SyncOAIStoreJobNode extends AbstractOAIJobNode implements ProgressJobNode {
17

  
18
	private static final Log log = LogFactory.getLog(SyncOAIStoreJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
19

  
20
	private String eprParam;
21

  
22
	private ProcessCountingResultSetFactory processCountingResultSetFactory;
23
	
24
	private ResultsetProgressProvider progressProvider;
25

  
26
	private String formatParam, layoutParam, interpretationParam, oai_dbName;
27
	
28
	private boolean alwaysNewRecord = false;
29

  
30
	@Override
31
	void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
32

  
33
		final String eprS = token.getEnv().getAttribute(getEprParam());
34
		this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS);
35
		job.setAction("SYNC");
36
		job.getParameters().put("oai_syncEpr", progressProvider.getEpr().toString());
37
		job.getParameters().put("oai_recordSource", token.getEnv().getAttribute("oai_recordSource"));
38
		job.getParameters().put("oai_formatName", token.getEnv().getAttribute(formatParam));
39
		job.getParameters().put("oai_formatLayout", token.getEnv().getAttribute(layoutParam));
40
		job.getParameters().put("oai_formatInterpretation", token.getEnv().getAttribute(interpretationParam));
41
		job.getParameters().put("oai_dbName", getOai_dbName());		
42
		job.getParameters().put("oai_alwaysNewRecord", String.valueOf(alwaysNewRecord));
43
		token.getEnv().setAttribute("oai_dbName", getOai_dbName());
44
		log.fatal("Job prepared");
45

  
46
	}
47

  
48
	public String getEprParam() {
49
		return eprParam;
50
	}
51

  
52
	public void setEprParam(final String eprParam) {
53
		this.eprParam = eprParam;
54
	}
55

  
56
	public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() {
57
		return processCountingResultSetFactory;
58
	}
59

  
60
	@Required
61
	public void setProcessCountingResultSetFactory(final ProcessCountingResultSetFactory processCountingResultSetFactory) {
62
		this.processCountingResultSetFactory = processCountingResultSetFactory;
63
	}
64

  
65
	public String getFormatParam() {
66
		return formatParam;
67
	}
68

  
69
	public void setFormatParam(final String formatParam) {
70
		this.formatParam = formatParam;
71
	}
72

  
73
	public String getLayoutParam() {
74
		return layoutParam;
75
	}
76

  
77
	public void setLayoutParam(final String layoutParam) {
78
		this.layoutParam = layoutParam;
79
	}
80

  
81
	public String getInterpretationParam() {
82
		return interpretationParam;
83
	}
84

  
85
	public void setInterpretationParam(final String interpretationParam) {
86
		this.interpretationParam = interpretationParam;
87
	}
88

  
89
	public String getOai_dbName() {
90
		return oai_dbName;
91
	}
92

  
93
	public void setOai_dbName(final String oai_dbName) {
94
		this.oai_dbName = oai_dbName;
95
	}
96

  
97
	@Override
98
	public ProgressProvider getProgressProvider() {
99
		return this.progressProvider;
100
	}
101

  
102
	public boolean isAlwaysNewRecord() {
103
		return alwaysNewRecord;
104
	}
105

  
106
	public void setAlwaysNewRecord(boolean alwaysNewRecord) {
107
		this.alwaysNewRecord = alwaysNewRecord;
108
	}
109

  
110
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAICreateIndexJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.lang.StringUtils;
4

  
5
import com.googlecode.sarasvati.NodeToken;
6

  
7
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
8

  
9
public class OAICreateIndexJobNode extends AbstractOAIJobNode {
10

  
11
	private String oaiStoreCollectionParam;
12
	// overrides the value in the env param oaiStoreCollectionParam
13
	private String oaiStoreCollection;
14

  
15
	/**
16
	 * Name of the fields (comma separated) to be included in the same index. For several indexes separate the fieldNames with ;
17
	 * <p>
18
	 * Examples: field1,field2 -- one compound index on the given two fields field1,field2;field3,field4 -- two compound indices: one on
19
	 * field1 and field2, the other on field3 and field4
20
	 * </p>
21
	 * **/
22
	private String fieldNames;
23

  
24
	@Override
25
	public void completePrepareJob(final BlackboardJob job, final NodeToken token) {
26
		job.setAction("CREATE_OAI_INDEX");
27
		job.getParameters().put("collection", getCollectionName(token));
28
		job.getParameters().put("oai_index_fieldNames", fieldNames);
29
	}
30

  
31
	private String getCollectionName(final NodeToken token) {
32
		if (StringUtils.isNotBlank(oaiStoreCollection)) return oaiStoreCollection;
33
		else {
34
			String collName = token.getEnv().getAttribute(getOaiStoreCollectionParam());
35
			if (collName == null) {
36
				collName = "";
37
			}
38
			return collName;
39
		}
40
	}
41

  
42
	public String getFieldNames() {
43
		return fieldNames;
44
	}
45

  
46
	public void setFieldNames(final String fieldNames) {
47
		this.fieldNames = fieldNames;
48
	}
49

  
50
	public String getOaiStoreCollectionParam() {
51
		return oaiStoreCollectionParam;
52
	}
53

  
54
	public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
55
		this.oaiStoreCollectionParam = oaiStoreCollectionParam;
56
	}
57

  
58
	public String getOaiStoreCollection() {
59
		return oaiStoreCollection;
60
	}
61

  
62
	public void setOaiStoreCollection(final String oaiStoreCollection) {
63
		this.oaiStoreCollection = oaiStoreCollection;
64
	}
65

  
66
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/RefreshSetsFromConfigJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4

  
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6

  
7
public class RefreshSetsFromConfigJobNode extends AbstractOAIJobNode {
8

  
9
	@Override
10
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
11
		job.setAction("REFRESH_CONFIG");
12
	}
13

  
14
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAICreateStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4

  
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6

  
7
public class OAICreateStoreJobNode extends AbstractOAIJobNode {
8

  
9
	private String formatParam, layoutParam, interpretationParam;
10

  
11
	@Override
12
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
13
		job.setAction("CREATE_STORE");
14
		job.getParameters().put("format", token.getEnv().getAttribute(formatParam));
15
		job.getParameters().put("layout", token.getEnv().getAttribute(layoutParam));
16
		job.getParameters().put("interpretation", token.getEnv().getAttribute(interpretationParam));
17
	}
18

  
19
	public String getFormatParam() {
20
		return formatParam;
21
	}
22

  
23
	public void setFormatParam(final String formatParam) {
24
		this.formatParam = formatParam;
25
	}
26

  
27
	public String getLayoutParam() {
28
		return layoutParam;
29
	}
30

  
31
	public void setLayoutParam(final String layoutParam) {
32
		this.layoutParam = layoutParam;
33
	}
34

  
35
	public String getInterpretationParam() {
36
		return interpretationParam;
37
	}
38

  
39
	public void setInterpretationParam(final String interpretationParam) {
40
		this.interpretationParam = interpretationParam;
41
	}
42

  
43
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/ReadMDStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import javax.annotation.Resource;
4
import javax.xml.ws.wsaddressing.W3CEndpointReference;
5

  
6
import org.apache.commons.logging.Log;
7
import org.apache.commons.logging.LogFactory;
8

  
9
import com.googlecode.sarasvati.Arc;
10
import com.googlecode.sarasvati.NodeToken;
11

  
12
import eu.dnetlib.data.mdstore.MDStoreService;
13
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
14
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
15

  
16
public class ReadMDStoreJobNode extends SimpleJobNode {
17

  
18
	private static final Log log = LogFactory.getLog(ReadMDStoreJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
19

  
20
	/**
21
	 * Name of the env attribute where the output epr will be saved.
22
	 */
23
	private String eprParam;
24

  
25
	// info about the metadata format of the records I'm reading
26
	private String mdFormatName;
27
	private String mdFormatLayout;
28
	private String mdFormatInterpretation;
29

  
30
	/** Name of the datasource whose records I am reading **/
31
	private String datasource;
32

  
33
	/**
34
	 * Identifier of the input mdstore.
35
	 */
36
	private String mdstoreId;
37

  
38
	@Resource
39
	private UniqueServiceLocator serviceLocator;
40

  
41
	@Override
42
	protected String execute(final NodeToken token) throws Exception {
43

  
44
		/*
45
		 * public W3CEndpointReference deliverMDRecords( String mdId, String from, String until, String recordFilter) throws
46
		 * MDStoreServiceException;
47
		 */
48
		W3CEndpointReference epr = serviceLocator.getService(MDStoreService.class, mdstoreId).deliverMDRecords(mdstoreId, null, null, null);
49
		log.debug("Created W3CEndpointReference to read from mdstoreId = " + mdstoreId);
50
		token.getEnv().setAttribute(eprParam, epr.toString());
51
		token.getEnv().setAttribute("oai_formatName", mdFormatName);
52
		token.getEnv().setAttribute("oai_formatLayout", mdFormatLayout);
53
		token.getEnv().setAttribute("oai_formatInterpretation", mdFormatInterpretation);
54
		token.getEnv().setAttribute("oai_recordSource", datasource);
55
		return Arc.DEFAULT_ARC;
56
	}
57

  
58
	public String getEprParam() {
59
		return eprParam;
60
	}
61

  
62
	public void setEprParam(final String eprParam) {
63
		this.eprParam = eprParam;
64
	}
65

  
66
	public String getMdFormatName() {
67
		return mdFormatName;
68
	}
69

  
70
	public void setMdFormatName(final String mdFormatName) {
71
		this.mdFormatName = mdFormatName;
72
	}
73

  
74
	public String getMdFormatLayout() {
75
		return mdFormatLayout;
76
	}
77

  
78
	public void setMdFormatLayout(final String mdFormatLayout) {
79
		this.mdFormatLayout = mdFormatLayout;
80
	}
81

  
82
	public String getMdFormatInterpretation() {
83
		return mdFormatInterpretation;
84
	}
85

  
86
	public void setMdFormatInterpretation(final String mdFormatInterpretation) {
87
		this.mdFormatInterpretation = mdFormatInterpretation;
88
	}
89

  
90
	public String getDatasource() {
91
		return datasource;
92
	}
93

  
94
	public void setDatasource(final String datasource) {
95
		this.datasource = datasource;
96
	}
97

  
98
	public String getMdstoreId() {
99
		return mdstoreId;
100
	}
101

  
102
	public void setMdstoreId(final String mdstoreId) {
103
		this.mdstoreId = mdstoreId;
104
	}
105

  
106
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAIDropStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.lang.StringUtils;
4

  
5
import com.googlecode.sarasvati.NodeToken;
6
import com.googlecode.sarasvati.env.Env;
7

  
8
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
9

  
10
public class OAIDropStoreJobNode extends AbstractOAIJobNode {
11

  
12
	private String formatParam, layoutParam, interpretationParam;
13
	// name of the env attribute where you can find the set name
14
	private String setSpecParam;
15
	private String setSpec;
16

  
17
	@Override
18
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
19
		job.setAction("DROP_STORE");
20
		job.getParameters().put("format", token.getEnv().getAttribute(formatParam));
21
		job.getParameters().put("layout", token.getEnv().getAttribute(layoutParam));
22
		job.getParameters().put("interpretation", token.getEnv().getAttribute(interpretationParam));
23
		String set = getTheSetName(token.getEnv());
24
		if (StringUtils.isNotBlank(set)) {
25
			job.getParameters().put("set", set);
26
		}
27
	}
28

  
29
	private String getTheSetName(final Env env) {
30
		if (StringUtils.isNotBlank(setSpec)) return setSpec;
31
		else return env.getAttribute(setSpecParam);
32

  
33
	}
34

  
35
	public String getFormatParam() {
36
		return formatParam;
37
	}
38

  
39
	public void setFormatParam(final String formatParam) {
40
		this.formatParam = formatParam;
41
	}
42

  
43
	public String getLayoutParam() {
44
		return layoutParam;
45
	}
46

  
47
	public void setLayoutParam(final String layoutParam) {
48
		this.layoutParam = layoutParam;
49
	}
50

  
51
	public String getInterpretationParam() {
52
		return interpretationParam;
53
	}
54

  
55
	public void setInterpretationParam(final String interpretationParam) {
56
		this.interpretationParam = interpretationParam;
57
	}
58

  
59
	public String getSetNameParam() {
60
		return setSpecParam;
61
	}
62

  
63
	public void setSetNameParam(final String setNameParam) {
64
		this.setSpecParam = setNameParam;
65
	}
66

  
67
	public String getSetName() {
68
		return setSpec;
69
	}
70

  
71
	public void setSetName(final String setName) {
72
		this.setSpec = setName;
73
	}
74

  
75
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAIEnsureIndexesJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.lang.StringUtils;
4

  
5
import com.googlecode.sarasvati.NodeToken;
6

  
7
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
8

  
9
public class OAIEnsureIndexesJobNode extends AbstractOAIJobNode {
10

  
11
	private String oaiStoreCollectionParam;
12
	// overrides the value in the env param oaiStoreCollectionParam
13
	private String oaiStoreCollection;
14

  
15
	@Override
16
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
17

  
18
		job.setAction("ENSURE_INDEXES");
19
		job.getParameters().put("collection", getCollectionName(token));
20
	}
21

  
22
	private String getCollectionName(final NodeToken token) {
23
		if (StringUtils.isNotBlank(oaiStoreCollection)) return oaiStoreCollection;
24
		else {
25
			String collName = token.getEnv().getAttribute(getOaiStoreCollectionParam());
26
			return StringUtils.isBlank(collName)? "" : collName;
27
		}
28
	}
29

  
30
	public String getOaiStoreCollectionParam() {
31
		return oaiStoreCollectionParam;
32
	}
33

  
34
	public void setOaiStoreCollectionParam(final String oaiStoreCollectionParam) {
35
		this.oaiStoreCollectionParam = oaiStoreCollectionParam;
36
	}
37

  
38
	public String getOaiStoreCollection() {
39
		return oaiStoreCollection;
40
	}
41

  
42
	public void setOaiStoreCollection(final String oaiStoreCollection) {
43
		this.oaiStoreCollection = oaiStoreCollection;
44
	}
45

  
46
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/AbstractOAIJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import org.apache.commons.lang.StringUtils;
4

  
5
import com.googlecode.sarasvati.NodeToken;
6

  
7
import eu.dnetlib.data.oai.store.OAIStoreService;
8
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
9
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
10
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
11

  
12
public abstract class AbstractOAIJobNode extends BlackboardJobNode {
13

  
14
	private String dbNameParam;
15
	// overrides the value in the env param dbNameParam
16
	private String dbName;
17

  
18
	protected String getTheDBName(final NodeToken token) {
19
		if (StringUtils.isNotBlank(dbName)) {
20
			return dbName;
21
		} else {
22
			return token.getEnv().getAttribute(getDbNameParam());
23
		}
24
	}
25

  
26
	@Override
27
	protected String obtainServiceId(final NodeToken token) {
28
		return getServiceLocator().getServiceId(OAIStoreService.class);
29
	}
30

  
31
	@Override
32
	protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
33
		job.getParameters().put("oai_dbName", getTheDBName(token));
34
		completePrepareJob(job, token);
35
	}
36

  
37
	abstract void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException;
38

  
39
	public String getDbNameParam() {
40
		return dbNameParam;
41
	}
42

  
43
	public void setDbNameParam(final String dbNameParam) {
44
		this.dbNameParam = dbNameParam;
45
	}
46

  
47
	public String getDbName() {
48
		return dbName;
49
	}
50

  
51
	public void setDbName(final String dbName) {
52
		this.dbName = dbName;
53
	}
54
}
modules/dnet-oai-common-workflows/trunk/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/SetCurrentOAIDBJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import javax.annotation.Resource;
4

  
5
import org.apache.commons.lang.StringUtils;
6
import org.apache.commons.logging.Log;
7
import org.apache.commons.logging.LogFactory;
8

  
9
import com.googlecode.sarasvati.Arc;
10
import com.googlecode.sarasvati.NodeToken;
11

  
12
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
13
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
14
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
15

  
16
/**
17
 * The Class PrepareOaiDataJobNode.
18
 */
19
public class SetCurrentOAIDBJobNode extends SimpleJobNode {
20

  
21
	/** The Constant log. */
22
	private static final Log log = LogFactory.getLog(SetCurrentOAIDBJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	/** The service locator. */
25
	@Resource
26
	private UniqueServiceLocator serviceLocator;
27

  
28
	/** Target mongo database name. **/
29
	private String oaiDBName;
30
	/** Name of the env property where to put the value of oaiDBName. **/
31
	private String oaiDBNameParam;
32

  
33
	private String xpathToCurrentDB = "//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'OAIPublisherConfigurationDSResourceType']//CONFIGURATION/CURRENTDB";
34

  
35
	protected String getTheDBName(final NodeToken token) {
36
		if (StringUtils.isNotBlank(oaiDBName)) {
37
			return oaiDBName;
38
		} else {
39
			return token.getEnv().getAttribute(oaiDBNameParam);
40
		}
41
	}
42

  
43
	/*
44
	 * (non-Javadoc)
45
	 * 
46
	 * @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
47
	 */
48
	@Override
49
	protected String execute(final NodeToken token) throws Exception {
50
		String dbToSet = getTheDBName(token);
51
		log.fatal("Setting OAI Publisher to use db " + dbToSet);
52
		String xUpdate = "update value " + xpathToCurrentDB + " with '" + dbToSet + "'";
53
		this.serviceLocator.getService(ISRegistryService.class).executeXUpdate(xUpdate);
54
		return Arc.DEFAULT_ARC;
55
	}
56

  
57
	public String getOaiDBName() {
58
		return oaiDBName;
59
	}
60

  
61
	public void setOaiDBName(final String oaiDBName) {
62
		this.oaiDBName = oaiDBName;
63
	}
64

  
65
	public String getOaiDBNameParam() {
66
		return oaiDBNameParam;
67
	}
68

  
69
	public void setOaiDBNameParam(final String oaiDBNameParam) {
70
		this.oaiDBNameParam = oaiDBNameParam;
71
	}
72

  
73
	public String getXpathToCurrentDB() {
74
		return xpathToCurrentDB;
75
	}
76

  
77
	public void setXpathToCurrentDB(final String xpathToCurrentDB) {
78
		this.xpathToCurrentDB = xpathToCurrentDB;
79

  
80
	}
81
}
modules/dnet-oai-common-workflows/trunk/src/main/resources/eu/dnetlib/test/profiles/workflows/oai/oai.consistency.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<RESOURCE_PROFILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
    <HEADER>
4
        <RESOURCE_IDENTIFIER value="440e5de7-7106-469c-8c8d-89c261a1e09d_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl"/>
5
        <RESOURCE_TYPE value="WorkflowDSResourceType"/>
6
        <RESOURCE_KIND value="WorkflowDSResources"/>
7
        <RESOURCE_URI value=""/>
8
        <DATE_OF_CREATION value="2014-07-16T18:13:51.0Z"/>
9
    </HEADER>
10
    <BODY>
11
        <WORKFLOW_NAME>OAI Post feed</WORKFLOW_NAME>
12
        <WORKFLOW_TYPE>Provision</WORKFLOW_TYPE>
13
        <WORKFLOW_PRIORITY>30</WORKFLOW_PRIORITY>
14
		<CONFIGURATION start="manual">
15
			<NODE name="setFormat" type="SetFormatInfo" isStart="true">
16
				<DESCRIPTION />
17
				<PARAMETERS>
18
					<PARAM name="format" type="string" managedBy="user" required="true">oaf</PARAM>
19
					<PARAM name="layout" type="string" managedBy="user" required="true">index</PARAM>
20
					<PARAM name="interpretation" type="string" managedBy="user" required="true">openaire</PARAM>	
21
					<PARAM name="formatParam" type="string" managedBy="system" required="true">oai_format</PARAM>
22
					<PARAM name="layoutParam" type="string" managedBy="system" required="true">oai_layout</PARAM>
23
					<PARAM name="interpretationParam" type="string" managedBy="system" required="true">oai_interpretation</PARAM>													
24
				</PARAMETERS>
25
				<ARCS>
26
					<ARC to="prepareOAI" />
27
				</ARCS>
28
			</NODE>	
29
			<NODE name="prepareOAI" type="PrepareOaiJob">
30
				<DESCRIPTION>Prepare target OAI store</DESCRIPTION>
31
				<PARAMETERS>
32
					<PARAM name="oaiStoreCollectionParam" type="string" managedBy="system" required="true">oaiStoreCollection</PARAM>
33
					<PARAM name="oaiDBName" type="string" managedBy="user" required="true">oaistore</PARAM>
34
					<PARAM name="oaiDBNameParam" type="string" managedBy="system" required="true">oai_dbName</PARAM>
35
				</PARAMETERS>
36
				<ARCS>
37
					<ARC to="RefreshConfig" />
38
				</ARCS>
39
			</NODE>
40
			<NODE name="RefreshConfig" type="OAIRefreshConfiguration">
41
				<DESCRIPTION>Reads the current OAI configuration and upsert OAI sets accordingly</DESCRIPTION>
42
				<PARAMETERS>
43
					<PARAM name="dbNameParam" required="true" type="string" managedBy="system">oai_dbName</PARAM>
44
				</PARAMETERS>
45
				<ARCS>
46
					<ARC to="SELECT_UPDATE_INDICES" />
47
				</ARCS>
48
			</NODE>
49
			<NODE name="SELECT_UPDATE_INDICES" type="Selection">
50
				<DESCRIPTION>Do we update the indices on the oai store?</DESCRIPTION>
51
				<PARAMETERS>
52
					<PARAM function="validValues(['YES', 'NO'])" managedBy="user" name="selection" required="true" type="string">YES</PARAM>
53
				</PARAMETERS>
54
				<ARCS>
55
					<ARC name="YES" to="CompoundIndexes" />
56
					<ARC name="NO" to="SELECT_REFRESH_SET_COUNTS" />
57
				</ARCS>
58
			</NODE>
59
			<NODE name="CompoundIndexes" type="OAICreateIndex">
60
				<DESCRIPTION>Create composite indexes for the OAI store</DESCRIPTION>
61
				<PARAMETERS>
62
					<PARAM name="dbNameParam" required="true" type="string" managedBy="system">oai_dbName</PARAM>
63
					<PARAM name="oaiStoreCollectionParam" type="string" managedBy="system" required="true">oaiStoreCollection</PARAM>
64
					<PARAM name="fieldNames" type="string" managedBy="user" required="true">set,datestamp;license,oaftype;set,oaftype;oaftype,funder;resulttypeid,oaftype</PARAM>
65
				</PARAMETERS>
66
				<ARCS>
67
					<ARC to="ConfigIndexes" />
68
				</ARCS>
69
			</NODE>
70
			<NODE name="ConfigIndexes" type="OAIEnsureIndexes" >
71
				<DESCRIPTION>Ensure an index exists on fields as specified in the configuration profile</DESCRIPTION>
72
				<PARAMETERS>
73
					<PARAM name="dbNameParam" required="true" type="string" managedBy="system">oai_dbName</PARAM>
74
					<PARAM name="oaiStoreCollectionParam" type="string" managedBy="system" required="true">oaiStoreCollection</PARAM>
75
				</PARAMETERS>
76
				<ARCS>
77
					<ARC to="SELECT_REFRESH_SET_COUNTS" />
78
				</ARCS>
79
			</NODE>			
80
			<NODE name="SELECT_REFRESH_SET_COUNTS" type="Selection">
81
				<DESCRIPTION>Do we refresh the sets counts?</DESCRIPTION>
82
				<PARAMETERS>
83
					<PARAM function="validValues(['YES', 'NO'])" managedBy="user" name="selection" required="true" type="string">YES</PARAM>
84
				</PARAMETERS>
85
				<ARCS>
86
					<ARC name="YES" to="SetsCount" />
87
					<ARC name="NO" to="SELECT_SWITCH_OAIDB" />
88
				</ARCS>
89
			</NODE>
90
			<NODE name="SetsCount" type="OAISetsCountUpdate">
91
				<DESCRIPTION>Count records in each OAI set, for each exported metadata format linked to the given oai collection</DESCRIPTION>
92
				<PARAMETERS>
93
				<PARAM name="dbNameParam" required="true" type="string" managedBy="system">oai_dbName</PARAM>
94
					<PARAM name="oaiStoreCollectionParam" type="string" managedBy="system" required="true">oaiStoreCollection</PARAM>
95
					<PARAM name="configuredOnly" type="boolean" managedBy="user" required="true">false</PARAM>	
96
				</PARAMETERS>
97
				<ARCS>
98
					<ARC to="SELECT_SWITCH_OAIDB" />
99
				</ARCS>
100
			</NODE>			
101
			
102
			<NODE name="SELECT_SWITCH_OAIDB" type="Selection">
103
				<DESCRIPTION>Do we switch the oaistore db for the public now? If not, you can change the value manually on the configuration profile</DESCRIPTION>
104
				<PARAMETERS>
105
					<PARAM function="validValues(['YES', 'NO'])" managedBy="user" name="selection" required="true" type="string">YES</PARAM>
106
				</PARAMETERS>
107
				<ARCS>
108
					<ARC name="YES" to="SetOAIDB" />
109
					<ARC name="NO" to="success" />
110
				</ARCS>
111
			</NODE>
112
			<NODE name="SetOAIDB" type="SetCurrentOAIDB">
113
				<DESCRIPTION>Update the currentdb in the OAI configuration profile to the value in oai_dbName</DESCRIPTION>
114
				<PARAMETERS>
115
					<PARAM name="oaiDBNameParam" required="true" type="string" managedBy="system">oai_dbName</PARAM>
116
				</PARAMETERS>
117
				<ARCS>
118
					<ARC to="success" />
119
				</ARCS>
120
			</NODE>
121
			
122
		</CONFIGURATION>
123
		<STATUS />
124
	</BODY>
125
</RESOURCE_PROFILE>
modules/dnet-oai-common-workflows/trunk/src/main/resources/eu/dnetlib/test/profiles/workflows/oai/oai-consistency.meta.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<RESOURCE_PROFILE>
3
	<HEADER>
4
		<RESOURCE_IDENTIFIER value="f2779189-b313-4b14-867b-09afd07eeb8f_TWV0YVdvcmtmbG93RFNSZXNvdXJjZXMvTWV0YVdvcmtmbG93RFNSZXNvdXJjZVR5cGU=" />
5
		<RESOURCE_TYPE value="MetaWorkflowDSResourceType" />
6
		<RESOURCE_KIND value="MetaWorkflowDSResources" />
7
		<RESOURCE_URI value="" />
8
		<DATE_OF_CREATION value="2013-11-25T17:47:51.0Z" />
9
	</HEADER>
10
	<BODY>
11
		<METAWORKFLOW_NAME family="provision">OAI consistency</METAWORKFLOW_NAME>
12
		<METAWORKFLOW_DESCRIPTION>Perform operations to ensure data consistency in OAI store</METAWORKFLOW_DESCRIPTION>
13
		<METAWORKFLOW_SECTION>InfoSpace Provision</METAWORKFLOW_SECTION>
14
		<ADMIN_EMAIL/>
15
		<CONFIGURATION status="EXECUTABLE">
16
			<WORKFLOW id="440e5de7-7106-469c-8c8d-89c261a1e09d_V29ya2Zsb3dEU1Jlc291cmNlcy9Xb3JrZmxvd0RTUmVzb3VyY2VUeXBl" name="OAI Post feed"/>
17
		</CONFIGURATION>
18
		<SCHEDULING enabled="false">
19
			<CRON>29 5 22 ? * *</CRON>
20
			<MININTERVAL>10080</MININTERVAL>
21
		</SCHEDULING>
22
	</BODY>
23
</RESOURCE_PROFILE>
modules/dnet-oai-common-workflows/trunk/src/main/resources/eu/dnetlib/applicationContext-dnet-oai-common-workflows.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
4
	xmlns:util="http://www.springframework.org/schema/util"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
6
 		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
7
        http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
8

  
9
	<bean id="wfNodePrepareOaiJob"
10
		class="eu.dnetlib.msro.oai.workflows.nodes.PrepareOaiDataJobNode"
11
		scope="prototype" />
12

  
13
	<!-- OAI feed -->
14
	<bean id="wfNodeSyncOAIStores" class="eu.dnetlib.msro.oai.workflows.nodes.SyncOAIStoreJobNode"
15
		scope="prototype" p:processCountingResultSetFactory-ref="msroProcessCountingResultSetFactory" />
16

  
17
	<!-- Update OAI sets count -->
18
	<bean id="wfNodeOAISetsCountUpdate" class="eu.dnetlib.msro.oai.workflows.nodes.OAISetsCountJobNode"
19
		scope="prototype" />
20

  
21
	<!-- Reload the current sets configuration -->
22
	<bean id="wfNodeOAIRefreshConfiguration"
23
		class="eu.dnetlib.msro.oai.workflows.nodes.RefreshSetsFromConfigJobNode"
24
		scope="prototype" />
25
	<!-- Keeping the old name as alias, just to avoid things at runtime to fail 
26
		becasue of the renaming -->
27
	<alias name="wfNodeOAIRefreshConfiguration" alias="wfNodeRefreshSetsFromConfig" />
28

  
29

  
30
	<!-- Refresh sets based on current config -->
31
	<bean id="wfNodeOAIEnsureIndexes"
32
		class="eu.dnetlib.msro.oai.workflows.nodes.OAIEnsureIndexesJobNode"
33
		scope="prototype" />
34

  
35
	<!-- Read from MDStore -->
36
	<bean id="wfNodeReadMDStore" class="eu.dnetlib.msro.oai.workflows.nodes.ReadMDStoreJobNode"
37
		scope="prototype" />
38

  
39
	<!-- Create new OAI store if needed -->
40
	<bean id="wfNodeOAICreateStore"
41
		class="eu.dnetlib.msro.oai.workflows.nodes.OAICreateStoreJobNode"
42
		scope="prototype" />
43

  
44
	<!-- Create new (compound) index on OAI stores -->
45
	<bean id="wfNodeOAICreateIndex"
46
		class="eu.dnetlib.msro.oai.workflows.nodes.OAICreateIndexJobNode"
47
		scope="prototype" />
48

  
49
	<!-- Drop OAI store -->
50
	<bean id="wfNodeOAIDropStore" class="eu.dnetlib.msro.oai.workflows.nodes.OAIDropStoreJobNode"
51
		scope="prototype" />
52

  
53
	<!-- Set backend db -->
54
	<bean id="wfNodeSetCurrentOAIDB"
55
		class="eu.dnetlib.msro.oai.workflows.nodes.SetCurrentOAIDBJobNode"
56
		scope="prototype" />
57
</beans>
modules/dnet-oai-common-workflows/trunk/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
	</parent>
8
	<modelVersion>4.0.0</modelVersion>
9
	<groupId>eu.dnetlib</groupId>
10
	<artifactId>dnet-oai-common-workflows</artifactId>
11
	<packaging>jar</packaging>
12
	<version>3.2.4-SNAPSHOT</version>
13
	<scm>
14
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-oai-common-workflows/trunk</developerConnection>
15
	</scm>
16
	<dependencies>
17
		<dependency>
18
			<groupId>eu.dnetlib</groupId>
19
			<artifactId>dnet-msro-service</artifactId>
20
			<version>[2.1.0,3.0.0)</version>
21
			<scope>provided</scope>
22
		</dependency>
23
		<dependency>
24
			<groupId>eu.dnetlib</groupId>
25
			<artifactId>dnet-oai-store-service-rmi</artifactId>
26
			<version>[4.0.0,5.0.0)</version>
27
		</dependency>
28
	</dependencies>
29
</project>
modules/dnet-oai-common-workflows/branches/nodeRefactoring/deploy.info
1
{"type_source": "SVN", "goal": "package -U source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-oai-common-workflows/branches/refactoring/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-oai-common-workflows"}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAISetsCountJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6

  
7
public class OAISetsCountJobNode extends AbstractOAIJobNode {
8

  
9
	private String configuredOnly;
10

  
11
	@Override
12
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
13
		job.setAction("COUNT_SETS");
14
		job.getParameters().put(OAIParameterNames.OAI_CONFIGURED_SETS_ONLY, getConfiguredOnly());
15
	}
16

  
17
	public String getConfiguredOnly() {
18
		return configuredOnly;
19
	}
20

  
21
	public void setConfiguredOnly(final String configuredOnly) {
22
		this.configuredOnly = configuredOnly;
23
	}
24

  
25
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/PrepareOaiDataJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import javax.annotation.Resource;
4

  
5
import com.googlecode.sarasvati.Arc;
6
import com.googlecode.sarasvati.NodeToken;
7
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
8
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
9
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
10
import eu.dnetlib.msro.rmi.MSROException;
11
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
12
import org.apache.commons.lang.StringUtils;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15

  
16
/**
17
 * The Class PrepareOaiDataJobNode. Sets the OAI parameters in the env using the constants in OAIParameterNames, to be used by subsequent nodes.
18
 */
19
public class PrepareOaiDataJobNode extends SimpleJobNode {
20

  
21
	/** The Constant log. */
22
	private static final Log log = LogFactory.getLog(PrepareOaiDataJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	/** The service locator. */
25
	@Resource
26
	private UniqueServiceLocator serviceLocator;
27

  
28
	private String oaiDbName;
29
	private String oaiFormat;
30
	private String oaiLayout;
31
	private String oaiInterpretation;
32
	private String oaiSource;
33

  
34
	/*
35
	 * (non-Javadoc)
36
	 * 
37
	 * @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
38
	 */
39
	@Override
40
	protected String execute(final NodeToken token) throws Exception {
41

  
42
		log.info("start preparing job");
43
		setIfNotBlank(OAIParameterNames.OAI_DB, oaiDbName, token);
44
		setIfNotBlank(OAIParameterNames.OAI_FORMAT_NAME, oaiFormat, token);
45
		setIfNotBlank(OAIParameterNames.OAI_FORMAT_LAYOUT, oaiLayout, token);
46
		setIfNotBlank(OAIParameterNames.OAI_FORMAT_INTERPRETATION, oaiInterpretation, token);
47
		setIfNotBlank(OAIParameterNames.OAI_COLLECTON, oaiFormat + "-" + oaiLayout + "-" + oaiInterpretation, token);
48

  
49
		String configurationProfile = getConfigurationProfile();
50
		setIfNotBlank(OAIParameterNames.OAI_CONFIGURATION_PROFILE, configurationProfile, token);
51
		return Arc.DEFAULT_ARC;
52
	}
53

  
54
	private void setIfNotBlank(final String attrName, final String attrValue, final NodeToken token){
55
		if(StringUtils.isNotBlank(attrValue))
56
			token.getEnv().setAttribute(attrName, attrValue);
57
	}
58

  
59
	/**
60
	 * Gets the configuration profile.
61
	 * 
62
	 * @return the configuration profile
63
	 * @throws MSROException
64
	 *             the MSRO exception
65
	 */
66
	private String getConfigurationProfile() throws MSROException {
67
		try {
68
			return this.serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
69
					"//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'OAIPublisherConfigurationDSResourceType']");
70
		} catch (Exception e) {
71
			throw new MSROException("Cannot find OAI configuration profile", e);
72
		}
73
	}
74

  
75
	public String getOaiDbName() {
76
		return oaiDbName;
77
	}
78

  
79
	public void setOaiDbName(final String oaiDbName) {
80
		this.oaiDbName = oaiDbName;
81
	}
82

  
83
	public String getOaiFormat() {
84
		return oaiFormat;
85
	}
86

  
87
	public void setOaiFormat(final String oaiFormat) {
88
		this.oaiFormat = oaiFormat;
89
	}
90

  
91
	public String getOaiLayout() {
92
		return oaiLayout;
93
	}
94

  
95
	public void setOaiLayout(final String oaiLayout) {
96
		this.oaiLayout = oaiLayout;
97
	}
98

  
99
	public String getOaiInterpretation() {
100
		return oaiInterpretation;
101
	}
102

  
103
	public void setOaiInterpretation(final String oaiInterpretation) {
104
		this.oaiInterpretation = oaiInterpretation;
105
	}
106

  
107
	public String getOaiSource() {
108
		return oaiSource;
109
	}
110

  
111
	public void setOaiSource(final String oaiSource) {
112
		this.oaiSource = oaiSource;
113
	}
114

  
115

  
116
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/SyncOAIStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
5
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
6
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
7
import eu.dnetlib.miscutils.datetime.DateUtils;
8
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
9
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory;
10
import eu.dnetlib.msro.workflows.util.ProgressProvider;
11
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
12
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
14
import org.springframework.beans.factory.annotation.Required;
15

  
16
public class SyncOAIStoreJobNode extends AbstractOAIJobNode implements ProgressJobNode {
17

  
18
	private static final Log log = LogFactory.getLog(SyncOAIStoreJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
19

  
20
	private ProcessCountingResultSetFactory processCountingResultSetFactory;
21
	
22
	private ResultsetProgressProvider progressProvider;
23

  
24
	private String eprParam;
25
	private boolean alwaysNewRecord = false;
26
	private boolean skipDuplicates = false;
27
	private String duplicateXPath;
28

  
29
	@Override
30
	void completePrepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
31

  
32
		final String eprS = token.getEnv().getAttribute(getEprParam());
33
		this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS);
34
		job.setAction("SYNC");
35
		job.getParameters().put(OAIParameterNames.OAI_FEED_DATE, DateUtils.now_ISO8601());
36
		job.getParameters().put(OAIParameterNames.OAI_SKIP_DUPLICATES, String.valueOf(skipDuplicates));
37
		if(skipDuplicates) job.getParameters().put(OAIParameterNames.OAI_DUPLICATE_XPATH, duplicateXPath);
38
		job.getParameters().put(OAIParameterNames.OAI_SYNC_EPR, progressProvider.getEpr().toString());
39
		job.getParameters().put(OAIParameterNames.OAI_ALWAYS_NEW_RECORD, String.valueOf(alwaysNewRecord));
40
		log.fatal("OAI Sync Job prepared");
41
	}
42

  
43
	public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() {
44
		return processCountingResultSetFactory;
45
	}
46

  
47
	@Required
48
	public void setProcessCountingResultSetFactory(final ProcessCountingResultSetFactory processCountingResultSetFactory) {
49
		this.processCountingResultSetFactory = processCountingResultSetFactory;
50
	}
51

  
52
	@Override
53
	public ProgressProvider getProgressProvider() {
54
		return this.progressProvider;
55
	}
56

  
57

  
58
	public String getEprParam() {
59
		return eprParam;
60
	}
61

  
62
	public void setEprParam(final String eprParam) {
63
		this.eprParam = eprParam;
64
	}
65

  
66
	public boolean isAlwaysNewRecord() {
67
		return alwaysNewRecord;
68
	}
69

  
70
	public void setAlwaysNewRecord(boolean alwaysNewRecord) {
71
		this.alwaysNewRecord = alwaysNewRecord;
72
	}
73

  
74
	public boolean isSkipDuplicates() {
75
		return skipDuplicates;
76
	}
77

  
78
	public void setSkipDuplicates(final boolean skipDuplicates) {
79
		this.skipDuplicates = skipDuplicates;
80
	}
81

  
82
	public String getDuplicateXPath() {
83
		return duplicateXPath;
84
	}
85

  
86
	public void setDuplicateXPath(final String duplicateXPath) {
87
		this.duplicateXPath = duplicateXPath;
88
	}
89

  
90
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAICreateIndexJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6

  
7
/**
8
 * Create indexes on the oaistore on the fields specified in the parameter.
9
 */
10
public class OAICreateIndexJobNode extends AbstractOAIJobNode {
11

  
12
	/**
13
	 * Name of the fields (comma separated) to be included in the same index. For several indexes separate the fieldNames with ;
14
	 * <p>
15
	 * Examples: field1,field2 -- one compound index on the given two fields field1,field2;field3,field4 -- two compound indices: one on
16
	 * field1 and field2, the other on field3 and field4
17
	 * </p>
18
	 * **/
19
	private String fieldNames;
20

  
21
	@Override
22
	public void completePrepareJob(final BlackboardJob job, final NodeToken token) {
23
		job.setAction("CREATE_OAI_INDEX");
24
		job.getParameters().put(OAIParameterNames.OAI_INDEXES, getFieldNames());
25
	}
26

  
27
	public String getFieldNames() {
28
		return fieldNames;
29
	}
30

  
31
	public void setFieldNames(final String fieldNames) {
32
		this.fieldNames = fieldNames;
33
	}
34
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAICreateStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4

  
5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6

  
7
public class OAICreateStoreJobNode extends AbstractOAIJobNode {
8

  
9
	@Override
10
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
11
		job.setAction("CREATE_STORE");
12
	}
13

  
14

  
15
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAIDropStoreJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
5

  
6
public class OAIDropStoreJobNode extends AbstractOAIJobNode {
7

  
8
	@Override
9
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
10
		job.setAction("DROP_STORE");
11
	}
12

  
13
}
modules/dnet-oai-common-workflows/branches/nodeRefactoring/src/main/java/eu/dnetlib/msro/oai/workflows/nodes/OAIEnsureIndexesJobNode.java
1
package eu.dnetlib.msro.oai.workflows.nodes;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
5

  
6
/**
7
 * Creates the indexes on OAI stores based on the OAI configuration.
8
 */
9
public class OAIEnsureIndexesJobNode extends AbstractOAIJobNode {
10

  
11
	@Override
12
	void completePrepareJob(final BlackboardJob job, final NodeToken token) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff