Search in sources :

Example 71 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class QueryGuessCommand method generateNewQueryFromDQRuler.

private String generateNewQueryFromDQRuler(IElementParameter dqRulerParam) {
    ITDQRuleService rulerService = null;
    try {
        rulerService = (ITDQRuleService) GlobalServiceRegister.getDefault().getService(ITDQRuleService.class);
    } catch (RuntimeException e) {
    // nothing to do
    }
    if (rulerService != null) {
        //$NON-NLS-1$
        IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
        boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
        INode connectionNode = null;
        if (node != null && node instanceof INode) {
            process = ((INode) node).getProcess();
        }
        if (useExistConnection && process != null) {
            IElementParameter connector = node.getElementParameter("CONNECTION");
            if (connector != null) {
                String connectorValue = connector.getValue().toString();
                List<? extends INode> graphicalNodes = process.getGeneratingNodes();
                for (INode node : graphicalNodes) {
                    if (node.getUniqueName().equals(connectorValue)) {
                        connectionNode = node;
                        break;
                    }
                }
            }
        }
        //$NON-NLS-1$
        IElementParameter typeParam = node.getElementParameter("TYPE");
        IElementParameter dbParam = node.getElementParameter(EParameterName.DBNAME.getName());
        IContext lastRunContext = ((IProcess2) process).getLastRunContext();
        String dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
        IElementParameter schemaParam = node.getElementParameter(EParameterName.SCHEMA_DB.getName());
        String schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
        IElementParameter tableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
        String tableName = JavaProcessUtil.getRealParamValue(process, tableParam.getValue().toString(), lastRunContext);
        //$NON-NLS-1$
        IElementParameter whereClause = node.getElementParameter("WHERE_CLAUSE");
        String whereStr = org.apache.commons.lang.StringUtils.EMPTY;
        if (whereClause.getValue() != null) {
            whereStr = JavaProcessUtil.getRealParamValue(process, whereClause.getValue().toString(), lastRunContext);
        }
        if (connectionNode != null) {
            //$NON-NLS-1$
            typeParam = connectionNode.getElementParameter("TYPE");
            dbParam = connectionNode.getElementParameter(EParameterName.DBNAME.getName());
            dbName = JavaProcessUtil.getRealParamValue(process, dbParam.getValue().toString(), lastRunContext);
            schemaParam = connectionNode.getElementParameter(EParameterName.SCHEMA_DB.getName());
            schemaName = JavaProcessUtil.getRealParamValue(process, schemaParam == null ? org.apache.commons.lang.StringUtils.EMPTY : schemaParam.getValue().toString(), lastRunContext);
        }
        List<IMetadataTable> metadataList = null;
        IMetadataTable metadataTable = null;
        if (node instanceof Node) {
            metadataList = ((Node) node).getMetadataList();
            if (metadataList != null && !metadataList.isEmpty()) {
                metadataTable = metadataList.get(0);
            }
        }
        return rulerService.getQueryByRule(dqRulerParam, typeParam, dbName, schemaName, tableName, metadataTable, node.getElementName().contains("Invalid"), //$NON-NLS-1$
        whereStr);
    }
    return org.apache.commons.lang.StringUtils.EMPTY;
}
Also used : INode(org.talend.core.model.process.INode) IContext(org.talend.core.model.process.IContext) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQRuleService(org.talend.core.ITDQRuleService)

Example 72 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationUtil method addComponentCreationAssist.

public static void addComponentCreationAssist(AbstractTalendEditor talendEditor) {
    final GraphicalViewer graphicalViewer = (GraphicalViewer) talendEditor.getAdapter(GraphicalViewer.class);
    final CommandStack commandStack = (CommandStack) talendEditor.getAdapter(CommandStack.class);
    final String categoryName = talendEditor.getComponenentsHandler().extractComponentsCategory().getName();
    final IProcess2 process = talendEditor.getProcess();
    KeyListener listener = new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (Character.isISOControl(e.character) || Character.isSpaceChar(e.character)) {
                return;
            }
            TalendEditorComponentCreationAssist assist = new TalendEditorComponentCreationAssist(categoryName, graphicalViewer, commandStack, process);
            assist.showComponentCreationAssist(e.character);
        }
    };
    graphicalViewer.getControl().addKeyListener(listener);
    graphicalViewer.getControl().setData(COMPONENT_CREATION_ASSIST_LISTENER, listener);
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IProcess2(org.talend.core.model.process.IProcess2) KeyListener(org.eclipse.swt.events.KeyListener)

Example 73 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class JobLaunchConfigurationDelegate method findProcessFromRepository.

/**
     * DOC bqian Comment method "findProcessFromRepository".
     * 
     * @param jobName
     * @return
     */
