Revision 44413
Added by Claudio Atzori about 8 years ago
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/info/MDStoreToApiExtraFieldJobNode.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 MDStoreToApiExtraFieldJobNode extends SimpleJobNode { |
|
22 |
|
|
23 |
private String mdId; |
|
24 |
private String datasourceId; |
|
25 |
private String datasourceInterface; |
|
26 |
private String extraFieldForTotal; |
|
27 |
private String extraFieldForDate; |
|
28 |
private String extraFieldForMdId; |
|
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/MDStoreDSResources/MDStoreDSResourceType') " + |
|
36 |
"where $x//RESOURCE_IDENTIFIER/@value='" + mdId + "' " + |
|
37 |
"return concat($x//NUMBER_OF_RECORDS, ' @=@ ', $x//LAST_STORAGE_DATE)"; |
|
38 |
|
|
39 |
final String s = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xq); |
|
40 |
|
|
41 |
final String[] arr = s.split(" @=@ "); |
|
42 |
|
|
43 |
final Map<String, String> map = getCurrentExtraFields(datasourceId, datasourceInterface); |
|
44 |
map.put(extraFieldForTotal, arr[0].trim()); |
|
45 |
map.put(extraFieldForDate, arr[1].trim()); |
|
46 |
map.put(extraFieldForMdId, mdId); |
|
47 |
|
|
48 |
serviceLocator.getService(DatasourceManagerService.class).bulkUpdateApiExtraFields(datasourceId, datasourceInterface, map); |
|
49 |
|
|
50 |
return Arc.DEFAULT_ARC; |
|
51 |
} |
|
52 |
|
|
53 |
private Map<String, String> getCurrentExtraFields(final String repoId, final String ifaceId) throws Exception { |
|
54 |
final Map<String, String> res = Maps.newHashMap(); |
|
55 |
|
|
56 |
final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId); |
|
57 |
|
|
58 |
final SAXReader reader = new SAXReader(); |
|
59 |
final Document doc = reader.read(new StringReader(profile)); |
|
60 |
|
|
61 |
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']"); |
|
62 |
if (ifcNode != null) { |
|
63 |
for (Object o : ifcNode.selectNodes("./INTERFACE_EXTRA_FIELD")) { |
|
64 |
res.put(((Node) o).valueOf("@name"), ((Node) o).getText()); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
return res; |
|
69 |
} |
|
70 |
|
|
71 |
public String getMdId() { |
|
72 |
return mdId; |
|
73 |
} |
|
74 |
|
|
75 |
public void setMdId(final String mdId) { |
|
76 |
this.mdId = mdId; |
|
77 |
} |
|
78 |
|
|
79 |
public String getDatasourceId() { |
|
80 |
return datasourceId; |
|
81 |
} |
|
82 |
|
|
83 |
public void setDatasourceId(final String datasourceId) { |
|
84 |
this.datasourceId = datasourceId; |
|
85 |
} |
|
86 |
|
|
87 |
public String getDatasourceInterface() { |
|
88 |
return datasourceInterface; |
|
89 |
} |
|
90 |
|
|
91 |
public void setDatasourceInterface(final String datasourceInterface) { |
|
92 |
this.datasourceInterface = datasourceInterface; |
|
93 |
} |
|
94 |
|
|
95 |
public String getExtraFieldForTotal() { |
|
96 |
return extraFieldForTotal; |
|
97 |
} |
|
98 |
|
|
99 |
public void setExtraFieldForTotal(final String extraFieldForTotal) { |
|
100 |
this.extraFieldForTotal = extraFieldForTotal; |
|
101 |
} |
|
102 |
|
|
103 |
public String getExtraFieldForDate() { |
|
104 |
return extraFieldForDate; |
|
105 |
} |
|
106 |
|
|
107 |
public void setExtraFieldForDate(final String extraFieldForDate) { |
|
108 |
this.extraFieldForDate = extraFieldForDate; |
|
109 |
} |
|
110 |
|
|
111 |
public String getExtraFieldForMdId() { |
|
112 |
return extraFieldForMdId; |
|
113 |
} |
|
114 |
|
|
115 |
public void setExtraFieldForMdId(final String extraFieldForMdId) { |
|
116 |
this.extraFieldForMdId = extraFieldForMdId; |
|
117 |
} |
|
118 |
|
|
119 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/db/ExecuteSqlFromEnvJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.db; |
|
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.Arc; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
import eu.dnetlib.enabling.database.rmi.DatabaseService; |
|
8 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
9 |
import eu.dnetlib.msro.workflows.nodes.AsyncJobNode; |
|
10 |
import org.apache.commons.lang.StringUtils; |
|
11 |
|
|
12 |
public class ExecuteSqlFromEnvJobNode extends AsyncJobNode { |
|
13 |
|
|
14 |
private String db; |
|
15 |
private String dbParam; |
|
16 |
private String dbProperty; |
|
17 |
|
|
18 |
private String sqlParamName; |
|
19 |
|
|
20 |
@Resource |
|
21 |
private UniqueServiceLocator serviceLocator; |
|
22 |
|
|
23 |
@Override |
|
24 |
protected String execute(final NodeToken token) throws Exception { |
|
25 |
String sql = token.getEnv().getAttribute(sqlParamName); |
|
26 |
if (StringUtils.isBlank(sql)) throw new IllegalArgumentException("Missing value in env attribute named: " + sqlParamName); |
|
27 |
serviceLocator.getService(DatabaseService.class).updateSQL(findDb(token), sql); |
|
28 |
|
|
29 |
return Arc.DEFAULT_ARC; |
|
30 |
} |
|
31 |
|
|
32 |
private String findDb(final NodeToken token) { |
|
33 |
if (dbParam != null && !dbParam.isEmpty()) { |
|
34 |
return token.getEnv().getAttribute(dbParam); |
|
35 |
} else if (dbProperty != null && !dbProperty.isEmpty()) { |
|
36 |
return getPropertyFetcher().getProperty(dbProperty); |
|
37 |
} else { |
|
38 |
return db; |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
public String getDb() { |
|
43 |
return db; |
|
44 |
} |
|
45 |
|
|
46 |
public void setDb(final String db) { |
|
47 |
this.db = db; |
|
48 |
} |
|
49 |
|
|
50 |
public String getDbParam() { |
|
51 |
return dbParam; |
|
52 |
} |
|
53 |
|
|
54 |
public void setDbParam(final String dbParam) { |
|
55 |
this.dbParam = dbParam; |
|
56 |
} |
|
57 |
|
|
58 |
public String getDbProperty() { |
|
59 |
return dbProperty; |
|
60 |
} |
|
61 |
|
|
62 |
public void setDbProperty(final String dbProperty) { |
|
63 |
this.dbProperty = dbProperty; |
|
64 |
} |
|
65 |
|
|
66 |
public String getSqlParamName() { |
|
67 |
return sqlParamName; |
|
68 |
} |
|
69 |
|
|
70 |
public void setSqlParamName(final String sqlParamName) { |
|
71 |
this.sqlParamName = sqlParamName; |
|
72 |
} |
|
73 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/objectStore/UpdateObjectStoreSizeJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.objectStore; |
|
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.Arc; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
|
|
8 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; |
|
9 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
11 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
12 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
13 |
|
|
14 |
// TODO: Auto-generated Javadoc |
|
15 |
/** |
|
16 |
* The Class UpdateObjectStoreSizeJobNode. |
|
17 |
*/ |
|
18 |
public class UpdateObjectStoreSizeJobNode extends SimpleJobNode { |
|
19 |
|
|
20 |
/** The object store id. */ |
|
21 |
private String objectStoreIdParam; |
|
22 |
|
|
23 |
/** The service locator. */ |
|
24 |
@Resource |
|
25 |
private UniqueServiceLocator serviceLocator; |
|
26 |
|
|
27 |
/* |
|
28 |
* (non-Javadoc) |
|
29 |
* |
|
30 |
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken) |
|
31 |
*/ |
|
32 |
@Override |
|
33 |
protected String execute(final NodeToken token) throws Exception { |
|
34 |
|
|
35 |
final ISRegistryService registry = serviceLocator.getService(ISRegistryService.class); |
|
36 |
|
|
37 |
int size = serviceLocator.getService(ObjectStoreService.class, objectStoreIdParam).getSize(objectStoreIdParam); |
|
38 |
|
|
39 |
String now = DateUtils.now_ISO8601(); |
|
40 |
|
|
41 |
String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']" |
|
42 |
+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'"; |
|
43 |
|
|
44 |
registry.executeXUpdate(mdstoreXUpdate); |
|
45 |
|
|
46 |
String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']" |
|
47 |
+ "return update value $x//COUNT_STORE with '" + size + "'"; |
|
48 |
|
|
49 |
registry.executeXUpdate(mdstoreNumberXUpdate); |
|
50 |
|
|
51 |
mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']" |
|
52 |
+ "return update value $x//STORE_SIZE with '" + size + "'"; |
|
53 |
|
|
54 |
registry.executeXUpdate(mdstoreNumberXUpdate); |
|
55 |
|
|
56 |
return Arc.DEFAULT_ARC; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Gets the object store id param. |
|
61 |
* |
|
62 |
* @return the objectStoreIdParam |
|
63 |
*/ |
|
64 |
public String getObjectStoreIdParam() { |
|
65 |
return objectStoreIdParam; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Sets the object store id param. |
|
70 |
* |
|
71 |
* @param objectStoreIdParam |
|
72 |
* the new object store id param |
|
73 |
*/ |
|
74 |
public void setObjectStoreIdParam(final String objectStoreIdParam) { |
|
75 |
this.objectStoreIdParam = objectStoreIdParam; |
|
76 |
} |
|
77 |
|
|
78 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/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.21</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.21</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.21/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/MdBuilderJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.transform; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.net.URLEncoder; |
|
5 |
import java.util.List; |
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import com.googlecode.sarasvati.Arc; |
|
9 |
import com.googlecode.sarasvati.NodeToken; |
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
11 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
12 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
13 |
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory; |
|
14 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
15 |
import eu.dnetlib.msro.rmi.MSROException; |
|
16 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
17 |
import org.antlr.stringtemplate.StringTemplate; |
|
18 |
import org.apache.commons.io.IOUtils; |
|
19 |
import org.apache.commons.logging.Log; |
|
20 |
import org.apache.commons.logging.LogFactory; |
|
21 |
import org.springframework.beans.factory.annotation.Required; |
|
22 |
import org.springframework.core.io.Resource; |
|
23 |
|
|
24 |
public class MdBuilderJobNode extends SimpleJobNode { |
|
25 |
|
|
26 |
private static final Log log = LogFactory.getLog(MdBuilderJobNode.class); |
|
27 |
|
|
28 |
private Resource mdBuilderTemplateXslt; |
|
29 |
|
|
30 |
private String inputEprParam; |
|
31 |
private String outputEprParam; |
|
32 |
private String datasourceId; |
|
33 |
private String datasourceInterface; |
|
34 |
|
|
35 |
private XSLTMappedResultSetFactory xsltMappedResultSetFactory; |
|
36 |
|
|
37 |
@javax.annotation.Resource |
|
38 |
private UniqueServiceLocator serviceLocator; |
|
39 |
|
|
40 |
@Override |
|
41 |
protected String execute(final NodeToken token) throws MSROException { |
|
42 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam); |
|
43 |
|
|
44 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
|
45 |
StringTemplate st = null; |
|
46 |
try { |
|
47 |
st = new StringTemplate(IOUtils.toString(getMdBuilderTemplateXslt().getInputStream())); |
|
48 |
st.setAttribute("datasourceId", datasourceId); |
|
49 |
st.setAttribute("xpath", getMetadataIdentifierPath().replace("\"", "'")); |
|
50 |
st.setAttribute("baseurl", URLEncoder.encode(getBaseUrl(), "UTF-8")); |
|
51 |
st.setAttribute("metadatanamespace", getMetadataNamespace()); |
|
52 |
|
|
53 |
/* |
|
54 |
* If namespacePrefix has been already pushed to env by some custom JobNode e.g. ObtainOpenaireDataSourceParamsJobNode then push |
|
55 |
* it to ST. Else: a) try to get it from EXTRAFIELDS of the datasource b) try to get it from DATASOURCE_ORIGINAL_ID of the |
|
56 |
* datasource c) if any of the is present, then push to ST the datasourceId |
|
57 |
*/ |
|
58 |
if (token.getEnv().hasAttribute("namespacePrefix")) { |
|
59 |
st.setAttribute("namespacePrefix", token.getEnv().getAttribute("namespacePrefix")); |
|
60 |
} else { |
|
61 |
List<String> namespacePrefix; |
|
62 |
String xQuery = "/*[.//RESOURCE_IDENTIFIER/@value='" + datasourceId + "']//EXTRA_FIELDS/FIELD/value[../key='NamespacePrefix']/string()"; |
|
63 |
namespacePrefix = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQuery); |
|
64 |
if (namespacePrefix.size() != 0) { |
|
65 |
st.setAttribute("namespacePrefix", namespacePrefix.get(0)); |
|
66 |
} else { |
|
67 |
xQuery = "/*[.//RESOURCE_IDENTIFIER/@value='" + datasourceId + "']//DATASOURCE_ORIGINAL_ID/string()"; |
|
68 |
namespacePrefix = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xQuery); |
|
69 |
if (namespacePrefix.size() != 0) { |
|
70 |
st.setAttribute("namespacePrefix", namespacePrefix.get(0)); |
|
71 |
} else { |
|
72 |
st.setAttribute("namespacePrefix", datasourceId); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
final W3CEndpointReference epr = xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), st.toString()); |
|
78 |
|
|
79 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
80 |
|
|
81 |
return Arc.DEFAULT_ARC; |
|
82 |
} catch (ISLookUpException e) { |
|
83 |
throw new MSROException("Error while initializing mdBuilder template (" + getMdBuilderTemplateXslt().getFilename() + ") for datasource " |
|
84 |
+ datasourceId, e); |
|
85 |
} catch (IOException e) { |
|
86 |
throw new MSROException("Error parsing template: " + getMdBuilderTemplateXslt().getFilename(), e); |
|
87 |
} catch (Exception e) { |
|
88 |
log.error(st.toString()); |
|
89 |
throw new MSROException(e); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
private String getBaseUrl() throws ISLookUpException { |
|
94 |
String xQuery = "/*[.//RESOURCE_IDENTIFIER/@value='{datasourceId}']//INTERFACE[@id='{interfaceId}']//BASE_URL/string()"; |
|
95 |
xQuery = xQuery.replace("{interfaceId}", datasourceInterface).replace("{datasourceId}", datasourceId); |
|
96 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery); |
|
97 |
} |
|
98 |
|
|
99 |
private String getMetadataIdentifierPath() throws ISLookUpException { |
|
100 |
String xQuery = "for $x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType') " |
|
101 |
+ "return $x//INTERFACE[@id='{interfaceId}']/INTERFACE_EXTRA_FIELD[@name='metadata_identifier_path']/string()"; |
|
102 |
xQuery = xQuery.replace("{interfaceId}", datasourceInterface); |
|
103 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery); |
|
104 |
} |
|
105 |
|
|
106 |
private String getMetadataNamespace() { |
|
107 |
try { |
|
108 |
String xQuery = "let $x := /*[.//RESOURCE_IDENTIFIER/@value='{datasourceId}']//INTERFACE[@id='{interfaceId}']/ACCESS_PROTOCOL/@format/string() " |
|
109 |
+ "return /*[.//RESOURCE_TYPE/@value='MetadataFormatDSResourceType']//METADATAFORMAT[@Prefix=$x]/@NameSpace/string()"; |
|
110 |
xQuery = xQuery.replace("{interfaceId}", datasourceInterface).replace("{datasourceId}", datasourceId); |
|
111 |
return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xQuery); |
|
112 |
} catch (ISLookUpException e) { |
|
113 |
log.error("The interface is not OAI or the format is not found in the MetadataFormatDSResourceType, thus metadata format in the <about> section " |
|
114 |
+ "cannot managed here and it will be leaved empty (for the time being)"); |
|
115 |
return ""; |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
public String getInputEprParam() { |
|
120 |
return inputEprParam; |
|
121 |
} |
|
122 |
|
|
123 |
public void setInputEprParam(final String inputEprParam) { |
|
124 |
this.inputEprParam = inputEprParam; |
|
125 |
} |
|
126 |
|
|
127 |
public String getOutputEprParam() { |
|
128 |
return outputEprParam; |
|
129 |
} |
|
130 |
|
|
131 |
public void setOutputEprParam(final String outputEprParam) { |
|
132 |
this.outputEprParam = outputEprParam; |
|
133 |
} |
|
134 |
|
|
135 |
public XSLTMappedResultSetFactory getXsltMappedResultSetFactory() { |
|
136 |
return xsltMappedResultSetFactory; |
|
137 |
} |
|
138 |
|
|
139 |
@Required |
|
140 |
public void setXsltMappedResultSetFactory(final XSLTMappedResultSetFactory xsltMappedResultSetFactory) { |
|
141 |
this.xsltMappedResultSetFactory = xsltMappedResultSetFactory; |
|
142 |
} |
|
143 |
|
|
144 |
public String getDatasourceId() { |
|
145 |
return datasourceId; |
|
146 |
} |
|
147 |
|
|
148 |
public void setDatasourceId(final String datasourceId) { |
|
149 |
this.datasourceId = datasourceId; |
|
150 |
} |
|
151 |
|
|
152 |
public String getDatasourceInterface() { |
|
153 |
return datasourceInterface; |
|
154 |
} |
|
155 |
|
|
156 |
public void setDatasourceInterface(final String datasourceInterface) { |
|
157 |
this.datasourceInterface = datasourceInterface; |
|
158 |
} |
|
159 |
|
|
160 |
public Resource getMdBuilderTemplateXslt() { |
|
161 |
return mdBuilderTemplateXslt; |
|
162 |
} |
|
163 |
|
|
164 |
@Required |
|
165 |
public void setMdBuilderTemplateXslt(final Resource mdBuilderTemplateXslt) { |
|
166 |
this.mdBuilderTemplateXslt = mdBuilderTemplateXslt; |
|
167 |
} |
|
168 |
|
|
169 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/cron/ScheduledWorkflowLauncher.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.cron; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
|
|
7 |
import org.apache.commons.lang.StringUtils; |
|
8 |
import org.apache.commons.lang.math.NumberUtils; |
|
9 |
import org.apache.commons.logging.Log; |
|
10 |
import org.apache.commons.logging.LogFactory; |
|
11 |
import org.quartz.CronExpression; |
|
12 |
import org.springframework.beans.factory.annotation.Required; |
|
13 |
|
|
14 |
import com.googlecode.sarasvati.GraphProcess; |
|
15 |
|
|
16 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
20 |
import eu.dnetlib.msro.workflows.sarasvati.loader.WorkflowExecutor; |
|
21 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
22 |
|
|
23 |
public class ScheduledWorkflowLauncher { |
|
24 |
|
|
25 |
private static final Log log = LogFactory.getLog(ScheduledWorkflowLauncher.class); |
|
26 |
|
|
27 |
private static final DateUtils dateUtils = new DateUtils(); |
|
28 |
|
|
29 |
private WorkflowExecutor workflowExecutor; |
|
30 |
|
|
31 |
private GraphProcessRegistry graphProcessRegistry; |
|
32 |
|
|
33 |
private int windowSize = 1800000; // 30 minutes |
|
34 |
|
|
35 |
@Resource |
|
36 |
private UniqueServiceLocator serviceLocator; |
|
37 |
|
|
38 |
public void verifySheduledWorkflows() { |
|
39 |
log.debug("Verifying scheduled workflows - START"); |
|
40 |
|
|
41 |
final String query = "for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') " + |
|
42 |
"where $x//CONFIGURATION/@status='EXECUTABLE' " + |
|
43 |
"and $x//SCHEDULING/@enabled='true' " + |
|
44 |
"return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x//SCHEDULING/CRON, ' @@@ ', $x//SCHEDULING/MININTERVAL)"; |
|
45 |
|
|
46 |
try { |
|
47 |
for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
48 |
final String[] arr = s.split("@@@"); |
|
49 |
final String id = arr[0].trim(); |
|
50 |
final String cron = arr[1].trim(); |
|
51 |
final int minInterval = Math.max(NumberUtils.toInt(arr[2].trim(), 0), windowSize); |
|
52 |
final Date lastExecutionDate = calculateLastExecutionDate(id); |
|
53 |
|
|
54 |
if (isReady(id, cron, minInterval, lastExecutionDate, new Date()) && !isAlreadyRunning(id)) { |
|
55 |
try { |
|
56 |
workflowExecutor.startMetaWorkflow(id, false); |
|
57 |
} catch (final Exception e) { |
|
58 |
log.debug("Error launching scheduled wf: " + id, e); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
} catch (final ISLookUpException e) { |
|
63 |
log.error("Error executing query " + query); |
|
64 |
} |
|
65 |
|
|
66 |
log.debug("Verifying scheduled workflows - END"); |
|
67 |
} |
|
68 |
|
|
69 |
protected boolean isReady(final String id, final String cron, final int minInterval, final Date lastExecutionDate, final Date now) { |
|
70 |
if (CronExpression.isValidExpression(cron)) { |
|
71 |
final int minIntervalMillis = minInterval * 60000; // minutes to millis; |
|
72 |
|
|
73 |
final boolean res; |
|
74 |
if (lastExecutionDate != null) { |
|
75 |
final int elapsed = Math.round(now.getTime() - lastExecutionDate.getTime()); |
|
76 |
res = (elapsed > minIntervalMillis) && verifyCron(cron, now); |
|
77 |
} else { |
|
78 |
res = verifyCron(cron, now); |
|
79 |
} |
|
80 |
|
|
81 |
if (log.isDebugEnabled()) { |
|
82 |
log.debug("**************************************************************"); |
|
83 |
log.debug("META WORKFLOW ID : " + id); |
|
84 |
log.debug("NOW : " + now); |
|
85 |
log.debug("LAST EXECUTION DATE : " + lastExecutionDate); |
|
86 |
log.debug("MIN INTERVAL (minutes) : " + minInterval); |
|
87 |
log.debug("REAL MIN INTERVAL (ms) : " + minIntervalMillis); |
|
88 |
log.debug("WINDOW SIZE (ms) : " + windowSize); |
|
89 |
log.debug("MUST BE EXECUTED : " + res); |
|
90 |
log.debug("**************************************************************"); |
|
91 |
} |
|
92 |
|
|
93 |
return res; |
|
94 |
} |
|
95 |
|
|
96 |
return false; |
|
97 |
} |
|
98 |
|
|
99 |
private boolean verifyCron(final String cronExpression, final Date now) { |
|
100 |
try { |
|
101 |
final CronExpression cron = new CronExpression(cronExpression); |
|
102 |
|
|
103 |
final Date date = new Date(now.getTime() - windowSize); |
|
104 |
|
|
105 |
final Date cronDate = cron.getNextValidTimeAfter(date); |
|
106 |
|
|
107 |
if (log.isDebugEnabled()) { |
|
108 |
log.debug("NEXT EXECUTION DATE: " + cronDate); |
|
109 |
log.debug("FIRED : " + (cronDate.getTime() < now.getTime())); |
|
110 |
} |
|
111 |
return cronDate.getTime() < now.getTime(); |
|
112 |
} catch (final Exception e) { |
|
113 |
log.error("Error calculating next cron event: " + cronExpression, e); |
|
114 |
return false; |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
private boolean isAlreadyRunning(final String metaWfId) { |
|
119 |
final String query = "doc('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType/" + StringUtils.substringBefore(metaWfId, "_") |
|
120 |
+ "')//WORKFLOW/@id/string()"; |
|
121 |
|
|
122 |
try { |
|
123 |
for (final String profileId : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
124 |
if (profileId.length() > 0) { |
|
125 |
for (final GraphProcess p : graphProcessRegistry.findProcessesByResource(profileId)) { |
|
126 |
switch (p.getState()) { |
|
127 |
case Created: |
|
128 |
return true; |
|
129 |
case Executing: |
|
130 |
return true; |
|
131 |
default: |
|
132 |
break; |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
} catch (final ISLookUpException e) { |
|
138 |
log.error("Error executing query " + query); |
|
139 |
} |
|
140 |
return false; |
|
141 |
} |
|
142 |
|
|
143 |
private Date calculateLastExecutionDate(final String id) { |
|
144 |
final String query = "for $id in doc('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType/" + StringUtils.substringBefore(id, "_") |
|
145 |
+ "')//WORKFLOW/@id/string() " + |
|
146 |
"for $x in doc(concat('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType/', substring-before($id, '_'))) " + |
|
147 |
"where $x//LAST_EXECUTION_STATUS = 'SUCCESS' " + |
|
148 |
"return $x//LAST_EXECUTION_DATE/text() "; |
|
149 |
|
|
150 |
long time = 0; |
|
151 |
try { |
|
152 |
for (final String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query)) { |
|
153 |
if (s.length() > 0) { |
|
154 |
final Date d = dateUtils.parse(s); |
|
155 |
if (time < d.getTime()) { |
|
156 |
time = d.getTime(); |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
} catch (final ISLookUpException e) { |
|
161 |
log.error("Error executing query " + query); |
|
162 |
} catch (final Exception e) { |
|
163 |
log.error("Error calculating date", e); |
|
164 |
} |
|
165 |
|
|
166 |
return time > 0 ? new Date(time) : null; |
|
167 |
} |
|
168 |
|
|
169 |
public WorkflowExecutor getWorkflowExecutor() { |
|
170 |
return workflowExecutor; |
|
171 |
} |
|
172 |
|
|
173 |
@Required |
|
174 |
public void setWorkflowExecutor(final WorkflowExecutor workflowExecutor) { |
|
175 |
this.workflowExecutor = workflowExecutor; |
|
176 |
} |
|
177 |
|
|
178 |
public GraphProcessRegistry getGraphProcessRegistry() { |
|
179 |
return graphProcessRegistry; |
|
180 |
} |
|
181 |
|
|
182 |
@Required |
|
183 |
public void setGraphProcessRegistry(final GraphProcessRegistry graphProcessRegistry) { |
|
184 |
this.graphProcessRegistry = graphProcessRegistry; |
|
185 |
} |
|
186 |
|
|
187 |
public int getWindowSize() { |
|
188 |
return windowSize; |
|
189 |
} |
|
190 |
|
|
191 |
@Required |
|
192 |
public void setWindowSize(final int windowSize) { |
|
193 |
this.windowSize = windowSize; |
|
194 |
} |
|
195 |
|
|
196 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/GroovyJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.transform; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Map; |
|
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.Required; |
|
12 |
|
|
13 |
import com.google.common.collect.Maps; |
|
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.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.enabling.resultset.MappedResultSetFactory; |
|
20 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
21 |
import eu.dnetlib.msro.rmi.MSROException; |
|
22 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
23 |
import groovy.lang.GroovyShell; |
|
24 |
import groovy.util.GroovyScriptEngine; |
|
25 |
|
|
26 |
public class GroovyJobNode extends SimpleJobNode { |
|
27 |
|
|
28 |
private static final Log log = LogFactory.getLog(GroovyJobNode.class); |
|
29 |
|
|
30 |
/** |
|
31 |
* used to transform the records using Groovy. |
|
32 |
*/ |
|
33 |
|
|
34 |
private MappedResultSetFactory mappedResultSetFactory; |
|
35 |
|
|
36 |
private String inputEprParam; |
|
37 |
private String outputEprParam; |
|
38 |
private String transformationRuleId; |
|
39 |
// private String groovyParams; |
|
40 |
|
|
41 |
@Resource |
|
42 |
private UniqueServiceLocator serviceLocator; |
|
43 |
|
|
44 |
private Map<String, String> retrieveGroovyParameter() { |
|
45 |
Map<String, String> out = Maps.newHashMap(); |
|
46 |
|
|
47 |
String query = "for $x in collection('/db/DRIVER/GroovyProcessingDSResource/GroovyProcessingDSResourceType')" |
|
48 |
+ "where $x[.//RESOURCE_IDENTIFIER/@value='" + transformationRuleId + "']" |
|
49 |
+ "return concat($x//GROOVY_CLASSPATH/text(),':::',$x//GROOVY_DNETCLASS/text())"; |
|
50 |
try { |
|
51 |
String result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query).get(0); |
|
52 |
if (result == null) { return null; } |
|
53 |
String[] data = result.trim().split(":::"); |
|
54 |
if (data.length == 2) { |
|
55 |
out.put("classpath", data[0]); |
|
56 |
out.put("mainClass", data[1]); |
|
57 |
} |
|
58 |
|
|
59 |
return out; |
|
60 |
} catch (Exception e) { |
|
61 |
log.error(e); |
|
62 |
return null; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
protected String execute(final NodeToken token) throws Exception { |
|
68 |
final String inputEprString = token.getEnv().getAttribute(inputEprParam); |
|
69 |
if (inputEprString == null || inputEprString.isEmpty()) { throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); } |
|
70 |
final W3CEndpointReference inputEpr = new EPRUtils().getEpr(inputEprString); |
|
71 |
String groovyClasspath, groovyDnetClass; |
|
72 |
Map<String, String> prop = retrieveGroovyParameter(); |
|
73 |
groovyClasspath = prop.get("classpath"); |
|
74 |
groovyDnetClass = prop.get("mainClass"); |
|
75 |
W3CEndpointReference epr = transformGroovy(inputEpr, groovyClasspath, groovyDnetClass, parseJsonParameters(token)); |
|
76 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
77 |
return Arc.DEFAULT_ARC; |
|
78 |
} |
|
79 |
|
|
80 |
private W3CEndpointReference transformGroovy(final W3CEndpointReference source, |
|
81 |
final String groovyClasspath, |
|
82 |
final String groovyDnetClass, |
|
83 |
final Map<String, String> params) throws ClassNotFoundException, IOException { |
|
84 |
|
|
85 |
GroovyScriptEngine gse = new GroovyScriptEngine(groovyClasspath); |
|
86 |
gse.getGroovyClassLoader().loadClass(groovyDnetClass); |
|
87 |
log.info("***********************************************"); |
|
88 |
log.info("Loaded Groovy classes:"); |
|
89 |
for (Class<?> c : gse.getGroovyClassLoader().getLoadedClasses()) { |
|
90 |
log.info(c.getCanonicalName()); |
|
91 |
} |
|
92 |
log.info("***********************************************"); |
|
93 |
GroovyShell groovyShell = new GroovyShell(gse.getGroovyClassLoader()); |
|
94 |
|
|
95 |
Object go = groovyShell.evaluate("new " + groovyDnetClass + "()"); |
|
96 |
if (go instanceof GroovyUnaryFunction) { |
|
97 |
GroovyUnaryFunction groovyUnaryFunction = (GroovyUnaryFunction) go; |
|
98 |
if (params != null) { |
|
99 |
groovyUnaryFunction.setParams(params); |
|
100 |
} |
|
101 |
return mappedResultSetFactory.createMappedResultSet(source, groovyUnaryFunction); |
|
102 |
} else { |
|
103 |
throw new RuntimeException("Groovy object " + go + " is not supported"); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
public MappedResultSetFactory getMappedResultSetFactory() { |
|
108 |
return mappedResultSetFactory; |
|
109 |
} |
|
110 |
|
|
111 |
@Required |
|
112 |
public void setMappedResultSetFactory(final MappedResultSetFactory mappedResultSetFactory) { |
|
113 |
this.mappedResultSetFactory = mappedResultSetFactory; |
|
114 |
} |
|
115 |
|
|
116 |
public String getInputEprParam() { |
|
117 |
return inputEprParam; |
|
118 |
} |
|
119 |
|
|
120 |
public void setInputEprParam(final String inputEprParam) { |
|
121 |
this.inputEprParam = inputEprParam; |
|
122 |
} |
|
123 |
|
|
124 |
public String getOutputEprParam() { |
|
125 |
return outputEprParam; |
|
126 |
} |
|
127 |
|
|
128 |
public void setOutputEprParam(final String outputEprParam) { |
|
129 |
this.outputEprParam = outputEprParam; |
|
130 |
} |
|
131 |
|
|
132 |
public String getTransformationRuleId() { |
|
133 |
return transformationRuleId; |
|
134 |
} |
|
135 |
|
|
136 |
public void setTransformationRuleId(final String transformationRuleId) { |
|
137 |
this.transformationRuleId = transformationRuleId; |
|
138 |
} |
|
139 |
|
|
140 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/ApplyXsltJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.transform; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Required; |
|
9 |
import org.springframework.core.io.ClassPathResource; |
|
10 |
|
|
11 |
import com.googlecode.sarasvati.Arc; |
|
12 |
import com.googlecode.sarasvati.NodeToken; |
|
13 |
|
|
14 |
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory; |
|
15 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
16 |
import eu.dnetlib.msro.rmi.MSROException; |
|
17 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
18 |
|
|
19 |
public class ApplyXsltJobNode extends SimpleJobNode { |
|
20 |
|
|
21 |
private String inputEprParam; |
|
22 |
private String outputEprParam; |
|
23 |
private String xsltClasspath; |
|
24 |
|
|
25 |
private XSLTMappedResultSetFactory xsltMappedResultSetFactory; |
|
26 |
|
|
27 |
@Override |
|
28 |
protected String execute(final NodeToken token) throws Exception { |
|
29 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam); |
|
30 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
|
31 |
|
|
32 |
final Map<String, String> xsltParams = new HashMap<String, String>(); |
|
33 |
|
|
34 |
for (String name : token.getFullEnv().getAttributeNames()) { |
|
35 |
xsltParams.put(name.replaceAll(":", "_"), token.getFullEnv().getAttribute(name)); |
|
36 |
} |
|
37 |
for (String name : token.getEnv().getAttributeNames()) { |
|
38 |
xsltParams.put(name.replaceAll(":", "_"), token.getEnv().getAttribute(name)); |
|
39 |
} |
|
40 |
|
|
41 |
xsltParams.putAll(parseJsonParameters(token)); |
|
42 |
|
|
43 |
final W3CEndpointReference epr = xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), |
|
44 |
(new ClassPathResource(xsltClasspath)), xsltParams); |
|
45 |
|
|
46 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
47 |
|
|
48 |
return Arc.DEFAULT_ARC; |
|
49 |
} |
|
50 |
|
|
51 |
public String getInputEprParam() { |
|
52 |
return inputEprParam; |
|
53 |
} |
|
54 |
|
|
55 |
public void setInputEprParam(final String inputEprParam) { |
|
56 |
this.inputEprParam = inputEprParam; |
|
57 |
} |
|
58 |
|
|
59 |
public String getOutputEprParam() { |
|
60 |
return outputEprParam; |
|
61 |
} |
|
62 |
|
|
63 |
public void setOutputEprParam(final String outputEprParam) { |
|
64 |
this.outputEprParam = outputEprParam; |
|
65 |
} |
|
66 |
|
|
67 |
public String getXsltClasspath() { |
|
68 |
return xsltClasspath; |
|
69 |
} |
|
70 |
|
|
71 |
public void setXsltClasspath(final String xsltClasspath) { |
|
72 |
this.xsltClasspath = xsltClasspath; |
|
73 |
} |
|
74 |
|
|
75 |
public XSLTMappedResultSetFactory getXsltMappedResultSetFactory() { |
|
76 |
return xsltMappedResultSetFactory; |
|
77 |
} |
|
78 |
|
|
79 |
@Required |
|
80 |
public void setXsltMappedResultSetFactory(final XSLTMappedResultSetFactory xsltMappedResultSetFactory) { |
|
81 |
this.xsltMappedResultSetFactory = xsltMappedResultSetFactory; |
|
82 |
} |
|
83 |
|
|
84 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/sarasvati/loader/WorkflowExecutor.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.sarasvati.loader; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Comparator; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
import java.util.concurrent.Executors; |
|
8 |
import java.util.concurrent.PriorityBlockingQueue; |
|
9 |
import java.util.concurrent.ScheduledExecutorService; |
|
10 |
import java.util.concurrent.TimeUnit; |
|
11 |
import javax.annotation.Resource; |
|
12 |
|
|
13 |
import com.googlecode.sarasvati.Graph; |
|
14 |
import com.googlecode.sarasvati.GraphProcess; |
|
15 |
import com.googlecode.sarasvati.mem.MemEngine; |
|
16 |
import com.googlecode.sarasvati.mem.MemGraphProcess; |
|
17 |
import eu.dnetlib.enabling.common.Stoppable; |
|
18 |
import eu.dnetlib.enabling.common.StoppableDetails; |
|
19 |
import eu.dnetlib.enabling.common.StoppableDetails.StopStatus; |
|
20 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
21 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
22 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
23 |
import eu.dnetlib.msro.rmi.MSROException; |
|
24 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
25 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
26 |
import org.apache.commons.lang.math.NumberUtils; |
|
27 |
import org.apache.commons.logging.Log; |
|
28 |
import org.apache.commons.logging.LogFactory; |
|
29 |
import org.springframework.beans.factory.annotation.Required; |
|
30 |
|
|
31 |
public class WorkflowExecutor implements Stoppable { |
|
32 |
|
|
33 |
private static final Log log = LogFactory.getLog(WorkflowExecutor.class); |
|
34 |
private MemEngine engine; |
|
35 |
private GraphLoader graphLoader; |
|
36 |
private GraphProcessRegistry graphProcessRegistry; |
|
37 |
private ProfileToSarasvatiConverter profileToSarasvatiConverter; |
|
38 |
private ScheduledExecutorService queueConsumers; |
|
39 |
private boolean paused = false; |
|
40 |
private int maxRunningWorkflows = WorkflowsConstants.MAX_WF_THREADS; |
|
41 |
@Resource |
|
42 |
private UniqueServiceLocator serviceLocator; |
|
43 |
private PriorityBlockingQueue<GraphProcess> pendingProcs = new PriorityBlockingQueue<GraphProcess>(20, new Comparator<GraphProcess>() { |
|
44 |
|
|
45 |
@Override |
|
46 |
public int compare(final GraphProcess p1, final GraphProcess p2) { |
|
47 |
int n1 = NumberUtils.toInt(p1.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PRIORITY), WorkflowsConstants.DEFAULT_WF_PRIORITY); |
|
48 |
int n2 = NumberUtils.toInt(p2.getEnv().getAttribute(WorkflowsConstants.SYSTEM_WF_PRIORITY), WorkflowsConstants.DEFAULT_WF_PRIORITY); |
|
49 |
return NumberUtils.compare(n1, n2); |
|
50 |
} |
|
51 |
}); |
|
52 |
|
|
53 |
public boolean isPaused() { |
|
54 |
return paused; |
|
55 |
} |
|
56 |
|
|
57 |
public void setPaused(final boolean paused) { |
|
58 |
this.paused = paused; |
|
59 |
} |
|
60 |
|
|
61 |
public void init() { |
|
62 |
this.queueConsumers = Executors.newScheduledThreadPool(WorkflowsConstants.MAX_WF_THREADS); |
|
63 |
final int period = 60; |
|
64 |
final int step = period / WorkflowsConstants.MAX_WF_THREADS; |
|
65 |
|
|
66 |
for (int i = 0; i < WorkflowsConstants.MAX_WF_THREADS; i++) { |
|
67 |
this.queueConsumers.scheduleAtFixedRate(new Runnable() { |
|
68 |
|
|
69 |
@Override |
|
70 |
public void run() { |
|
71 |
if (isPaused()) { |
|
72 |
return; |
|
73 |
} |
|
74 |
int running = graphProcessRegistry.countRunningWfs(false); |
|
75 |
if (running >= getMaxRunningWorkflows()) { |
|
76 |
if (log.isDebugEnabled()) { |
|
77 |
log.debug("reached max running workflows: " + running); |
|
78 |
} |
|
79 |
return; |
|
80 |
} |
|
81 |
|
|
82 |
final GraphProcess process = pendingProcs.poll(); |
|
83 |
if (process != null) { |
|
84 |
log.info("Starting workflow: " + process); |
|
85 |
final long now = DateUtils.now(); |
|
86 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_START_DATE, now); |
|
87 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_START_HUMAN_DATE, DateUtils.calculate_ISO8601(now)); |
|
88 |
engine.startProcess(process); |
|
89 |
} else { |
|
90 |
log.debug("Process queue is empty"); |
|
91 |
} |
|
92 |
} |
|
93 |
}, i * step, period, TimeUnit.SECONDS); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
public String startProcess(final String profileId) throws Exception { |
|
98 |
return startProcess(profileId, null); |
|
99 |
} |
|
100 |
|
|
101 |
public String startProcess(final String profileId, final Map<String, Object> params) throws Exception { |
|
102 |
final WfProfileDescriptor desc = profileToSarasvatiConverter.getSarasvatiWorkflow(profileId); |
|
103 |
|
|
104 |
if (isPaused()) { |
|
105 |
log.warn("Wf " + profileId + " not launched, because WorkflowExecutor is preparing for shutdown"); |
|
106 |
throw new MSROException("WorkflowExecutor is preparing for shutdown"); |
|
107 |
} |
|
108 |
if (!desc.isReady()) { |
|
109 |
log.warn("Wf " + profileId + " not launched, because it is not ready to start"); |
|
110 |
throw new MSROException("Workflow " + profileId + " is not ready to start"); |
|
111 |
} |
|
112 |
if (pendingProcs.size() > WorkflowsConstants.MAX_PENDING_PROCS_SIZE) { |
|
113 |
log.warn("Wf " + profileId + " not launched, Max number of pending procs reached: " + WorkflowsConstants.MAX_PENDING_PROCS_SIZE); |
|
114 |
throw new MSROException("Max number of pending procs reached: " + WorkflowsConstants.MAX_PENDING_PROCS_SIZE); |
|
115 |
} |
|
116 |
|
|
117 |
final File tmpFile = File.createTempFile("wftfs", null); |
|
118 |
try { |
|
119 |
final Graph graph = graphLoader.loadGraph(desc.getWorkflowXml()); |
|
120 |
final GraphProcess process = new MemGraphProcess(graph); |
|
121 |
final String procId = graphProcessRegistry.registerProcess(process); |
|
122 |
|
|
123 |
graphProcessRegistry.associateProcessWithResource(process, profileId); |
|
124 |
|
|
125 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_PROCESS_ID, procId); |
|
126 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_ID, profileId); |
|
127 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_NAME, desc.getName()); |
|
128 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_NAME, graph.getName()); |
|
129 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY, desc.getType()); |
|
130 |
process.getEnv().setAttribute(WorkflowsConstants.SYSTEM_WF_PRIORITY, desc.getPriority()); |
|
131 |
|
|
132 |
if (params != null) { |
|
133 |
for (Map.Entry<String, Object> e : params.entrySet()) { |
|
134 |
process.getEnv().setAttribute(e.getKey(), e.getValue()); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
log.info("Process " + process + " in queue, priority=" + desc.getPriority()); |
|
139 |
pendingProcs.put(process); |
|
140 |
|
|
141 |
return procId; |
|
142 |
} catch (Exception e) { |
|
143 |
log.error("Error parsing workflow xml: " + desc.getWorkflowXml(), e); |
|
144 |
throw new IllegalArgumentException("Error parsing workflow"); |
|
145 |
} finally { |
|
146 |
tmpFile.delete(); |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
public void startMetaWorkflow(final String id, final boolean manual) throws Exception { |
|
151 |
final String query = "/*[.//RESOURCE_IDENTIFIER/@value='" + id + "']//CONFIGURATION[@status='EXECUTABLE']/WORKFLOW/@id/string()"; |
|
152 |
|
|
153 |
final ISLookUpService lookup = serviceLocator.getService(ISLookUpService.class); |
|
154 |
|
|
155 |
final List<String> list = lookup.quickSearchProfile(query); |
|
156 |
|
|
157 |
if (list == null || list.isEmpty()) { throw new MSROException("Metaworkflow " + id + " not launched"); } |
|
158 |
|
|
159 |
for (String wfId : list) { |
|
160 |
final String q = "/*[.//RESOURCE_IDENTIFIER/@value='" + wfId + "']//CONFIGURATION/@start/string()"; |
|
161 |
if (manual || lookup.getResourceProfileByQuery(q).equals("auto")) { |
|
162 |
startProcess(wfId); |
|
163 |
} else { |
|
164 |
log.debug("Worflow " + wfId + " can not be launched AUTOMATICALLY"); |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
public GraphLoader getGraphLoader() { |
|
170 |
return graphLoader; |
|
171 |
} |
|
172 |
|
|
173 |
@Required |
|
174 |
public void setGraphLoader(final GraphLoader graphLoader) { |
|
175 |
this.graphLoader = graphLoader; |
|
176 |
} |
|
177 |
|
|
178 |
public MemEngine getEngine() { |
|
179 |
return engine; |
|
180 |
} |
|
181 |
|
|
182 |
@Required |
|
183 |
public void setEngine(final MemEngine engine) { |
|
184 |
this.engine = engine; |
|
185 |
} |
|
186 |
|
|
187 |
public GraphProcessRegistry getGraphProcessRegistry() { |
|
188 |
return graphProcessRegistry; |
|
189 |
} |
|
190 |
|
|
191 |
@Required |
|
192 |
public void setGraphProcessRegistry(final GraphProcessRegistry graphProcessRegistry) { |
|
193 |
this.graphProcessRegistry = graphProcessRegistry; |
|
194 |
} |
|
195 |
|
|
196 |
public ProfileToSarasvatiConverter getProfileToSarasvatiConverter() { |
|
197 |
return profileToSarasvatiConverter; |
|
198 |
} |
|
199 |
|
|
200 |
@Required |
|
201 |
public void setProfileToSarasvatiConverter(final ProfileToSarasvatiConverter profileToSarasvatiConverter) { |
|
202 |
this.profileToSarasvatiConverter = profileToSarasvatiConverter; |
|
203 |
} |
|
204 |
|
|
205 |
@Override |
|
206 |
public void stop() { |
|
207 |
this.paused = true; |
|
208 |
} |
|
209 |
|
|
210 |
@Override |
|
211 |
public void resume() { |
|
212 |
this.paused = false; |
|
213 |
} |
|
214 |
|
|
215 |
@Override |
|
216 |
public StoppableDetails getStopDetails() { |
|
217 |
final int count = graphProcessRegistry.countRunningWfs(); |
|
218 |
|
|
219 |
StoppableDetails.StopStatus status = StopStatus.RUNNING; |
|
220 |
if (isPaused()) { |
|
221 |
if (count == 0) { |
|
222 |
status = StopStatus.STOPPED; |
|
223 |
} else { |
|
224 |
status = StopStatus.STOPPING; |
|
225 |
} |
|
226 |
} |
|
227 |
graphProcessRegistry.listIdentifiers(); |
|
228 |
|
|
229 |
return new StoppableDetails("D-NET workflow manager", "Running workflows: " + count, status); |
|
230 |
} |
|
231 |
|
|
232 |
public int getMaxRunningWorkflows() { |
|
233 |
return maxRunningWorkflows; |
|
234 |
} |
|
235 |
|
|
236 |
public void setMaxRunningWorkflows(final int maxRunningWorkflows) { |
|
237 |
this.maxRunningWorkflows = maxRunningWorkflows; |
|
238 |
} |
|
239 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/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.21/src/main/java/eu/dnetlib/msro/workflows/nodes/index/PrepareCreateIndexJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.index; |
|
2 |
|
|
3 |
import org.apache.commons.logging.Log; |
|
4 |
import org.apache.commons.logging.LogFactory; |
|
5 |
|
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
|
|
8 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
9 |
|
|
10 |
public class PrepareCreateIndexJobNode extends SimpleJobNode { |
|
11 |
|
|
12 |
private static final Log log = LogFactory.getLog(PrepareCreateIndexJobNode.class); |
|
13 |
|
|
14 |
private String layout; |
|
15 |
private String format; |
|
16 |
private String interpretation; |
|
17 |
|
|
18 |
@Override |
|
19 |
protected String execute(final NodeToken token) throws Exception { |
|
20 |
log.info("Preparing env for CreateIndexJobNode"); |
|
21 |
token.getEnv().setAttribute("layout", layout); |
|
22 |
token.getEnv().setAttribute("format", format); |
|
23 |
token.getEnv().setAttribute("interpretation", interpretation); |
|
24 |
return null; |
|
25 |
} |
|
26 |
|
|
27 |
public String getLayout() { |
|
28 |
return layout; |
|
29 |
} |
|
30 |
|
|
31 |
public void setLayout(final String layout) { |
|
32 |
this.layout = layout; |
|
33 |
} |
|
34 |
|
|
35 |
public String getFormat() { |
|
36 |
return format; |
|
37 |
} |
|
38 |
|
|
39 |
public void setFormat(final String format) { |
|
40 |
this.format = format; |
|
41 |
} |
|
42 |
|
|
43 |
public String getInterpretation() { |
|
44 |
return interpretation; |
|
45 |
} |
|
46 |
|
|
47 |
public void setInterpretation(final String interpretation) { |
|
48 |
this.interpretation = interpretation; |
|
49 |
} |
|
50 |
|
|
51 |
} |
modules/dnet-msro-service/tags/dnet-msro-service-3.1.21/src/main/java/eu/dnetlib/msro/workflows/nodes/repohi/VerifyDatasourceJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows.nodes.repohi; |
|
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
|
|
5 |
import com.google.common.base.Splitter; |
|
6 |
import com.googlecode.sarasvati.Arc; |
|
7 |
import com.googlecode.sarasvati.NodeToken; |
|
8 |
import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants; |
|
9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; |
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
11 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
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 |
|
|
17 |
public class VerifyDatasourceJobNode extends SimpleJobNode { |
|
18 |
|
|
19 |
@Resource |
|
20 |
private UniqueServiceLocator serviceLocator; |
|
21 |
|
|
22 |
private String expectedInterfaceTypologyPrefixes; |
|
23 |
|
|
24 |
private String expectedCompliancePrefixes; |
|
25 |
|
|
26 |
@Override |
|
27 |
protected String execute(final NodeToken token) throws Exception { |
|
28 |
final String dsId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID); |
|
29 |
final String ifaceId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE); |
|
30 |
final ISLookUpService lookupService = serviceLocator.getService(ISLookUpService.class); |
|
31 |
|
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-msro-service-3.1.21