Search in sources :

Example 86 with IProcess

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

the class ShadowProcess method run.

public CsvArray run() throws ProcessorException {
    IProcess talendProcess = buildProcess();
    IProcessor processor = ProcessorUtilities.getProcessor(talendProcess, null);
    processor.setProxyParameters(getProxyParameters());
    // try {
    // Delete previous Perl generated file
    File previousFile = outPath.toFile();
    if (previousFile.exists()) {
        previousFile.delete();
    }
    // Process ps = processor.run(process.getContextManager().getDefaultContext(), Processor.NO_STATISTICS,
    // Processor.NO_TRACES,Processor.WATCH_ALLOWED);//Old
    IContext context = talendProcess.getContextManager().getDefaultContext();
    processor.setContext(context);
    process = processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
    ProcessStreamTrashReader.readAndForget(process);
    if (!outPath.toFile().exists()) {
        //$NON-NLS-1$
        throw new ProcessorException(Messages.getString("ShadowProcess.notGeneratedOutputException"));
    }
    try {
        CsvArray array = new CsvArray();
        array = array.createFrom(outPath.toFile(), currentProcessEncoding);
        return array;
    } catch (IOException ioe) {
        throw new ProcessorException(ioe);
    }
}
Also used : IContext(org.talend.core.model.process.IContext) ProcessorException(org.talend.designer.runprocess.ProcessorException) CsvArray(org.talend.core.utils.CsvArray) IProcessor(org.talend.designer.runprocess.IProcessor) IOException(java.io.IOException) IProcess(org.talend.core.model.process.IProcess) File(java.io.File)

Example 87 with IProcess

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

the class MapperManager method removeSelectedAliasInputTable.

public void removeSelectedAliasInputTable() {
    InputDataMapTableView currentSelectedDataMapTableView = uiManager.getCurrentSelectedInputTableView();
    if (currentSelectedDataMapTableView != null) {
        String tableName = currentSelectedDataMapTableView.getDataMapTable().getName();
        if (MessageDialog.openConfirm(currentSelectedDataMapTableView.getShell(), //$NON-NLS-1$
        Messages.getString("MapperManager.removeInputTableTitle"), Messages.getString("MapperManager.removeInputTableTitleMessage", new Object[] { tableName }))) {
            //$NON-NLS-1$
            IProcess process = mapperComponent.getProcess();
            uiManager.removeInputTableView(currentSelectedDataMapTableView);
            uiManager.updateToolbarButtonsStates(Zone.INPUTS);
            process.removeUniqueConnectionName(currentSelectedDataMapTableView.getDataMapTable().getName());
            uiManager.refreshSqlExpression();
        }
    }
}
Also used : InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) IProcess(org.talend.core.model.process.IProcess)

Example 88 with IProcess

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

the class GEFDeleteAction method createDeleteCommand.

@Override
public Command createDeleteCommand(List objects) {
    objects = filterSameObject(objectsToDelete);
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    EditPart object = (EditPart) objects.get(0);
    // for TUP-1015
    boolean isConnAttachedJLTriggerComp = false;
    ConnectionPart connectionPart = null;
    if (object instanceof ConnectionPart) {
        connectionPart = (ConnectionPart) object;
    } else if (object instanceof ConnLabelEditPart) {
        connectionPart = (ConnectionPart) object.getParent();
    }
    if (connectionPart != null) {
        Node srcNode = null;
        Object srcModel = connectionPart.getSource().getModel();
        if (srcModel instanceof Node) {
            srcNode = (Node) srcModel;
        }
        Node tarNode = null;
        Object tarModel = connectionPart.getTarget().getModel();
        if (tarModel instanceof Node) {
            tarNode = (Node) tarModel;
        }
        if (srcNode == null || tarNode == null) {
            return null;
        }
        IProcess process = srcNode.getProcess();
        if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
            IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
            if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
                isConnAttachedJLTriggerComp = true;
            }
        }
    }
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
    if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
        MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
        null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
        IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
        jlTriggerConfirmDialog.setPrefStore(preferenceStore);
        jlTriggerConfirmDialog.setPrefKey(preKey);
        if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
            return null;
        }
        preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
    }
    List nodeParts = new ArrayList();
    List noteParts = new ArrayList();
    List others = new ArrayList(objects);
    for (Object o : objects) {
        if (o instanceof NodePart) {
            others.remove(o);
            Node model = (Node) ((NodePart) o).getModel();
            if (model.getJobletNode() != null) {
                continue;
            }
            if (model.getJunitNode() != null) {
                continue;
            }
            nodeParts.add(o);
        } else if (o instanceof NoteEditPart) {
            noteParts.add(o);
            others.remove(o);
        } else if (o instanceof SubjobContainerPart) {
            others.remove(o);
            SubjobContainerPart subjob = (SubjobContainerPart) o;
            for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
                NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
                if (nodeContainerPart instanceof JobletContainerPart) {
                    JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
                    JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
                    if (!jobletCon.isCollapsed()) {
                        jobletFigure.doCollapse();
                    }
                }
                NodePart nodePart = nodeContainerPart.getNodePart();
                if (nodePart != null) {
                    Node model = (Node) nodePart.getModel();
                    if (model.getJunitNode() != null) {
                        continue;
                    }
                    nodeParts.add(nodePart);
                }
            }
        }
    }
    if (others.size() == 0) {
        // so notes & nodes only
        CompoundCommand cpdCmd = new CompoundCommand();
        //$NON-NLS-1$
        cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
        if (nodeParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(nodeParts);
            cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
        }
        if (noteParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(noteParts);
            cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
        }
        return cpdCmd;
    } else {
        GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
        deleteReq.setEditParts(objects);
        Command cmd = object.getCommand(deleteReq);
        return cmd;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) Iterator(java.util.Iterator) JobletContainerFigure(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerFigure) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IProcess(org.talend.core.model.process.IProcess)

