Search in sources :

Example 6 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class PaletteSettingPage method addUsedComponents.

private void addUsedComponents(Set<IComponent> components, List<IRepositoryViewObject> allProcess, ComponentCategory category) {
    for (IRepositoryViewObject object : allProcess) {
        Item item = object.getProperty().getItem();
        List parameters = null;
        ProcessType processType = null;
        if (item instanceof ProcessItem) {
            processType = ((ProcessItem) item).getProcess();
        } else if (item instanceof JobletProcessItem) {
            processType = ((JobletProcessItem) item).getJobletProcess();
        }
        if (processType != null) {
            for (Object oNode : processType.getNode()) {
                NodeType node = (NodeType) oNode;
                IComponent component = ComponentsFactoryProvider.getInstance().get(node.getComponentName(), category.getName());
                if (component != null && component.getComponentType() == EComponentType.EMF) {
                    components.add(component);
                }
            }
            if (processType.getParameters() != null) {
                // occurs actually only in joblets
                parameters = processType.getParameters().getElementParameter();
            }
        }
        if (parameters != null) {
            // used in stats&log and implicite
            Set<IComponent> inStatsLogsAndImplicit = getComponentsInStatsLogsAndImplicit(parameters);
            if (inStatsLogsAndImplicit != null) {
                components.addAll(inStatsLogsAndImplicit);
            }
        }
    }
}
Also used : RootPaletteItem(org.talend.repository.preference.palettesettings.RootPaletteItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) FolderPaletteItem(org.talend.repository.preference.palettesettings.FolderPaletteItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IComponent(org.talend.core.model.components.IComponent) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 7 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class ComponentSearcher method search.

/**
     * DOC hcw Comment method "search".
     * 
     * @param monitor
     * @param nodeName
     * @param found
     */
protected void search(IProgressMonitor monitor, String nodeName, List<IRepositoryViewObject> found) {
    IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
    try {
        List<IRepositoryViewObject> repositoryObjectList = factory.getAll(ERepositoryObjectType.PROCESS, false);
        repositoryObjectList.addAll(factory.getAll(ERepositoryObjectType.PROCESS_MR, false));
        repositoryObjectList.addAll(factory.getAll(ERepositoryObjectType.valueOf("PROCESS_STORM"), false));
        if (ProjectManager.getInstance().getReferencedProjects(ProjectManager.getInstance().getCurrentProject()).size() > 0) {
            for (Project refProject : ProjectManager.getInstance().getReferencedProjects(ProjectManager.getInstance().getCurrentProject())) {
                repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.PROCESS, false));
                repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.PROCESS_MR, false));
                repositoryObjectList.addAll(factory.getAll(refProject, ERepositoryObjectType.valueOf("PROCESS_STORM"), false));
            }
        }
        //$NON-NLS-1$
        monitor.beginTask("Searching Component in Jobs ", repositoryObjectList.size());
        for (IRepositoryViewObject rObject : repositoryObjectList) {
            if (monitor.isCanceled()) {
                break;
            }
            //$NON-NLS-1$
            monitor.setTaskName("Search " + rObject.getLabel());
            monitor.worked(1);
            Item item = rObject.getProperty().getItem();
            if (item instanceof ProcessItem) {
                ProcessItem processItem = (ProcessItem) item;
                IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
                List<INode> nodes = (List<INode>) process.getGraphicalNodes();
                for (INode node : nodes) {
                    if (node.getComponent().getName().equals(nodeName)) {
                        found.add(rObject);
                        break;
                    }
                }
            }
        }
        monitor.done();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
