Project

General

Profile

« Previous | Next » 

Revision 44365

added common wf nodes

View differences:

modules/dnet-msro-service/trunk/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/LoadMappingProfileJobNode.java
1
package eu.dnetlib.msro.workflows.nodes.transform;
2

  
3
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
4
import eu.dnetlib.msro.workflows.graph.Arc;
5
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
6
import eu.dnetlib.msro.workflows.procs.Env;
7
import eu.dnetlib.rmi.enabling.ISLookUpService;
8
import org.apache.commons.lang3.StringUtils;
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.springframework.beans.factory.annotation.Autowired;
12

  
13
/**
14
 * Takes a mapping profile id and loads the corresponding xslt mapping definition as a TDS fragment.
15
 */
16
public class LoadMappingProfileJobNode extends SimpleJobNode {
17

  
18
	private static final Log log = LogFactory.getLog(LoadMappingProfileJobNode.class);
19

  
20
	@Autowired
21
	private UniqueServiceLocator serviceLocator;
22

  
23
	private String profileId;
24

  
25
	private String loadedMappingParam;
26

  
27
	@Override
28
	protected String execute(final Env env) throws Exception {
29

  
30
		log.info(String.format("loading mapping from: %s", profileId));
31

  
32
		final String xquery = String.format("/RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='%s']/BODY/CONFIGURATION/SCRIPT/CODE/*[local-name()='stylesheet']",
33
				getProfileId());
34
		final String xslt = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
35

  
36
		log.debug(String.format("mapping: %s", xslt));
37

  
38
		if (StringUtils.isBlank(xslt)) {
39
			throw new IllegalStateException("unable to load mapping from profile: " + getProfileId());
40
		}
41

  
42
		env.setAttribute(getLoadedMappingParam(), xslt);
43

  
44
		return Arc.DEFAULT_ARC;
45
	}
46

  
47
	public String getProfileId() {
48
		return profileId;
49
	}
50

  
51
	public void setProfileId(final String profileId) {
52
		this.profileId = profileId;
53
	}
54

  
55
	public String getLoadedMappingParam() {
56
		return loadedMappingParam;
57
	}
58

  
59
	public void setLoadedMappingParam(final String loadedMappingParam) {
60
		this.loadedMappingParam = loadedMappingParam;
61
	}
62
}
modules/dnet-msro-service/trunk/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/MDStoreBatchExporterJobNode.java
1
package eu.dnetlib.msro.workflows.nodes.mdstore;
2

  
3
import javax.annotation.Resource;
4

  
5
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
6
import eu.dnetlib.msro.workflows.graph.Arc;
7
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
8
import eu.dnetlib.msro.workflows.procs.Env;
9
import eu.dnetlib.rmi.common.ResultSet;
10
import eu.dnetlib.rmi.data.MDStoreService;
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
13

  
14
/**
15
 * This jobNode reads all the metadata records from all the mongodb collections and generates an hdfs sequence file.
16
 *
17
 * @author claudio
18
 */
19
public class MDStoreBatchExporterJobNode extends SimpleJobNode {
20

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

  
23
	private String format;
24

  
25
	private String layout;
26

  
27
	private String interpretation;
28

  
29
	private String outputEprParam;
30

  
31
	@Resource
32
	private UniqueServiceLocator serviceLocator;
33

  
34
	@Override
35
	public String execute(final Env env) throws Exception {
36
		log.info("bulk reading MDStores: " + getFormat() + "-" + getLayout() + "-" + getInterpretation());
37
		final ResultSet<String> rs =
38
				getServiceLocator().getService(MDStoreService.class).bulkDeliverMDRecords(getFormat(), getLayout(), getInterpretation());
39

  
40
		env.setAttribute(getOutputEprParam(), rs);
41

  
42
		return Arc.DEFAULT_ARC;
43
	}
44

  
45
	public String getFormat() {
46
		return format;
47
	}
48

  
49
	public void setFormat(final String format) {
50
		this.format = format;
51
	}
52

  
53
	public String getLayout() {
54
		return layout;
55
	}
56

  
57
	public void setLayout(final String layout) {
58
		this.layout = layout;
59
	}
60

  
61
	public String getInterpretation() {
62
		return interpretation;
63
	}
64

  
65
	public void setInterpretation(final String interpretation) {
66
		this.interpretation = interpretation;
67
	}
68

  
69
	public String getOutputEprParam() {
70
		return outputEprParam;
71
	}
72

  
73
	public void setOutputEprParam(final String outputEprParam) {
74
		this.outputEprParam = outputEprParam;
75
	}
76

  
77
	public UniqueServiceLocator getServiceLocator() {
78
		return serviceLocator;
79
	}
80

  
81
}
82

  
modules/dnet-msro-service/trunk/src/main/resources/eu/dnetlib/msro/service/applicationContext-msro-nodes.xml
33 33
		class="eu.dnetlib.msro.workflows.nodes.is.ValidateProfilesJobNode"
34 34
		scope="prototype"/>
35 35

  
36
	<bean id="wfNodeLoadMappingProfile"
37
	      class="eu.dnetlib.msro.workflows.nodes.transform.LoadMappingProfileJobNode"
38
	      scope="prototype"/>
39

  
36 40
	<!-- Datasources -->
37 41
	<bean id="wfNodeValidateDatasource"
38 42
		class="eu.dnetlib.msro.workflows.nodes.misc.ValidateDatasourceJobNode"
......
148 152
		scope="prototype"/>
149 153

  
150 154
	<!-- MDStore -->
155

  
156
	<bean id="wfNodeMDStoreBatchExporter"
157
	      class="eu.dnetlib.msro.workflows.nodes.mdstore.MDStoreBatchExporterJobNode"
158
	      scope="prototype"/>
159

  
151 160
	<bean id="wfNodeCreateMDStore"
152 161
		class="eu.dnetlib.msro.workflows.nodes.mdstore.CreateMDStoreJobNode"
153 162
		scope="prototype"/>

Also available in: Unified diff