Search in sources :

Example 81 with ProcessType

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

the class SynchronizeSchemaOnlyForPerlDemoMigrationTask method execute.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
     * ProcessItem)
     */
@Override
public ExecutionResult execute(Item item) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        boolean modified = false;
        ECodeLanguage language = LanguageManager.getCurrentLanguage();
        if (language == ECodeLanguage.PERL) {
            Project project = ProjectManager.getInstance().getProject(item);
            if (project != null && project.getTechnicalLabel().equalsIgnoreCase("TALENDDEMOSPERL")) {
                //$NON-NLS-1$
                IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getProcessFromItem(item);
                modified = synchronizeSchema(process);
                if (modified) {
                    ProcessType processType = process.saveXmlFile();
                    if (item instanceof ProcessItem) {
                        ((ProcessItem) item).setProcess(processType);
                    } else if (item instanceof JobletProcessItem) {
                        ((JobletProcessItem) item).setJobletProcess((JobletProcess) processType);
                    }
                    factory.save(item, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Project(org.talend.core.model.properties.Project) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) JobletProcess(org.talend.designer.joblet.model.JobletProcess) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 82 with ProcessType

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

the class SetupProcessDependenciesRoutinesAction method doRun.

@Override
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (obj == null) {
        return;
    }
    RepositoryNode node = (RepositoryNode) obj;
    boolean readonly = false;
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    ERepositoryStatus status = repFactory.getStatus(node.getObject());
    if (!repFactory.isPotentiallyEditable(node.getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
        readonly = true;
    }
    Item item = node.getObject().getProperty().getItem();
    if (item instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) item;
        ProcessType process = processItem.getProcess();
        SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
        if (dialog.open() == Window.OK && !readonly) {
            process.getParameters().getRoutinesParameter().clear();
            createRoutinesDependencies(process, dialog.getSystemRoutines());
            createRoutinesDependencies(process, dialog.getUserRoutines());
            try {
                CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(processItem);
                RelationshipItemBuilder.getInstance().addOrUpdateItem(processItem);
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
    } else if (item instanceof JobletProcessItem) {
        JobletProcessItem jobProcessItem = (JobletProcessItem) item;
        ProcessType process = jobProcessItem.getJobletProcess();
        SetupProcessDependenciesRoutinesDialog dialog = new SetupProcessDependenciesRoutinesDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), process, readonly);
        if (dialog.open() == Window.OK && !readonly) {
            process.getParameters().getRoutinesParameter().clear();
            createRoutinesDependencies(process, dialog.getSystemRoutines());
            createRoutinesDependencies(process, dialog.getUserRoutines());
            try {
                CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(jobProcessItem);
                IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                if (jobletService != null) {
                    jobletService.loadComponentsFromProviders();
                }
                RelationshipItemBuilder.getInstance().addOrUpdateItem(jobProcessItem);
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryService(org.talend.repository.model.IRepositoryService) IJobletProviderService(org.talend.core.ui.IJobletProviderService) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) SetupProcessDependenciesRoutinesDialog(org.talend.designer.core.ui.routine.SetupProcessDependenciesRoutinesDialog) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ISelection(org.eclipse.jface.viewers.ISelection) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 83 with ProcessType

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

the class UpgradeParameterHelper method upgradeItem.

/**
     * 
     * ggu Comment method "upgradeItem".
     * 
     * upgrade the item parameters.
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
public static boolean upgradeItem(Item item) {
    if (item == null) {
        return false;
    }
    boolean changed = false;
    if (item instanceof ProcessItem) {
        // job
        ProcessType process = ((ProcessItem) item).getProcess();
        if (process != null) {
            ParametersType parameters = process.getParameters();
            if (parameters != null) {
                changed = upgradeMainParameters(parameters.getElementParameter());
            }
            changed = changed | upgradeNodes(process.getNode());
        }
    } else if (item instanceof JobletProcessItem) {
        // Joblet
        JobletProcess jobletProcess = ((JobletProcessItem) item).getJobletProcess();
        if (jobletProcess != null) {
            ParametersType parameters = jobletProcess.getParameters();
            if (parameters != null) {
                changed = upgradeMainParameters(parameters.getElementParameter());
            }
            changed = changed | upgradeNodes(jobletProcess.getNode());
        }
    }
    return changed;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) JobletProcess(org.talend.designer.joblet.model.JobletProcess)

Example 84 with ProcessType

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

the class TXMLMapChangeAllInOneValueMigrationTask method execute.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
	 * (org .talend.core.model.properties.Item)
	 */
@Override
public ExecutionResult execute(Item item) {
    IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    ProcessType processType = getProcessType(item);
    boolean modified = false;
    if (processType != null) {
        for (Object obj : processType.getNode()) {
            NodeType nodeType = (NodeType) obj;
            if (nodeType.getComponentName().startsWith("tXMLMap")) {
                XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
                EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
                EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
                boolean hasDocumentInTheMainInputTable = false;
                for (InputXmlTree inputTable : inputTables) {
                    if (!(inputTable.isLookup())) {
                        for (TreeNode inputEntry : inputTable.getNodes()) {
                            if ("id_Document".equals(inputEntry.getType())) {
                                hasDocumentInTheMainInputTable = true;
                            }
                        }
                    }
                }
                if (hasDocumentInTheMainInputTable) {
                    for (OutputXmlTree outputTable : outputTables) {
                        for (TreeNode outputEntry : outputTable.getNodes()) {
                            if ("id_Document".equals(outputEntry.getType())) {
                                if (!outputTable.isAllInOne()) {
                                    outputTable.setAllInOne(true);
                                    modified = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    try {
        if (modified) {
            factory.save(item, true);
            return ExecutionResult.SUCCESS_WITH_ALERT;
        } else {
            return ExecutionResult.SUCCESS_NO_ALERT;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 85 with ProcessType

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

the class AddPortForTCassandraConfigurationSpark method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    final ProcessType processType = getProcessType(item);
    //$NON-NLS-1$ 
    String[] compNames = { "tCassandraConfiguration" };
    IComponentConversion conversion = new IComponentConversion() {

        @Override
        public void transform(NodeType node) {
            if (node == null) {
                return;
            }
            //$NON-NLS-1$
            ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "PORT");
            List<Object> needRemovedList = new ArrayList<Object>();
            if (parameter == null) {
                // get the value of native port if the user defined it on the configuration table
                String portValue = null;
                //$NON-NLS-1$
                ElementParameterType configTable = ComponentUtilities.getNodeProperty(node, "CASSANDRA_CONFIGURATION");
                boolean findNative = false;
                boolean findRpc = false;
                for (Object e : configTable.getElementValue()) {
                    ElementValueTypeImpl el = (ElementValueTypeImpl) e;
                    if (findNative && "VALUE".equals(el.getElementRef())) {
                        //$NON-NLS-1$
                        portValue = el.getValue();
                        needRemovedList.add(e);
                        findNative = false;
                    }
                    if (findRpc && "VALUE".equals(el.getElementRef())) {
                        //$NON-NLS-1$
                        needRemovedList.add(e);
                        findRpc = false;
                    }
                    if ("KEY".equals(el.getElementRef())) {
                        //$NON-NLS-1$
                        if ("connection_native_port".equals(el.getValue())) {
                            //$NON-NLS-1$
                            findNative = true;
                            needRemovedList.add(e);
                        }
                        if ("connection_rpc_port".equals(el.getValue())) {
                            //$NON-NLS-1$
                            findRpc = true;
                            needRemovedList.add(e);
                        }
                    }
                }
                configTable.getElementValue().removeAll(needRemovedList);
                //$NON-NLS-1$ //$NON-NLS-2$
                ComponentUtilities.addNodeProperty(node, "PORT", "TEXT");
                //$NON-NLS-1$ //$NON-NLS-2$ 
                ComponentUtilities.setNodeValue(node, "PORT", portValue == null ? "\"9042\"" : portValue);
            }
        }
    };
    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 : IComponentFilter(org.talend.core.model.components.filters.IComponentFilter) ArrayList(java.util.ArrayList) NameComponentFilter(org.talend.core.model.components.filters.NameComponentFilter) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ElementValueTypeImpl(org.talend.designer.core.model.utils.emf.talendfile.impl.ElementValueTypeImpl) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException) IComponentConversion(org.talend.core.model.components.conversions.IComponentConversion)

Aggregations

ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)244 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)157 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)155 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)153 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)145 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)115 PersistenceException (org.talend.commons.exception.PersistenceException)109 ProcessItem (org.talend.core.model.properties.ProcessItem)29 ArrayList (java.util.ArrayList)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 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)12 HashMap (java.util.HashMap)10 IComponent (org.talend.core.model.components.IComponent)10