private IProcess2 findProcessFromRepository(String jobId, String version) {
    try {
        ItemCacheManager.clearCache();
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, version);
        if (processItem != null) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                IProcess process = service.getProcessFromItem(processItem);
                if (process instanceof IProcess2) {
                    return (IProcess2) process;
                }
            }
            // keep old code for now, but it should never be called.
            ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, true, true);
            IProcess2 process = fileEditorInput.getLoadedProcess();
            return process;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 74 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class MissingSettingsMultiThreadDynamicComposite method afterChangingLibraries.

@Override
public void afterChangingLibraries() {
    final Element ele = this.getElement();
    if (ele instanceof Node) {
        final Node node = (Node) ele;
        // after install, need update the error marks for node
        IProcess process = node.getProcess();
        if (process instanceof IProcess2) {
            // check whole process to make sure other related nodes can be updated also.
            ((IProcess2) process).checkProcess();
        }
    }
}
Also used : Element(org.talend.core.model.process.Element) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2) IProcess(org.talend.core.model.process.IProcess)

Example 75 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method doSave.

/**
     * Saves the multi-page editor's document.
     */
@Override
public void doSave(final IProgressMonitor monitor) {
    Item curItem = getProcess().getProperty().getItem();
    IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    try {
        // For TDI-23825, if not lock by user try to lock again.
        if (!getProcess().isReadOnly()) {
            repFactory.lock(curItem);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    if (getProcess().isReadOnly() || repFactory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.readonly"), Messages.getString("AbstractMultiPageTalendEditor.readonlyMessage"));
        return;
    }
    ERepositoryStatus status = repFactory.getStatus(curItem);
    if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
        MessageDialog.openWarning(getEditor(0).getEditorSite().getShell(), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveTitle"), Messages.getString("AbstractMultiPageTalendEditor.canNotSaveMessage"));
        return;
    }
    if (!isDirty()) {
        return;
    }
    Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
    changeCollapsedState(true, jobletMap);
    updateRunJobContext();
    designerEditor.getProcess().getProperty().eAdapters().remove(dirtyListener);
    repFactory.addRepositoryWorkUnitListener(repositoryWorkListener);
    if (jobletEditor == getActiveEditor()) {
        boolean isDirty = jobletEditor.isDirty();
        refreshPropertyDirtyStatus();
        jobletEditor.doSave(monitor);
        try {
            IProcess2 oldProcess = getProcess();
            ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
            ProcessType processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
            IProcess2 newProcess = null;
            Item item = getProcess().getProperty().getItem();
            if (item instanceof ProcessItem) {
                ((Process) designerEditor.getProcess()).updateProcess(processType);
                if (isDirty) {
                    getProcess().setProcessModified(true);
                    getProcess().setNeedRegenerateCode(true);
                }
            } else if (item instanceof JobletProcessItem) {
                AbstractProcessProvider processProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
                if (processProvider != null) {
                    newProcess = processProvider.buildNewGraphicProcess(item);
                }
                designerEditor.setProcess(newProcess);
                Boolean lastVersion = null;
                if (oldProcess instanceof ILastVersionChecker) {
                    lastVersion = ((ILastVersionChecker) oldProcess).isLastVersion(item);
                }
                if (designerEditor.getEditorInput() instanceof JobEditorInput) {
                    ((JobEditorInput) designerEditor.getEditorInput()).checkInit(lastVersion, null, true);
                }
            }
            getEditor(0).doSave(monitor);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    } else {
        refreshPropertyDirtyStatus();
        getEditor(0).doSave(monitor);
    }
    /*
         * refresh should be executed before add the listener,or it will has eProxy on the property,it will cause a
         * editor dirty problem. hywang commet bug 17357
         */
    if (processEditorInput != null) {
        propertyInformation = new ArrayList(processEditorInput.getItem().getProperty().getInformations());
        propertyIsDirty = false;
    }
    if (designerEditor != null && dirtyListener != null) {
        designerEditor.getProcess().getProperty().eAdapters().add(dirtyListener);
    }
    refreshJobSettingsView();
    changeCollapsedState(false, jobletMap);
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
        ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
        if (testContainerService != null) {
            testContainerService.updateDetect(getProcess(), false);
        }
    }
    if (isCheckout) {
        CommandStack stack = (CommandStack) getAdapter(CommandStack.class);
        stack.flush();
        isCheckout = false;
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) Process(org.talend.designer.core.ui.editor.process.Process) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) IRepositoryService(org.talend.repository.model.IRepositoryService) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ILastVersionChecker(org.talend.core.ui.ILastVersionChecker) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CommandStack(org.eclipse.gef.commands.CommandStack) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ProcessorException(org.talend.designer.runprocess.ProcessorException) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IResource(org.eclipse.core.resources.IResource)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7