Search in sources :

Example 31 with IElementParameter

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

the class NodePart method performRequest.

@Override
public void performRequest(Request req) {
    Node node = (Node) getModel();
    IExternalData oldExternalData = node.getExternalData();
    if (req.getType().equals(RequestConstants.REQ_OPEN)) {
        IExternalNode externalNode = null;
        if (node.isExternalNode()) {
            IElementParameter externalParam = node.getElementParameterFromField(EParameterFieldType.EXTERNAL);
            if (externalParam != null && externalParam.isShow(node.getElementParameters())) {
                externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
            }
        }
        IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
            boolean isOriginalNode = false;
            ITestContainerProviderService testContainerService = null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
                testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
                if (testContainerService != null) {
                    isOriginalNode = testContainerService.isOriginalNode(node);
                    if (isOriginalNode) {
                        testContainerService.renameConnection(node, true);
                    }
                }
            }
            int returnValue = externalNode.open(getViewer().getControl().getShell());
            if (!node.isReadOnly()) {
                if (returnValue == SWT.OK) {
                    Command cmd = new ExternalNodeChangeCommand(node, externalNode, oldExternalData);
                    CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
                    cmdStack.execute(cmd);
                } else {
                    externalNode.setExternalData(oldExternalData);
                }
            }
            if (isOriginalNode && (testContainerService != null)) {
                testContainerService.renameConnection(node, false);
            }
        } else {
            // add for feature 13361
            boolean isJoblet = false;
            if (PluginChecker.isJobLetPluginLoaded()) {
                AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
                final IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                boolean isAvoidShowJobletAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService componentService = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (componentService != null) {
                        isAvoidShowJobletAfterDoubleClick = componentService.isAvoidToShowJobletAfterDoubleClick();
                    }
                }
                if (service != null && service.isJobletComponent(node) && !isAvoidShowJobletAfterDoubleClick) {
                    isJoblet = true;
                    String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
                    final Item jobletItem = jobletProcessProvider.getJobletItem(node, version);
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            if (jobletItem != null) {
                                service.openJobletItem((JobletProcessItem) jobletItem);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                }
            }
            if (!isJoblet) {
                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());
                boolean isAvoidShowJobAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (service != null) {
                        isAvoidShowJobAfterDoubleClick = service.isAvoidToShowJobAfterDoubleClick();
                    }
                }
                // bug 20796
                boolean isSelectUseDynamic = false;
                Object useDynamicJobValue = node.getPropertyValue(EParameterName.USE_DYNAMIC_JOB.getName());
                if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
                    isSelectUseDynamic = (Boolean) useDynamicJobValue;
                }
                if (processName != null && !"".equals(processName) && !isAvoidShowJobAfterDoubleClick && !isSelectUseDynamic) {
                    //$NON-NLS-1$
                    ItemCacheManager.clearCache();
                    ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                    if (processItem == null) {
                        return;
                    }
                    Property updatedProperty = null;
                    try {
                        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(processItem)), processName).getProperty();
                    } catch (PersistenceException e) {
                        CommonExceptionHandler.process(e);
                    }
                    // update the property of the node repository object
                    // node.getObject().setProperty(updatedProperty);
                    processItem = (ProcessItem) updatedProperty.getItem();
                    final ProcessItem item = processItem;
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            try {
                                if (item != null) {
                                    ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(item);
                                    IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                                    editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(item, true));
                                }
                            } catch (PartInitException e) {
                                MessageBoxExceptionHandler.process(e);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                } else {
                    try {
                        // modified for feature 2454.
                        page.showView(ComponentSettingsView.ID);
                    } catch (PartInitException e) {
                        CommonExceptionHandler.process(e);
                    }
                }
            }
        }
    }
    super.performRequest(req);
}
Also used : IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) IComponentsLocalProviderService(org.talend.core.ui.services.IComponentsLocalProviderService) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IElementParameter(org.talend.core.model.process.IElementParameter) PartInitException(org.eclipse.ui.PartInitException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) IExternalNode(org.talend.core.model.process.IExternalNode) CommandStack(org.eclipse.gef.commands.CommandStack) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) Point(org.eclipse.draw2d.geometry.Point) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Project(org.talend.core.model.general.Project) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IExternalData(org.talend.core.model.process.IExternalData)

Example 32 with IElementParameter

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

the class ProcessController method setProcessTypeRelatedValues.

/**
     * 
     * ggu Comment method "setProcessTypeRelatedValues".
     * 
     * 
     */
