Revision 42328
Added by Alessia Bardi over 8 years ago
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/CreateMDStoreJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.apache.commons.logging.Log; |
|
6 |
import org.apache.commons.logging.LogFactory; |
|
7 |
|
|
8 |
import com.googlecode.sarasvati.Engine; |
|
9 |
import com.googlecode.sarasvati.NodeToken; |
|
10 |
import com.googlecode.sarasvati.env.Env; |
|
11 |
|
|
12 |
import eu.dnetlib.data.mdstore.MDStoreService; |
|
13 |
import eu.dnetlib.enabling.locators.comparators.HandledDatastructuresComparator; |
|
14 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
15 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
16 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
17 |
|
|
18 |
public class CreateMDStoreJobNode extends BlackboardJobNode { |
|
19 |
|
|
20 |
private static final Log log = LogFactory.getLog(CreateMDStoreJobNode.class); |
|
21 |
|
|
22 |
private String format; |
|
23 |
private String layout; |
|
24 |
private String interpretation; |
|
25 |
private String outputPrefix = "mdstore"; |
|
26 |
|
|
27 |
@Override |
|
28 |
protected String obtainServiceId(final NodeToken token) { |
|
29 |
return getServiceLocator().getServiceId(MDStoreService.class, new HandledDatastructuresComparator()); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) { |
|
34 |
log.info("preparing blackboard job: " + getFormat()); |
|
35 |
|
|
36 |
job.setAction("CREATE"); |
|
37 |
job.getParameters().put("format", getFormat()); |
|
38 |
job.getParameters().put("interpretation", getInterpretation()); |
|
39 |
job.getParameters().put("layout", getLayout()); |
|
40 |
} |
|
41 |
|
|
42 |
public String getFormat() { |
|
43 |
return format; |
|
44 |
} |
|
45 |
|
|
46 |
public void setFormat(final String format) { |
|
47 |
this.format = format; |
|
48 |
} |
|
49 |
|
|
50 |
public String getInterpretation() { |
|
51 |
return interpretation; |
|
52 |
} |
|
53 |
|
|
54 |
public void setInterpretation(final String interpretation) { |
|
55 |
this.interpretation = interpretation; |
|
56 |
} |
|
57 |
|
|
58 |
public String getLayout() { |
|
59 |
return layout; |
|
60 |
} |
|
61 |
|
|
62 |
public void setLayout(final String layout) { |
|
63 |
this.layout = layout; |
|
64 |
} |
|
65 |
|
|
66 |
public String getOutputPrefix() { |
|
67 |
return outputPrefix; |
|
68 |
} |
|
69 |
|
|
70 |
public void setOutputPrefix(final String outputPrefix) { |
|
71 |
this.outputPrefix = outputPrefix; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
76 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
77 |
|
|
78 |
@Override |
|
79 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
80 |
env.setAttribute(getOutputPrefix() + "format", format); |
|
81 |
env.setAttribute(getOutputPrefix() + "layout", layout); |
|
82 |
env.setAttribute(getOutputPrefix() + "interpretation", interpretation); |
|
83 |
env.setAttribute(getOutputPrefix() + "id", responseParams.get("id")); |
|
84 |
} |
|
85 |
}; |
|
86 |
} |
|
87 |
|
|
88 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/UpdateMetaWfStatusJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import com.googlecode.sarasvati.Arc; |
|
8 |
import com.googlecode.sarasvati.NodeToken; |
|
9 |
|
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
11 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
13 |
import eu.dnetlib.msro.rmi.MSROException; |
|
14 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
15 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
16 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
17 |
|
|
18 |
public class UpdateMetaWfStatusJobNode extends SimpleJobNode { |
|
19 |
|
|
20 |
@Resource |
|
21 |
private UniqueServiceLocator serviceLocator; |
|
22 |
|
|
23 |
@Override |
|
24 |
protected String execute(final NodeToken token) throws Exception { |
|
25 |
final String metaWfId = token.getFullEnv().getAttribute("META_WORKFLOW_ID"); |
|
26 |
|
|
27 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
28 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
29 |
|
|
30 |
updateDatasource(dsId, ifaceId); |
|
31 |
|
|
32 |
if (isReady(metaWfId)) { |
|
33 |
serviceLocator.getService(ISRegistryService.class).updateProfileNode(metaWfId, "//CONFIGURATION/@status", "'" + WorkflowStatus.EXECUTABLE + "'"); |
|
34 |
} |
|
35 |
|
|
36 |
return Arc.DEFAULT_ARC; |
|
37 |
} |
|
38 |
|
|
39 |
protected void updateDatasource(final String dsId, final String ifaceId) throws Exception { |
|
40 |
serviceLocator.getService(ISRegistryService.class).updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'true'"); |
|
41 |
} |
|
42 |
|
|
43 |
private boolean isReady(final String metaWfId) throws Exception { |
|
44 |
final String query = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType')" |
|
45 |
+ "//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value eq '" + metaWfId + "']//WORKFLOW/@id " |
|
46 |
+ "for $y in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') " + "where $y//RESOURCE_IDENTIFIER/@value = $x " |
|
47 |
+ "return $y//PARAM[@required='true' and string-length(text()) = 0]/@managedBy/string()"; |
|
48 |
|
|
49 |
final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query); |
|
50 |
|
|
51 |
if (list.contains("system")) { throw new MSROException("A system param is missing in profile: " + metaWfId); } |
|
52 |
|
|
53 |
return list.isEmpty(); |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/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 |
<relativePath /> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>dnet-msro-service</artifactId> |
|
12 |
<packaging>jar</packaging> |
|
13 |
<version>3.1.12</version> |
|
14 |
<scm> |
|
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-msro-service/tags/dnet-msro-service-3.1.12</developerConnection> |
|
16 |
</scm> |
|
17 |
<dependencies> |
|
18 |
<dependency> |
|
19 |
<groupId>opensymphony</groupId> |
|
20 |
<artifactId>quartz</artifactId> |
|
21 |
<version>1.6.6</version> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>eu.dnetlib</groupId> |
|
25 |
<artifactId>dnet-msro-service-api</artifactId> |
|
26 |
<version>[2.0.0,3.0.0)</version> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>eu.dnetlib</groupId> |
|
30 |
<artifactId>cnr-resultset-service</artifactId> |
|
31 |
<version>[2.0.0,3.0.0)</version> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>eu.dnetlib</groupId> |
|
35 |
<artifactId>cnr-data-utility-cleaner-rmi</artifactId> |
|
36 |
<version>[2.0.0,3.0.0)</version> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>eu.dnetlib</groupId> |
|
40 |
<artifactId>cnr-resultset-client</artifactId> |
|
41 |
<version>[2.0.0,3.0.0)</version> |
|
42 |
</dependency> |
|
43 |
<dependency> |
|
44 |
<groupId>eu.dnetlib</groupId> |
|
45 |
<artifactId>dnet-download-service-rmi</artifactId> |
|
46 |
<version>[1.1.0,2.0.0)</version> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>eu.dnetlib</groupId> |
|
50 |
<artifactId>dnet-datasource-manager-rmi</artifactId> |
|
51 |
<version>[4.0.0,5.0.0)</version> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>eu.dnetlib</groupId> |
|
55 |
<artifactId>cnr-blackboard-common</artifactId> |
|
56 |
<version>[2.1.0,3.0.0)</version> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>eu.dnetlib</groupId> |
|
60 |
<artifactId>dnet-mongo-logging</artifactId> |
|
61 |
<version>[2.0.0,3.0.0)</version> |
|
62 |
</dependency> |
|
63 |
<dependency> |
|
64 |
<groupId>com.googlecode</groupId> |
|
65 |
<artifactId>sarasvati</artifactId> |
|
66 |
<version>1.0.3</version> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>com.googlecode</groupId> |
|
70 |
<artifactId>sarasvati-visual</artifactId> |
|
71 |
<version>1.0.3</version> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>eu.dnetlib</groupId> |
|
75 |
<artifactId>dnet-modular-collector-service-rmi</artifactId> |
|
76 |
<version>[1.3.0,2.0.0)</version> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>eu.dnetlib</groupId> |
|
80 |
<artifactId>cnr-enabling-database-api</artifactId> |
|
81 |
<version>[2.0.0,3.0.0)</version> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>eu.dnetlib</groupId> |
|
85 |
<artifactId>dnet-objectstore-rmi</artifactId> |
|
86 |
<version>[2.0.0,3.0.0)</version> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>eu.dnetlib</groupId> |
|
90 |
<artifactId>dnet-data-transformation-service-rmi</artifactId> |
|
91 |
<version>[1.0.0,2.0.0)</version> |
|
92 |
</dependency> |
|
93 |
<dependency> |
|
94 |
<groupId>eu.dnetlib</groupId> |
|
95 |
<artifactId>dnet-data-provision-rmi</artifactId> |
|
96 |
<version>[1.0.0,2.0.0)</version> |
|
97 |
</dependency> |
|
98 |
<dependency> |
|
99 |
<groupId>eu.dnetlib</groupId> |
|
100 |
<artifactId>dnet-runtime</artifactId> |
|
101 |
<version>[1.0.0,2.0.0)</version> |
|
102 |
</dependency> |
|
103 |
<dependency> |
|
104 |
<groupId>javax.mail</groupId> |
|
105 |
<artifactId>mail</artifactId> |
|
106 |
<version>1.4</version> |
|
107 |
</dependency> |
|
108 |
<dependency> |
|
109 |
<groupId>org.codehaus.groovy</groupId> |
|
110 |
<artifactId>groovy-all</artifactId> |
|
111 |
<version>2.1.6</version> |
|
112 |
</dependency> |
|
113 |
<dependency> |
|
114 |
<groupId>junit</groupId> |
|
115 |
<artifactId>junit</artifactId> |
|
116 |
<version>${junit.version}</version> |
|
117 |
<scope>test</scope> |
|
118 |
</dependency> |
|
119 |
<dependency> |
|
120 |
<groupId>joda-time</groupId> |
|
121 |
<artifactId>joda-time</artifactId> |
|
122 |
<version>2.3</version> |
|
123 |
</dependency> |
|
124 |
</dependencies> |
|
125 |
|
|
126 |
<properties> |
|
127 |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|
128 |
</properties> |
|
129 |
|
|
130 |
</project> |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/StoreMDStoreRecordsJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.mdstore; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.Engine; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
import com.googlecode.sarasvati.env.Env; |
|
8 |
import eu.dnetlib.data.mdstore.MDStoreService; |
|
9 |
import eu.dnetlib.enabling.resultset.rmi.ResultSetException; |
|
10 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
11 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
12 |
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode; |
|
13 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
14 |
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory; |
|
15 |
import eu.dnetlib.msro.workflows.util.ProgressProvider; |
|
16 |
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; |
|
17 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
18 |
import org.apache.commons.logging.Log; |
|
19 |
import org.apache.commons.logging.LogFactory; |
|
20 |
import org.springframework.beans.factory.annotation.Required; |
|
21 |
|
|
22 |
public class StoreMDStoreRecordsJobNode extends BlackboardJobNode implements ProgressJobNode { |
|
23 |
|
|
24 |
private static final Log log = LogFactory.getLog(StoreMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
25 |
|
|
26 |
private String eprParam; |
|
27 |
private String mdId; |
|
28 |
private String storingType; |
|
29 |
private ProcessCountingResultSetFactory processCountingResultSetFactory; |
|
30 |
private ResultsetProgressProvider progressProvider; |
|
31 |
|
|
32 |
@Override |
|
33 |
protected String obtainServiceId(final NodeToken token) { |
|
34 |
return getServiceLocator().getServiceId(MDStoreService.class, mdId); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException { |
|
39 |
job.setAction("FEED"); |
|
40 |
|
|
41 |
final String eprS = token.getEnv().getAttribute(getEprParam()); |
|
42 |
|
|
43 |
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS); |
|
44 |
|
|
45 |
job.getParameters().put("epr", progressProvider.getEpr().toString()); |
|
46 |
job.getParameters().put("storingType", getStoringType()); |
|
47 |
job.getParameters().put("mdId", getMdId()); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
52 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
53 |
|
|
54 |
@Override |
|
55 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
56 |
log.info("Total records: " + responseParams.get("total")); |
|
57 |
log.info("Number of stored records: " + responseParams.get("stored")); |
|
58 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "total", responseParams.get("total")); |
|
59 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "stored", responseParams.get("stored")); |
|
60 |
} |
|
61 |
}; |
|
62 |
} |
|
63 |
|
|
64 |
public String getEprParam() { |
|
65 |
return eprParam; |
|
66 |
} |
|
67 |
|
|
68 |
public void setEprParam(final String eprParam) { |
|
69 |
this.eprParam = eprParam; |
|
70 |
} |
|
71 |
|
|
72 |
public String getMdId() { |
|
73 |
return mdId; |
|
74 |
} |
|
75 |
|
|
76 |
public void setMdId(final String mdId) { |
|
77 |
this.mdId = mdId; |
|
78 |
} |
|
79 |
|
|
80 |
public String getStoringType() { |
|
81 |
return storingType; |
|
82 |
} |
|
83 |
|
|
84 |
public void setStoringType(final String storingType) { |
|
85 |
this.storingType = storingType; |
|
86 |
} |
|
87 |
|
|
88 |
public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() { |
|
89 |
return processCountingResultSetFactory; |
|
90 |
} |
|
91 |
|
|
92 |
@Required |
|
93 |
public void setProcessCountingResultSetFactory(final ProcessCountingResultSetFactory processCountingResultSetFactory) { |
|
94 |
this.processCountingResultSetFactory = processCountingResultSetFactory; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public ProgressProvider getProgressProvider() { |
|
99 |
return progressProvider; |
|
100 |
} |
|
101 |
|
|
102 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/MultipleMdStoreIterator.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.mdstore; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
8 |
|
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
|
|
13 |
import com.google.common.base.Function; |
|
14 |
import com.google.common.collect.Iterables; |
|
15 |
|
|
16 |
import eu.dnetlib.data.mdstore.MDStoreService; |
|
17 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
20 |
|
|
21 |
// TODO: Auto-generated Javadoc |
|
22 |
/** |
|
23 |
* The Class MultipleMdStoreIterator. |
|
24 |
*/ |
|
25 |
public class MultipleMdStoreIterator implements Iterator<String> { |
|
26 |
|
|
27 |
private static final Log log = LogFactory.getLog(MultipleMdStoreIterator.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
28 |
|
|
29 |
/** The service locator. */ |
|
30 |
@Resource |
|
31 |
private UniqueServiceLocator serviceLocator; |
|
32 |
|
|
33 |
/** The current iterator. */ |
|
34 |
private Iterator<String> currentIterator; |
|
35 |
|
|
36 |
/** The result set client factory. */ |
|
37 |
@Autowired |
|
38 |
private ResultSetClientFactory resultSetClientFactory; |
|
39 |
|
|
40 |
/** |
|
41 |
* Instantiates a new multiple md store iterator. |
|
42 |
* |
|
43 |
* @param mdstoreLocator |
|
44 |
* the mdstore locator |
|
45 |
* @param mdIds |
|
46 |
* the md ids |
|
47 |
*/ |
|
48 |
public MultipleMdStoreIterator(final UniqueServiceLocator serviceLocator, final List<String> mdIds, final ResultSetClientFactory resultSetClientFactory) { |
|
49 |
this.serviceLocator = serviceLocator; |
|
50 |
this.resultSetClientFactory = resultSetClientFactory; |
|
51 |
|
|
52 |
log.info(String.format("iterating over mdIds: '%s'", mdIds)); |
|
53 |
|
|
54 |
this.currentIterator = Iterables.concat(Iterables.transform(mdIds, new Function<String, Iterable<String>>() { |
|
55 |
|
|
56 |
@Override |
|
57 |
public Iterable<String> apply(final String mdId) { |
|
58 |
|
|
59 |
log.debug(String.format("current mdId '%s'", mdId)); |
|
60 |
try { |
|
61 |
W3CEndpointReference epr = serviceLocator.getService(MDStoreService.class, mdId).deliverMDRecords(mdId, "", "", ""); |
|
62 |
return resultSetClientFactory.getClient(epr); |
|
63 |
} catch (MDStoreServiceException e) { |
|
64 |
log.error(e); |
|
65 |
throw new RuntimeException(String.format("unable to iterate over %s", mdId), e); |
|
66 |
} |
|
67 |
} |
|
68 |
})).iterator(); |
|
69 |
} |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* |
|
74 |
* @see java.util.Iterator#hasNext() |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public boolean hasNext() { |
|
78 |
if (currentIterator == null) return false; |
|
79 |
|
|
80 |
return currentIterator.hasNext(); |
|
81 |
} |
|
82 |
|
|
83 |
/* |
|
84 |
* (non-Javadoc) |
|
85 |
* |
|
86 |
* @see java.util.Iterator#next() |
|
87 |
*/ |
|
88 |
@Override |
|
89 |
public String next() { |
|
90 |
return currentIterator.next(); |
|
91 |
} |
|
92 |
|
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* |
|
96 |
* @see java.util.Iterator#remove() |
|
97 |
*/ |
|
98 |
@Override |
|
99 |
public void remove() { |
|
100 |
throw new UnsupportedOperationException("Cannot remove"); |
|
101 |
} |
|
102 |
|
|
103 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/FetchMultipleMDStores.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.mdstore; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
|
11 |
|
|
12 |
import com.google.gson.Gson; |
|
13 |
import com.googlecode.sarasvati.Arc; |
|
14 |
import com.googlecode.sarasvati.NodeToken; |
|
15 |
|
|
16 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
17 |
import eu.dnetlib.enabling.resultset.IterableResultSetFactory; |
|
18 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
19 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
20 |
|
|
21 |
public class FetchMultipleMDStores extends SimpleJobNode { |
|
22 |
|
|
23 |
private static final Log log = LogFactory.getLog(FetchMultipleMDStores.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
24 |
|
|
25 |
@Resource |
|
26 |
private UniqueServiceLocator serviceLocator; |
|
27 |
|
|
28 |
private List<String> mdId; |
|
29 |
|
|
30 |
private String eprParam; |
|
31 |
|
|
32 |
/** The result set factory. */ |
|
33 |
@Resource(name = "iterableResultSetFactory") |
|
34 |
private IterableResultSetFactory resultSetFactory; |
|
35 |
|
|
36 |
/** The result set client factory. */ |
|
37 |
@Autowired |
|
38 |
private ResultSetClientFactory resultSetClientFactory; |
|
39 |
|
|
40 |
@Override |
|
41 |
protected String execute(final NodeToken token) throws Exception { |
|
42 |
|
|
43 |
if (getMdId() == null) { |
|
44 |
final String mdIdsJson = token.getEnv().getAttribute("mdId"); |
|
45 |
@SuppressWarnings("unchecked") |
|
46 |
final List<String> mdIds = new Gson().fromJson(mdIdsJson, List.class); |
|
47 |
log.info(String.format("fetching records for %s mdstores", mdIds.size())); |
|
48 |
if (log.isDebugEnabled()) { |
|
49 |
log.debug(String.format("fetching records for mdstores: %s", mdIdsJson)); |
|
50 |
} |
|
51 |
setMdId(mdIds); |
|
52 |
} |
|
53 |
|
|
54 |
final MultipleMdStoreIterable iter = new MultipleMdStoreIterable(serviceLocator, getMdId(), resultSetClientFactory); |
|
55 |
final W3CEndpointReference epr = resultSetFactory.createIterableResultSet(iter); |
|
56 |
token.getEnv().setAttribute(getEprParam(), epr.toString()); |
|
57 |
return Arc.DEFAULT_ARC; |
|
58 |
} |
|
59 |
|
|
60 |
public List<String> getMdId() { |
|
61 |
return mdId; |
|
62 |
} |
|
63 |
|
|
64 |
public void setMdId(final List<String> mdId) { |
|
65 |
this.mdId = mdId; |
|
66 |
} |
|
67 |
|
|
68 |
public String getEprParam() { |
|
69 |
return eprParam; |
|
70 |
} |
|
71 |
|
|
72 |
public void setEprParam(final String eprParam) { |
|
73 |
this.eprParam = eprParam; |
|
74 |
} |
|
75 |
|
|
76 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/MultipleMdStoreIterable.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.mdstore; |
|
2 |
|
|
3 |
import java.util.Iterator; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
7 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
8 |
|
|
9 |
// TODO: Auto-generated Javadoc |
|
10 |
/** |
|
11 |
* The Class MultipleMdStoreIterable. |
|
12 |
*/ |
|
13 |
public class MultipleMdStoreIterable implements Iterable<String> { |
|
14 |
|
|
15 |
/** The service locator. */ |
|
16 |
private UniqueServiceLocator serviceLocator; |
|
17 |
|
|
18 |
/** The md ids. */ |
|
19 |
private List<String> mdIds; |
|
20 |
|
|
21 |
/** The result set client factory. */ |
|
22 |
private ResultSetClientFactory resultSetClientFactory; |
|
23 |
|
|
24 |
/** |
|
25 |
* Instantiates a new multiple md store iterable. |
|
26 |
* |
|
27 |
* @param serviceLocator |
|
28 |
* the service locator |
|
29 |
* @param mdIds |
|
30 |
* the md ids |
|
31 |
* @param resultSetClientFactory |
|
32 |
* the result set client factory |
|
33 |
*/ |
|
34 |
public MultipleMdStoreIterable(final UniqueServiceLocator serviceLocator, final List<String> mdIds, final ResultSetClientFactory resultSetClientFactory) { |
|
35 |
super(); |
|
36 |
this.serviceLocator = serviceLocator; |
|
37 |
this.mdIds = mdIds; |
|
38 |
this.resultSetClientFactory = resultSetClientFactory; |
|
39 |
} |
|
40 |
|
|
41 |
/* |
|
42 |
* (non-Javadoc) |
|
43 |
* |
|
44 |
* @see java.lang.Iterable#iterator() |
|
45 |
*/ |
|
46 |
@Override |
|
47 |
public Iterator<String> iterator() { |
|
48 |
return new MultipleMdStoreIterator(serviceLocator, mdIds, resultSetClientFactory); |
|
49 |
} |
|
50 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/info/ObjectStoreToApiExtraFieldJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.info; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.dom4j.Document; |
|
9 |
import org.dom4j.Node; |
|
10 |
import org.dom4j.io.SAXReader; |
|
11 |
|
|
12 |
import com.google.common.collect.Maps; |
|
13 |
import com.googlecode.sarasvati.Arc; |
|
14 |
import com.googlecode.sarasvati.NodeToken; |
|
15 |
|
|
16 |
import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService; |
|
17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
20 |
|
|
21 |
public class ObjectStoreToApiExtraFieldJobNode extends SimpleJobNode { |
|
22 |
|
|
23 |
private String objId; |
|
24 |
private String datasourceId; |
|
25 |
private String datasourceInterface; |
|
26 |
private String extraFieldForTotal; |
|
27 |
private String extraFieldForDate; |
|
28 |
private String extraFieldForObjId; |
|
29 |
|
|
30 |
@Resource |
|
31 |
private UniqueServiceLocator serviceLocator; |
|
32 |
|
|
33 |
@Override |
|
34 |
protected String execute(final NodeToken token) throws Exception { |
|
35 |
final String xq = "for $x in collection('/db/DRIVER/ObjectStoreDSResources/ObjectStoreDSResourceType') " + "where $x//RESOURCE_IDENTIFIER/@value='" |
|
36 |
+ objId + "' " + "return concat($x//COUNT_STORE, ' @=@ ', $x//LAST_STORAGE_DATE)"; |
|
37 |
|
|
38 |
final String s = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xq); |
|
39 |
|
|
40 |
final String[] arr = s.split(" @=@ "); |
|
41 |
|
|
42 |
final Map<String, String> map = getCurrentExtraFields(datasourceId, datasourceInterface); |
|
43 |
map.put(extraFieldForTotal, arr[0].trim()); |
|
44 |
map.put(extraFieldForDate, arr[1].trim()); |
|
45 |
map.put(extraFieldForObjId, objId); |
|
46 |
|
|
47 |
serviceLocator.getService(DatasourceManagerService.class).bulkUpdateApiExtraFields(datasourceId, datasourceInterface, map); |
|
48 |
|
|
49 |
return Arc.DEFAULT_ARC; |
|
50 |
} |
|
51 |
|
|
52 |
private Map<String, String> getCurrentExtraFields(final String repoId, final String ifaceId) throws Exception { |
|
53 |
final Map<String, String> res = Maps.newHashMap(); |
|
54 |
|
|
55 |
final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId); |
|
56 |
|
|
57 |
final SAXReader reader = new SAXReader(); |
|
58 |
final Document doc = reader.read(new StringReader(profile)); |
|
59 |
|
|
60 |
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']"); |
|
61 |
if (ifcNode != null) { |
|
62 |
for (Object o : ifcNode.selectNodes("./INTERFACE_EXTRA_FIELD")) { |
|
63 |
res.put(((Node) o).valueOf("@name"), ((Node) o).getText()); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
return res; |
|
68 |
} |
|
69 |
|
|
70 |
public String getDatasourceId() { |
|
71 |
return datasourceId; |
|
72 |
} |
|
73 |
|
|
74 |
public void setDatasourceId(final String datasourceId) { |
|
75 |
this.datasourceId = datasourceId; |
|
76 |
} |
|
77 |
|
|
78 |
public String getDatasourceInterface() { |
|
79 |
return datasourceInterface; |
|
80 |
} |
|
81 |
|
|
82 |
public void setDatasourceInterface(final String datasourceInterface) { |
|
83 |
this.datasourceInterface = datasourceInterface; |
|
84 |
} |
|
85 |
|
|
86 |
public String getExtraFieldForTotal() { |
|
87 |
return extraFieldForTotal; |
|
88 |
} |
|
89 |
|
|
90 |
public void setExtraFieldForTotal(final String extraFieldForTotal) { |
|
91 |
this.extraFieldForTotal = extraFieldForTotal; |
|
92 |
} |
|
93 |
|
|
94 |
public String getExtraFieldForDate() { |
|
95 |
return extraFieldForDate; |
|
96 |
} |
|
97 |
|
|
98 |
public void setExtraFieldForDate(final String extraFieldForDate) { |
|
99 |
this.extraFieldForDate = extraFieldForDate; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* @return the objId |
|
104 |
*/ |
|
105 |
public String getObjId() { |
|
106 |
return objId; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @param objId |
|
111 |
* the objId to set |
|
112 |
*/ |
|
113 |
public void setObjId(final String objId) { |
|
114 |
this.objId = objId; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @return the extraFieldForObjId |
|
119 |
*/ |
|
120 |
public String getExtraFieldForObjId() { |
|
121 |
return extraFieldForObjId; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* @param extraFieldForObjId |
|
126 |
* the extraFieldForObjId to set |
|
127 |
*/ |
|
128 |
public void setExtraFieldForObjId(final String extraFieldForObjId) { |
|
129 |
this.extraFieldForObjId = extraFieldForObjId; |
|
130 |
} |
|
131 |
|
|
132 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/db/UpdateDbJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.db; |
|
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.database.rmi.DatabaseService; |
|
10 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
11 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
12 |
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode; |
|
13 |
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory; |
|
14 |
import eu.dnetlib.msro.workflows.util.ProgressProvider; |
|
15 |
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; |
|
16 |
|
|
17 |
public class UpdateDbJobNode extends BlackboardJobNode implements ProgressJobNode { |
|
18 |
|
|
19 |
private String db; |
|
20 |
private String dbParam; |
|
21 |
private String eprParam; |
|
22 |
private ProcessCountingResultSetFactory processCountingResultSetFactory; |
|
23 |
private ResultsetProgressProvider progressProvider; |
|
24 |
|
|
25 |
private static final Log log = LogFactory.getLog(UpdateDbJobNode.class); |
|
26 |
|
|
27 |
@Override |
|
28 |
protected String obtainServiceId(final NodeToken token) { |
|
29 |
return getServiceLocator().getServiceId(DatabaseService.class); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception { |
|
34 |
if (db == null || db.isEmpty()) { |
|
35 |
db = token.getEnv().getAttribute(getDbParam()); |
|
36 |
} |
|
37 |
|
|
38 |
log.info("preparing blackboard job to update DB: " + db); |
|
39 |
|
|
40 |
final String epr = token.getEnv().getAttribute(getEprParam()); |
|
41 |
|
|
42 |
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), epr); |
|
43 |
|
|
44 |
job.setAction("IMPORT"); |
|
45 |
job.getParameters().put("db", db); |
|
46 |
job.getParameters().put("epr", this.progressProvider.getEpr().toString()); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public ProgressProvider getProgressProvider() { |
|
51 |
return progressProvider; |
|
52 |
} |
|
53 |
|
|
54 |
public String getDb() { |
|
55 |
return db; |
|
56 |
} |
|
57 |
|
|
58 |
public void setDb(final String db) { |
|
59 |
this.db = db; |
|
60 |
} |
|
61 |
|
|
62 |
public String getEprParam() { |
|
63 |
return eprParam; |
|
64 |
} |
|
65 |
|
|
66 |
public void setEprParam(final String eprParam) { |
|
67 |
this.eprParam = eprParam; |
|
68 |
} |
|
69 |
|
|
70 |
public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() { |
|
71 |
return processCountingResultSetFactory; |
|
72 |
} |
|
73 |
|
|
74 |
@Required |
|
75 |
public void setProcessCountingResultSetFactory(final ProcessCountingResultSetFactory processCountingResultSetFactory) { |
|
76 |
this.processCountingResultSetFactory = processCountingResultSetFactory; |
|
77 |
} |
|
78 |
|
|
79 |
public String getDbParam() { |
|
80 |
return dbParam; |
|
81 |
} |
|
82 |
|
|
83 |
public void setDbParam(final String dbParam) { |
|
84 |
this.dbParam = dbParam; |
|
85 |
} |
|
86 |
|
|
87 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/mdstore/FetchMDStoreRecordsJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.mdstore; |
|
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.rmi.MSROException; |
|
15 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
16 |
|
|
17 |
public class FetchMDStoreRecordsJobNode extends SimpleJobNode { |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
20 |
|
|
21 |
@Resource |
|
22 |
private UniqueServiceLocator serviceLocator; |
|
23 |
|
|
24 |
private String mdId; |
|
25 |
private String mdFormat; |
|
26 |
private String eprParam; |
|
27 |
|
|
28 |
@Override |
|
29 |
protected String execute(final NodeToken token) throws Exception { |
|
30 |
if (getMdId() == null) { |
|
31 |
setMdId(token.getEnv().getAttribute("mdId")); |
|
32 |
} |
|
33 |
if (getMdFormat() == null) { |
|
34 |
setMdFormat(token.getEnv().getAttribute("mdFormat")); |
|
35 |
} |
|
36 |
|
|
37 |
log.info("getting MDRecords from: " + getMdId()); |
|
38 |
final W3CEndpointReference epr = serviceLocator.getService(MDStoreService.class, getMdId()).deliverMDRecords(getMdId(), "", "", ""); |
|
39 |
if (epr == null) { throw new MSROException("unable to read MDRecords from: " + getMdId()); } |
|
40 |
token.getEnv().setAttribute(getEprParam(), epr.toString()); |
|
41 |
return Arc.DEFAULT_ARC; |
|
42 |
} |
|
43 |
|
|
44 |
public String getMdId() { |
|
45 |
return mdId; |
|
46 |
} |
|
47 |
|
|
48 |
public void setMdId(final String mdId) { |
|
49 |
this.mdId = mdId; |
|
50 |
} |
|
51 |
|
|
52 |
public String getMdFormat() { |
|
53 |
return mdFormat; |
|
54 |
} |
|
55 |
|
|
56 |
public void setMdFormat(final String mdFormat) { |
|
57 |
this.mdFormat = mdFormat; |
|
58 |
} |
|
59 |
|
|
60 |
public String getEprParam() { |
|
61 |
return eprParam; |
|
62 |
} |
|
63 |
|
|
64 |
public void setEprParam(final String eprParam) { |
|
65 |
this.eprParam = eprParam; |
|
66 |
} |
|
67 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/download/DownloadFromMetadataJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.download; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.Engine; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
import com.googlecode.sarasvati.env.Env; |
|
8 |
import eu.dnetlib.data.download.rmi.DownloadService; |
|
9 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
10 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
11 |
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode; |
|
12 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
13 |
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory; |
|
14 |
import eu.dnetlib.msro.workflows.util.ProgressProvider; |
|
15 |
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; |
|
16 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
17 |
import org.apache.commons.codec.binary.Base64; |
|
18 |
import org.apache.commons.lang.StringUtils; |
|
19 |
import org.apache.commons.logging.Log; |
|
20 |
import org.apache.commons.logging.LogFactory; |
|
21 |
import org.springframework.beans.factory.annotation.Autowired; |
|
22 |
|
|
23 |
// TODO: Auto-generated Javadoc |
|
24 |
/** |
|
25 |
* The Class DownloadFromMetadata is a job node that send a blackboard message to the Download service to start to download file from url |
|
26 |
* retrieved by Metadata . |
|
27 |
*/ |
|
28 |
public class DownloadFromMetadataJobNode extends BlackboardJobNode implements ProgressJobNode { |
|
29 |
|
|
30 |
private static final Log log = LogFactory.getLog(DownloadFromMetadataJobNode.class); |
|
31 |
|
|
32 |
protected String regularExpression; |
|
33 |
/** The inputepr param. */ |
|
34 |
private String inputeprParam; |
|
35 |
/** The obejct store id. */ |
|
36 |
private String objectStoreID; |
|
37 |
/** The plugin. */ |
|
38 |
private String plugin; |
|
39 |
/** The protocol. */ |
|
40 |
private String protocol; |
|
41 |
/** The mime type. */ |
|
42 |
private String mimeType; |
|
43 |
private int numberOfThreads = -1; |
|
44 |
private int connectTimeoutMs = -1; |
|
45 |
private int readTimeoutMs = -1; |
|
46 |
|
|
47 |
private int sleepTimeMs = 0; |
|
48 |
/** The process counting result set factory. */ |
|
49 |
@Autowired |
|
50 |
private ProcessCountingResultSetFactory processCountingResultSetFactory; |
|
51 |
|
|
52 |
/** The progress provider. */ |
|
53 |
private ResultsetProgressProvider progressProvider; |
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* |
|
58 |
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#obtainServiceId(com.googlecode.sarasvati.NodeToken) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
protected String obtainServiceId(final NodeToken token) { |
|
62 |
return getServiceLocator().getServiceId(DownloadService.class); |
|
63 |
} |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* |
|
68 |
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#prepareJob(eu.dnetlib.enabling.tools.blackboard.BlackboardJob, |
|
69 |
* com.googlecode.sarasvati.NodeToken) |
|
70 |
*/ |
|
71 |
@Override |
|
72 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception { |
|
73 |
job.setAction("DOWNLOAD"); |
|
74 |
final String eprS = token.getEnv().getAttribute(getInputeprParam()); |
|
75 |
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS); |
|
76 |
job.getParameters().put("epr", progressProvider.getEpr().toString()); |
|
77 |
job.getParameters().put("protocol", getProtocol()); |
|
78 |
job.getParameters().put("plugin", getPlugin()); |
|
79 |
job.getParameters().put("mimeType", getMimeType()); |
|
80 |
job.getParameters().put("objectStoreID", getObjectStoreID()); |
|
81 |
if (getNumberOfThreads() > 0) { |
|
82 |
job.getParameters().put("numberOfThreads", "" + getNumberOfThreads()); |
|
83 |
} |
|
84 |
if (getConnectTimeoutMs() > 0) { |
|
85 |
job.getParameters().put("connectTimeoutMs", "" + getConnectTimeoutMs()); |
|
86 |
} |
|
87 |
if (getReadTimeoutMs() > 0) { |
|
88 |
job.getParameters().put("readTimeoutMs", "" + getReadTimeoutMs()); |
|
89 |
} |
|
90 |
if (getSleepTimeMs() > 0) { |
|
91 |
job.getParameters().put("sleepTimeMs", "" + getSleepTimeMs()); |
|
92 |
} |
|
93 |
if (!StringUtils.isEmpty(getRegularExpression())){ |
|
94 |
job.getParameters().put("regularExpressions", getRegularExpression()); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
/* |
|
99 |
* (non-Javadoc) |
|
100 |
* |
|
101 |
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#generateBlackboardListener(com.googlecode.sarasvati.Engine, |
|
102 |
* com.googlecode.sarasvati.NodeToken) |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
106 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
107 |
|
|
108 |
@Override |
|
109 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
110 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "total", responseParams.get("total")); |
|
111 |
|
|
112 |
final String base64 = responseParams.get("report"); |
|
113 |
if (StringUtils.isNotBlank(base64) && Base64.isBase64(base64.getBytes())) { |
|
114 |
final String report = new String(Base64.decodeBase64(base64.getBytes())); |
|
115 |
log.info("found download report"); |
|
116 |
log.debug(report); |
|
117 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "report", report); |
|
118 |
} else { |
|
119 |
log.warn("unable to find or decode download report"); |
|
120 |
} |
|
121 |
} |
|
122 |
}; |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Gets the inputepr param. |
|
127 |
* |
|
128 |
* @return the inputeprParam |
|
129 |
*/ |
|
130 |
public String getInputeprParam() { |
|
131 |
return inputeprParam; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Sets the inputepr param. |
|
136 |
* |
|
137 |
* @param inputeprParam |
|
138 |
* the inputeprParam to set |
|
139 |
*/ |
|
140 |
public void setInputeprParam(final String inputeprParam) { |
|
141 |
this.inputeprParam = inputeprParam; |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Gets the object store id. |
|
146 |
* |
|
147 |
* @return the objectStoreID |
|
148 |
*/ |
|
149 |
public String getObjectStoreID() { |
|
150 |
return objectStoreID; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* Sets the object store id. |
|
155 |
* |
|
156 |
* @param objectStoreID |
|
157 |
* the objectStoreID to set |
|
158 |
*/ |
|
159 |
public void setObjectStoreID(final String objectStoreID) { |
|
160 |
this.objectStoreID = objectStoreID; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* Gets the plugin. |
|
165 |
* |
|
166 |
* @return the plugin |
|
167 |
*/ |
|
168 |
public String getPlugin() { |
|
169 |
return plugin; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Sets the plugin. |
|
174 |
* |
|
175 |
* @param plugin |
|
176 |
* the plugin to set |
|
177 |
*/ |
|
178 |
public void setPlugin(final String plugin) { |
|
179 |
this.plugin = plugin; |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* Gets the protocol. |
|
184 |
* |
|
185 |
* @return the protol |
|
186 |
*/ |
|
187 |
public String getProtocol() { |
|
188 |
return protocol; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Sets the protocol. |
|
193 |
* |
|
194 |
* @param protol |
|
195 |
* the protol to set |
|
196 |
*/ |
|
197 |
public void setProtocol(final String protol) { |
|
198 |
this.protocol = protol; |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* Gets the mime type. |
|
203 |
* |
|
204 |
* @return the mimeType |
|
205 |
*/ |
|
206 |
public String getMimeType() { |
|
207 |
return mimeType; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* Sets the mime type. |
|
212 |
* |
|
213 |
* @param mimeType |
|
214 |
* the mimeType to set |
|
215 |
*/ |
|
216 |
public void setMimeType(final String mimeType) { |
|
217 |
this.mimeType = mimeType; |
|
218 |
} |
|
219 |
|
|
220 |
/* |
|
221 |
* (non-Javadoc) |
|
222 |
* |
|
223 |
* @see eu.dnetlib.msro.workflows.nodes.ProgressJobNode#getProgressProvider() |
|
224 |
*/ |
|
225 |
@Override |
|
226 |
public ProgressProvider getProgressProvider() { |
|
227 |
return progressProvider; |
|
228 |
} |
|
229 |
|
|
230 |
public String getRegularExpression() { |
|
231 |
return regularExpression; |
|
232 |
} |
|
233 |
|
|
234 |
public void setRegularExpression(final String regularExpression) { |
|
235 |
this.regularExpression = regularExpression; |
|
236 |
} |
|
237 |
|
|
238 |
public int getNumberOfThreads() { |
|
239 |
return numberOfThreads; |
|
240 |
} |
|
241 |
|
|
242 |
public void setNumberOfThreads(final int numberOfThreads) { |
|
243 |
this.numberOfThreads = numberOfThreads; |
|
244 |
} |
|
245 |
|
|
246 |
public int getConnectTimeoutMs() { |
|
247 |
return connectTimeoutMs; |
|
248 |
} |
|
249 |
|
|
250 |
public void setConnectTimeoutMs(final int connectTimeoutMs) { |
|
251 |
this.connectTimeoutMs = connectTimeoutMs; |
|
252 |
} |
|
253 |
|
|
254 |
public int getReadTimeoutMs() { |
|
255 |
return readTimeoutMs; |
|
256 |
} |
|
257 |
|
|
258 |
public void setReadTimeoutMs(final int readTimeoutMs) { |
|
259 |
this.readTimeoutMs = readTimeoutMs; |
|
260 |
} |
|
261 |
|
|
262 |
public int getSleepTimeMs() { |
|
263 |
return sleepTimeMs; |
|
264 |
} |
|
265 |
|
|
266 |
public void setSleepTimeMs(final int sleepTimeMs) { |
|
267 |
this.sleepTimeMs = sleepTimeMs; |
|
268 |
} |
|
269 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/db/QueryDbJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.db; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import org.apache.commons.io.IOUtils; |
|
9 |
import org.apache.commons.lang.StringUtils; |
|
10 |
|
|
11 |
import com.googlecode.sarasvati.Arc; |
|
12 |
import com.googlecode.sarasvati.NodeToken; |
|
13 |
|
|
14 |
import eu.dnetlib.enabling.database.rmi.DatabaseService; |
|
15 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
16 |
import eu.dnetlib.msro.workflows.nodes.AsyncJobNode; |
|
17 |
|
|
18 |
public class QueryDbJobNode extends AsyncJobNode { |
|
19 |
|
|
20 |
private String db; |
|
21 |
private String dbParam; |
|
22 |
private String dbProperty; |
|
23 |
|
|
24 |
private String sql; |
|
25 |
private String sqlForSize; |
|
26 |
private String xslt; |
|
27 |
private String outputEprParam; |
|
28 |
|
|
29 |
@Resource |
|
30 |
private UniqueServiceLocator serviceLocator; |
|
31 |
|
|
32 |
@Override |
|
33 |
protected String execute(final NodeToken token) throws Exception { |
|
34 |
final String sqlText = fetchSqlAsText(sql); |
|
35 |
|
|
36 |
W3CEndpointReference epr = null; |
|
37 |
|
|
38 |
final DatabaseService dbService = serviceLocator.getService(DatabaseService.class); |
|
39 |
|
|
40 |
if (StringUtils.isNotBlank(xslt)) { |
|
41 |
final String xsltText = IOUtils.toString(getClass().getResourceAsStream(xslt)); |
|
42 |
|
|
43 |
if (StringUtils.isBlank(sqlForSize)) { |
|
44 |
epr = dbService.xsltSearchSQL(findDb(token), sqlText, xsltText); |
|
45 |
} else { |
|
46 |
epr = dbService.alternativeXsltSearchSQL(findDb(token), sqlText, fetchSqlAsText(sqlForSize), xsltText); |
|
47 |
} |
|
48 |
} else { |
|
49 |
if (StringUtils.isBlank(sqlForSize)) { |
|
50 |
epr = dbService.searchSQL(findDb(token), sqlText); |
|
51 |
} else { |
|
52 |
epr = dbService.alternativeSearchSQL(findDb(token), sqlText, fetchSqlAsText(sqlForSize)); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
57 |
|
|
58 |
return Arc.DEFAULT_ARC; |
|
59 |
} |
|
60 |
|
|
61 |
private String fetchSqlAsText(final String path) throws IOException { |
|
62 |
return IOUtils.toString(getClass().getResourceAsStream(path)); |
|
63 |
} |
|
64 |
|
|
65 |
private String findDb(final NodeToken token) { |
|
66 |
if (dbParam != null && !dbParam.isEmpty()) { |
|
67 |
return token.getEnv().getAttribute(dbParam); |
|
68 |
} else if (dbProperty != null && !dbProperty.isEmpty()) { |
|
69 |
return getPropertyFetcher().getProperty(dbProperty); |
|
70 |
} else { |
|
71 |
return db; |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
public String getDb() { |
|
76 |
return db; |
|
77 |
} |
|
78 |
|
|
79 |
public void setDb(final String db) { |
|
80 |
this.db = db; |
|
81 |
} |
|
82 |
|
|
83 |
public String getDbParam() { |
|
84 |
return dbParam; |
|
85 |
} |
|
86 |
|
|
87 |
public void setDbParam(final String dbParam) { |
|
88 |
this.dbParam = dbParam; |
|
89 |
} |
|
90 |
|
|
91 |
public String getSql() { |
|
92 |
return sql; |
|
93 |
} |
|
94 |
|
|
95 |
public void setSql(final String sql) { |
|
96 |
this.sql = sql; |
|
97 |
} |
|
98 |
|
|
99 |
public String getXslt() { |
|
100 |
return xslt; |
|
101 |
} |
|
102 |
|
|
103 |
public void setXslt(final String xslt) { |
|
104 |
this.xslt = xslt; |
|
105 |
} |
|
106 |
|
|
107 |
public String getOutputEprParam() { |
|
108 |
return outputEprParam; |
|
109 |
} |
|
110 |
|
|
111 |
public void setOutputEprParam(final String outputEprParam) { |
|
112 |
this.outputEprParam = outputEprParam; |
|
113 |
} |
|
114 |
|
|
115 |
public String getDbProperty() { |
|
116 |
return dbProperty; |
|
117 |
} |
|
118 |
|
|
119 |
public void setDbProperty(final String dbProperty) { |
|
120 |
this.dbProperty = dbProperty; |
|
121 |
} |
|
122 |
|
|
123 |
public String getSqlForSize() { |
|
124 |
return sqlForSize; |
|
125 |
} |
|
126 |
|
|
127 |
public void setSqlForSize(final String sqlForSize) { |
|
128 |
this.sqlForSize = sqlForSize; |
|
129 |
} |
|
130 |
|
|
131 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/RegisterMetaWfJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import com.googlecode.sarasvati.Arc; |
|
8 |
import com.googlecode.sarasvati.NodeToken; |
|
9 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
10 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
11 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
12 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
13 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
14 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
15 |
import org.antlr.stringtemplate.StringTemplate; |
|
16 |
import org.apache.commons.io.IOUtils; |
|
17 |
import org.apache.commons.lang.StringEscapeUtils; |
|
18 |
|
|
19 |
public class RegisterMetaWfJobNode extends SimpleJobNode { |
|
20 |
|
|
21 |
@Resource |
|
22 |
private UniqueServiceLocator serviceLocator; |
|
23 |
private String adminEmail; |
|
24 |
|
|
25 |
private String wfName; |
|
26 |
|
|
27 |
@Override |
|
28 |
protected String execute(final NodeToken token) throws Exception { |
|
29 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
30 |
final String dsName = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME); |
|
31 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
32 |
|
|
33 |
final String metaWfId = registerDatasourceWorkflow(dsId, dsName, ifaceId); |
|
34 |
|
|
35 |
token.getFullEnv().setAttribute("META_WORKFLOW_ID", metaWfId); |
|
36 |
token.getFullEnv().setAttribute("META_WORKFLOW_STATUS", WorkflowStatus.ASSIGNED.toString()); |
|
37 |
|
|
38 |
return Arc.DEFAULT_ARC; |
|
39 |
} |
|
40 |
|
|
41 |
public String registerDatasourceWorkflow(final String dsId, final String dsName, final String ifaceId) throws ISRegistryException, IOException { |
|
42 |
final StringWriter sw = new StringWriter(); |
|
43 |
IOUtils.copy(getClass().getResourceAsStream("/eu/dnetlib/msro/workflows/templates/meta-workflow.xml.st"), sw); |
|
44 |
|
|
45 |
final StringTemplate st = new StringTemplate(sw.toString()); |
|
46 |
st.setAttribute("dsId", dsId); |
|
47 |
st.setAttribute("ifaceId", ifaceId); |
|
48 |
st.setAttribute("dsName", StringEscapeUtils.escapeXml(dsName)); |
|
49 |
st.setAttribute("section", "dataproviders"); |
|
50 |
st.setAttribute("wfName", StringEscapeUtils.escapeXml(getWfName())); |
|
51 |
st.setAttribute("wfFamily", StringEscapeUtils.escapeXml(getWfName())); |
|
52 |
st.setAttribute("adminEmail", adminEmail); |
|
53 |
st.setAttribute("status", WorkflowStatus.ASSIGNED.toString()); |
|
54 |
|
|
55 |
return serviceLocator.getService(ISRegistryService.class).registerProfile(st.toString()); |
|
56 |
} |
|
57 |
|
|
58 |
public String getWfName() { |
|
59 |
return wfName; |
|
60 |
} |
|
61 |
|
|
62 |
public void setWfName(final String wfName) { |
|
63 |
this.wfName = wfName; |
|
64 |
} |
|
65 |
|
|
66 |
public String getAdminEmail() { |
|
67 |
return adminEmail; |
|
68 |
} |
|
69 |
|
|
70 |
public void setAdminEmail(final String adminEmail) { |
|
71 |
this.adminEmail = adminEmail; |
|
72 |
} |
|
73 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.12/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/CreateObjectStoreJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
2 |
|
|
3 |
import java.util.Map; |
|
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.Engine; |
|
10 |
import com.googlecode.sarasvati.NodeToken; |
|
11 |
import com.googlecode.sarasvati.env.Env; |
|
12 |
|
|
13 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; |
|
14 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
15 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
16 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
17 |
|
|
18 |
public class CreateObjectStoreJobNode extends BlackboardJobNode { |
|
19 |
|
|
20 |
private static final Log log = LogFactory.getLog(CreateObjectStoreJobNode.class); |
|
21 |
|
|
22 |
private String interpretation; |
|
23 |
private String outputPrefix = "objectStore_"; |
|
24 |
|
|
25 |
@Override |
|
26 |
protected String obtainServiceId(final NodeToken token) { |
|
27 |
return getServiceLocator().getServiceId(ObjectStoreService.class); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) { |
|
32 |
log.info("preparing blackboard job for the creation of the objectStore "); |
|
33 |
String basePath = token.getEnv().getAttribute("objectStoreBasePath"); |
|
34 |
job.setAction("CREATE"); |
|
35 |
job.getParameters().put("interpretation", interpretation); |
|
36 |
if (!StringUtils.isEmpty(basePath)) { |
|
37 |
job.getParameters().put("basePath", basePath); |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public String getInterpretation() { |
|
42 |
return interpretation; |
|
43 |
} |
|
44 |
|
|
45 |
public void setInterpretation(final String interpretation) { |
|
46 |
this.interpretation = interpretation; |
|
47 |
} |
|
48 |
|
|
49 |
public String getOutputPrefix() { |
|
50 |
return outputPrefix; |
|
51 |
} |
|
52 |
|
|
53 |
public void setOutputPrefix(final String outputPrefix) { |
|
54 |
this.outputPrefix = outputPrefix; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
59 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
63 |
|
|
64 |
env.setAttribute(getOutputPrefix() + "interpretation", interpretation); |
|
65 |
env.setAttribute(getOutputPrefix() + "id", responseParams.get("objectStoreId")); |
|
66 |
} |
|
67 |
}; |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-msro-service-3.1.12