Revision 33018
Added by Sandro La Bruzzo almost 10 years ago
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/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>2.1.2</version> |
|
14 |
<scm> |
|
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-msro-service/tags/dnet-msro-service-2.1.2</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.0.0,2.0.0)</version> |
|
47 |
</dependency> |
|
48 |
|
|
49 |
<dependency> |
|
50 |
<groupId>eu.dnetlib</groupId> |
|
51 |
<artifactId>cnr-blackboard-common</artifactId> |
|
52 |
<version>[2.1.0,3.0.0)</version> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>eu.dnetlib</groupId> |
|
56 |
<artifactId>dnet-mongo-logging</artifactId> |
|
57 |
<version>[1.0.0,2.0.0)</version> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>eu.dnetlib</groupId> |
|
61 |
<artifactId>dnet-datasource-common</artifactId> |
|
62 |
<version>[3.0.0,4.0.0)</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>com.googlecode</groupId> |
|
66 |
<artifactId>sarasvati</artifactId> |
|
67 |
<version>1.0.3</version> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>com.googlecode</groupId> |
|
71 |
<artifactId>sarasvati-visual</artifactId> |
|
72 |
<version>1.0.3</version> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>eu.dnetlib</groupId> |
|
76 |
<artifactId>dnet-modular-collector-service-rmi</artifactId> |
|
77 |
<version>[1.2.0,2.0.0)</version> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>eu.dnetlib</groupId> |
|
81 |
<artifactId>cnr-enabling-database-api</artifactId> |
|
82 |
<version>[1.0.0,2.0.0)</version> |
|
83 |
</dependency> |
|
84 |
<dependency> |
|
85 |
<groupId>eu.dnetlib</groupId> |
|
86 |
<artifactId>dnet-objectstore-rmi</artifactId> |
|
87 |
<version>[2.0.0,3.0.0)</version> |
|
88 |
</dependency> |
|
89 |
<dependency> |
|
90 |
<groupId>eu.dnetlib</groupId> |
|
91 |
<artifactId>dnet-data-transformation-service-rmi</artifactId> |
|
92 |
<version>[1.0.0,2.0.0)</version> |
|
93 |
</dependency> |
|
94 |
<dependency> |
|
95 |
<groupId>eu.dnetlib</groupId> |
|
96 |
<artifactId>dnet-data-provision-rmi</artifactId> |
|
97 |
<version>[1.0.0,2.0.0)</version> |
|
98 |
</dependency> |
|
99 |
<dependency> |
|
100 |
<groupId>eu.dnetlib</groupId> |
|
101 |
<artifactId>dnet-runtime</artifactId> |
|
102 |
<version>[1.0.0,2.0.0)</version> |
|
103 |
</dependency> |
|
104 |
<dependency> |
|
105 |
<groupId>javax.mail</groupId> |
|
106 |
<artifactId>mail</artifactId> |
|
107 |
<version>1.4</version> |
|
108 |
</dependency> |
|
109 |
<dependency> |
|
110 |
<groupId>org.codehaus.groovy</groupId> |
|
111 |
<artifactId>groovy-all</artifactId> |
|
112 |
<version>2.1.6</version> |
|
113 |
</dependency> |
|
114 |
<dependency> |
|
115 |
<groupId>junit</groupId> |
|
116 |
<artifactId>junit</artifactId> |
|
117 |
<version>${junit.version}</version> |
|
118 |
<scope>test</scope> |
|
119 |
</dependency> |
|
120 |
<dependency> |
|
121 |
<groupId>joda-time</groupId> |
|
122 |
<artifactId>joda-time</artifactId> |
|
123 |
<version>2.3</version> |
|
124 |
</dependency> |
|
125 |
</dependencies> |
|
126 |
|
|
127 |
<properties> |
|
128 |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
|
129 |
</properties> |
|
130 |
|
|
131 |
</project> |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/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-2.1.2/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.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.objectstore.rmi.ObjectStoreService; |
|
13 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
14 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
|
15 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
16 |
|
|
17 |
public class CreateObjectStoreJobNode extends BlackboardJobNode { |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(CreateObjectStoreJobNode.class); |
|
20 |
|
|
21 |
private String interpretation; |
|
22 |
private String outputPrefix = "objectStore_"; |
|
23 |
|
|
24 |
@Override |
|
25 |
protected String obtainServiceId(final NodeToken token) { |
|
26 |
return getServiceLocator().getServiceId(ObjectStoreService.class); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) { |
|
31 |
log.info("preparing blackboard job for the creation of the objectStore "); |
|
32 |
job.setAction("CREATE"); |
|
33 |
job.getParameters().put("interpretation", interpretation); |
|
34 |
} |
|
35 |
|
|
36 |
public String getInterpretation() { |
|
37 |
return interpretation; |
|
38 |
} |
|
39 |
|
|
40 |
public void setInterpretation(final String interpretation) { |
|
41 |
this.interpretation = interpretation; |
|
42 |
} |
|
43 |
|
|
44 |
public String getOutputPrefix() { |
|
45 |
return outputPrefix; |
|
46 |
} |
|
47 |
|
|
48 |
public void setOutputPrefix(final String outputPrefix) { |
|
49 |
this.outputPrefix = outputPrefix; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
54 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
55 |
|
|
56 |
@Override |
|
57 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
58 |
; |
|
59 |
env.setAttribute(getOutputPrefix() + "interpretation", interpretation); |
|
60 |
env.setAttribute(getOutputPrefix() + "id", responseParams.get("objectStoreId")); |
|
61 |
} |
|
62 |
}; |
|
63 |
} |
|
64 |
|
|
65 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/resources/eu/dnetlib/test/schemas/WorkflowDSResourceType.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" |
|
3 |
elementFormDefault="qualified"> |
|
4 |
<xs:element name="RESOURCE_PROFILE"> |
|
5 |
<xs:complexType> |
|
6 |
<xs:sequence> |
|
7 |
<xs:element ref="HEADER" /> |
|
8 |
<xs:element ref="BODY" /> |
|
9 |
</xs:sequence> |
|
10 |
</xs:complexType> |
|
11 |
</xs:element> |
|
12 |
<xs:element name="HEADER"> |
|
13 |
<xs:complexType> |
|
14 |
<xs:sequence> |
|
15 |
<xs:element ref="RESOURCE_IDENTIFIER" /> |
|
16 |
<xs:element ref="RESOURCE_TYPE" /> |
|
17 |
<xs:element ref="RESOURCE_KIND" /> |
|
18 |
<xs:element ref="RESOURCE_URI" /> |
|
19 |
<xs:element ref="DATE_OF_CREATION" /> |
|
20 |
</xs:sequence> |
|
21 |
</xs:complexType> |
|
22 |
</xs:element> |
|
23 |
<xs:element name="RESOURCE_IDENTIFIER"> |
|
24 |
<xs:complexType> |
|
25 |
<xs:attribute name="value" use="required" /> |
|
26 |
</xs:complexType> |
|
27 |
</xs:element> |
|
28 |
<xs:element name="RESOURCE_TYPE"> |
|
29 |
<xs:complexType> |
|
30 |
<xs:attribute name="value" use="required" fixed="WorkflowDSResourceType" /> |
|
31 |
</xs:complexType> |
|
32 |
</xs:element> |
|
33 |
<xs:element name="RESOURCE_KIND"> |
|
34 |
<xs:complexType> |
|
35 |
<xs:attribute name="value" use="required" fixed="WorkflowDSResources" /> |
|
36 |
</xs:complexType> |
|
37 |
</xs:element> |
|
38 |
<xs:element name="RESOURCE_URI"> |
|
39 |
<xs:complexType> |
|
40 |
<xs:attribute name="value" use="required" /> |
|
41 |
</xs:complexType> |
|
42 |
</xs:element> |
|
43 |
<xs:element name="DATE_OF_CREATION"> |
|
44 |
<xs:complexType> |
|
45 |
<xs:attribute name="value" use="required" type="xs:dateTime" /> |
|
46 |
</xs:complexType> |
|
47 |
</xs:element> |
|
48 |
<xs:element name="BODY"> |
|
49 |
<xs:complexType> |
|
50 |
<xs:sequence> |
|
51 |
<xs:element name="WORKFLOW_NAME" type="xs:string" /> |
|
52 |
<xs:element name="WORKFLOW_INFO" minOccurs="0" maxOccurs="1"> |
|
53 |
<xs:complexType> |
|
54 |
<xs:sequence> |
|
55 |
<xs:element name="FIELD" minOccurs="0" maxOccurs="unbounded"> |
|
56 |
<xs:complexType> |
|
57 |
<xs:simpleContent> |
|
58 |
<xs:extension base="xs:string"> |
|
59 |
<xs:attribute name="name" use="required" type="xs:string"/> |
|
60 |
</xs:extension> |
|
61 |
</xs:simpleContent> |
|
62 |
</xs:complexType> |
|
63 |
</xs:element> |
|
64 |
</xs:sequence> |
|
65 |
</xs:complexType> |
|
66 |
</xs:element> |
|
67 |
<xs:element name="WORKFLOW_TYPE" type="xs:string" /> |
|
68 |
<xs:element name="WORKFLOW_PRIORITY"> |
|
69 |
<xs:simpleType> |
|
70 |
<xs:restriction base="xs:integer"> |
|
71 |
<xs:minInclusive value="0" /> |
|
72 |
<xs:maxInclusive value="100" /> |
|
73 |
</xs:restriction> |
|
74 |
</xs:simpleType> |
|
75 |
</xs:element> |
|
76 |
<xs:element ref="CONFIGURATION" /> |
|
77 |
<xs:element ref="STATUS" /> |
|
78 |
</xs:sequence> |
|
79 |
</xs:complexType> |
|
80 |
</xs:element> |
|
81 |
<xs:element name="WORKFLOW_NAME" type="xs:string" /> |
|
82 |
<xs:element name="CONFIGURATION"> |
|
83 |
<xs:complexType> |
|
84 |
<xs:sequence> |
|
85 |
<xs:element maxOccurs="unbounded" ref="NODE" /> |
|
86 |
</xs:sequence> |
|
87 |
<xs:attribute name="start" use="required"> |
|
88 |
<xs:simpleType> |
|
89 |
<xs:restriction base="xs:NCName"> |
|
90 |
<xs:enumeration value="auto" /> |
|
91 |
<xs:enumeration value="manual" /> |
|
92 |
<xs:enumeration value="disabled" /> |
|
93 |
</xs:restriction> |
|
94 |
</xs:simpleType> |
|
95 |
</xs:attribute> |
|
96 |
</xs:complexType> |
|
97 |
</xs:element> |
|
98 |
<xs:element name="NODE"> |
|
99 |
<xs:complexType> |
|
100 |
<xs:sequence> |
|
101 |
<xs:element ref="DESCRIPTION" /> |
|
102 |
<xs:element ref="PARAMETERS" /> |
|
103 |
<xs:element ref="ARCS" /> |
|
104 |
</xs:sequence> |
|
105 |
<xs:attribute name="isStart" use="optional" type="xs:boolean" /> |
|
106 |
<xs:attribute name="isJoin" use="optional" type="xs:boolean" /> |
|
107 |
<xs:attribute name="name" use="required" type="xs:NCName" /> |
|
108 |
<xs:attribute name="type" use="optional" type="xs:NCName" /> |
|
109 |
</xs:complexType> |
|
110 |
</xs:element> |
|
111 |
<xs:element name="DESCRIPTION" type="xs:string" /> |
|
112 |
<xs:element name="PARAMETERS"> |
|
113 |
<xs:complexType> |
|
114 |
<xs:sequence> |
|
115 |
<xs:element minOccurs="0" maxOccurs="unbounded" ref="PARAM" /> |
|
116 |
</xs:sequence> |
|
117 |
</xs:complexType> |
|
118 |
</xs:element> |
|
119 |
<xs:element name="PARAM"> |
|
120 |
<xs:complexType mixed="true"> |
|
121 |
<xs:simpleContent> |
|
122 |
<xs:extension base="xs:string"> |
|
123 |
<xs:attribute name="name" use="required" type="xs:NCName" /> |
|
124 |
<xs:attribute name="required" use="optional" type="xs:boolean" /> |
|
125 |
<xs:attribute name="managedBy" use="required"> |
|
126 |
<xs:simpleType> |
|
127 |
<xs:restriction base="xs:NCName"> |
|
128 |
<xs:enumeration value="user" /> |
|
129 |
<xs:enumeration value="system" /> |
|
130 |
</xs:restriction> |
|
131 |
</xs:simpleType> |
|
132 |
</xs:attribute> |
|
133 |
<xs:attribute name="type" use="optional"> |
|
134 |
<xs:simpleType> |
|
135 |
<xs:restriction base="xs:NCName"> |
|
136 |
<xs:enumeration value="int" /> |
|
137 |
<xs:enumeration value="boolean" /> |
|
138 |
<xs:enumeration value="float" /> |
|
139 |
<xs:enumeration value="string" /> |
|
140 |
<xs:enumeration value="date" /> |
|
141 |
<xs:enumeration value="datetime" /> |
|
142 |
<xs:enumeration value="property" /> |
|
143 |
</xs:restriction> |
|
144 |
</xs:simpleType> |
|
145 |
</xs:attribute> |
|
146 |
<xs:attribute name="function" use="optional" type="xs:string" /> |
|
147 |
<xs:attribute name="category" use="optional" type="xs:string" /> |
|
148 |
</xs:extension> |
|
149 |
</xs:simpleContent> |
|
150 |
</xs:complexType> |
|
151 |
</xs:element> |
|
152 |
<xs:element name="ARCS"> |
|
153 |
<xs:complexType> |
|
154 |
<xs:sequence> |
|
155 |
<xs:element maxOccurs="unbounded" ref="ARC" /> |
|
156 |
</xs:sequence> |
|
157 |
</xs:complexType> |
|
158 |
</xs:element> |
|
159 |
<xs:element name="ARC"> |
|
160 |
<xs:complexType> |
|
161 |
<xs:attribute name="name" use="optional" type="xs:string" /> |
|
162 |
<xs:attribute name="to" use="required" type="xs:NCName" /> |
|
163 |
</xs:complexType> |
|
164 |
</xs:element> |
|
165 |
|
|
166 |
<xs:element name="STATUS"> |
|
167 |
<xs:complexType> |
|
168 |
<xs:sequence minOccurs="0"> |
|
169 |
<xs:element name="LAST_EXECUTION_ID" type="xs:string" /> |
|
170 |
<xs:element name="LAST_EXECUTION_DATE" type="xs:dateTime" /> |
|
171 |
<xs:element name="LAST_EXECUTION_STATUS" type="xs:NCName" /> |
|
172 |
<xs:element name="LAST_EXECUTION_ERROR" type="xs:string" /> |
|
173 |
<xs:element name="LAST_EXECUTION_OUTPUT" minOccurs="0" maxOccurs="unbounded"> |
|
174 |
<xs:complexType> |
|
175 |
<xs:simpleContent> |
|
176 |
<xs:extension base="xs:string"> |
|
177 |
<xs:attribute name="name" type="xs:string" use="required" /> |
|
178 |
</xs:extension> |
|
179 |
</xs:simpleContent> |
|
180 |
</xs:complexType> |
|
181 |
</xs:element> |
|
182 |
</xs:sequence> |
|
183 |
</xs:complexType> |
|
184 |
</xs:element> |
|
185 |
|
|
186 |
</xs:schema> |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/repobye/DeleteMetaWfJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repobye; |
|
2 |
|
|
3 |
import java.io.StringReader; |
|
4 |
import java.io.StringWriter; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.apache.commons.logging.Log; |
|
9 |
import org.apache.commons.logging.LogFactory; |
|
10 |
import org.dom4j.Document; |
|
11 |
import org.dom4j.Node; |
|
12 |
import org.dom4j.io.SAXReader; |
|
13 |
|
|
14 |
import com.googlecode.sarasvati.Arc; |
|
15 |
import com.googlecode.sarasvati.NodeToken; |
|
16 |
|
|
17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
18 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
19 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
20 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
21 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
22 |
|
|
23 |
public class DeleteMetaWfJobNode extends SimpleJobNode { |
|
24 |
|
|
25 |
private String metaWfId; |
|
26 |
|
|
27 |
@Resource |
|
28 |
private UniqueServiceLocator serviceLocator; |
|
29 |
|
|
30 |
private static final Log log = LogFactory.getLog(DeleteMetaWfJobNode.class); |
|
31 |
|
|
32 |
@Override |
|
33 |
protected String execute(final NodeToken token) throws Exception { |
|
34 |
final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(metaWfId); |
|
35 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
|
36 |
|
|
37 |
final String dsId = doc.valueOf("//DATAPROVIDER/@id"); |
|
38 |
final String dsName = doc.valueOf("//DATAPROVIDER/text()"); |
|
39 |
final String ifaceId = doc.valueOf("//DATAPROVIDER/@interface"); |
|
40 |
final String destroyWfId = doc.valueOf("//CONFIGURATION/@destroyWorkflow"); |
|
41 |
|
|
42 |
log.info("Removing a MetaWf of dataprovider: " + dsId); |
|
43 |
|
|
44 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, dsId); |
|
45 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_NAME, dsName); |
|
46 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE, ifaceId); |
|
47 |
|
|
48 |
final ISRegistryService registry = serviceLocator.getService(ISRegistryService.class); |
|
49 |
|
|
50 |
for (Object o : doc.selectNodes("//WORKFLOW")) { |
|
51 |
final String wfId = ((Node) o).valueOf("@id"); |
|
52 |
try { |
|
53 |
registry.deleteProfile(wfId); |
|
54 |
log.info(" - Deleted Workflow: " + wfId); |
|
55 |
} catch (Exception e) { |
|
56 |
log.error(" - (ERR) Error deleting profile " + wfId); |
|
57 |
} |
|
58 |
} |
|
59 |
registry.deleteProfile(metaWfId); |
|
60 |
log.info(" - Deleted MetaWorkflow: " + metaWfId); |
|
61 |
|
|
62 |
registry.deleteProfile(destroyWfId); |
|
63 |
log.info(" - Deleted destroy workflow: " + destroyWfId); |
|
64 |
|
|
65 |
verifyDatasource(dsId, ifaceId); |
|
66 |
|
|
67 |
return Arc.DEFAULT_ARC; |
|
68 |
} |
|
69 |
|
|
70 |
private void verifyDatasource(final String dsId, final String ifaceId) throws Exception { |
|
71 |
final StringWriter sw = new StringWriter(); |
|
72 |
|
|
73 |
sw.append("for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') where"); |
|
74 |
sw.append(" $x//DATAPROVIDER/@id = '" + dsId + "' and "); |
|
75 |
sw.append(" $x//DATAPROVIDER/@interface = '" + ifaceId + "' and "); |
|
76 |
sw.append(" $x//RESOURCE_IDENTIFIER/@value != '" + metaWfId + "' "); |
|
77 |
sw.append("return $x//RESOURCE_IDENTIFIER/@value/string()"); |
|
78 |
|
|
79 |
final boolean active = !serviceLocator.getService(ISLookUpService.class).quickSearchProfile(sw.toString()).isEmpty(); |
|
80 |
|
|
81 |
log.info(" - Updating iface, active status: " + active); |
|
82 |
|
|
83 |
updateIfaceActivationStatus(dsId, ifaceId, active); |
|
84 |
} |
|
85 |
|
|
86 |
protected void updateIfaceActivationStatus(final String dsId, final String ifaceId, final boolean active) throws Exception { |
|
87 |
serviceLocator.getService(ISRegistryService.class).updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'"); |
|
88 |
} |
|
89 |
|
|
90 |
public String getMetaWfId() { |
|
91 |
return metaWfId; |
|
92 |
} |
|
93 |
|
|
94 |
public void setMetaWfId(final String metaWfId) { |
|
95 |
this.metaWfId = metaWfId; |
|
96 |
} |
|
97 |
|
|
98 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/blackboard/BlackboardWorkflowJobListener.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.blackboard; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
import java.util.Map.Entry; |
|
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.Engine; |
|
11 |
import com.googlecode.sarasvati.NodeToken; |
|
12 |
import com.googlecode.sarasvati.env.Env; |
|
13 |
|
|
14 |
import eu.dnetlib.enabling.tools.blackboard.AbstractBlackboardJobListener; |
|
15 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
16 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
17 |
|
|
18 |
public class BlackboardWorkflowJobListener extends AbstractBlackboardJobListener { |
|
19 |
|
|
20 |
/** |
|
21 |
* logger. |
|
22 |
*/ |
|
23 |
private static final Log log = LogFactory.getLog(BlackboardWorkflowJobListener.class); |
|
24 |
|
|
25 |
/** |
|
26 |
* workflow engine. |
|
27 |
*/ |
|
28 |
private Engine engine; |
|
29 |
|
|
30 |
/** |
|
31 |
* workflow node token. |
|
32 |
*/ |
|
33 |
private NodeToken token; |
|
34 |
|
|
35 |
@Override |
|
36 |
protected void onDone(final BlackboardJob job) { |
|
37 |
log.debug("Blackboard workflow node DONE"); |
|
38 |
complete(job, Arc.DEFAULT_ARC); |
|
39 |
} |
|
40 |
|
|
41 |
public BlackboardWorkflowJobListener(final Engine engine, final NodeToken token) { |
|
42 |
super(); |
|
43 |
this.engine = engine; |
|
44 |
this.token = token; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
final public void processJob(final BlackboardJob job) { |
|
49 |
token.getEnv().setTransientAttribute(WorkflowsConstants.BLACKBOARD_JOB, job); |
|
50 |
super.processJob(job); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
final protected void onFailed(final BlackboardJob job) { |
|
55 |
log.warn("Blackboard workflow node FAILED: " + job.getError()); |
|
56 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_HAS_FAILED, true); |
|
57 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_ERROR, job.getError()); |
|
58 |
complete(job, "failed"); |
|
59 |
} |
|
60 |
|
|
61 |
final protected void complete(final BlackboardJob job, final String arc) { |
|
62 |
final Env env = token.getEnv(); |
|
63 |
|
|
64 |
populateEnv(env, job.getParameters()); |
|
65 |
|
|
66 |
engine.complete(token, arc); |
|
67 |
engine.executeQueuedArcTokens(token.getProcess()); |
|
68 |
} |
|
69 |
|
|
70 |
protected void populateEnv(final Env env, Map<String, String> responseParams) { |
|
71 |
for (Entry<String, String> entry : responseParams.entrySet()) { |
|
72 |
env.setAttribute(WorkflowsConstants.BLACKBOARD_PARAM_PREFIX + entry.getKey(), entry.getValue()); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
protected void onOngoing(final BlackboardJob job) { |
|
78 |
token.getEnv().setAttribute(WorkflowsConstants.BLACKBOARD_IS_GOING, true); |
|
79 |
} |
|
80 |
|
|
81 |
public Engine getEngine() { |
|
82 |
return engine; |
|
83 |
} |
|
84 |
|
|
85 |
public void setEngine(final Engine engine) { |
|
86 |
this.engine = engine; |
|
87 |
} |
|
88 |
|
|
89 |
public NodeToken getToken() { |
|
90 |
return token; |
|
91 |
} |
|
92 |
|
|
93 |
public void setToken(final NodeToken token) { |
|
94 |
this.token = token; |
|
95 |
} |
|
96 |
|
|
97 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/ValidateDatasourceJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
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.registry.rmi.ISRegistryException; |
|
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 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
16 |
|
|
17 |
public class ValidateDatasourceJobNode extends SimpleJobNode { |
|
18 |
|
|
19 |
@Resource |
|
20 |
private UniqueServiceLocator serviceLocator; |
|
21 |
|
|
22 |
private static final Log log = LogFactory.getLog(ValidateDatasourceJobNode.class); |
|
23 |
|
|
24 |
@Override |
|
25 |
protected String execute(final NodeToken token) throws Exception { |
|
26 |
String oldId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
27 |
String newId = registerDatasourceWorkflow(oldId); |
|
28 |
token.getFullEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, newId); |
|
29 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, newId); |
|
30 |
|
|
31 |
log.info("Validated datasource - OLD ID: " + oldId); |
|
32 |
log.info("Validated datasource - NEW ID: " + newId); |
|
33 |
|
|
34 |
return Arc.DEFAULT_ARC; |
|
35 |
} |
|
36 |
|
|
37 |
public String registerDatasourceWorkflow(final String oldId) throws ISRegistryException { |
|
38 |
return serviceLocator.getService(ISRegistryService.class).validateProfile(oldId); |
|
39 |
} |
|
40 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/index/CreateIndexJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.index; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.apache.commons.logging.Log; |
|
6 |
import org.apache.commons.logging.LogFactory; |
|
7 |
import org.springframework.beans.factory.annotation.Required; |
|
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.provision.index.rmi.IndexService; |
|
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 |
// TODO: Auto-generated Javadoc |
|
19 |
/** |
|
20 |
* The Class CreateIndexJobNode. |
|
21 |
*/ |
|
22 |
public class CreateIndexJobNode extends BlackboardJobNode { |
|
23 |
|
|
24 |
/** The Constant log. */ |
|
25 |
private static final Log log = LogFactory.getLog(CreateIndexJobNode.class); |
|
26 |
|
|
27 |
/** The output prefix. */ |
|
28 |
private String outputPrefix = "index_"; |
|
29 |
|
|
30 |
/** The default backend id. */ |
|
31 |
private String defaultBackendId; |
|
32 |
|
|
33 |
/** The format. */ |
|
34 |
private String format; |
|
35 |
|
|
36 |
/** The layout. */ |
|
37 |
private String layout; |
|
38 |
|
|
39 |
/** The interpretation. */ |
|
40 |
private String interpretation; |
|
41 |
|
|
42 |
@Override |
|
43 |
protected String obtainServiceId(final NodeToken token) { |
|
44 |
return getServiceLocator().getServiceId(IndexService.class); |
|
45 |
} |
|
46 |
|
|
47 |
/* |
|
48 |
* (non-Javadoc) |
|
49 |
* |
|
50 |
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#prepareJob(eu.dnetlib.enabling.tools.blackboard.BlackboardJob, |
|
51 |
* com.googlecode.sarasvati.NodeToken) |
|
52 |
*/ |
|
53 |
@Override |
|
54 |
protected void prepareJob(final BlackboardJob job, final NodeToken token) { |
|
55 |
final String env_format = token.getFullEnv().getAttribute("format"); |
|
56 |
final String env_layout = token.getFullEnv().getAttribute("layout"); |
|
57 |
final String env_interp = token.getFullEnv().getAttribute("interpretation"); |
|
58 |
|
|
59 |
if (env_format != null && !env_format.isEmpty()) { |
|
60 |
this.format = env_format; |
|
61 |
} |
|
62 |
if (env_layout != null && !env_layout.isEmpty()) { |
|
63 |
this.layout = env_layout; |
|
64 |
} |
|
65 |
if (env_interp != null && !env_interp.isEmpty()) { |
|
66 |
this.interpretation = env_interp; |
|
67 |
} |
|
68 |
|
|
69 |
log.info("preparing CREATE blackboard job: " + format + "-" + layout + "-" + interpretation); |
|
70 |
|
|
71 |
job.setAction("CREATE"); |
|
72 |
job.getParameters().put("format", format); |
|
73 |
job.getParameters().put("layout", layout); |
|
74 |
job.getParameters().put("interpretation", interpretation); |
|
75 |
job.getParameters().put("backend_Id", defaultBackendId); |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* Gets the output prefix. |
|
80 |
* |
|
81 |
* @return the output prefix |
|
82 |
*/ |
|
83 |
public String getOutputPrefix() { |
|
84 |
return outputPrefix; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Sets the output prefix. |
|
89 |
* |
|
90 |
* @param outputPrefix |
|
91 |
* the output prefix |
|
92 |
*/ |
|
93 |
public void setOutputPrefix(final String outputPrefix) { |
|
94 |
this.outputPrefix = outputPrefix; |
|
95 |
} |
|
96 |
|
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* |
|
100 |
* @see eu.dnetlib.msro.workflows.nodes.BlackboardJobNode#generateBlackboardListener(com.googlecode.sarasvati.Engine, |
|
101 |
* com.googlecode.sarasvati.NodeToken) |
|
102 |
*/ |
|
103 |
@Override |
|
104 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
105 |
return new BlackboardWorkflowJobListener(engine, token) { |
|
106 |
|
|
107 |
@Override |
|
108 |
protected void populateEnv(final Env env, final Map<String, String> responseParams) { |
|
109 |
env.setAttribute(getOutputPrefix() + "format", getFormat()); |
|
110 |
env.setAttribute(getOutputPrefix() + "layout", getLayout()); |
|
111 |
env.setAttribute(getOutputPrefix() + "interpretation", getInterpretation()); |
|
112 |
env.setAttribute(getOutputPrefix() + "id", responseParams.get("id")); |
|
113 |
} |
|
114 |
}; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* Gets the default backend id. |
|
119 |
* |
|
120 |
* @return the default backend id |
|
121 |
*/ |
|
122 |
public String getDefaultBackendId() { |
|
123 |
return defaultBackendId; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* Sets the default backend id. |
|
128 |
* |
|
129 |
* @param defaultBackendId |
|
130 |
* the default backend id |
|
131 |
*/ |
|
132 |
@Required |
|
133 |
public void setDefaultBackendId(final String defaultBackendId) { |
|
134 |
this.defaultBackendId = defaultBackendId; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Gets the format. |
|
139 |
* |
|
140 |
* @return the format |
|
141 |
*/ |
|
142 |
public String getFormat() { |
|
143 |
return format; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Sets the format. |
|
148 |
* |
|
149 |
* @param format |
|
150 |
* the format |
|
151 |
*/ |
|
152 |
public void setFormat(final String format) { |
|
153 |
this.format = format; |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Gets the layout. |
|
158 |
* |
|
159 |
* @return the layout |
|
160 |
*/ |
|
161 |
public String getLayout() { |
|
162 |
return layout; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* Sets the layout. |
|
167 |
* |
|
168 |
* @param layout |
|
169 |
* the layout |
|
170 |
*/ |
|
171 |
public void setLayout(final String layout) { |
|
172 |
this.layout = layout; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* Gets the interpretation. |
|
177 |
* |
|
178 |
* @return the interpretation |
|
179 |
*/ |
|
180 |
public String getInterpretation() { |
|
181 |
return interpretation; |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* Sets the interpretation. |
|
186 |
* |
|
187 |
* @param interpretation |
|
188 |
* the interpretation |
|
189 |
*/ |
|
190 |
public void setInterpretation(final String interpretation) { |
|
191 |
this.interpretation = interpretation; |
|
192 |
} |
|
193 |
|
|
194 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/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 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import org.antlr.stringtemplate.StringTemplate; |
|
9 |
import org.apache.commons.io.IOUtils; |
|
10 |
|
|
11 |
import com.googlecode.sarasvati.Arc; |
|
12 |
import com.googlecode.sarasvati.NodeToken; |
|
13 |
|
|
14 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
15 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
16 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
17 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
18 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
19 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
20 |
|
|
21 |
public class RegisterMetaWfJobNode extends SimpleJobNode { |
|
22 |
|
|
23 |
@Resource |
|
24 |
private UniqueServiceLocator serviceLocator; |
|
25 |
|
|
26 |
private String wfName; |
|
27 |
|
|
28 |
@Override |
|
29 |
protected String execute(final NodeToken token) throws Exception { |
|
30 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
31 |
final String dsName = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME); |
|
32 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
33 |
|
|
34 |
final String metaWfId = registerDatasourceWorkflow(dsId, dsName, ifaceId); |
|
35 |
|
|
36 |
token.getFullEnv().setAttribute("META_WORKFLOW_ID", metaWfId); |
|
37 |
token.getFullEnv().setAttribute("META_WORKFLOW_STATUS", WorkflowStatus.ASSIGNED.toString()); |
|
38 |
|
|
39 |
return Arc.DEFAULT_ARC; |
|
40 |
} |
|
41 |
|
|
42 |
public String registerDatasourceWorkflow(final String dsId, final String dsName, final String ifaceId) throws ISRegistryException, IOException { |
|
43 |
final StringWriter sw = new StringWriter(); |
|
44 |
IOUtils.copy(getClass().getResourceAsStream("/eu/dnetlib/msro/workflows/templates/meta-workflow.xml.st"), sw); |
|
45 |
|
|
46 |
final StringTemplate st = new StringTemplate(sw.toString()); |
|
47 |
st.setAttribute("dsId", dsId); |
|
48 |
st.setAttribute("ifaceId", ifaceId); |
|
49 |
st.setAttribute("dsName", dsName); |
|
50 |
st.setAttribute("section", "dataproviders"); |
|
51 |
st.setAttribute("wfName", getWfName()); |
|
52 |
st.setAttribute("wfFamily", getWfName()); |
|
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 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/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.springframework.beans.factory.annotation.Autowired; |
|
10 |
|
|
11 |
import eu.dnetlib.data.mdstore.MDStoreService; |
|
12 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
|
13 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
14 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
15 |
|
|
16 |
// TODO: Auto-generated Javadoc |
|
17 |
/** |
|
18 |
* The Class MultipleMdStoreIterator. |
|
19 |
*/ |
|
20 |
public class MultipleMdStoreIterator implements Iterable<String>, Iterator<String> { |
|
21 |
|
|
22 |
/** The service locator. */ |
|
23 |
@Resource |
|
24 |
private UniqueServiceLocator serviceLocator; |
|
25 |
|
|
26 |
/** The md i ds. */ |
|
27 |
private List<String> mdIDs; |
|
28 |
|
|
29 |
/** The current id. */ |
|
30 |
private String currentId = null; |
|
31 |
|
|
32 |
/** The current iterator. */ |
|
33 |
private Iterator<String> currentIterator; |
|
34 |
|
|
35 |
/** The result set client factory. */ |
|
36 |
@Autowired |
|
37 |
private ResultSetClientFactory resultSetClientFactory; |
|
38 |
|
|
39 |
/** |
|
40 |
* Instantiates a new multiple md store iterator. |
|
41 |
* |
|
42 |
* @param mdstoreLocator |
|
43 |
* the mdstore locator |
|
44 |
* @param mdIds |
|
45 |
* the md ids |
|
46 |
*/ |
|
47 |
public MultipleMdStoreIterator(final UniqueServiceLocator serviceLocator, final List<String> mdIds, |
|
48 |
final ResultSetClientFactory resultSetClientFactory) { |
|
49 |
this.serviceLocator = serviceLocator; |
|
50 |
this.mdIDs = mdIds; |
|
51 |
this.resultSetClientFactory = resultSetClientFactory; |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* |
|
58 |
* @see java.lang.Iterable#iterator() |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public Iterator<String> iterator() { |
|
62 |
getNextMDStoreRecords(); |
|
63 |
return this; |
|
64 |
|
|
65 |
} |
|
66 |
|
|
67 |
/* |
|
68 |
* (non-Javadoc) |
|
69 |
* |
|
70 |
* @see java.util.Iterator#hasNext() |
|
71 |
*/ |
|
72 |
@Override |
|
73 |
public boolean hasNext() { |
|
74 |
if (currentId == null || currentIterator == null) { return false; } |
|
75 |
if (!currentIterator.hasNext()) { |
|
76 |
getNextMDStoreRecords(); |
|
77 |
} |
|
78 |
return currentIterator.hasNext(); |
|
79 |
} |
|
80 |
|
|
81 |
/* |
|
82 |
* (non-Javadoc) |
|
83 |
* |
|
84 |
* @see java.util.Iterator#next() |
|
85 |
*/ |
|
86 |
@Override |
|
87 |
public String next() { |
|
88 |
return currentIterator.next(); |
|
89 |
} |
|
90 |
|
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* |
|
94 |
* @see java.util.Iterator#remove() |
|
95 |
*/ |
|
96 |
@Override |
|
97 |
public void remove() { |
|
98 |
currentIterator.remove(); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Gets the next md store records. |
|
103 |
* |
|
104 |
* @return the next md store records |
|
105 |
*/ |
|
106 |
private void getNextMDStoreRecords() { |
|
107 |
if (mdIDs.size() > 0) { |
|
108 |
currentId = mdIDs.remove(0); |
|
109 |
currentIterator = getIterableResultset(currentId); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Gets the iterable resultset. |
|
115 |
* |
|
116 |
* @param id |
|
117 |
* the id |
|
118 |
* @return the iterable resultset |
|
119 |
*/ |
|
120 |
private Iterator<String> getIterableResultset(final String id) { |
|
121 |
try { |
|
122 |
W3CEndpointReference epr = serviceLocator.getService(MDStoreService.class, id).deliverMDRecords(id, "", "", ""); |
|
123 |
Iterable<String> input = resultSetClientFactory.getClient(epr); |
|
124 |
return input.iterator(); |
|
125 |
} catch (MDStoreServiceException e) { |
|
126 |
return null; |
|
127 |
} |
|
128 |
} |
|
129 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/BlackboardJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.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.Engine; |
|
10 |
import com.googlecode.sarasvati.NodeToken; |
|
11 |
|
|
12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
13 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardClientHandler; |
|
14 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
15 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJobImpl; |
|
16 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJobRegistry; |
|
17 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
18 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
19 |
|
|
20 |
public abstract class BlackboardJobNode extends SarasvatiJobNode { |
|
21 |
|
|
22 |
@Resource |
|
23 |
private UniqueServiceLocator serviceLocator; |
|
24 |
|
|
25 |
/** |
|
26 |
* logger. |
|
27 |
*/ |
|
28 |
private static final Log log = LogFactory.getLog(BlackboardJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
29 |
|
|
30 |
/** |
|
31 |
* blackboard handler. |
|
32 |
*/ |
|
33 |
@Resource |
|
34 |
private BlackboardClientHandler blackboardClientHandler; |
|
35 |
|
|
36 |
/** |
|
37 |
* blackboard job registry. |
|
38 |
*/ |
|
39 |
@Resource |
|
40 |
private BlackboardJobRegistry jobRegistry; |
|
41 |
|
|
42 |
@Override |
|
43 |
public void execute(final Engine engine, final NodeToken token) { |
|
44 |
super.execute(engine, token); |
|
45 |
|
|
46 |
log.info("executing blackboard node"); |
|
47 |
|
|
48 |
try { |
|
49 |
token.getEnv().setAttribute(WorkflowsConstants.BLACKBOARD_IS_BLACKBOARD, true); |
|
50 |
|
|
51 |
final String serviceId = obtainServiceId(token); |
|
52 |
if (StringUtils.isBlank(serviceId)) { |
|
53 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_HAS_FAILED, true); |
|
54 |
final String msg = "cannot locate target service profile: " + serviceId; |
|
55 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_ERROR, msg); |
|
56 |
log.error(msg); |
|
57 |
engine.complete(token, "failed"); |
|
58 |
return; |
|
59 |
} |
|
60 |
|
|
61 |
final BlackboardJob job = blackboardClientHandler.newJob(serviceId); |
|
62 |
|
|
63 |
token.getEnv().setTransientAttribute(WorkflowsConstants.BLACKBOARD_JOB, job); |
|
64 |
token.getEnv().setAttribute(WorkflowsConstants.BLACKBOARD_SERVICE_ID, ((BlackboardJobImpl) job).getServiceId()); |
|
65 |
prepareJob(job, token); |
|
66 |
|
|
67 |
jobRegistry.registerJobListener(job, generateBlackboardListener(engine, token)); |
|
68 |
|
|
69 |
blackboardClientHandler.assign(job); |
|
70 |
|
|
71 |
} catch (final Throwable e) { |
|
72 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_HAS_FAILED, true); |
|
73 |
token.getEnv().setAttribute(WorkflowsConstants.SYSTEM_ERROR, "cannot prepare blackboard job: " + e); |
|
74 |
engine.complete(token, "failed"); |
|
75 |
log.error("cannot prepare blackboard job", e); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
abstract protected String obtainServiceId(NodeToken token); |
|
80 |
|
|
81 |
abstract protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception; |
|
82 |
|
|
83 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) { |
|
84 |
return new BlackboardWorkflowJobListener(engine, token); |
|
85 |
} |
|
86 |
|
|
87 |
public UniqueServiceLocator getServiceLocator() { |
|
88 |
return serviceLocator; |
|
89 |
} |
|
90 |
|
|
91 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/collect/FindDateRangeForIncrementalHarvestingJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.collect; |
|
2 |
|
|
3 |
import java.text.SimpleDateFormat; |
|
4 |
import java.util.Date; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import javax.annotation.Resource; |
|
9 |
|
|
10 |
import org.apache.commons.lang.math.NumberUtils; |
|
11 |
import org.apache.commons.logging.Log; |
|
12 |
import org.apache.commons.logging.LogFactory; |
|
13 |
|
|
14 |
import com.googlecode.sarasvati.Arc; |
|
15 |
import com.googlecode.sarasvati.NodeToken; |
|
16 |
|
|
17 |
import eu.dnetlib.common.logging.DnetLogger; |
|
18 |
import eu.dnetlib.msro.rmi.MSROException; |
|
19 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
20 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
21 |
|
|
22 |
public class FindDateRangeForIncrementalHarvestingJobNode extends SimpleJobNode { |
|
23 |
|
|
24 |
private String fromDateParam; |
|
25 |
private String untilDateParam; |
|
26 |
private long ONE_DAY = 1000 * 60 * 60 * 24; |
|
27 |
|
|
28 |
@Resource(name = "msroWorkflowLogger") |
|
29 |
private DnetLogger dnetLogger; |
|
30 |
|
|
31 |
private static final Log log = LogFactory.getLog(FindDateRangeForIncrementalHarvestingJobNode.class); |
|
32 |
|
|
33 |
@Override |
|
34 |
protected String execute(NodeToken token) throws Exception { |
|
35 |
final String profId = findCurrentWfProfileId(token); |
|
36 |
final String fromDate = calculateFromDate(profId); |
|
37 |
final String untilDate = null; |
|
38 |
|
|
39 |
log.info("Incremental Harv Details - profId: " + profId + " - from: " + fromDate + " - until: " + untilDate); |
|
40 |
|
|
41 |
if (fromDate != null) { |
|
42 |
token.getEnv().setAttribute(getFromDateParam(), fromDate); |
|
43 |
} |
|
44 |
|
|
45 |
//if (untilDate != null) { |
|
46 |
// token.getEnv().setAttribute(getUntilDateParam(), untilDate); |
|
47 |
//} |
|
48 |
|
|
49 |
return Arc.DEFAULT_ARC; |
|
50 |
} |
|
51 |
|
|
52 |
private String calculateFromDate(final String profId) { |
|
53 |
final long d = findLastSuccessStartDate(profId); |
|
54 |
return (d > 0) ? (new SimpleDateFormat("yyyy-MM-dd")).format(new Date(d - ONE_DAY)) : null; |
|
55 |
} |
|
56 |
|
|
57 |
private long findLastSuccessStartDate(String profId) { |
|
58 |
long res = -1; |
|
59 |
|
|
60 |
final Iterator<Map<String, String>> iter = dnetLogger.find(WorkflowsConstants.SYSTEM_WF_PROFILE_ID, profId); |
|
61 |
while (iter.hasNext()) { |
|
62 |
final Map<String, String> map = iter.next(); |
|
63 |
if ("true".equalsIgnoreCase(map.get(WorkflowsConstants.SYSTEM_COMPLETED_SUCCESSFULLY))) { |
|
64 |
final long curr = NumberUtils.toLong(map.get(WorkflowsConstants.SYSTEM_START_DATE), -1); |
|
65 |
if (curr > res) { |
|
66 |
res = curr; |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
return res; |
|
71 |
} |
|
72 |
|
|
73 |
private String findCurrentWfProfileId(NodeToken token) throws MSROException { |
|
74 |
final String p1 = token.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID); |
|
75 |
if (p1 != null && !p1.isEmpty()) { |
|
76 |
return p1; |
|
77 |
} |
|
78 |
final String p2 = token.getFullEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID); |
|
79 |
if (p2 != null && !p2.isEmpty()) { |
|
80 |
return p2; |
|
81 |
} |
|
82 |
final String p3 = token.getProcess().getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID); |
|
83 |
if (p3 != null && !p3.isEmpty()) { |
|
84 |
return p3; |
|
85 |
} |
|
86 |
throw new MSROException("Missing property in env: " + WorkflowsConstants.SYSTEM_WF_PROFILE_ID); |
|
87 |
} |
|
88 |
|
|
89 |
public String getFromDateParam() { |
|
90 |
return fromDateParam; |
|
91 |
} |
|
92 |
public void setFromDateParam(String fromDateParam) { |
|
93 |
this.fromDateParam = fromDateParam; |
|
94 |
} |
|
95 |
public String getUntilDateParam() { |
|
96 |
return untilDateParam; |
|
97 |
} |
|
98 |
public void setUntilDateParam(String untilDateParam) { |
|
99 |
this.untilDateParam = untilDateParam; |
|
100 |
} |
|
101 |
|
|
102 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/resources/eu/dnetlib/test/schemas/MetaWorkflowDSResourceType.xsd | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> |
|
4 |
<xs:element name="RESOURCE_PROFILE"> |
|
5 |
<xs:complexType> |
|
6 |
<xs:sequence> |
|
7 |
<xs:element name="HEADER" type="HEADERType" /> |
|
8 |
<xs:element name="BODY" type="BODYType" /> |
|
9 |
</xs:sequence> |
|
10 |
</xs:complexType> |
|
11 |
</xs:element> |
|
12 |
<xs:complexType name="HEADERType"> |
|
13 |
<xs:all> |
|
14 |
<xs:element name="RESOURCE_IDENTIFIER" type="RESOURCE_IDENTIFIERType" /> |
|
15 |
<xs:element name="RESOURCE_TYPE" type="RESOURCE_TYPEType" /> |
|
16 |
<xs:element name="RESOURCE_KIND" type="RESOURCE_KINDType" /> |
|
17 |
<xs:element name="RESOURCE_URI" type="RESOURCE_URIType" /> |
|
18 |
<xs:element name="DATE_OF_CREATION" type="DATEType" /> |
|
19 |
</xs:all> |
|
20 |
</xs:complexType> |
|
21 |
<xs:complexType name="BODYType"> |
|
22 |
<xs:sequence> |
|
23 |
<xs:element name="DATAPROVIDER" minOccurs="0" maxOccurs="1"> |
|
24 |
<xs:complexType> |
|
25 |
<xs:simpleContent> |
|
26 |
<xs:extension base="xs:string"> |
|
27 |
<xs:attribute name="id" type="xs:string" use="required" /> |
|
28 |
<xs:attribute name="interface" type="xs:string" use="required" /> |
|
29 |
</xs:extension> |
|
30 |
</xs:simpleContent> |
|
31 |
</xs:complexType> |
|
32 |
</xs:element> |
|
33 |
|
|
34 |
<xs:element name="METAWORKFLOW_NAME"> |
|
35 |
<xs:complexType> |
|
36 |
<xs:simpleContent> |
|
37 |
<xs:extension base="xs:string"> |
|
38 |
<xs:attribute name="family" type="xs:string" use="required"/> |
|
39 |
</xs:extension> |
|
40 |
</xs:simpleContent> |
|
41 |
</xs:complexType> |
|
42 |
</xs:element> |
|
43 |
<xs:element name="METAWORKFLOW_DESCRIPTION" type="xs:string" /> |
|
44 |
<xs:element name="METAWORKFLOW_SECTION" type="xs:string"/> |
|
45 |
<xs:element name="ADMIN_EMAIL" type="xs:string"/> |
|
46 |
<xs:element name="CONFIGURATION" type="CONFIGURATIONType" /> |
|
47 |
<xs:element name="SCHEDULING" type="SCHEDULINGType" /> |
|
48 |
</xs:sequence> |
|
49 |
</xs:complexType> |
|
50 |
<xs:complexType name="RESOURCE_IDENTIFIERType"> |
|
51 |
<xs:attribute name="value" type="xs:string" use="required" /> |
|
52 |
</xs:complexType> |
|
53 |
<xs:complexType name="RESOURCE_TYPEType"> |
|
54 |
<xs:attribute name="value" use="required"> |
|
55 |
<xs:simpleType> |
|
56 |
<xs:restriction base="xs:string"> |
|
57 |
<xs:enumeration value="MetaWorkflowDSResourceType" /> |
|
58 |
</xs:restriction> |
|
59 |
</xs:simpleType> |
|
60 |
</xs:attribute> |
|
61 |
</xs:complexType> |
|
62 |
<xs:complexType name="RESOURCE_KINDType"> |
|
63 |
<xs:attribute name="value" use="required"> |
|
64 |
<xs:simpleType> |
|
65 |
<xs:restriction base="xs:string"> |
|
66 |
<xs:enumeration value="MetaWorkflowDSResources" /> |
|
67 |
</xs:restriction> |
|
68 |
</xs:simpleType> |
|
69 |
</xs:attribute> |
|
70 |
</xs:complexType> |
|
71 |
<xs:complexType name="RESOURCE_URIType"> |
|
72 |
<xs:attribute name="value" type="xs:string" use="required" /> |
|
73 |
</xs:complexType> |
|
74 |
<xs:complexType name="DATEType"> |
|
75 |
<xs:attribute name="value" type="xs:dateTime" use="required" /> |
|
76 |
</xs:complexType> |
|
77 |
|
|
78 |
<xs:complexType name="CONFIGURATIONType"> |
|
79 |
<xs:sequence minOccurs="0"> |
|
80 |
<xs:any processContents="skip"/> |
|
81 |
</xs:sequence> |
|
82 |
<xs:attribute name="status" use="required"> |
|
83 |
<xs:simpleType> |
|
84 |
<xs:restriction base="xs:string"> |
|
85 |
<xs:enumeration value="EXECUTABLE" /> |
|
86 |
<xs:enumeration value="WAIT_USER_SETTINGS" /> |
|
87 |
<xs:enumeration value="WAIT_SYS_SETTINGS" /> |
|
88 |
<xs:enumeration value="ASSIGNED" /> |
|
89 |
<xs:enumeration value="MISSING" /> |
|
90 |
</xs:restriction> |
|
91 |
</xs:simpleType> |
|
92 |
</xs:attribute> |
|
93 |
<xs:attribute name="destroyWorkflow" use="optional" type="xs:string" /> |
|
94 |
</xs:complexType> |
|
95 |
|
|
96 |
<xs:complexType name="SCHEDULINGType"> |
|
97 |
<xs:sequence> |
|
98 |
<xs:element name="CRON" type="xs:string" /> |
|
99 |
<xs:element name="MININTERVAL" type="xs:int" /> |
|
100 |
</xs:sequence> |
|
101 |
<xs:attribute name="enabled" use="required" type="xs:boolean" /> |
|
102 |
</xs:complexType> |
|
103 |
|
|
104 |
</xs:schema> |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/java/eu/dnetlib/msro/workflows/nodes/info/SetProviderInfoJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.info; |
|
2 |
|
|
3 |
import com.googlecode.sarasvati.Arc; |
|
4 |
import com.googlecode.sarasvati.NodeToken; |
|
5 |
|
|
6 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
7 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
8 |
|
|
9 |
public class SetProviderInfoJobNode extends SimpleJobNode { |
|
10 |
private String providerId; |
|
11 |
private String providerName; |
|
12 |
private String api; |
|
13 |
|
|
14 |
@Override |
|
15 |
protected String execute(NodeToken token) throws Exception { |
|
16 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, getProviderId()); |
|
17 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_NAME, getProviderName()); |
|
18 |
token.getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE, getApi()); |
|
19 |
|
|
20 |
token.getFullEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, getProviderId()); |
|
21 |
token.getFullEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_NAME, getProviderName()); |
|
22 |
token.getFullEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE, getApi()); |
|
23 |
|
|
24 |
token.getProcess().getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_ID, getProviderId()); |
|
25 |
token.getProcess().getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_NAME, getProviderName()); |
|
26 |
token.getProcess().getEnv().setAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE, getApi()); |
|
27 |
|
|
28 |
return Arc.DEFAULT_ARC; |
|
29 |
} |
|
30 |
|
|
31 |
public String getProviderId() { |
|
32 |
return providerId; |
|
33 |
} |
|
34 |
|
|
35 |
public void setProviderId(String providerId) { |
|
36 |
this.providerId = providerId; |
|
37 |
} |
|
38 |
|
|
39 |
public String getProviderName() { |
|
40 |
return providerName; |
|
41 |
} |
|
42 |
|
|
43 |
public void setProviderName(String providerName) { |
|
44 |
this.providerName = providerName; |
|
45 |
} |
|
46 |
|
|
47 |
public String getApi() { |
|
48 |
return api; |
|
49 |
} |
|
50 |
|
|
51 |
public void setApi(String api) { |
|
52 |
this.api = api; |
|
53 |
} |
|
54 |
|
|
55 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-2.1.2/src/main/resources/eu/dnetlib/msro/workflows/xslt/mdBuilder.xslt.st | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-msro-service-2.1.2