// JobletEditorInput fileEditorInput = new JobletEditorInput(processItem, true);
// IEditorPart editorPart = page.findEditor(fileEditorInput);
}
Also used : Project(org.talend.core.model.general.Project) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) INode(org.talend.core.model.process.INode) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ArrayList(java.util.ArrayList) List(java.util.List) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 8 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class OpentRunJobComponentAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof NodePart) {
        NodePart part = (NodePart) input;
        Node node = (Node) part.getModel();
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
        String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
        if (processName != null && !"".equals(processName)) {
            //$NON-NLS-1$
            try {
                ItemCacheManager.clearCache();
                ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                if (processItem != null) {
                    ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true);
                    IEditorPart editorPart = page.findEditor(fileEditorInput);
                    if (editorPart == null) {
                        ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(processItem);
                        IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                        editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(processItem, true));
                    } else {
                        page.activate(editorPart);
                    }
                }
            } catch (PartInitException e) {
                MessageBoxExceptionHandler.process(e);
            } catch (PersistenceException e) {
                MessageBoxExceptionHandler.process(e);
            }
        } else {
            try {
                // modified for feature 2454.
                page.showView(ComponentSettingsView.ID);
            } catch (PartInitException e) {
                ExceptionHandler.process(e);
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IEditorPart(org.eclipse.ui.IEditorPart) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) List(java.util.List) PartInitException(org.eclipse.ui.PartInitException) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 9 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createNewComponent.

public void createNewComponent(DropTargetEvent event1) {
    boolean quickCreateInput = event1.detail == DND.DROP_LINK;
    boolean quickCreateOutput = event1.detail == DND.DROP_COPY;
    Iterator iterator = getSelection().iterator();
    List<TempStore> list = new ArrayList<TempStore>();
    List<IComponent> components = new ArrayList<IComponent>();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) obj;
            if (equalsJobInCurrentEditor(sourceNode)) {
                continue;
            }
            Item item = sourceNode.getObject().getProperty().getItem();
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
                ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
                if (testContainerService != null && testContainerService.isTestContainerItem(item)) {
                    continue;
                }
            }
            ERepositoryObjectType type = sourceNode.getObjectType();
            if (!(item instanceof ConnectionItem) && !(item instanceof ProcessItem) && !(item instanceof JobletProcessItem) && !(item instanceof RulesItem) && !(item instanceof LinkRulesItem)) {
                // RulesItem
                return;
            }
            {
            /**
                     * Remove this limitation for feature: TDI-32362, I think it should be ok, don't know why adding
                     * this limitation to forbid to d&d salseforce connection, I keep those code in case this behavior
                     * will cause some bugs when d&d salseforce connection, then maybe need to review
                     */
            // if (item instanceof SalesforceSchemaConnectionItem && type ==
            // ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
            // return;
            // }
            }
            TempStore store = new TempStore();
            store.seletetedNode = sourceNode;
            getAppropriateComponent(item, quickCreateInput, quickCreateOutput, store, type);
            if (store.component != null) {
                list.add(store);
            } else {
                MessageDialog.openInformation(editor.getEditorSite().getShell(), //$NON-NLS-1$
                Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.title"), //$NON-NLS-1$
                Messages.getString("TalendEditorDropTargetListener.dngsupportdialog.content"));
            }
        }
        org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event1.x, event1.y);
        Canvas canvas = (Canvas) editor.getViewer().getControl();
        /*
             * translate to Canvas coordinate
             */
        swtLocation = canvas.toControl(swtLocation);
        org.eclipse.swt.graphics.Point size = canvas.getSize();
        /*
             * translate to Viewport coordinate with zoom
             */
        org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
        /*
             * calcule the view port position. Take into acounte the scroll position
             */
        ProcessPart part = (ProcessPart) editor.getViewer().getRootEditPart().getRoot().getChildren().get(0);
        IFigure targetFigure = part.getFigure();
        translateAbsolateToRelative(targetFigure, draw2dPosition);
        //$NON-NLS-1$
        String lastUniqname = "";
        // creates every node
        for (TempStore store : list) {
            RepositoryNode selectedNode = store.seletetedNode;
            IComponent element = store.component;
            if (!components.contains(element)) {
                components.add(element);
            }
            Node node = new Node(element);
            // for bug4564(metadata label format)
            // IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
            // if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
            // node.setPropertyValue(EParameterName.LABEL.getName(), selectedNode.getObject().getLabel());
            // }
            IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
            if (preferenceStore.getBoolean(TalendDesignerPrefConstants.USE_REPOSITORY_NAME)) {
                String LabelValue = null;
                RepositoryNode repositoryNode = null;
                repositoryNode = (RepositoryNode) getSelection().getFirstElement();
                // dnd a table
                IElementParameter dbTableParam = node.getElementParameterFromField(EParameterFieldType.DBTABLE);
                boolean hasDbTableField = dbTableParam != null;
                if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE && repositoryNode.getObject() != null && repositoryNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem && hasDbTableField) {
                    LabelValue = DesignerUtilities.getParameterVar(dbTableParam.getName());
                } else if (repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_MR || repositoryNode.getObjectType() == ERepositoryObjectType.PROCESS_STORM) {
                    // dnd a job
                    LabelValue = DesignerUtilities.getParameterVar(EParameterName.PROCESS);
                } else if (repositoryNode.getObjectType() == ERepositoryObjectType.JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_JOBLET || repositoryNode.getObjectType() == ERepositoryObjectType.SPARK_STREAMING_JOBLET) {
                    LabelValue = element.getName();
                } else if (CorePlugin.getDefault().getDesignerCoreService().getPreferenceStore(TalendDesignerPrefConstants.DEFAULT_LABEL).equals(node.getPropertyValue(EParameterName.LABEL.getName()))) {
                    // dnd a default
                    LabelValue = selectedNode.getObject().getLabel();
                }
                if (LabelValue != null) {
                    node.setPropertyValue(EParameterName.LABEL.getName(), LabelValue);
                }
            }
            processSpecificDBTypeIfSameProduct(store.componentName, node);
            NodeContainer nc = ((Process) node.getProcess()).loadNodeContainer(node, false);
            ;
            // create component on link
            boolean executed = false;
            if (getSelection().size() == 1 && getTargetEditPart() instanceof SubjobContainerPart) {
                executed = createComponentOnLink(node, draw2dPosition);
            }
            if (!executed) {
                // create the node on the design sheet
                execCommandStack(new CreateNodeContainerCommand((Process) editor.getProcess(), nc, draw2dPosition));
            }
            // initialize the propertiesView
            CompoundCommand cc = new CompoundCommand();
            createRefreshingPropertiesCommand(cc, selectedNode, node);
            execCommandStack(cc);
            // for (Command command : commands) {
            // }
            propaHadoopCfgChanges(selectedNode);
            draw2dPosition = draw2dPosition.getCopy();
            draw2dPosition.x += TalendEditor.GRID_SIZE;
            draw2dPosition.y += TalendEditor.GRID_SIZE;
            node.checkNode();
            lastUniqname = node.getUniqueName();
        }
    // setselecte(part, lastUniqname);
    }
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), components);
}
Also used : IComponent(org.talend.core.model.components.IComponent) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) ArrayList(java.util.ArrayList) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ValidationRulesConnectionItem(org.talend.core.model.properties.ValidationRulesConnectionItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) RulesItem(org.talend.core.model.properties.RulesItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) FileItem(org.talend.core.model.properties.FileItem) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) Iterator(java.util.Iterator) IElementParameter(org.talend.core.model.process.IElementParameter) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IFigure(org.eclipse.draw2d.IFigure) Point(org.eclipse.draw2d.geometry.Point) Canvas(org.eclipse.swt.widgets.Canvas) Point(org.eclipse.draw2d.geometry.Point) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 10 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createChildJob.

