Search in sources :

Example 16 with ProcessType

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

the class ChangeDefaultValueTDIBug21708 method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    try {
        boolean modified = false;
        for (Object o : processType.getNode()) {
            NodeType node = (NodeType) o;
            if (ComponentUtilities.getNodeProperty(node, "PARALLELIZE") != null) {
                if (ComponentUtilities.getNodeProperty(node, "PARALLELIZE_KEEP_EMPTY") == null) {
                    ComponentUtilities.addNodeProperty(node, "PARALLELIZE_KEEP_EMPTY", "CHECK");
                    ComponentUtilities.getNodeProperty(node, "PARALLELIZE_KEEP_EMPTY").setValue("true");
                    modified = true;
                }
            }
        }
        if (modified) {
            ProxyRepositoryFactory.getInstance().save(item, true);
            return ExecutionResult.SUCCESS_NO_ALERT;
        } else {
            return ExecutionResult.NOTHING_TO_DO;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 17 with ProcessType

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

the class ChangeDefaultEncodingMigrationTask method AddExecuteMode.

@SuppressWarnings("cast")
private void AddExecuteMode(Item item) throws Exception {
    ProcessType processType = getProcessType(item);
    java.util.List<IComponentFilter> filters = new java.util.ArrayList<IComponentFilter>();
    //$NON-NLS-1$
    filters.add(new NameComponentFilter("tSybaseBulkExec"));
    //$NON-NLS-1$
    filters.add(new NameComponentFilter("tSybaseOutputBulkExec"));
    //$NON-NLS-1$
    filters.add(new NameComponentFilter("tOracleBulkExec"));
    //$NON-NLS-1$
    filters.add(new NameComponentFilter("tOracleOutputBulkExec"));
    //$NON-NLS-1$
    IComponentConversion addOption = new AddExecuteMode();
    java.util.Iterator<IComponentFilter> iter = filters.iterator();
    while (iter.hasNext()) {
        IComponentFilter filter = (IComponentFilter) iter.next();
        ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(addOption));
    }
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Example 18 with ProcessType

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

the class ChangeDefaultValue4JSONComponents method execute.

@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    String[] compNames = { "tFileInputJSON", "tExtractJSONFields", "tExtractAbstractJSONFields", "tFileInputJSON", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    "tInputFormatJSON" };
    IComponentConversion conversion = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "READ_BY");
            if (parameter == null) {
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "READ_BY", "CLOSED_LIST");
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.setNodeValue(node, "READ_BY", "XPATH");
            }
        }
    };
    for (String name : compNames) {
        IComponentFilter filter = new NameComponentFilter(name);
        try {
            ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
        } catch (PersistenceException e) {
            // TODO Auto-generated catch block
            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) 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)

Example 19 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType 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 20 with ProcessType

use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType 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)

Aggregations

ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)237 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)154 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)152 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)151 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)143 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)114 PersistenceException (org.talend.commons.exception.PersistenceException)107 ArrayList (java.util.ArrayList)24 ProcessItem (org.talend.core.model.properties.ProcessItem)24 EList (org.eclipse.emf.common.util.EList)23 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)22 List (java.util.List)18 ElementValueType (org.talend.designer.core.model.utils.emf.talendfile.ElementValueType)16 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 RenameComponentConversion (org.talend.core.model.components.conversions.RenameComponentConversion)12 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)10 MetadataType (org.talend.designer.core.model.utils.emf.talendfile.MetadataType)10 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)10