Search in sources :

Example 76 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class ChangeDefaultValue4tLogRow method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    IComponentFilter filter = new NameComponentFilter("tLogRow");
    try {
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

            public void transform(NodeType node) {
                ElementParameterType printContent = ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J");
                if (printContent == null) {
                    ComponentUtilities.addNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J", "CHECK");
                    ComponentUtilities.getNodeProperty(node, "PRINT_CONTENT_WITH_LOG4J").setValue("false");
                }
            }
        }));
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.SUCCESS_NO_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 77 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class ResetVMArgumentMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    ParametersType parameters = processType.getParameters();
    if (parameters == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        EList listParamType = parameters.getElementParameter();
        for (int j = 0; j < listParamType.size(); j++) {
            ElementParameterType pType = (ElementParameterType) listParamType.get(j);
            if (pType.getName().equals("JOB_RUN_VM_ARGUMENTS")) {
                //$NON-NLS-1$
                String value = pType.getValue().trim();
                if (value != null && value.length() > 0 && !isJson(value)) {
                    try {
                        JSONObject root = new JSONObject();
                        JSONArray args = new JSONArray();
                        //$NON-NLS-1$
                        String[] vms = value.split(" ");
                        for (String vm : vms) {
                            args.put(vm);
                        }
                        //$NON-NLS-1$
                        root.put("JOB_RUN_VM_ARGUMENTS", args);
                        pType.setValue(root.toString());
                        factory.save(item, true);
                        break;
                    } catch (JSONException e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) JSONObject(us.monoid.json.JSONObject) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) JSONException(us.monoid.json.JSONException)

Example 78 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class ReviewPigLoadLayout method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType != null) {
        try {
            //$NON-NLS-1$
            IComponentFilter filter = new NameComponentFilter("tPigLoad");
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {

                @Override
                public void transform(NodeType node) {
                    //$NON-NLS-1$
                    ElementParameterType mr = ComponentUtilities.getNodeProperty(node, "MAPREDUCE");
                    //$NON-NLS-1$
                    ElementParameterType tez = ComponentUtilities.getNodeProperty(node, "TEZ");
                    //$NON-NLS-1$ //$NON-NLS-2$
                    ComponentUtilities.addNodeProperty(node, "ENGINE", "CLOSED_LIST");
                    if ("true".equalsIgnoreCase(mr.getValue())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("MAPREDUCE");
                    } else if ("true".equalsIgnoreCase(tez.getValue())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$ //$NON-NLS-2$
                        ComponentUtilities.getNodeProperty(node, "ENGINE").setValue("TEZ");
                    }
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "MAPREDUCE");
                    //$NON-NLS-1$
                    ComponentUtilities.removeNodeProperty(node, "TEZ");
                }
            }));
            return ExecutionResult.SUCCESS_NO_ALERT;
        } catch (Exception e) {
            CommonExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 79 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class ReplaceMultiFlowBytReplicateMigrationTask method createNodeType.

/**
     * DOC nrousseau Comment method "createNodeType".
     * 
     * @param processType
     * @param replicatePos
     * @param nodeTypeSource
     * @param sourceName
     * @param nodeConnector
     * @param connections
     * @param fileFact
     * @return
     */
private String createNodeType(ProcessType processType, Point replicatePos, NodeType nodeTypeSource, String sourceName, INodeConnector nodeConnector, List<ConnectionType> connections, TalendFileFactory fileFact) {
    NodeType nodeType = fileFact.createNodeType();
    //$NON-NLS-1$
    String uniqueName = ComponentUtilities.generateUniqueNodeName("tReplicate", processType);
    ElementParameterType elemParam = fileFact.createElementParameterType();
    //$NON-NLS-1$
    elemParam.setField("TEXT");
    //$NON-NLS-1$
    elemParam.setName("UNIQUE_NAME");
    elemParam.setValue(uniqueName);
    nodeType.getElementParameter().add(elemParam);
    ComponentUtilities.setNodeUniqueName(nodeType, uniqueName);
    //$NON-NLS-1$
    nodeType.setComponentName("tReplicate");
    for (ConnectionType connectionType : connections) {
        //$NON-NLS-1$
        connectionType.setConnectorName("FLOW");
        connectionType.setSource(uniqueName);
        connectionType.setMetaname(uniqueName);
    }
    nodeType.setPosX(replicatePos.x);
    nodeType.setPosY(replicatePos.y);
    nodeType.setSizeX(GRID_SIZE);
    nodeType.setSizeY(GRID_SIZE);
    if (nodeTypeSource.getMetadata().size() != 0) {
        MetadataType metadataTypeSource = null;
        for (Object oMetadataType : nodeTypeSource.getMetadata()) {
            MetadataType metadataType = (MetadataType) oMetadataType;
            if ((metadataType.getConnector() != null && metadataType.getConnector().equals(nodeConnector.getName())) || metadataType.getName().equals(sourceName)) {
                metadataTypeSource = metadataType;
            }
        }
        if (metadataTypeSource != null) {
            MetadataType newMetadataType = fileFact.createMetadataType();
            newMetadataType.setComment(metadataTypeSource.getComment());
            //$NON-NLS-1$
            newMetadataType.setConnector("FLOW");
            newMetadataType.setName(uniqueName);
            for (Object oColumn : metadataTypeSource.getColumn()) {
                ColumnType columnType = (ColumnType) oColumn;
                ColumnType newColumnType = fileFact.createColumnType();
                newColumnType.setComment(columnType.getComment());
                newColumnType.setDefaultValue(columnType.getDefaultValue());
                if (columnType.isSetKey()) {
                    newColumnType.setKey(columnType.isKey());
                }
                if (columnType.isSetLength()) {
                    newColumnType.setLength(columnType.getLength());
                }
                newColumnType.setName(columnType.getName());
                if (columnType.isSetNullable()) {
                    newColumnType.setNullable(columnType.isNullable());
                }
                newColumnType.setOriginalDbColumnName(columnType.getOriginalDbColumnName());
                newColumnType.setPattern(columnType.getPattern());
                if (columnType.isSetPrecision()) {
                    newColumnType.setPrecision(columnType.getPrecision());
                }
                newColumnType.setSourceType(columnType.getSourceType());
                newColumnType.setType(columnType.getType());
                newMetadataType.getColumn().add(newColumnType);
            }
            nodeType.getMetadata().add(newMetadataType);
        }
    }
    processType.getNode().add(nodeType);
    return uniqueName;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ColumnType(org.talend.designer.core.model.utils.emf.talendfile.ColumnType) ConnectionType(org.talend.designer.core.model.utils.emf.talendfile.ConnectionType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) MetadataType(org.talend.designer.core.model.utils.emf.talendfile.MetadataType)

Example 80 with ElementParameterType

use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.

the class SetUrltStewardshipXXXTDI32354 method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    String[] componentsName = new String[] { "tStewardshipTaskInput", "tStewardshipTaskOutput", "tStewardshipTaskDelete" };
    IComponentConversion changeDeletEmptyFileValue = new IComponentConversion() {

        public void transform(NodeType node) {
            ElementParameterType host = ComponentUtilities.getNodeProperty(node, "HOST");
            ElementParameterType port = ComponentUtilities.getNodeProperty(node, "PORT");
            String url = "";
            if (host != null && port != null) {
                if ("tStewardshipTaskOutput".equals(node.getComponentName())) {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/dsctaskloader\"";
                } else {
                    url = "\"http://\" + " + host.getValue() + " + \":\" + " + port.getValue() + " + \"/talendmdm/services/TDSCWS?wsdl\"";
                }
            }
            ElementParameterType serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
            if (serverVersion == null) {
                ComponentUtilities.addNodeProperty(node, "URL", "TEXT");
                serverVersion = ComponentUtilities.getNodeProperty(node, "URL");
                serverVersion.setValue(url);
            }
        }
    };
    for (String name : componentsName) {
        //$NON-NLS-1$
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDeletEmptyFileValue));
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.SUCCESS_WITH_ALERT;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) PersistenceException(org.talend.commons.exception.PersistenceException) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)197 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)126 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)114 PersistenceException (org.talend.commons.exception.PersistenceException)86 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)85 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)83 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)83 EList (org.eclipse.emf.common.util.EList)40 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)28 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)25 List (java.util.List)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 ArrayList (java.util.ArrayList)16 ProcessItem (org.talend.core.model.properties.ProcessItem)16 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)15 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)13 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)9 HashMap (java.util.HashMap)7 IOException (java.io.IOException)6 IElementParameter (org.talend.core.model.process.IElementParameter)6