Search in sources :

Example 1 with WSTransformerVariablesMapping

use of com.amalto.workbench.webservices.WSTransformerVariablesMapping 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;
}
Also used : WSTransformerVariablesMappingE(org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE) ArrayList(java.util.ArrayList) Execution(org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog.Execution) WSTransformerV2E(org.talend.mdm.repository.model.mdmserverobject.WSTransformerV2E) WSTransformerVariablesMapping(com.amalto.workbench.webservices.WSTransformerVariablesMapping) Parameter(org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog.Parameter) WSTransformerProcessStepE(org.talend.mdm.repository.model.mdmserverobject.WSTransformerProcessStepE)

Example 2 with WSTransformerVariablesMapping

use of com.amalto.workbench.webservices.WSTransformerVariablesMapping in project tmdm-studio-se by Talend.

the class SetupTransformerInputVariablesDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Group comp = new Group(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    ((GridLayout) parent.getLayout()).marginTop = 5;
    ((GridLayout) parent.getLayout()).marginLeft = 5;
    ((GridLayout) parent.getLayout()).marginRight = 5;
    ((GridLayout) parent.getLayout()).marginBottom = 5;
    parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    comp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    comp.setLayout(new GridLayout(1, false));
    comp.setText(Messages.bind(Messages.SetupTransformerInputVariablesDialog_CompText, transformer.getName()));
    // Get the input variable names
    Set<String> inputVariables = new HashSet<String>();
    for (WSTransformerProcessStep step : transformer.getProcessSteps()) {
        for (WSTransformerVariablesMapping mapping : step.getInputMappings()) {
            inputVariables.add(mapping.getPipelineVariable() == null ? TransformerMainPage.DEFAULT_VAR : mapping.getPipelineVariable());
        }
    }
    ComplexTableViewerColumn[] columns = new ComplexTableViewerColumn[] { new // name
    ComplexTableViewerColumn(// name
    Messages.SetupTransformerInputVariablesDialog_InputVariables, // is Nillable ?
    true, // Nill value//$NON-NLS-1$
    "_DEFAULT_", // Nill display//$NON-NLS-1$
    "_DEFAULT_", // Default Value//$NON-NLS-1$
    "", // is Combo ?
    ComplexTableViewerColumn.COMBO_STYLE, // Combo Values
    inputVariables.toArray(new String[inputVariables.size()]), // Text Lines
    0), new // name
    ComplexTableViewerColumn(// name
    Messages.SetupTransformerInputVariablesDialog_ContentType, // is Nillable ?
    false, // Nill value//$NON-NLS-1$
    "", // Nill display//$NON-NLS-1$
    "", // Default Value//$NON-NLS-1$
    "text/xml", // is Combo ?
    ComplexTableViewerColumn.COMBO_STYLE, // Combo Values
    EContentType.allTypes().toArray(new String[EContentType.allTypes().size()]), // Text Lines
    0), new // name
    ComplexTableViewerColumn(// name
    Messages.SetupTransformerInputVariablesDialog_Value, // is Nillable ?
    true, // Nill value//$NON-NLS-1$
    "", // Nill display//$NON-NLS-1$
    "", // Default Value//$NON-NLS-1$
    "", // is Combo ?
    ComplexTableViewerColumn.TEXT_STYLE, // Combo Values
    null, // Text Lines
    10) };
    objectViewer = new ComplexTableViewerR(Arrays.asList(columns), toolkit, comp, page.getSite());
    objectViewer.create();
    Table table = objectViewer.getViewer().getTable();
    table.getColumns()[2].setWidth(500);
    // GridData gd=(GridData)objectViewer.getTxtLists().get(0).getLayoutData();
    // gd.minimumHeight=200;
    // gd.minimumWidth=300;
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    // ((GridData)table.getLayoutData()).minimumWidth = 600;
    if (page.getCacheList() != null) {
        objectViewer.getViewer().setInput(page.getCacheList());
    } else {
        List<Line> list = new ArrayList<Line>();
        objectViewer.getViewer().setInput(list);
    }
    final CCombo combo = (CCombo) objectViewer.getColumns().get(1).getControl();
    combo.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (combo.getText().equals(EInputTemplate.APPLICATION_ITEMPK.getName())) {
                Text t = (Text) objectViewer.getColumns().get(2).getControl();
                t.setText(EInputTemplate.APPLICATION_ITEMPK.getContent());
            }
        }
    });
    return comp;
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) ComplexTableViewerColumn(com.amalto.workbench.widgets.ComplexTableViewerColumn) ComplexTableViewerR(com.amalto.workbench.widgets.ComplexTableViewerR) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) Line(com.amalto.workbench.models.Line) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) WSTransformerVariablesMapping(com.amalto.workbench.webservices.WSTransformerVariablesMapping) GridData(org.eclipse.swt.layout.GridData) WSTransformerProcessStep(com.amalto.workbench.webservices.WSTransformerProcessStep) SelectionEvent(org.eclipse.swt.events.SelectionEvent) HashSet(java.util.HashSet) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with WSTransformerVariablesMapping