private void setProcessTypeRelatedValues(IElementParameter parentParam, List<String> nameList, List<String> valueList, final String childName, final String defaultValue) {
    if (parentParam == null || childName == null) {
        return;
    }
    //$NON-NLS-1$
    final String fullChildName = parentParam.getName() + ":" + childName;
    IElementParameter childParam = parentParam.getChildParameters().get(childName);
    IElementParameter jobNameParam = parentParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    if (jobNameParam != null) {
        String value = (String) jobNameParam.getValue();
        if (value == null || "".equals(value)) {
            //$NON-NLS-1$
            childParam.setValue(null);
        }
    }
    if (nameList == null) {
        childParam.setListItemsDisplayName(new String[0]);
    } else {
        childParam.setListItemsDisplayName(nameList.toArray(new String[0]));
    }
    if (valueList == null) {
        childParam.setListItemsValue(new String[0]);
    } else {
        childParam.setListItemsValue(valueList.toArray(new String[0]));
    }
    if (elem != null) {
        if (valueList != null && !valueList.contains(childParam.getValue())) {
            if (nameList != null && nameList.size() > 0) {
                // set default value
                if (defaultValue != null) {
                    childParam.setValue(defaultValue);
                } else {
                    elem.setPropertyValue(fullChildName, valueList.get(valueList.size() - 1));
                }
            }
        } else {
            // force to store the value again to activate the code
            // generation in Node.setPropertyValue
            elem.setPropertyValue(fullChildName, childParam.getValue());
        }
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter)

Example 33 with IElementParameter

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

the class PropertyTypeController method createButtonCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createControl(org.eclipse
     * .swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
protected Command createButtonCommand(Button button) {
    // hwang add for feature 6484
    FileItem repositoryFileItem = null;
    LinkRulesItem linkItem = null;
    Map<String, FileItem> repositoryFileItemMap = null;
    Map<String, LinkRulesItem> repositoryLinkRulesItemMap = null;
    String paramName = (String) button.getData(PARAMETER_NAME);
    IElementParameter param = elem.getElementParameter(paramName);
    Object data = button.getData(NAME);
    if (data != null && data.equals(REPOSITORY_CHOICE)) {
        IElementParameter dbTypeParam = null;
        if (elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement) {
            if (EParameterName.PROPERTY_TYPE.getName().equals(paramName)) {
                dbTypeParam = elem.getElementParameter(EParameterName.DB_TYPE.getName());
            } else if (JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()).equals(paramName)) {
                dbTypeParam = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()));
            }
        }
        Item item = null;
        String id = null;
        RepositoryNode selectNode = null;
        if (id == null) {
            RepositoryReviewDialog dialog = null;
            if (dbTypeParam != null) {
                String[] listRepositoryItems = dbTypeParam.getListRepositoryItems();
                dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, param.getRepositoryValue(), listRepositoryItems);
            } else {
                // Added TDQ-11688
                ITDQPatternService service = null;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
                    service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
                }
                if (service != null && service.isSinglePatternNode(elem)) {
                    return processPattern(elem);
                }
                // ~
                dialog = new RepositoryReviewDialog(Display.getCurrent().getActiveShell(), ERepositoryObjectType.METADATA, elem, param);
            }
            if (dialog.open() == RepositoryReviewDialog.OK) {
                selectNode = dialog.getResult();
                id = selectNode.getObject().getId();
            }
        }
        if (id != null && !"".equals(id)) {
            //$NON-NLS-1$
            IElementParameter repositoryParam = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            //$NON-NLS-1$
            String fullParamName = paramName + ":" + getRepositoryChoiceParamName();
            Connection repositoryConnection = null;
            // Map<String, ConnectionItem> repositoryConnectionItemMap =
            // dynamicProperty.getRepositoryConnectionItemMap();
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(id);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
            if (item != null) {
                if (item instanceof ConnectionItem) {
                    repositoryConnection = ((ConnectionItem) item).getConnection();
                }
            } else {
                repositoryConnection = null;
                if (repositoryParam != null) {
                    item = selectNode.getObject().getProperty().getItem();
                    if (item instanceof ConnectionItem) {
                        repositoryConnection = ((ConnectionItem) item).getConnection();
                    }
                }
            }
            if (repositoryConnection != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                ChangeValuesFromRepository changeValuesFromRepository = null;
                if (selectNode.getObjectType() == ERepositoryObjectType.SERVICESOPERATION && GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                    IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
                    IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
                    String currentJobId = process.getProperty().getId();
                    String serviceId = item.getProperty().getId();
                    String portId = selectNode.getParent().getObject().getId();
                    String operationId = selectNode.getObject().getId();
                    changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, param.getName() + ":" + //$NON-NLS-1$
                    EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$ //$NON-NLS-2$
                    serviceId + " - " + portId + " - " + operationId);
                    service.deleteOldRelation(currentJobId);
                    //$NON-NLS-1$ //$NON-NLS-2$
                    service.updateOperation((INode) elem, serviceId + " - " + portId + " - " + operationId, selectNode);
                } else {
                    changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, fullParamName, id);
                }
                if (changeValuesFromRepository != null) {
                    compoundCommand.add(changeValuesFromRepository);
                }
                updateDBType(compoundCommand, repositoryConnection);
                return compoundCommand;
            }
            // for ruleItem,hywang add
            if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
                repositoryFileItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryFileItemMap();
                repositoryLinkRulesItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryLinkRulesItemMap();
            }
            if (repositoryFileItemMap.containsKey(id)) {
                repositoryFileItem = repositoryFileItemMap.get(id);
            } else if (repositoryLinkRulesItemMap.containsKey(id)) {
                linkItem = repositoryLinkRulesItemMap.get(id);
            } else {
                if (!repositoryFileItemMap.isEmpty()) {
                    repositoryFileItem = repositoryFileItemMap.values().iterator().next();
                } else {
                    repositoryFileItem = null;
                }
            }
            if (repositoryFileItem == null && item instanceof FileItem) {
                repositoryFileItem = (FileItem) item;
            }
            if (repositoryFileItem != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                final String showId = repositoryFileItem.getProperty().getId();
                Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                compoundCommand.add(command);
                return compoundCommand;
            }
            if (linkItem != null) {
                CompoundCommand compoundCommand = new CompoundCommand();
                final String showId = linkItem.getProperty().getId();
                Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                compoundCommand.add(command);
                return compoundCommand;
            }
        }
    } else {
        // 1. open wizard
        if (elem instanceof INode) {
            INode node = (INode) elem;
            final IRepositoryService repositoryService = CorePlugin.getDefault().getRepositoryService();
            if (param != null) {
                RepositoryNode realNode = null;
                String repositoryValue = param.getRepositoryValue();
                if (repositoryValue != null && repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_CONNECTIONS);
                } else // file delimited
                if (ERepositoryCategoryType.DELIMITED.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_DELIMITED);
                }
                // file positional
                if (ERepositoryCategoryType.POSITIONAL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_POSITIONAL);
                }
                // file regexp
                if (ERepositoryCategoryType.REGEX.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_REGEXP);
                }
                // file xml
                if (ERepositoryCategoryType.XML.getName().equals(repositoryValue) || // bug 18012
                repositoryValue.startsWith(ERepositoryCategoryType.XML.getName())) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_XML);
                }
                // file ldif
                if (ERepositoryCategoryType.LDIF.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_LDIF);
                }
                // excel
                if (ERepositoryCategoryType.EXCEL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EXCEL);
                }
                // generic schema
                if (ERepositoryCategoryType.GENERIC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_GENERIC_SCHEMA);
                }
                // ldap
                if (ERepositoryCategoryType.LDAP.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_LDAP_SCHEMA);
                }
                // wsdl
                if (ERepositoryCategoryType.WSDL.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
                }
                if (ERepositoryCategoryType.WEBSERVICE.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_WSDL_SCHEMA);
                }
                // salesforce
                if (ERepositoryCategoryType.SALESFORCE.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA);
                }
                // ebcdic
                if (ERepositoryCategoryType.EBCDIC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_EBCDIC);
                }
                // mdm
                if (ERepositoryCategoryType.MDM.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_MDMCONNECTION);
                }
                // sap
                if (ERepositoryCategoryType.SAP.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAPCONNECTIONS);
                }
                // sapIDoc
                if (ERepositoryCategoryType.SAPIDOC.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_SAP_IDOC);
                }
                if (ERepositoryCategoryType.HEADERFOOTER.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_HEADER_FOOTER);
                }
                // brms
                if (ERepositoryCategoryType.BRMS.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_BRMS);
                }
                // hl7
                if (ERepositoryCategoryType.HL7.getName().equals(repositoryValue)) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.METADATA_FILE_HL7);
                }
                // last resort we assume that the repository value was named after the root component type key
                if (realNode == null) {
                    realNode = (RepositoryNode) repositoryService.getRootRepositoryNode(ERepositoryObjectType.getTypeFromKey(repositoryValue));
                }
                if (realNode != null) {
                    final IMetadataService metadataService = CorePlugin.getDefault().getMetadataService();
                    if (metadataService != null) {
                        ConnectionItem connItem = metadataService.openMetadataConnection(true, realNode, node);
                        if (connItem != null) {
                            IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
                            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                            // 2. commnd
                            Command cmd = new ChangeValuesFromRepository(node, connItem.getConnection(), //$NON-NLS-1$
                            propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), connItem.getProperty().getId());
                            executeCommand(cmd);
                            // see bug in feature 5998.refresh repositoryList.
                            if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
                                ((MultipleThreadDynamicComposite) dynamicProperty).updateRepositoryList();
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : INode(org.talend.core.model.process.INode) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) IRepositoryService(org.talend.repository.model.IRepositoryService) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) IElementParameter(org.talend.core.model.process.IElementParameter) ITDQPatternService(org.talend.core.ITDQPatternService) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryReviewDialog(org.talend.repository.ui.dialog.RepositoryReviewDialog) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IESBService(org.talend.core.IESBService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ImplicitContextLoadElement(org.talend.designer.core.ui.projectsetting.ImplicitContextLoadElement) StatsAndLogsElement(org.talend.designer.core.ui.projectsetting.StatsAndLogsElement) IMetadataService(org.talend.repository.model.IMetadataService)

Example 34 with IElementParameter

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

the class PasswordController method createButtonCommand.

protected Command createButtonCommand(final Button button) {
    if (button.getData(NAME).equals(PASSWORD)) {
        String paramName = (String) button.getData(PARAMETER_NAME);
        IElementParameter param = elem.getElementParameter(paramName);
        //$NON-NLS-1$
        String initValue = "\"\"";
        if (param.getValue() != null && ContextParameterUtils.containContextVariables(param.getValue().toString())) {
            initValue = param.getValue().toString();
        }
        InputDialog dlg = new InputDialog(button.getShell(), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("PasswordController.NewPassword"), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("PasswordController.NoteConvention"), initValue, null) {

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
                 */
            @Override
            protected Control createDialogArea(Composite parent) {
                Control control = super.createDialogArea(parent);
                String paramName = (String) button.getData(PARAMETER_NAME);
                getText().setData(PARAMETER_NAME, paramName);
                editionControlHelper.register(paramName, getText());
                return control;
            }
        };
        if (dlg.open() == Window.OK) {
            elem.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), new Boolean(true));
            return new PropertyChangeCommand(elem, paramName, dlg.getValue());
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) InputDialog(org.eclipse.jface.dialogs.InputDialog) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Composite(org.eclipse.swt.widgets.Composite) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 35 with IElementParameter

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

the class SapSchemaTypeController method createComboCommand.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createComboCommand(org
     * .eclipse.swt.custom.CCombo)
     */
@Override
protected Command createComboCommand(CCombo combo) {
    IMetadataTable repositoryMetadata = null;
    String fullParamName = (String) combo.getData(PARAMETER_NAME);
    IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
    //$NON-NLS-1$
    String value = new String("");
    IElementParameter param = elem.getElementParameter(fullParamName);
    for (int j = 0; j < param.getListItemsValue().length; j++) {
        if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
            value = (String) param.getListItemsValue()[j];
        }
    }
    // if change to build-in, unuse the validation rule if the component has.
    boolean isValRulesLost = false;
    IRepositoryViewObject currentValRuleObj = ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
    if (value.equals(EmfComponent.BUILTIN) && currentValRuleObj != null) {
        if (!MessageDialog.openConfirm(combo.getShell(), //$NON-NLS-1$
        Messages.getString("SchemaTypeController.validationrule.title.confirm"), Messages.getString("SchemaTypeController.validationrule.selectBuildInMsg"))) {
            //$NON-NLS-1$
            return null;
        } else {
            isValRulesLost = true;
        }
    }
    org.talend.core.model.metadata.builder.connection.Connection connection = null;
    if (elem instanceof Node) {
        Node node = (Node) elem;
        Command baseCommand = null;
        boolean isReadOnly = false;
        String newRepositoryIdValue = null;
        if (node.getMetadataFromConnector(param.getContext()) != null) {
            isReadOnly = node.getMetadataFromConnector(param.getContext()).isReadOnly();
        }
        if (//$NON-NLS-1$
        value.equals(EmfComponent.BUILTIN) && isReadOnly && !"tLogCatcher".equals(node.getComponent().getName()) && !"tStatCatcher".equals(node.getComponent().getName())) {
            //$NON-NLS-1$
            boolean hasMetadataInput = false;
            if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0) {
                hasMetadataInput = true;
            }
            repositoryMetadata = new MetadataTable();
            if (hasMetadataInput) {
                for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
                    if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE))) {
                        repositoryMetadata = connec.getMetadataTable().clone();
                    }
                }
            }
        } else if (value.equals(EmfComponent.REPOSITORY)) {
            // Map<String, IMetadataTable> repositoryTableMap = dynamicProperty.getRepositoryTableMap();
            IElementParameter property = ((Node) elem).getElementParameter(EParameterName.PROPERTY_TYPE.getName());
            if ((property != null) && EmfComponent.REPOSITORY.equals(property.getValue())) {
                String propertySelected = (String) ((Node) elem).getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
                IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                /* 16969 */
                Item item = null;
                try {
                    IRepositoryViewObject repobj = factory.getLastVersion(propertySelected);
                    if (repobj != null) {
                        Property tmpproperty = repobj.getProperty();
                        if (tmpproperty != null) {
                            item = tmpproperty.getItem();
                        }
                    }
                // item = factory.getLastVersion(propertySelected).getProperty().getItem();
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
                if (item != null && item instanceof ConnectionItem) {
                    final ConnectionItem connectionItem = (ConnectionItem) item;
                    if (connectionItem != null) {
                        connection = connectionItem.getConnection();
                    }
                }
            }
            IElementParameter repositorySchemaType = param.getParentParameter().getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
            String schemaSelected = (String) repositorySchemaType.getValue();
            /* value can be devided means the value like "connectionid - label" */
            //$NON-NLS-1$
            String[] keySplitValues = schemaSelected.toString().split(" - ");
            if (keySplitValues.length > 1) {
                String connectionId = keySplitValues[0];
                String tableLabel = keySplitValues[1];
                IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                Item item = null;
                try {
                    IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                    if (repobj != null) {
                        Property tmpproperty = repobj.getProperty();
                        if (tmpproperty != null) {
                            item = tmpproperty.getItem();
                        }
                    }
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
                if (item != null && item instanceof ConnectionItem) {
                    final ConnectionItem connectionItem = (ConnectionItem) item;
                    if (connectionItem != null) {
                        connection = connectionItem.getConnection();
                    }
                }
                if (item != null && item instanceof ConnectionItem) {
                    boolean findTable = false;
                    for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                        if (table.getLabel().equals(tableLabel)) {
                            repositoryMetadata = ConvertionHelper.convert(table);
                            newRepositoryIdValue = schemaSelected;
                            findTable = true;
                            break;
                        }
                    }
                    if (!findTable) {
                        repositoryMetadata = new MetadataTable();
                    }
                } else {
                    repositoryMetadata = new MetadataTable();
                }
            } else {
                // value only got a empty string
                repositoryMetadata = new MetadataTable();
            }
        /* see bug 16969 */
        // if (repositoryTableMap.containsKey(schemaSelected)) {
        // repositoryMetadata = repositoryTableMap.get(schemaSelected);
        // // bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
        // newRepositoryIdValue = schemaSelected;// + " - " + repositoryMetadata.getLabel();
        // } else {
        // if (repositoryTableMap.keySet().size() == 0) {
        // repositoryMetadata = new MetadataTable();
        // } else {
        // newRepositoryIdValue = repositoryTableMap.keySet().iterator().next();
        // // Gets the schema of the first item in repository schema type combo.
        // repositoryMetadata = repositoryTableMap.get(newRepositoryIdValue);
        // // bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
        // // newRepositoryIdValue = newRepositoryIdValue + " - " + repositoryMetadata.getLabel();
        // }
        // }
        } else {
            baseCommand = new PropertyChangeCommand(elem, fullParamName, value);
        }
        if (switchParam != null) {
            switchParam.setValue(Boolean.FALSE);
        }
        CompoundCommand cc = new CompoundCommand();
        if (baseCommand != null) {
            cc.add(baseCommand);
        } else {
            RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) elem, fullParamName, value, repositoryMetadata, newRepositoryIdValue, null);
            changeMetadataCommand.setConnection(connection);
            cc.add(changeMetadataCommand);
        }
        // unuse the validation rules of the component.
        if (isValRulesLost) {
            ValidationRulesUtil.appendRemoveValidationRuleCommands(cc, elem);
        }
        return cc;
    }
    return null;
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) Point(org.eclipse.swt.graphics.Point) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)426 ArrayList (java.util.ArrayList)161 List (java.util.List)108 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)95 INode (org.talend.core.model.process.INode)92 HashMap (java.util.HashMap)82 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)37 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)35 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28