Search in sources :

Example 61 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class EditRouteResourcePropertiesAction method init.

public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = selection.size() == 1;
    if (canWork) {
        Object o = ((IStructuredSelection) selection).getFirstElement();
        if (o instanceof IRepositoryNode) {
            final IRepositoryNode node = (IRepositoryNode) o;
            canWork = node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType() == CamelRepositoryNodeType.repositoryRouteResourceType && node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED && isLastVersion(node);
        }
    }
    setEnabled(canWork);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 62 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class CamelFeatureUtil method getJobProjectName.

private static String getJobProjectName(String jobId, String jobName, String defaultProject) {
    if (jobId == null || jobId.isEmpty()) {
        return defaultProject;
    }
    if (jobName == null || jobName.isEmpty()) {
        return defaultProject;
    }
    IRepositoryNode referencedJobNode = null;
    Project referenceProject = null;
    try {
        List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
        if (projects == null) {
            return defaultProject;
        }
        for (Project p : projects) {
            List<IRepositoryViewObject> jobs = ProxyRepositoryFactory.getInstance().getAll(p, ERepositoryObjectType.PROCESS);
            if (jobs == null) {
                continue;
            }
            for (IRepositoryViewObject job : jobs) {
                if (job.getId().equals(jobId)) {
                    referencedJobNode = new RepositoryNode(job, null, IRepositoryNode.ENodeType.REPOSITORY_ELEMENT);
                    referenceProject = p;
                    break;
                }
            }
            if (referenceProject != null) {
                break;
            }
        }
    } catch (PersistenceException e) {
        return defaultProject;
    }
    if (referencedJobNode == null) {
        return defaultProject;
    }
    Property p = referencedJobNode.getObject().getProperty();
    String jobNameFound = p.getDisplayName();
    String jobLabelFound = p.getLabel();
    if ((jobNameFound == null || !jobNameFound.equals(jobName)) && (jobLabelFound == null || !jobNameFound.equals(jobName))) {
        return defaultProject;
    }
    if (referenceProject != null) {
        return referenceProject.getLabel().toLowerCase();
    }
    return defaultProject;
}
Also used : Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property)

Example 63 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class CreateRouteResourceAction method doRun.

@Override
protected void doRun() {
    IRepositoryNode node = null;
    NewRouteResourceWizard wizard = null;
    ISelection selection = getSelection();
    if (selection == null) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    node = (IRepositoryNode) obj;
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IPath path = service.getRepositoryPath(node);
    if (RepositoryConstants.isSystemFolder(path.toString())) {
        // Not allowed to create in system folder.
        return;
    }
    wizard = new NewRouteResourceWizard(path);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    int open = dlg.open();
    if (open == Window.OK) {
        RouteResourceItem item = wizard.getItem();
        IWorkbenchPage page = getActivePage();
        RouteResourceEditorUtil.openEditor(page, null, item);
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) RouteResourceItem(org.talend.camel.core.model.camelProperties.RouteResourceItem) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NewRouteResourceWizard(org.talend.designer.camel.resource.ui.wizards.NewRouteResourceWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 64 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.

the class ComponentChooseDialog method getChangeMetadataCommand.

/**
     * DOC bqian Comment method "getChangeMetadataCommand".
     *
     * @param selectedNode
     * @param node
     * @param list
     * @param connectionItem
     */
private void getChangeMetadataCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node, ConnectionItem connectionItem) {
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
        RepositoryNode columnParentNode = selectedNode.getParent().getParent();
        if (columnParentNode != null) {
            selectedNode = columnParentNode;
        }
    }
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
        String etlSchema = null;
        if (connectionItem.getConnection() instanceof DatabaseConnection) {
            DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
            if (connection instanceof DatabaseConnection) {
                etlSchema = connection.getUiSchema();
            }
            if (!"".equals(etlSchema)) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                IElementParameter e = node.getElementParameter("ELT_SCHEMA_NAME");
                if (e != null) {
                    if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
                        e.setValue(etlSchema);
                    } else {
                        e.setValue(TalendTextUtils.addQuotes(etlSchema));
                    }
                }
            // node.getElementParameter("ELT_SCHEMA_NAME").setValue("\"" + etlSchema + "\"");
            }
        }
        IRepositoryViewObject object = selectedNode.getObject();
        MetadataTable table = null;
        if (object instanceof MetadataTableRepositoryObject) {
            table = ((MetadataTableRepositoryObject) object).getTable();
        } else if (object instanceof SalesforceModuleRepositoryObject) {
            table = ((SalesforceModuleRepositoryObject) object).getDefaultTable();
            IRepositoryViewObject obj = null;
            if (selectedNode.getChildren() != null) {
                for (IRepositoryNode repositoryNode : selectedNode.getChildren()) {
                    obj = repositoryNode.getObject();
                    if (obj instanceof MetadataTableRepositoryObject) {
                        table = ((MetadataTableRepositoryObject) obj).getTable();
                        break;
                    }
                }
            }
        }
        // for SAP
        if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
            getSAPCommand(cc, object, connectionItem, table, node);
            return;
        }
        if (table != null) {
            //$NON-NLS-1$
            String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
            IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
            if (schemaParam == null) {
                schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
            }
            IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
            if (queryParam != null) {
                queryParam = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
                if (queryParam != null) {
                    queryParam.setValue(EmfComponent.BUILTIN);
                }
            }
            // }
            if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
                Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                cc.add(hl7Cmd);
                return;
            }
            if (schemaParam == null) {
                return;
            }
            if (node.isELTComponent()) {
                //$NON-NLS-1$
                node.setPropertyValue(EParameterName.LABEL.getName(), "__ELT_TABLE_NAME__");
            }
            schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
            schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
            cc.add(command2);
            return;
        }
    }
}
Also used : RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) 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) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 65 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.