use of com.amalto.workbench.webservices.WSTransformerVariablesMapping in project tmdm-studio-se by Talend.

the class ProcessAllCallJobVariableCandidatesHolder method getExternalInfo.

@Override
public String[] getExternalInfo() {
    if (service == null) {
        return new String[0];
    }
    Set<String> inputVariables = new HashSet<String>();
    for (WSTransformerProcessStep step : service.getProcessSteps()) {
        for (WSTransformerVariablesMapping mapping : step.getInputMappings()) {
            inputVariables.add(mapping.getPipelineVariable() == null ? TransformerMainPage.DEFAULT_VAR : mapping.getPipelineVariable());
        }
    }
    String[] results = inputVariables.toArray(new String[0]);
    Arrays.sort(results);
    return results;
}
Also used : WSTransformerVariablesMapping(com.amalto.workbench.webservices.WSTransformerVariablesMapping) WSTransformerProcessStep(com.amalto.workbench.webservices.WSTransformerProcessStep) HashSet(java.util.HashSet)

Example 4 with WSTransformerVariablesMapping

use of com.amalto.workbench.webservices.WSTransformerVariablesMapping in project tmdm-studio-se by Talend.

the class TransformerMainPage method beforeDoSave.

@Override
public boolean beforeDoSave() {
    String processName = getXObject().getName();
    if (processName.startsWith("beforeSaving_")) {
        // $NON-NLS-1$
        boolean has = false;
        WSTransformerProcessStep processStep = stepWidget.getProcessStep();
        for (WSTransformerVariablesMapping map : processStep.getOutputMappings()) {
            if ("output_report".equals(map.getPipelineVariable())) {
                // $NON-NLS-1$
                has = true;
                break;
            }
        }
        if (!has) {
            MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.bind(Messages.TransformerMainPage_OutputReportMissing, processName));
        }
    }
    return super.beforeDoSave();
}
Also used : WSTransformerVariablesMapping(com.amalto.workbench.webservices.WSTransformerVariablesMapping) WSTransformerProcessStep(com.amalto.workbench.webservices.WSTransformerProcessStep)

Aggregations

WSTransformerVariablesMapping (com.amalto.workbench.webservices.WSTransformerVariablesMapping)4 WSTransformerProcessStep (com.amalto.workbench.webservices.WSTransformerProcessStep)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Line (com.amalto.workbench.models.Line)1 ComplexTableViewerColumn (com.amalto.workbench.widgets.ComplexTableViewerColumn)1 ComplexTableViewerR (com.amalto.workbench.widgets.ComplexTableViewerR)1 CCombo (org.eclipse.swt.custom.CCombo)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Group (org.eclipse.swt.widgets.Group)1 Table (org.eclipse.swt.widgets.Table)1 Text (org.eclipse.swt.widgets.Text)1 WSTransformerProcessStepE (org.talend.mdm.repository.model.mdmserverobject.WSTransformerProcessStepE)1 WSTransformerV2E (org.talend.mdm.repository.model.mdmserverobject.WSTransformerV2E)1 WSTransformerVariablesMappingE (org.talend.mdm.repository.model.mdmserverobject.WSTransformerVariablesMappingE)1 Execution (org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog.Execution)1 Parameter (org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog.Parameter)1