use of org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE in project tmdm-studio-se by Talend.
the class NewProcessAction method newProcess.
private WSTransformerV2E newProcess(String key) {
WSTransformerV2E transformer = MdmserverobjectFactory.eINSTANCE.createWSTransformerV2E();
transformer.setName(key);
// $NON-NLS-1$
transformer.setDescription("");
if (key.toString().startsWith("Smart_view_")) {
// $NON-NLS-1$
final String parameters = // $NON-NLS-1$
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>\n" + // $NON-NLS-1$
" <xsl:output method='html' indent='yes' omit-xml-declaration='yes'/>\n" + " <xsl:template match='/'>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <html>\n" + " <head><title>Smart View</title></head>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <body>\n" + // $NON-NLS-1$
" <h1>This is the default Smart View for: <xsl:value-of select='./text()'/></h1>\n" + " <xsl:copy-of select='.'/>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <!-- Customize the stylesheet -->\n" + " </body>\n" + " </html>\n" + " </xsl:template>" + // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"</xsl:stylesheet>";
// $NON-NLS-1$
final String TRANSFORMER_PLUGIN = "amalto/local/transformer/plugin/xslt";
List<WSTransformerVariablesMappingE> inItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
inputLine.setPipelineVariable("_DEFAULT_");
// $NON-NLS-1$
inputLine.setPluginVariable("xml");
inItems.add(inputLine);
List<WSTransformerVariablesMappingE> outItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine.setPipelineVariable("html");
// $NON-NLS-1$
outputLine.setPluginVariable("text");
outItems.add(outputLine);
ArrayList<WSTransformerProcessStepE> list = new ArrayList<WSTransformerProcessStepE>();
WSTransformerProcessStepE step = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
step.setPluginJNDI(TRANSFORMER_PLUGIN);
// $NON-NLS-1$
step.setDescription("Stylesheet");
step.setParameters(parameters);
step.getInputMappings().addAll(inItems);
step.getOutputMappings().addAll(outItems);
step.setDisabled(false);
list.add(step);
transformer.getProcessSteps().addAll(list);
}
return transformer;
}
use of org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE in project tmdm-studio-se by Talend.
the class GenerateJobTransformerAction method createTransformer.
/**
* @param jobVersion
*/
private WSTransformerV2E createTransformer(String jobName, String jobVersion, JobOptionsDialog dialog) {
// $NON-NLS-1$
String server = "http://localhost:8180";
Execution execution = dialog.getExecution();
Parameter executionParameter = dialog.getParameter();
// $NON-NLS-1$
final String TRANSFORMER_PLUGIN = "amalto/local/transformer/plugin/xslt";
WSTransformerV2E transformer = MdmserverobjectFactory.eINSTANCE.createWSTransformerV2E();
// $NON-NLS-1$
String url = "";
switch(execution) {
case EMBEDDED:
// $NON-NLS-1$//$NON-NLS-2$
url = "ltj://" + jobName + "/" + jobVersion;
break;
case WEB_SERVICE:
url = Messages.bind(Messages.GenerateJobXX_UrlString, server, jobName, jobVersion, jobName);
break;
}
// Generate the job call
List<WSTransformerProcessStepE> steps = new ArrayList<WSTransformerProcessStepE>();
WSTransformerVariablesMapping[] input;
WSTransformerVariablesMapping[] output;
try {
List<WSTransformerVariablesMappingE> inItems;
List<WSTransformerVariablesMappingE> outItems;
switch(executionParameter) {
case CONTEXT_VARIABLE:
String itemstr = // $NON-NLS-1$
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:mdm=\"java:com.amalto.core.plugin.base.xslt.MdmExtension\" version=\"1.0\"> <xsl:output method=\"xml\" indent=\"yes\" omit-xml-declaration=\"yes\" /> <xsl:template match=\"/\" priority=\"1\">\n" + // $NON-NLS-1$
"<exchange> <report>\n <xsl:copy-of select=\"Update\"/> </report> <item><xsl:copy-of select='mdm:getItemProjection(Update/RevisionID,Update/DataCluster,Update/Concept,Update/Key)'/></item></exchange> " + // $NON-NLS-1$
"</xsl:template> </xsl:stylesheet>\n";
WSTransformerProcessStepE steps1 = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
inItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
inputLine.setPipelineVariable("_DEFAULT_");
// $NON-NLS-1$
inputLine.setPluginVariable("xml");
inItems.add(inputLine);
outItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine.setPipelineVariable("item_xml");
// $NON-NLS-1$
outputLine.setPluginVariable("text");
outItems.add(outputLine);
steps1.setPluginJNDI(TRANSFORMER_PLUGIN);
// $NON-NLS-1$
steps1.setDescription("Stylesheet");
steps1.setParameters(itemstr);
steps1.getInputMappings().addAll(inItems);
steps1.getOutputMappings().addAll(outItems);
steps1.setDisabled(false);
// Generate the XSLT step to retrieve the item from an update report
// step 2
WSTransformerProcessStepE steps2 = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
List<WSTransformerVariablesMappingE> inItems2 = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine2 = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
inputLine2.setPipelineVariable("item_xml");
// $NON-NLS-1$
inputLine2.setPluginVariable("law_text");
inItems2.add(inputLine2);
List<WSTransformerVariablesMappingE> outItems2 = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine2 = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine2.setPipelineVariable("decode_xml");
// $NON-NLS-1$
outputLine2.setPluginVariable("codec_text");
outItems2.add(outputLine2);
// $NON-NLS-1$
steps2.setPluginJNDI("amalto/local/transformer/plugin/codec");
// $NON-NLS-1$
steps2.setDescription("Escape the item XML");
String parameter = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"<parameters>\n" + "<method>DECODE</method>\n" + "<algorithm>XMLESCAPE</algorithm>\n" + // $NON-NLS-1$
"</parameters>\n";
steps2.setParameters(parameter);
steps2.getInputMappings().addAll(inItems2);
steps2.getOutputMappings().addAll(outItems2);
steps2.setDisabled(false);
// step 3
WSTransformerProcessStepE steps3 = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
List<WSTransformerVariablesMappingE> inItems3 = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine3 = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
inputLine3.setPipelineVariable("decode_xml");
// $NON-NLS-1$
inputLine3.setPluginVariable("text");
inItems3.add(inputLine3);
List<WSTransformerVariablesMappingE> outItems3 = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine3 = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine3.setPipelineVariable("output");
// $NON-NLS-1$
outputLine3.setPluginVariable("result");
outItems3.add(outputLine3);
// $NON-NLS-1$
steps3.setPluginJNDI("amalto/local/transformer/plugin/callJob");
// $NON-NLS-1$
steps3.setDescription("Invoke the job");
input = new WSTransformerVariablesMapping[1];
// $NON-NLS-1$ //$NON-NLS-2$
input[0] = new WSTransformerVariablesMapping(null, "_DEFAULT_", "xml");
output = new WSTransformerVariablesMapping[1];
// $NON-NLS-1$ //$NON-NLS-2$
output[0] = new WSTransformerVariablesMapping(null, "item_xml", "text");
steps3.setParameters(parameter);
steps3.getInputMappings().addAll(inItems3);
steps3.getOutputMappings().addAll(outItems3);
steps3.setDisabled(false);
parameter = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"<configuration>\n" + "<url>" + url + "</url>\n" + "<contextParam>\n" + "<name>xmlInput</name>\n" + "<value>{decode_xml}</value>\n" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"</contextParam>\n" + // $NON-NLS-1$
"</configuration>\n";
steps3.setParameters(parameter);
steps.add(steps1);
steps.add(steps2);
steps.add(steps3);
break;
case INTEGRATED:
WSTransformerProcessStepE step1 = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
inItems = new ArrayList<WSTransformerVariablesMappingE>();
inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
inputLine.setPipelineVariable("_DEFAULT_");
// $NON-NLS-1$
inputLine.setPluginVariable("text");
inItems.add(inputLine);
outItems = new ArrayList<WSTransformerVariablesMappingE>();
outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine.setPipelineVariable("item_xml");
// $NON-NLS-1$
outputLine.setPluginVariable("result");
outItems.add(outputLine);
// $NON-NLS-1$
step1.setPluginJNDI("amalto/local/transformer/plugin/callJob");
// $NON-NLS-1$
step1.setDescription("Invoke the job");
step1.setParameters(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"<configuration>\n" + "<url>" + url + "</url>\n" + // $NON-NLS-1$
"</configuration>\n");
step1.getInputMappings().addAll(inItems);
step1.getOutputMappings().addAll(outItems);
step1.setDisabled(false);
steps.add(step1);
break;
default:
log.warn(Messages.bind(Messages.GenerateJobXX_UNSupportedType, executionParameter));
steps = Collections.emptyList();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
try {
// Generate the job call
transformer.setName(getNewProcessName(jobName));
transformer.setDescription(Messages.bind(Messages.GenerateJobXX_ProcessCallJob, jobName));
transformer.getProcessSteps().addAll(steps);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return transformer;
}
use of org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE in project tmdm-studio-se by Talend.
the class ProcessStepFactory method createReturnMessageStep.
private static WSTransformerProcessStepE createReturnMessageStep(Object param) {
if (param == null || !(param instanceof String[]) || ((String[]) param).length != 2) {
throw new IllegalArgumentException();
}
String type = ((String[]) param)[0];
String mulMessage = ((String[]) param)[1];
String prefixParam = // $NON-NLS-1$
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:mdm=\"java:com.amalto.core.plugin.base.xslt.MdmExtension\" version=\"1.0\">\n" + // $NON-NLS-1$
"<xsl:output method=\"xml\" indent=\"yes\" omit-xml-declaration=\"yes\"/>\n" + "<xsl:template match=\"/\" priority=\"1\">\n" + "<report>\n <message type=\"" + type + // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
"\">";
// $NON-NLS-1$
String suffixParam = "</message>\n</report>\n</xsl:template>\n</xsl:stylesheet>";
List<WSTransformerVariablesMappingE> inItems;
List<WSTransformerVariablesMappingE> outItems;
WSTransformerProcessStepE step = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
inItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
inputLine.setPipelineVariable(VAR_DEFAULT);
inputLine.setPluginVariable(VAR_XML);
inItems.add(inputLine);
outItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
outputLine.setPipelineVariable(VAR_OUTPUT_REPORT);
outputLine.setPluginVariable(VAR_TEXT);
outItems.add(outputLine);
step.setPluginJNDI(XSLT_PLUGIN);
// $NON-NLS-1$
step.setDescription("Retrieve Message");
step.setParameters(prefixParam + mulMessage + suffixParam);
step.getInputMappings().addAll(inItems);
step.getOutputMappings().addAll(outItems);
step.setDisabled(false);
return step;
}
use of org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE in project tmdm-studio-se by Talend.
the class ProcessStepFactory method createSmartViewStep.
public static WSTransformerProcessStepE createSmartViewStep() {
final String parameters = // $NON-NLS-1$
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>\n" + // $NON-NLS-1$
" <xsl:output method='html' indent='yes' omit-xml-declaration='yes'/>\n" + " <xsl:template match='/'>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <html>\n" + " <head><title>Smart View</title></head>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <body>\n" + // $NON-NLS-1$
" <h1>This is the default Smart View for: <xsl:value-of select='./text()'/></h1>\n" + " <xsl:copy-of select='.'/>\n" + // $NON-NLS-1$//$NON-NLS-2$
" <!-- Customize the stylesheet -->\n" + " </body>\n" + " </html>\n" + " </xsl:template>" + // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
"</xsl:stylesheet>";
List<WSTransformerVariablesMappingE> inItems;
List<WSTransformerVariablesMappingE> outItems;
WSTransformerProcessStepE step = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
inItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
inputLine.setPipelineVariable(VAR_DEFAULT);
inputLine.setPluginVariable(VAR_XML);
inItems.add(inputLine);
outItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
// $NON-NLS-1$
outputLine.setPipelineVariable("html");
outputLine.setPluginVariable(VAR_TEXT);
outItems.add(outputLine);
step.setPluginJNDI(XSLT_PLUGIN);
// $NON-NLS-1$
step.setDescription("Stylesheet");
step.setParameters(parameters);
step.getInputMappings().addAll(inItems);
step.getOutputMappings().addAll(outItems);
step.setDisabled(false);
return step;
}
use of org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE in project tmdm-studio-se by Talend.
the class ProcessStepFactory method createRedirectStep.
public static WSTransformerProcessStepE createRedirectStep(Object param, String outputPipleVariable) {
if (param == null || !(param instanceof String)) {
throw new IllegalArgumentException();
}
String prefixParam = // $NON-NLS-1$
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:mdm=\"java:com.amalto.core.plugin.base.xslt.MdmExtension\" version=\"1.0\">\n" + // $NON-NLS-1$
"<xsl:output method=\"xml\" indent=\"yes\" omit-xml-declaration=\"yes\"/>\n" + "<xsl:template match=\"/\" priority=\"1\">\n" + // $NON-NLS-1$//$NON-NLS-2$
"<results>\n<item>\n<attr>";
// $NON-NLS-1$
String suffixParam = "</attr>\n</item>\n</results>\n</xsl:template>\n</xsl:stylesheet>";
List<WSTransformerVariablesMappingE> inItems;
List<WSTransformerVariablesMappingE> outItems;
WSTransformerProcessStepE step = MdmserverobjectFactory.eINSTANCE.createWSTransformerProcessStepE();
inItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE inputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
inputLine.setPipelineVariable(VAR_DEFAULT);
inputLine.setPluginVariable(VAR_XML);
inItems.add(inputLine);
outItems = new ArrayList<WSTransformerVariablesMappingE>();
WSTransformerVariablesMappingE outputLine = MdmserverobjectFactory.eINSTANCE.createWSTransformerVariablesMappingE();
outputLine.setPipelineVariable(outputPipleVariable);
outputLine.setPluginVariable(VAR_TEXT);
outItems.add(outputLine);
step.setPluginJNDI(XSLT_PLUGIN);
// $NON-NLS-1$
step.setDescription("Redirect");
step.setParameters(prefixParam + param + suffixParam);
step.getInputMappings().addAll(inItems);
step.getOutputMappings().addAll(outItems);
step.setDisabled(false);
return step;
}
Aggregations