Search in sources :

Example 36 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class DataSourceConfig method getDatasourceAliasFrom.

@Deprecated
private static String getDatasourceAliasFrom(INode node) {
    if (!node.isActivate()) {
        return null;
    }
    //$NON-NLS-1$
    IElementParameter isSpecifyAlias = node.getElementParameter("SPECIFY_DATASOURCE_ALIAS");
    if (isSpecifyAlias == null || Boolean.FALSE.equals(isSpecifyAlias.getValue())) {
        return null;
    }
    //$NON-NLS-1$
    IElementParameter aliasParam = node.getElementParameter("DATASOURCE_ALIAS");
    if (aliasParam == null) {
        return null;
    }
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    boolean evaluate = designerCoreService.evaluate(isSpecifyAlias.getShowIf(), node.getElementParameters());
    if (!evaluate) {
        return null;
    }
    String result = aliasParam.getValue() == null ? null : aliasParam.getValue().toString();
    return TalendQuoteUtils.removeQuotes(result.trim());
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService)

Example 37 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class JobScriptsManager method getCommandByTalendJob.

protected String getCommandByTalendJob(String targetPlatform, ProcessItem processItem, String context, boolean needContext, int statisticPort, int tracePort, String... codeOptions) {
    String[] cmd = new String[] {};
    try {
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        IProcess currentProcess = service.getProcessFromProcessItem(processItem);
        cmd = ProcessorUtilities.getCommandLine(true, targetPlatform, true, currentProcess, processItem.getProperty(), context, needContext, statisticPort, tracePort, codeOptions);
    } catch (ProcessorException e) {
        ExceptionHandler.process(e);
    }
    return ProcessorUtilities.generateCmdByTalendJob(cmd);
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess)

Example 38 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class DataSourceConfig method getDatasourceAliasesFrom.

// TESB-17238:Include sub jobs datasource alias
private static void getDatasourceAliasesFrom(INode node, Collection<String> ds) {
    if (!node.isActivate()) {
        return;
    }
    if (TRUN_JOB.equals(node.getComponent().getName())) {
        List<? extends INode> subNodes = getSubProcessNodesFromTRunjob(node);
        if (subNodes != null) {
            for (INode n : subNodes) {
                getDatasourceAliasesFrom(n, ds);
            }
        }
    }
    //$NON-NLS-1$
    IElementParameter isSpecifyAlias = node.getElementParameter("SPECIFY_DATASOURCE_ALIAS");
    if (isSpecifyAlias == null || Boolean.FALSE.equals(isSpecifyAlias.getValue())) {
        return;
    }
    //$NON-NLS-1$
    IElementParameter aliasParam = node.getElementParameter("DATASOURCE_ALIAS");
    if (aliasParam == null) {
        return;
    }
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    boolean evaluate = designerCoreService.evaluate(isSpecifyAlias.getShowIf(), node.getElementParameters());
    if (!evaluate) {
        return;
    }
    String result = aliasParam.getValue() == null ? null : aliasParam.getValue().toString();
    ds.add(TalendQuoteUtils.removeQuotes(result.trim()));
}
Also used : INode(org.talend.core.model.process.INode) IElementParameter(org.talend.core.model.process.IElementParameter) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService)

Example 39 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tdi-studio-se by Talend.

the class DataSourceConfig method getSubProcessNodesFromTRunjob.

private static List<? extends INode> getSubProcessNodesFromTRunjob(INode tRunJobNode) {
    //$NON-NLS-1$
    String processId = (String) tRunJobNode.getElementParameter("PROCESS:PROCESS_TYPE_PROCESS").getValue();
    if (processId != null && !"".equals(processId)) {
        //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(processId);
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        if (processItem != null && service != null) {
            return service.getProcessFromItem(processItem).getGeneratingNodes();
        }
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService)

Example 40 with IDesignerCoreService

use of org.talend.designer.core.IDesignerCoreService in project tesb-studio-se by Talend.

the class AssignJobAction method changeOldJob.

public void changeOldJob() {
    String operationName = repositoryNode.getObject().getLabel();
    String portName = repositoryNode.getParent().getObject().getLabel();
    ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
    List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    String oldJobID = null;
    for (ServicePort port : listPort) {
        if (port.getName().equals(portName)) {
            List<ServiceOperation> listOperation = port.getServiceOperation();
            for (ServiceOperation operation : listOperation) {
                if (operation.getLabel().equals(operationName)) {
                    oldJobID = operation.getReferenceJobId();
                    break;
                }
            }
            break;
        }
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        if (oldJobID != null) {
            IRepositoryViewObject object = factory.getLastVersion(oldJobID);
            Item item = object.getProperty().getItem();
            ProcessItem processItem = (ProcessItem) item;
            //
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            IProcess2 process = null;
            IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
            List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
            for (IProcess2 processOpen : processes) {
                if (processOpen.getProperty().getItem() == processItem) {
                    process = processOpen;
                    break;
                }
            }
            if (process == null) {
                IProcess proc = service.getProcessFromProcessItem(processItem);
                if (proc instanceof IProcess2) {
                    process = (IProcess2) proc;
                }
            }
            if (process != null) {
                List<? extends INode> nodelist = process.getGraphicalNodes();
                for (INode node : nodelist) {
                    if (node.getComponent().getName().equals("tESBProviderRequest")) {
                        repositoryChangeToBuildIn(repositoryNode, node);
                    }
                }
                processItem.setProcess(process.saveXmlFile());
                factory.save(processItem);
            }
        }
    } catch (PersistenceException | IOException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) INode(org.talend.core.model.process.INode) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IOException(java.io.IOException) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)40 IProcess (org.talend.core.model.process.IProcess)25 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Item (org.talend.core.model.properties.Item)13 ArrayList (java.util.ArrayList)12 INode (org.talend.core.model.process.INode)12 PersistenceException (org.talend.commons.exception.PersistenceException)10 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 IOException (java.io.IOException)8 List (java.util.List)8 IProcess2 (org.talend.core.model.process.IProcess2)7 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IFile (org.eclipse.core.resources.IFile)6 IElementParameter (org.talend.core.model.process.IElementParameter)6 Process (org.talend.designer.core.ui.editor.process.Process)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 IEditorReference (org.eclipse.ui.IEditorReference)5 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)5 File (java.io.File)4