Example 89 with IProcess

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

the class HTMLDocGenerator method seperateNodes.

/**
     * This method is used for seperating all nodes into internal and external.
     * 
     * @param item
     * @return
     */
protected List<List> seperateNodes(Item item) {
    List<INode> internalNodeComponentList = new ArrayList<INode>();
    List<INode> externalNodeComponentList = new ArrayList<INode>();
    List<INode> allNodeComponentList = new ArrayList<INode>();
    List<List> componentsList = new ArrayList<List>();
    IProcess process = null;
    boolean isJobletProcessItem = item instanceof JobletProcessItem;
    boolean isProcessItem = item instanceof ProcessItem;
    if (isProcessItem) {
        process = CorePlugin.getDefault().getDesignerCoreService().getProcessFromProcessItem((ProcessItem) item, true);
    }
    // }
    if (process == null) {
        return componentsList;
    }
    List<INode> graphicalNodeList = (List<INode>) process.getGraphicalNodes();
    for (INode node : graphicalNodeList) {
        // If component is not activate, do not need to get it's information
        if (!node.isActivate()) {
            continue;
        }
        allNodeComponentList.add(node);
        if (node.getExternalNode() != null) {
            externalNodeComponentList.add(node);
        } else {
            internalNodeComponentList.add(node);
        }
    }
    // Sorts the component list in alpha-order.
    Comparator comparator = getComparator();
    Collections.sort(allNodeComponentList, comparator);
    Collections.sort(internalNodeComponentList, comparator);
    Collections.sort(externalNodeComponentList, comparator);
    componentsList.add(allNodeComponentList);
    componentsList.add(internalNodeComponentList);
    componentsList.add(externalNodeComponentList);
    if (process instanceof IProcess2) {
        ((IProcess2) process).dispose();
    }
    return componentsList;
}
Also used : INode(org.talend.core.model.process.INode) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ArrayList(java.util.ArrayList) IProcess2(org.talend.core.model.process.IProcess2) CSSRuleList(org.w3c.dom.css.CSSRuleList) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) EList(org.eclipse.emf.common.util.EList) IProcess(org.talend.core.model.process.IProcess) Comparator(java.util.Comparator)

Example 90 with IProcess

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

the class UIManager method refreshVisualMapImage.

private void refreshVisualMapImage() {
    AbstractMapComponent mapCom = mapperManager.getAbstractMapComponent();
    if (mapCom == null) {
        return;
    }
    INode component = mapCom.getOriginalNode();
    if (component != null && component.getExternalNode() != null && component.getExternalNode().getScreenshot() != null) {
        byte[] saveImageToData = ImageUtils.saveImageToData(component.getExternalNode().getScreenshot());
        IProcess process = component.getProcess();
        if (process instanceof IProcess2) {
            IProcess2 processtmp = (IProcess2) process;
            Item item = processtmp.getProperty().getItem();
            if (item instanceof ProcessItem) {
                ProcessItem processItem = (ProcessItem) item;
                processItem.getProcess().getScreenshots().put(component.getUniqueName(), saveImageToData);
            } else if (item instanceof JobletProcessItem) {
                JobletProcessItem jobletItem = (JobletProcessItem) item;
                jobletItem.getJobletProcess().getScreenshots().put(component.getUniqueName(), saveImageToData);
            }
        }
    }
}
Also used : ToolItem(org.eclipse.swt.widgets.ToolItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) TableItem(org.eclipse.swt.widgets.TableItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) INode(org.talend.core.model.process.INode) AbstractMapComponent(org.talend.designer.abstractmap.AbstractMapComponent) 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) IProcess(org.talend.core.model.process.IProcess)

Aggregations

IProcess (org.talend.core.model.process.IProcess)102 INode (org.talend.core.model.process.INode)33 ArrayList (java.util.ArrayList)28 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)24 IProcess2 (org.talend.core.model.process.IProcess2)22 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Node (org.talend.designer.core.ui.editor.nodes.Node)20 List (java.util.List)17 Item (org.talend.core.model.properties.Item)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 IOException (java.io.IOException)15 PersistenceException (org.talend.commons.exception.PersistenceException)14 IElementParameter (org.talend.core.model.process.IElementParameter)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 IEditorPart (org.eclipse.ui.IEditorPart)11 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 File (java.io.File)9 Element (org.talend.core.model.process.Element)9 IConnection (org.talend.core.model.process.IConnection)9 IContext (org.talend.core.model.process.IContext)9