the class ComponentChooseDialog method handleDrop.

// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
     */
@Override
protected void handleDrop() {
    updateTargetRequest();
    updateTargetEditPart();
    // checkRequiredModules();
    if (fromPalette && getTargetRequest() instanceof CreateRequest) {
        if (selectedConnectionPart != null) {
            CreateRequest req = ((CreateRequest) getTargetRequest());
            Object o = req.getNewObject();
            Point location = req.getLocation();
            if (o instanceof Node) {
                createComponentOnLink((Node) o, location);
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof ProcessPart) {
            // for palette dnd, feature 6457
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof SubjobContainerPart) {
            // TDI-24985:for palette dnd.
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            return;
        } else if (getTargetEditPart() instanceof JobletContainerPart) {
            JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
            if (isLock(jobletPart)) {
                Shell shell = Display.getCurrent().getActiveShell();
                ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
                if (dialog.open() == dialog.OK) {
                    EditPart part = getTargetEditPart();
                    if (dialog.addToJoblet()) {
                        AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
                        part = openEditor.getDesignerEditor().getProcessPart();
                        // editor = openEditor.getTalendEditor();
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
                                if (commandStack != null) {
                                    commandStack.execute(command);
                                } else {
                                    command.execute();
                                }
                            }
                        }
                        // checkRequiredModules();
                        return;
                    } else {
                        part = getParentPart(part);
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                execCommandStack(command);
                            }
                        }
                        // checkRequiredModules();
                        return;
                    }
                }
            }
        }
    }
    List<Object> sources = getSelectSource();
    if (containsContextSource(sources)) {
        createContext(sources);
    } else {
        if (!(getTargetEditPart() instanceof NodeContainerPart)) {
            try {
                createNewComponent(getCurrentEvent());
            } catch (OperationCanceledException e) {
                return;
            }
        } else {
            if (containsSQLPatternSource(sources)) {
                createSQLPattern(sources);
            } else {
                Object obj = getSelection().getFirstElement();
                createSchema(obj, getTargetEditPart());
                createQuery(obj, getTargetEditPart());
                createProperty(obj, getTargetEditPart());
                createChildJob(obj, getTargetEditPart());
                createValidationRule(obj, getTargetEditPart());
                if (obj instanceof IRepositoryNode) {
                    propaHadoopCfgChanges((IRepositoryNode) obj);
                }
                for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
                    boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
                    if (updated) {
                        break;
                    }
                }
            }
        }
    }
    // in case after drag/drop the editor is dirty but can not get focus
    if (editor.isDirty()) {
        editor.setFocus();
    }
    this.eraseTargetFeedback();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CreateRequest(org.eclipse.gef.requests.CreateRequest) 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) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) Point(org.eclipse.draw2d.geometry.Point) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ChooseJobletDialog(org.talend.designer.core.ui.dialog.mergeorder.ChooseJobletDialog) IExtendedNodeHandler(org.talend.designer.core.IExtendedNodeHandler) Shell(org.eclipse.swt.widgets.Shell) 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) 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)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5