Revision 32330
Added by Andrea Mannocci about 10 years ago
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/EditionXsltUnaryFunction.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.workflows.nodes.transform; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.dom4j.Document; |
|
10 |
import org.dom4j.DocumentException; |
|
11 |
import org.dom4j.Element; |
|
12 |
import org.dom4j.Node; |
|
13 |
import org.dom4j.io.SAXReader; |
|
14 |
import org.springframework.core.io.ClassPathResource; |
|
15 |
|
|
16 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
17 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
18 |
|
|
19 |
public class EditionXsltUnaryFunction implements UnaryFunction<String, String> { |
|
20 |
private static final Log log = LogFactory.getLog(EditionXsltUnaryFunction.class); |
|
21 |
|
|
22 |
private ApplyXslt xslt; |
|
23 |
private SAXReader reader; |
|
24 |
|
|
25 |
public EditionXsltUnaryFunction(final String xsltClasspath, Map<String, String> xsltParams) throws IOException { |
|
26 |
this.xslt = new ApplyXslt(new ClassPathResource(xsltClasspath), xsltParams); |
|
27 |
this.reader = new SAXReader(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* xPath the <metadata> node and applies xslt 2.0 transformation |
|
32 |
*/ |
|
33 |
@Override |
|
34 |
public String evaluate(String input) { |
|
35 |
try { |
|
36 |
Document doc = reader.read(new StringReader(input)); |
|
37 |
Node result = doc.selectSingleNode("//*[local-name()='metadata']/*"); |
|
38 |
String edition = xslt.evaluate(result.asXML()); |
|
39 |
result.detach(); |
|
40 |
((Element) doc.selectSingleNode("//*[local-name()='metadata']")).add(reader.read(new StringReader(edition)).getRootElement()); |
|
41 |
return doc.asXML(); |
|
42 |
} catch (DocumentException e) { |
|
43 |
log.error("Problem creating dom4j document from \n" + input, e); |
|
44 |
throw new RuntimeException(e); |
|
45 |
} |
|
46 |
|
|
47 |
} |
|
48 |
} |
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/ApplyEditionXsltJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.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 com.googlecode.sarasvati.Arc; |
|
9 |
import com.googlecode.sarasvati.NodeToken; |
|
10 |
|
|
11 |
import eu.dnetlib.enabling.resultset.MappedResultSetFactory; |
|
12 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
13 |
import eu.dnetlib.msro.rmi.MSROException; |
|
14 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
15 |
|
|
16 |
/** |
|
17 |
* This class is intended to process records coming in MDStore compliant form (with header) |
|
18 |
* and apply the xslt located at http://sourceforge.net/projects/epidoc/files/Example%20Stylesheets/ |
|
19 |
* to the <metadata> blocks of each record. |
|
20 |
* @author Andrea Mannocci |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class ApplyEditionXsltJobNode extends SimpleJobNode { |
|
24 |
|
|
25 |
private String inputEprParam; |
|
26 |
private String outputEprParam; |
|
27 |
private String xsltClasspath; |
|
28 |
|
|
29 |
private MappedResultSetFactory mappedResultSetFactory; |
|
30 |
private final Map<String, String> xsltParams = new HashMap<String, String>(); |
|
31 |
|
|
32 |
@Override |
|
33 |
protected String execute(final NodeToken token) throws Exception { |
|
34 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam); |
|
35 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
|
36 |
|
|
37 |
|
|
38 |
for (String name : token.getFullEnv().getAttributeNames()) { |
|
39 |
xsltParams.put(name, token.getFullEnv().getAttribute(name)); |
|
40 |
} |
|
41 |
for (String name : token.getEnv().getAttributeNames()) { |
|
42 |
xsltParams.put(name, token.getEnv().getAttribute(name)); |
|
43 |
} |
|
44 |
|
|
45 |
xsltParams.putAll(parseJsonParameters(token)); |
|
46 |
|
|
47 |
final W3CEndpointReference epr = mappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), |
|
48 |
new EditionXsltUnaryFunction(xsltClasspath, xsltParams)); |
|
49 |
|
|
50 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
51 |
|
|
52 |
return Arc.DEFAULT_ARC; |
|
53 |
} |
|
54 |
|
|
55 |
public String getInputEprParam() { |
|
56 |
return inputEprParam; |
|
57 |
} |
|
58 |
|
|
59 |
public void setInputEprParam(String inputEprParam) { |
|
60 |
this.inputEprParam = inputEprParam; |
|
61 |
} |
|
62 |
|
|
63 |
public String getOutputEprParam() { |
|
64 |
return outputEprParam; |
|
65 |
} |
|
66 |
|
|
67 |
public void setOutputEprParam(String outputEprParam) { |
|
68 |
this.outputEprParam = outputEprParam; |
|
69 |
} |
|
70 |
|
|
71 |
public String getXsltClasspath() { |
|
72 |
return xsltClasspath; |
|
73 |
} |
|
74 |
|
|
75 |
public void setXsltClasspath(String xsltClasspath) { |
|
76 |
this.xsltClasspath = xsltClasspath; |
|
77 |
} |
|
78 |
|
|
79 |
public MappedResultSetFactory getMappedResultSetFactory() { |
|
80 |
return mappedResultSetFactory; |
|
81 |
} |
|
82 |
|
|
83 |
public void setMappedResultSetFactory( |
|
84 |
MappedResultSetFactory mappedResultSetFactory) { |
|
85 |
this.mappedResultSetFactory = mappedResultSetFactory; |
|
86 |
} |
|
87 |
|
|
88 |
} |
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/tmid/TrismegistosInjectionJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.workflows.nodes.transform.tmid; |
|
2 |
|
|
3 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.Arc; |
|
6 |
import com.googlecode.sarasvati.NodeToken; |
|
7 |
|
|
8 |
import eu.dnetlib.enabling.resultset.MappedResultSetFactory; |
|
9 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
10 |
import eu.dnetlib.msro.rmi.MSROException; |
|
11 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
12 |
|
|
13 |
public class TrismegistosInjectionJobNode extends SimpleJobNode { |
|
14 |
private String inputEprParam; |
|
15 |
private String outputEprParam; |
|
16 |
private String tmIdListPath; |
|
17 |
|
|
18 |
private MappedResultSetFactory mappedResultSetFactory; |
|
19 |
|
|
20 |
@Override |
|
21 |
protected String execute(NodeToken token) throws Exception { |
|
22 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam); |
|
23 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
|
24 |
final W3CEndpointReference epr = getMappedResultSetFactory().createMappedResultSet(new EPRUtils().getEpr(inputEpr), |
|
25 |
new TrismegistosInjectionUnaryFunction(tmIdListPath)); |
|
26 |
|
|
27 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
28 |
|
|
29 |
return Arc.DEFAULT_ARC; |
|
30 |
} |
|
31 |
|
|
32 |
public String getInputEprParam() { |
|
33 |
return inputEprParam; |
|
34 |
} |
|
35 |
|
|
36 |
public void setInputEprParam(String inputEprParam) { |
|
37 |
this.inputEprParam = inputEprParam; |
|
38 |
} |
|
39 |
|
|
40 |
public String getOutputEprParam() { |
|
41 |
return outputEprParam; |
|
42 |
} |
|
43 |
|
|
44 |
public void setOutputEprParam(String outputEprParam) { |
|
45 |
this.outputEprParam = outputEprParam; |
|
46 |
} |
|
47 |
|
|
48 |
public String getTmIdListPath() { |
|
49 |
return tmIdListPath; |
|
50 |
} |
|
51 |
|
|
52 |
public void setTmIdListPath(String tmIdListPath) { |
|
53 |
this.tmIdListPath = tmIdListPath; |
|
54 |
} |
|
55 |
|
|
56 |
public MappedResultSetFactory getMappedResultSetFactory() { |
|
57 |
return mappedResultSetFactory; |
|
58 |
} |
|
59 |
|
|
60 |
public void setMappedResultSetFactory(MappedResultSetFactory mappedResultSetFactory) { |
|
61 |
this.mappedResultSetFactory = mappedResultSetFactory; |
|
62 |
} |
|
63 |
|
|
64 |
} |
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/tmid/TrismegistosInjectionUnaryFunction.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.workflows.nodes.transform.tmid; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import javax.xml.stream.XMLInputFactory; |
|
10 |
import javax.xml.stream.XMLStreamConstants; |
|
11 |
import javax.xml.stream.XMLStreamException; |
|
12 |
import javax.xml.stream.XMLStreamReader; |
|
13 |
|
|
14 |
import org.dom4j.Document; |
|
15 |
import org.dom4j.DocumentException; |
|
16 |
import org.dom4j.DocumentHelper; |
|
17 |
import org.dom4j.Element; |
|
18 |
import org.dom4j.Node; |
|
19 |
import org.dom4j.io.SAXReader; |
|
20 |
import org.springframework.core.io.FileSystemResource; |
|
21 |
|
|
22 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
23 |
|
|
24 |
public class TrismegistosInjectionUnaryFunction implements UnaryFunction<String, String> { |
|
25 |
private SAXReader reader; |
|
26 |
|
|
27 |
private static Map<String, List<String>> tmIdToLocalIdsMap; |
|
28 |
private static Map<String, String> localIdToTmIdMap; |
|
29 |
|
|
30 |
public TrismegistosInjectionUnaryFunction(String tmIdListPath) { |
|
31 |
this.reader = new SAXReader(); |
|
32 |
|
|
33 |
FileSystemResource tmIds = new FileSystemResource(tmIdListPath); |
|
34 |
XMLInputFactory factory = XMLInputFactory.newInstance(); |
|
35 |
try { |
|
36 |
XMLStreamReader reader = factory.createXMLStreamReader(tmIds.getInputStream()); |
|
37 |
|
|
38 |
boolean isSafeToGetNextXmlElement = true; |
|
39 |
while (isSafeToGetNextXmlElement) { |
|
40 |
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { |
|
41 |
if("tmid".equals(reader.getLocalName())){ |
|
42 |
parseTmEvent(reader); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
if (reader.hasNext()) { |
|
47 |
reader.next(); |
|
48 |
} else { |
|
49 |
isSafeToGetNextXmlElement = false; |
|
50 |
break; |
|
51 |
} |
|
52 |
} |
|
53 |
} catch (IOException e) { |
|
54 |
// TODO Auto-generated catch block |
|
55 |
e.printStackTrace(); |
|
56 |
} catch (XMLStreamException e) { |
|
57 |
// TODO Auto-generated catch block |
|
58 |
e.printStackTrace(); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
private void parseTmEvent(XMLStreamReader reader) { |
|
63 |
String tmId = reader.getAttributeValue(null, "id"); |
|
64 |
List<String> localIds = new ArrayList<String>(); |
|
65 |
|
|
66 |
boolean isSafeToGetNextXmlElement = true; |
|
67 |
while(isSafeToGetNextXmlElement) { |
|
68 |
if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) { |
|
69 |
break; |
|
70 |
} else { |
|
71 |
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { |
|
72 |
if("link".equals(reader.getLocalName())){ |
|
73 |
String localId = parseLinkEvent(reader); |
|
74 |
localIdToTmIdMap.put(localId, tmId); |
|
75 |
localIds.add(localId); |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
try{ |
|
81 |
if (reader.hasNext()) { |
|
82 |
reader.next(); |
|
83 |
} else { |
|
84 |
isSafeToGetNextXmlElement = false; |
|
85 |
break; |
|
86 |
} |
|
87 |
} catch (XMLStreamException e) { |
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
} |
|
91 |
tmIdToLocalIdsMap.put(tmId, localIds); |
|
92 |
} |
|
93 |
|
|
94 |
private String parseLinkEvent(XMLStreamReader reader) { |
|
95 |
String cp = reader.getAttributeValue(null, "cp"); |
|
96 |
String val = ""; |
|
97 |
boolean isSafeToGetNextXmlElement = true; |
|
98 |
while(isSafeToGetNextXmlElement) { |
|
99 |
if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) { |
|
100 |
break; |
|
101 |
} else if (reader.getEventType() == XMLStreamConstants.CHARACTERS) { |
|
102 |
val = reader.getText(); |
|
103 |
} |
|
104 |
|
|
105 |
try{ |
|
106 |
if (reader.hasNext()) { |
|
107 |
reader.next(); |
|
108 |
} else { |
|
109 |
isSafeToGetNextXmlElement = false; |
|
110 |
break; |
|
111 |
} |
|
112 |
} catch (XMLStreamException e) { |
|
113 |
e.printStackTrace(); |
|
114 |
} |
|
115 |
} |
|
116 |
return (cp + "::" + val); |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public String evaluate(String input) { |
|
121 |
try { |
|
122 |
Document doc = reader.read(new StringReader(input)); |
|
123 |
Node entityType = doc.selectSingleNode("//*[local-name()='entityType']"); |
|
124 |
|
|
125 |
// TMid injection on Artifacts/Inscriptions |
|
126 |
if ("artifact".equals(entityType.getText())) { |
|
127 |
Node recordSourceInfo = doc.selectSingleNode("//*[local-name()='eagleObject']/*[local-name()='recordSourceInfo']"); |
|
128 |
String localIdKey = (recordSourceInfo.selectSingleNode("@providerAcronym")).getText() + "::" + (recordSourceInfo.selectSingleNode("./text()")).getText(); |
|
129 |
String tmId = localIdToTmIdMap.get(localIdKey); |
|
130 |
if (tmId != null) { |
|
131 |
// TMid found! Prepare for injection.. |
|
132 |
List<String> alternateIds = tmIdToLocalIdsMap.get(tmId); |
|
133 |
Element inscription = (Element) doc.selectSingleNode("//*[local-name()='inscription']"); |
|
134 |
Element injectedHasTmId = prepareInjectedElement(tmId, alternateIds); |
|
135 |
replaceElement(inscription, (Element) inscription.selectSingleNode("hasTmId"), injectedHasTmId); |
|
136 |
return doc.asXML(); |
|
137 |
} else { |
|
138 |
// There is no TM ID for this localID. Just return the input string here.. |
|
139 |
return input; |
|
140 |
} |
|
141 |
} |
|
142 |
|
|
143 |
// TMid injection on other items with rel to Artifacts |
|
144 |
if ("visual".equals(entityType.getText()) || "documental".equals(entityType.getText())) { |
|
145 |
Node recordSourceInfo = doc.selectSingleNode("//*[local-name()='hasArtifact']/*[local-name()='recordSourceInfo']"); |
|
146 |
String localIdKey = (recordSourceInfo.selectSingleNode("@providerAcronym")).getText() + "::" + (recordSourceInfo.selectSingleNode("./text()")).getText(); |
|
147 |
String tmId = localIdToTmIdMap.get(localIdKey); |
|
148 |
if (tmId != null) { |
|
149 |
// TMid found! Prepare for injection.. |
|
150 |
List<String> alternateIds = tmIdToLocalIdsMap.get(tmId); |
|
151 |
Element inscription = (Element) doc.selectSingleNode("//*[local-name()='hasArtifact']"); |
|
152 |
Element injectedHasTmId = prepareInjectedElement(tmId, alternateIds); |
|
153 |
replaceElement(inscription, (Element) inscription.selectSingleNode("hasTmId"), injectedHasTmId); |
|
154 |
return doc.asXML(); |
|
155 |
} else { |
|
156 |
// There is no TM ID for this localID. Just return the input string here.. |
|
157 |
return input; |
|
158 |
} |
|
159 |
} |
|
160 |
} catch (DocumentException e) { |
|
161 |
// TODO Auto-generated catch block |
|
162 |
e.printStackTrace(); |
|
163 |
} |
|
164 |
|
|
165 |
return input; |
|
166 |
} |
|
167 |
|
|
168 |
private Element prepareInjectedElement(String tmId, List<String> alternateIds) { |
|
169 |
Document document = DocumentHelper.createDocument(); |
|
170 |
Element hasTmId = document.addElement( "hasTmId" ); |
|
171 |
hasTmId.addElement("tmId").addText(tmId); |
|
172 |
for (String alternateId : alternateIds) { |
|
173 |
String[] tokens = alternateId.split("::"); |
|
174 |
hasTmId.addElement("alternateId").addAttribute("providerAcronym", tokens[0]).addAttribute("localId", tokens[1]); |
|
175 |
} |
|
176 |
return (Element) document.selectSingleNode("hasTmId"); |
|
177 |
} |
|
178 |
|
|
179 |
private void replaceElement(Element parent, Element oldElement, Element newElement) { |
|
180 |
List parentContent = parent.content(); |
|
181 |
int index = parentContent.indexOf(oldElement); |
|
182 |
parentContent.set(index, newElement); |
|
183 |
} |
|
184 |
|
|
185 |
} |
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/editions/EditionXsltUnaryFunction.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.workflows.nodes.transform.editions; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.apache.commons.logging.Log; |
|
8 |
import org.apache.commons.logging.LogFactory; |
|
9 |
import org.dom4j.Document; |
|
10 |
import org.dom4j.DocumentException; |
|
11 |
import org.dom4j.Element; |
|
12 |
import org.dom4j.Node; |
|
13 |
import org.dom4j.io.SAXReader; |
|
14 |
import org.springframework.core.io.ClassPathResource; |
|
15 |
|
|
16 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
17 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
18 |
|
|
19 |
public class EditionXsltUnaryFunction implements UnaryFunction<String, String> { |
|
20 |
private static final Log log = LogFactory.getLog(EditionXsltUnaryFunction.class); |
|
21 |
|
|
22 |
private ApplyXslt xslt; |
|
23 |
private SAXReader reader; |
|
24 |
|
|
25 |
public EditionXsltUnaryFunction(final String xsltClasspath, Map<String, String> xsltParams) throws IOException { |
|
26 |
this.xslt = new ApplyXslt(new ClassPathResource(xsltClasspath), xsltParams); |
|
27 |
this.reader = new SAXReader(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* xPath the <metadata> node and applies xslt 2.0 transformation |
|
32 |
*/ |
|
33 |
@Override |
|
34 |
public String evaluate(String input) { |
|
35 |
try { |
|
36 |
Document doc = reader.read(new StringReader(input)); |
|
37 |
Node result = doc.selectSingleNode("//*[local-name()='metadata']/*"); |
|
38 |
String edition = xslt.evaluate(result.asXML()); |
|
39 |
result.detach(); |
|
40 |
((Element) doc.selectSingleNode("//*[local-name()='metadata']")).add(reader.read(new StringReader(edition)).getRootElement()); |
|
41 |
return doc.asXML(); |
|
42 |
} catch (DocumentException e) { |
|
43 |
log.error("Problem creating dom4j document from \n" + input, e); |
|
44 |
throw new RuntimeException(e); |
|
45 |
} |
|
46 |
|
|
47 |
} |
|
48 |
} |
modules/dnet-eagle-workflows/trunk/src/main/java/eu/dnetlib/msro/eagle/workflows/nodes/transform/editions/ApplyEditionXsltJobNode.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.eagle.workflows.nodes.transform.editions; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import com.googlecode.sarasvati.Arc; |
|
9 |
import com.googlecode.sarasvati.NodeToken; |
|
10 |
|
|
11 |
import eu.dnetlib.enabling.resultset.MappedResultSetFactory; |
|
12 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
|
13 |
import eu.dnetlib.msro.rmi.MSROException; |
|
14 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
|
15 |
|
|
16 |
/** |
|
17 |
* This class is intended to process records coming in MDStore compliant form (with header) |
|
18 |
* and apply the xslt located at http://sourceforge.net/projects/epidoc/files/Example%20Stylesheets/ |
|
19 |
* to the <metadata> blocks of each record. |
|
20 |
* @author Andrea Mannocci |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class ApplyEditionXsltJobNode extends SimpleJobNode { |
|
24 |
|
|
25 |
private String inputEprParam; |
|
26 |
private String outputEprParam; |
|
27 |
private String xsltClasspath; |
|
28 |
|
|
29 |
private MappedResultSetFactory mappedResultSetFactory; |
|
30 |
private final Map<String, String> xsltParams = new HashMap<String, String>(); |
|
31 |
|
|
32 |
@Override |
|
33 |
protected String execute(final NodeToken token) throws Exception { |
|
34 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam); |
|
35 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
|
36 |
|
|
37 |
|
|
38 |
for (String name : token.getFullEnv().getAttributeNames()) { |
|
39 |
xsltParams.put(name, token.getFullEnv().getAttribute(name)); |
|
40 |
} |
|
41 |
for (String name : token.getEnv().getAttributeNames()) { |
|
42 |
xsltParams.put(name, token.getEnv().getAttribute(name)); |
|
43 |
} |
|
44 |
|
|
45 |
xsltParams.putAll(parseJsonParameters(token)); |
|
46 |
|
|
47 |
final W3CEndpointReference epr = mappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), |
|
48 |
new EditionXsltUnaryFunction(xsltClasspath, xsltParams)); |
|
49 |
|
|
50 |
token.getEnv().setAttribute(outputEprParam, epr.toString()); |
|
51 |
|
|
52 |
return Arc.DEFAULT_ARC; |
|
53 |
} |
|
54 |
|
|
55 |
public String getInputEprParam() { |
|
56 |
return inputEprParam; |
|
57 |
} |
|
58 |
|
|
59 |
public void setInputEprParam(String inputEprParam) { |
|
60 |
this.inputEprParam = inputEprParam; |
|
61 |
} |
|
62 |
|
|
63 |
public String getOutputEprParam() { |
|
64 |
return outputEprParam; |
|
65 |
} |
|
66 |
|
|
67 |
public void setOutputEprParam(String outputEprParam) { |
|
68 |
this.outputEprParam = outputEprParam; |
|
69 |
} |
|
70 |
|
|
71 |
public String getXsltClasspath() { |
|
72 |
return xsltClasspath; |
|
73 |
} |
|
74 |
|
|
75 |
public void setXsltClasspath(String xsltClasspath) { |
|
76 |
this.xsltClasspath = xsltClasspath; |
|
77 |
} |
|
78 |
|
|
79 |
public MappedResultSetFactory getMappedResultSetFactory() { |
|
80 |
return mappedResultSetFactory; |
|
81 |
} |
|
82 |
|
|
83 |
public void setMappedResultSetFactory( |
|
84 |
MappedResultSetFactory mappedResultSetFactory) { |
|
85 |
this.mappedResultSetFactory = mappedResultSetFactory; |
|
86 |
} |
|
87 |
|
|
88 |
} |
modules/dnet-eagle-workflows/trunk/src/main/resources/eu/dnetlib/msro/eagle/workflows/applicationContext-eagle-wfnodes.xml | ||
---|---|---|
9 | 9 |
scope="prototype" /> |
10 | 10 |
|
11 | 11 |
<bean id="wfNodeApplyEditionXslt" |
12 |
class="eu.dnetlib.msro.eagle.workflows.nodes.transform.ApplyEditionXsltJobNode" |
|
12 |
class="eu.dnetlib.msro.eagle.workflows.nodes.transform.editions.ApplyEditionXsltJobNode"
|
|
13 | 13 |
scope="prototype" p:mappedResultSetFactory-ref="mappedResultSetFactory" /> |
14 | 14 |
|
15 | 15 |
<bean id="wfNodeComposeEpr" |
16 | 16 |
class="eu.dnetlib.msro.eagle.workflows.nodes.composition.ComposeEprJobNode" |
17 | 17 |
scope="prototype" p:mappedResultSetFactory-ref="mappedResultSetFactory" |
18 | 18 |
p:resultSetClientFactory-ref="resultSetClientFactory" /> |
19 |
|
|
20 |
<bean id="wfNodeTrismegistosInject" |
|
21 |
class="eu.dnetlib.msro.eagle.workflows.nodes.transform.tmid.TrismegistosInjectionJobNode" |
|
22 |
scope="prototype" p:mappedResultSetFactory-ref="mappedResultSetFactory" /> |
|
19 | 23 |
|
20 | 24 |
</beans> |
modules/dnet-eagle-workflows/trunk/src/main/resources/eu/dnetlib/msro/eagle/workflows/repo/transform-non-epidoc.wf.st | ||
---|---|---|
42 | 42 |
<PARAM required="true" type="string" name="xpath" managedBy="user">//*[local-name()='record']</PARAM> |
43 | 43 |
</PARAMETERS> |
44 | 44 |
<ARCS> |
45 |
<ARC to="trismegistosInjection"/> |
|
46 |
</ARCS> |
|
47 |
</NODE> |
|
48 |
|
|
49 |
<NODE name="trismegistosInjection" type="TrismegistosInject"> |
|
50 |
<DESCRIPTION>Unpack objects</DESCRIPTION> |
|
51 |
<PARAMETERS> |
|
52 |
<PARAM required="true" type="string" name="inputEprParam" managedBy="system">eagle_epr</PARAM> |
|
53 |
<PARAM required="true" type="string" name="outputEprParam" managedBy="system">injected_epr</PARAM> |
|
54 |
<PARAM required="true" type="string" name="tmIdListPath" managedBy="user">/var/lib/eagle/content/Trismegistos/tmid.xml</PARAM> |
|
55 |
</PARAMETERS> |
|
56 |
<ARCS> |
|
45 | 57 |
<ARC to="storeRecords"/> |
46 | 58 |
</ARCS> |
47 | 59 |
</NODE> |
... | ... | |
51 | 63 |
<PARAMETERS> |
52 | 64 |
<PARAM required="true" type="string" name="mdId" managedBy="system" category="MDSTORE_ID">$params.("tran_id")$</PARAM> |
53 | 65 |
<PARAM required="true" type="string" name="storingType" managedBy="system">REFRESH</PARAM> |
54 |
<PARAM required="true" type="string" name="eprParam" managedBy="system">eagle_epr</PARAM>
|
|
66 |
<PARAM required="true" type="string" name="eprParam" managedBy="system">injected_epr</PARAM>
|
|
55 | 67 |
</PARAMETERS> |
56 | 68 |
<ARCS> |
57 | 69 |
<ARC to="UPDATE_INFO"/> |
modules/dnet-eagle-workflows/trunk/src/main/resources/eu/dnetlib/msro/eagle/workflows/repo/transform.wf.st | ||
---|---|---|
27 | 27 |
<PARAMETERS> |
28 | 28 |
<PARAM required="true" type="string" name="inputEprParam" managedBy="system">orig_epr</PARAM> |
29 | 29 |
<PARAM required="true" type="string" name="outputEprParam" managedBy="system">edition_epr</PARAM> |
30 |
<PARAM required="true" type="string" name="xsltClasspath" managedBy="system">/eu/dnetlib/msro/eagle/workflows/xslt/edition/start-edition.xsl</PARAM> |
|
30 |
<PARAM required="true" type="string" name="xsltClasspath" managedBy="system">/eu/dnetlib/msro/eagle/workflows/xslt/editions/start-edition.xsl</PARAM>
|
|
31 | 31 |
<PARAM required="true" type="string" name="params" managedBy="system"> |
32 | 32 |
{ |
33 | 33 |
"edn-structure" : "london" |
... | ... | |
73 | 73 |
<PARAM required="true" type="string" name="xpath" managedBy="user">//*[local-name()='record']</PARAM> |
74 | 74 |
</PARAMETERS> |
75 | 75 |
<ARCS> |
76 |
<ARC to="trismegistosInjection"/> |
|
77 |
</ARCS> |
|
78 |
</NODE> |
|
79 |
|
|
80 |
<NODE name="trismegistosInjection" type="TrismegistosInject"> |
|
81 |
<DESCRIPTION>Unpack objects</DESCRIPTION> |
|
82 |
<PARAMETERS> |
|
83 |
<PARAM required="true" type="string" name="inputEprParam" managedBy="system">eagle_epr</PARAM> |
|
84 |
<PARAM required="true" type="string" name="outputEprParam" managedBy="system">injected_epr</PARAM> |
|
85 |
<PARAM required="true" type="string" name="tmIdListPath" managedBy="user">/var/lib/eagle/content/Trismegistos/tmid.xml</PARAM> |
|
86 |
</PARAMETERS> |
|
87 |
<ARCS> |
|
76 | 88 |
<ARC to="storeRecords"/> |
77 | 89 |
</ARCS> |
78 | 90 |
</NODE> |
... | ... | |
82 | 94 |
<PARAMETERS> |
83 | 95 |
<PARAM required="true" type="string" name="mdId" managedBy="system" category="MDSTORE_ID">$params.("tran_id")$</PARAM> |
84 | 96 |
<PARAM required="true" type="string" name="storingType" managedBy="system">REFRESH</PARAM> |
85 |
<PARAM required="true" type="string" name="eprParam" managedBy="system">eagle_epr</PARAM>
|
|
97 |
<PARAM required="true" type="string" name="eprParam" managedBy="system">injected_epr</PARAM>
|
|
86 | 98 |
</PARAMETERS> |
87 | 99 |
<ARCS> |
88 | 100 |
<ARC to="UPDATE_INFO"/> |
Also available in: Unified diff
added a first implementation for TMid injection