/**
     * DOC qwei Comment method "createChildJob".
     */
private void createChildJob(Object dragModel, EditPart targetEditPart) {
    if (!(dragModel instanceof RepositoryNode && targetEditPart instanceof NodeContainerPart)) {
        return;
    }
    RepositoryNode dragNode = (RepositoryNode) dragModel;
    NodeContainerPart nodePart = (NodeContainerPart) targetEditPart;
    if (dragNode.getObject().getProperty().getItem() instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) dragNode.getObject().getProperty().getItem();
        Command command = getChangeChildProcessCommand((Node) nodePart.getNodePart().getModel(), processItem);
        if (command != null) {
            execCommandStack(command);
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

ProcessItem (org.talend.core.model.properties.ProcessItem)191 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)58 PersistenceException (org.talend.commons.exception.PersistenceException)56 ArrayList (java.util.ArrayList)45 Item (org.talend.core.model.properties.Item)43 Property (org.talend.core.model.properties.Property)43 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)37 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)29 IProcess2 (org.talend.core.model.process.IProcess2)25 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)25 IProcess (org.talend.core.model.process.IProcess)24 ExportFileResource (org.talend.repository.documentation.ExportFileResource)24 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)24 File (java.io.File)23 INode (org.talend.core.model.process.INode)23 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)22 IOException (java.io.IOException)21 IFile (org.eclipse.core.resources.IFile)20 List (java.util.List)19 EList (org.eclipse.emf.common.util.EList)19