Search in sources :

Example 1 with LinkRulesItem

use of org.talend.core.model.properties.LinkRulesItem 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 2 with LinkRulesItem

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

the class MultipleThreadDynamicComposite method updateRepositoryList.

public void updateRepositoryList() {
    ProgressDialog progressDialog = new ProgressDialog(this.getShell(), 1000) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitorWrap = new EventLoopProgressMonitor(monitor);
            IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
            List<IRepositoryViewObject> repositoryObjects = getAllRepositoryMetadata();
            // + elem.getElementParameters().size();
            int total = repositoryObjects.size();
            //$NON-NLS-1$
            monitorWrap.beginTask(Messages.getString("MultipleThreadDynamicComposite.gatherInformation"), total);
            IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, section);
            String repositoryValue = null;
            if (propertyParam != null) {
                repositoryValue = propertyParam.getRepositoryValue();
            }
            if (repositoryObjects != null && (repositoryObjects.size() != 0)) {
                tableIdAndDbTypeMap.clear();
                tableIdAndDbSchemaMap.clear();
                for (IRepositoryViewObject curObject : repositoryObjects) {
                    Item item = curObject.getProperty().getItem();
                    if (item instanceof ConnectionItem) {
                        ConnectionItem connectionItem = (ConnectionItem) item;
                        Connection connection = connectionItem.getConnection();
                        if (connection == null || connection.isReadOnly()) {
                            continue;
                        }
                        for (Object tableObj : ConnectionHelper.getTables(connection)) {
                            org.talend.core.model.metadata.builder.connection.MetadataTable table;
                            table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
                            if (factory.getStatus(connectionItem) != ERepositoryStatus.DELETED) {
                                if (!factory.isDeleted(table)) {
                                    IMetadataTable newTable = ConvertionHelper.convert(table);
                                    // newTable);
                                    if (connection instanceof DatabaseConnection) {
                                        String dbType = ((DatabaseConnection) connection).getDatabaseType();
                                        String schema = ((DatabaseConnection) connection).getUiSchema();
                                        tableIdAndDbTypeMap.put(newTable.getId(), dbType);
                                        if (schema != null && !schema.equals("")) {
                                            //$NON-NLS-1$
                                            tableIdAndDbSchemaMap.put(newTable.getId(), schema);
                                        }
                                    }
                                }
                            }
                        }
                        monitorWrap.worked(1);
                    }
                    // hywang add for feature 6484
                    if (item instanceof FileItem) {
                        FileItem FileItem = (FileItem) item;
                        if (repositoryValue != null) {
                            if (repositoryValue.equals("RULE")) {
                                //$NON-NLS-1$
                                repositoryFileItemMap.put(FileItem.getProperty().getId(), FileItem);
                            }
                        }
                        monitorWrap.worked(1);
                    }
                    if (item instanceof LinkRulesItem) {
                        LinkRulesItem linkItem = (LinkRulesItem) item;
                        if (repositoryValue != null) {
                            if (repositoryValue.equals("RULE")) {
                                //$NON-NLS-1$
                                repositoryLinkRulesItemMap.put(linkItem.getProperty().getId(), linkItem);
                            }
                        }
                        monitorWrap.worked(1);
                    }
                }
            }
            monitorWrap.done();
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
        return;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return;
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) FileItem(org.talend.core.model.properties.FileItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 3 with LinkRulesItem

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

the class ControllerRepositoryValueHander method fastRepositoryUpdateProperty.

private void fastRepositoryUpdateProperty(IElementParameter param) {
    if (param != null && param.getValue() != null) {
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        String linkedRepository = (String) param.getValue();
        // value stored is the id, so we can get this item directly
        Item item;
        String displayName = "";
        try {
            IRepositoryViewObject object = factory.getLastVersion(linkedRepository.split(" - ")[0]);
            if (object == null) {
                return;
            }
            item = object.getProperty().getItem();
            // Assert.isTrue(item instanceof ConnectionItem);
            IESBService service = null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
            }
            if (service != null && ERepositoryObjectType.getItemType(item) == service.getServicesType()) {
                lastItemUsed = (ConnectionItem) item;
                displayName = "Service:" + service.getServiceLabel(item, linkedRepository);
            } else if (item instanceof ConnectionItem) {
                lastItemUsed = (ConnectionItem) item;
                displayName = //$NON-NLS-1$
                RepositoryObjectHelper.getRepositoryAliasName(lastItemUsed) + ":" + lastItemUsed.getProperty().getLabel();
            }
            if (item instanceof FileItem) {
                // hywang add for 6484
                lastFileItemUsed = (FileItem) item;
                if (lastFileItemUsed instanceof RulesItem) {
                    displayName = //$NON-NLS-1$
                    "Rules:" + lastFileItemUsed.getProperty().getLabel();
                }
            }
            if (item instanceof LinkRulesItem) {
                lastLinkItem = (LinkRulesItem) item;
                displayName = //$NON-NLS-1$
                "Rules:" + lastLinkItem.getProperty().getLabel();
            }
            if (StringUtils.isEmpty(displayName)) {
                ITDQPatternService tdqService = null;
                try {
                    tdqService = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
                    if (tdqService != null) {
                        displayName = tdqService.getPatternDisplayName(item);
                    }
                } catch (RuntimeException e) {
                // nothing to do
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
        param.setListItemsDisplayName(new String[] { displayName });
        param.setListItemsValue(new String[] { (String) param.getValue() });
    }
}
Also used : LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) Item(org.talend.core.model.properties.Item) FileItem(org.talend.core.model.properties.FileItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) FileItem(org.talend.core.model.properties.FileItem) IESBService(org.talend.core.IESBService) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ITDQPatternService(org.talend.core.ITDQPatternService) RulesItem(org.talend.core.model.properties.RulesItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 4 with LinkRulesItem

use of org.talend.core.model.properties.LinkRulesItem 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 5 with LinkRulesItem

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

the class ComponentChooseDialog method createRefreshingPropertiesCommand.

/**
     * DOC bqian Comment method "createRefreshingPropertiesCommand".
     *
     * @param selectedNode
     * @param node
     */
private List<Command> createRefreshingPropertiesCommand(CompoundCommand cc, RepositoryNode selectedNode, Node node) {
    // List<Command> list = new ArrayList<Command>();
    if (selectedNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
        String propertyId = selectedNode.getObject().getProperty().getId();
        ConnectionItem originalConnectionItem = (ConnectionItem) selectedNode.getObject().getProperty().getItem();
        ConnectionItem connectionItem = originalConnectionItem;
        Connection originalConnection = connectionItem.getConnection();
        Connection connection = connectionItem.getConnection();
        // if component is CDC, replace by the CDC connection.
        if (node.getComponent().getName().contains("CDC")) {
            // to replace by a flag CDC in component? //$NON-NLS-1$
            if (selectedNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem) {
                final DatabaseConnection databaseConnection = (DatabaseConnection) connection;
                CDCConnection cdcConn = databaseConnection.getCdcConns();
                if (cdcConn != null) {
                    EList cdcTypes = cdcConn.getCdcTypes();
                    if (cdcTypes != null && !cdcTypes.isEmpty()) {
                        CDCType cdcType = (CDCType) cdcTypes.get(0);
                        // replace property by CDC property.
                        propertyId = cdcType.getLinkDB();
                        try {
                            IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
                            if (object != null) {
                                if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                                    DatabaseConnectionItem dbConnItem = (DatabaseConnectionItem) object.getProperty().getItem();
                                    // replace connection by CDC connection
                                    connectionItem = dbConnItem;
                                    connection = dbConnItem.getConnection();
                                }
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                        // set cdc type mode.
                        IElementParameter logModeParam = node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
                        if (logModeParam != null) {
                            String cdcTypeMode = ((DatabaseConnection) originalConnection).getCdcTypeMode();
                            Command logModeCmd = new PropertyChangeCommand(node, EParameterName.CDC_TYPE_MODE.getName(), CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
                            cc.add(logModeCmd);
                        }
                        // set lib for as400 so far.
                        //$NON-NLS-1$
                        final String name = "SOURCE_LIB";
                        IElementParameter libParam = node.getElementParameter(name);
                        if (libParam != null) {
                            Object propValue;
                            if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
                                propValue = databaseConnection.getSID();
                            } else {
                                propValue = TalendTextUtils.addQuotes(databaseConnection.getSID());
                            }
                            Command libSettingCmd = new PropertyChangeCommand(node, name, propValue);
                            cc.add(libSettingCmd);
                        }
                    }
                }
            }
        }
        // fore EBCDIC, by cli
        if ((connectionItem instanceof EbcdicConnectionItem) && PluginChecker.isEBCDICPluginLoaded()) {
            // TDI-20505:integration the drag/drop for EBCDIC connection and EBCDIC metadataTable
            IRepositoryViewObject object = selectedNode.getObject();
            if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_EBCDIC) {
                for (MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
                    Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                    cc.add(ebcdicCmd);
                }
            }
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
                MetadataTable table = null;
                if (object instanceof MetadataTableRepositoryObject) {
                    table = ((MetadataTableRepositoryObject) object).getTable();
                }
                Command ebcdicCmd = new RepositoryChangeMetadataForEBCDICCommand(node, IEbcdicConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                cc.add(ebcdicCmd);
            }
        }
        // fore HL7, by gcui
        if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded())) {
            if (originalConnection instanceof HL7ConnectionImpl) {
                if (((HL7ConnectionImpl) originalConnection).getRoot() != null) {
                    List<Map<String, String>> mapList = new ArrayList<Map<String, String>>();
                    for (Object obj : ((HL7ConnectionImpl) originalConnection).getRoot()) {
                        if (obj instanceof HL7FileNode) {
                            Map<String, String> newMap = new HashMap<String, String>();
                            newMap.put(IHL7Constant.ATTRIBUTE, ((HL7FileNode) obj).getAttribute());
                            newMap.put(IHL7Constant.PATH, ((HL7FileNode) obj).getFilePath());
                            newMap.put(IHL7Constant.COLUMN, ((HL7FileNode) obj).getRelatedColumn());
                            newMap.put(IHL7Constant.ORDER, String.valueOf(((HL7FileNode) obj).getOrder()));
                            newMap.put(IHL7Constant.VALUE, ((HL7FileNode) obj).getDefaultValue());
                            newMap.put(IHL7Constant.REPEATABLE, String.valueOf(((HL7FileNode) obj).isRepeatable()));
                            mapList.add(newMap);
                        }
                    }
                    IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
                    if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("ROOT").setValue(mapList);
                    }
                    String fileName = ((HL7ConnectionImpl) originalConnection).getOutputFilePath();
                    if (externalNode != null && externalNode.getElementParameter("FILENAME") != null && fileName != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("FILENAME").setValue(TalendTextUtils.addQuotes(fileName));
                    }
                }
            }
            // fore HL7, by gcui
            if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
                for (MetadataTable table : ConnectionHelper.getTablesWithOrders(originalConnection)) {
                    Command hl7Cmd = new RepositoryChangeMetadataForHL7Command(node, IHL7Constant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table));
                    cc.add(hl7Cmd);
                }
            }
        }
        // for brms
        if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded())) {
            if (originalConnection instanceof BRMSConnectionImpl) {
                if (((BRMSConnectionImpl) originalConnection).getRoot() != null) {
                    List<Map<String, String>> rootList = new ArrayList<Map<String, String>>();
                    List<Map<String, String>> loopList = new ArrayList<Map<String, String>>();
                    List<Map<String, String>> groupList = new ArrayList<Map<String, String>>();
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getRoot()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> rootMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            rootMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            rootMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            rootMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            rootMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            rootMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            rootList.add(rootMap);
                        }
                    }
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getLoop()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> loopMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            loopMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            loopMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            loopMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            loopMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            loopMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            loopList.add(loopMap);
                        }
                    }
                    for (Object obj : ((BRMSConnectionImpl) originalConnection).getGroup()) {
                        if (obj instanceof XMLFileNode) {
                            Map<String, String> groupMap = new HashMap<String, String>();
                            //$NON-NLS-1$
                            groupMap.put("ATTRIBUTE", ((XMLFileNode) obj).getAttribute());
                            //$NON-NLS-1$
                            groupMap.put("PATH", ((XMLFileNode) obj).getXMLPath());
                            //$NON-NLS-1$
                            groupMap.put("COLUMN", ((XMLFileNode) obj).getRelatedColumn());
                            //$NON-NLS-1$
                            groupMap.put("ORDER", String.valueOf(((XMLFileNode) obj).getOrder()));
                            //$NON-NLS-1$
                            groupMap.put("VALUE", ((XMLFileNode) obj).getDefaultValue());
                            groupList.add(groupMap);
                        }
                    }
                    IExternalNode externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
                    if (externalNode != null && externalNode.getElementParameter("ROOT") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("ROOT").setValue(rootList);
                    }
                    if (externalNode != null && externalNode.getElementParameter("LOOP") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("LOOP").setValue(loopList);
                    }
                    if (externalNode != null && externalNode.getElementParameter("GROUP") != null) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        externalNode.getElementParameter("GROUP").setValue(groupList);
                    }
                }
            }
        }
        IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (propertyParam != null) {
            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(propertyId);
        }
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        Map<String, IMetadataTable> repositoryTableMap = new HashMap<String, IMetadataTable>();
        if (!originalConnection.isReadOnly()) {
            for (Object tableObj : ConnectionHelper.getTables(originalConnection)) {
                org.talend.core.model.metadata.builder.connection.MetadataTable table;
                table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
                if (factory.getStatus(originalConnectionItem) != ERepositoryStatus.DELETED) {
                    if (!factory.isDeleted(table)) {
                        String value = table.getId();
                        IMetadataTable newTable = ConvertionHelper.convert(table);
                        repositoryTableMap.put(value, newTable);
                    }
                }
            }
        }
        // DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion("")
        if (propertyParam != null) {
            // command used to set property type
            IMetadataTable metadataTable = null;
            // && selectedNode.getObjectType() == ERepositoryObjectType.METADATA_CON_TABLE) {
            if (selectedNode.getObject() instanceof IMetadataTable) {
                metadataTable = (IMetadataTable) selectedNode.getObject();
                if (metadataTable != null && repositoryTableMap.get(metadataTable.getId()) != null) {
                    metadataTable = repositoryTableMap.get(metadataTable.getId());
                }
            }
            // }
            ChangeValuesFromRepository command1 = new ChangeValuesFromRepository(node, connection, metadataTable, propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), propertyId, //$NON-NLS-1$
            true);
            command1.setMaps(repositoryTableMap);
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) != ERepositoryObjectType.METADATA_CON_QUERY) {
                command1.setGuessQuery(true);
            }
            setSAPSpecailValueForCommand(selectedNode, command1);
            // for salesForce module
            SalesforceModuleRepositoryObject sfObject = null;
            if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
                sfObject = (SalesforceModuleRepositoryObject) selectedNode.getObject();
            } else if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
                IRepositoryViewObject object = selectedNode.getParent().getObject();
                if (object instanceof SalesforceModuleRepositoryObject) {
                    sfObject = (SalesforceModuleRepositoryObject) object;
                }
            }
            if (sfObject != null) {
                ModelElement modelElement = sfObject.getModelElement();
                if (modelElement instanceof SalesforceModuleUnit) {
                    command1.setSalesForceModuleUnit((SalesforceModuleUnit) modelElement);
                }
            }
            cc.add(command1);
        }
        // command used to set metadata
        getChangeMetadataCommand(cc, selectedNode, node, originalConnectionItem);
        // command used to set query
        if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_QUERY) {
            IElementParameter queryParam = node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
            QueryRepositoryObject object = (QueryRepositoryObject) selectedNode.getObject();
            Query query = object.getQuery();
            //$NON-NLS-1$
            String value = originalConnectionItem.getProperty().getId() + " - " + query.getLabel();
            if (queryParam != null) {
                RepositoryChangeQueryCommand command3 = new RepositoryChangeQueryCommand(node, query, queryParam.getName() + ":" + EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(), //$NON-NLS-1$
                value);
                cc.add(command3);
            }
        } else {
            if (connection instanceof DatabaseConnection && hasQuery(node)) {
                DatabaseConnection connection2 = (DatabaseConnection) connection;
                String schema = connection2.getUiSchema();
                String dbType = connection2.getDatabaseType();
                QueryGuessCommand queryGuessCommand = null;
                if (node.getMetadataList().size() == 0) {
                    queryGuessCommand = new QueryGuessCommand(node, null, schema, dbType);
                } else {
                    // modified by hyWang for bug 7190
                    queryGuessCommand = new QueryGuessCommand(node, node.getMetadataList().get(0), schema, dbType, connection);
                }
                if (queryGuessCommand != null) {
                    cc.add(queryGuessCommand);
                }
            }
        }
    // context, moved to ChangeValuesFromRepository(bug 5198)
    // ConnectionContextHelper.addContextForNodeParameter(node, connectionItem);
    } else if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
        ProcessItem processItem = (ProcessItem) selectedNode.getObject().getProperty().getItem();
        // command used to set job
        String value = processItem.getProperty().getId();
        PropertyChangeCommand command4 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_PROCESS.getName(), value);
        cc.add(command4);
        PropertyChangeCommand command5 = new PropertyChangeCommand(node, EParameterName.PROCESS_TYPE_CONTEXT.getName(), processItem.getProcess().getDefaultContext());
        cc.add(command5);
    } else if (selectedNode.getObject().getProperty().getItem() instanceof FileItem) {
        // hywang add for 6484
        if (selectedNode.getObject().getProperty().getItem() instanceof RulesItem) {
            RulesItem rulesItem = (RulesItem) selectedNode.getObject().getProperty().getItem();
            //                String displayName = "Rules:" + rulesItem.getProperty().getLabel(); //$NON-NLS-N$
            IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
            if (propertyParam != null) {
                propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
                // propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
                // .setListItemsDisplayName(new String[] { displayName });
                final String showId = rulesItem.getProperty().getId();
                PropertyChangeCommand command6 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
                cc.add(command6);
            }
        }
    } else if (selectedNode.getObject().getProperty().getItem() instanceof LinkRulesItem) {
        LinkRulesItem linkItem = (LinkRulesItem) selectedNode.getObject().getProperty().getItem();
        IElementParameter propertyParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
        if (propertyParam != null) {
            propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            // propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName())
            // .setListItemsDisplayName(new String[] { displayName });
            final String showId = linkItem.getProperty().getId();
            PropertyChangeCommand command7 = new PropertyChangeCommand(node, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
            cc.add(command7);
        }
    }
    return null;
}
Also used : Query(org.talend.core.model.metadata.builder.connection.Query) HashMap(java.util.HashMap) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ArrayList(java.util.ArrayList) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HL7ConnectionImpl(org.talend.core.model.metadata.builder.connection.impl.HL7ConnectionImpl) SalesforceModuleUnit(org.talend.core.model.metadata.builder.connection.SalesforceModuleUnit) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) BRMSConnectionImpl(org.talend.core.model.metadata.builder.connection.impl.BRMSConnectionImpl) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) 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) Map(java.util.Map) HashMap(java.util.HashMap) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) 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) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) RulesItem(org.talend.core.model.properties.RulesItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IExternalNode(org.talend.core.model.process.IExternalNode) PolylineConnection(org.eclipse.draw2d.PolylineConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) 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) EbcdicConnectionItem(org.talend.core.model.properties.EbcdicConnectionItem) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) EList(org.eclipse.emf.common.util.EList) 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) CDCType(org.talend.core.model.metadata.builder.connection.CDCType)

Aggregations

ConnectionItem (org.talend.core.model.properties.ConnectionItem)5 FileItem (org.talend.core.model.properties.FileItem)5 LinkRulesItem (org.talend.core.model.properties.LinkRulesItem)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)4 Item (org.talend.core.model.properties.Item)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 RulesItem (org.talend.core.model.properties.RulesItem)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 ArrayList (java.util.ArrayList)2 Command (org.eclipse.gef.commands.Command)2 IESBService (org.talend.core.IESBService)2 ITDQPatternService (org.talend.core.ITDQPatternService)2 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)2 CDCConnection (org.talend.core.model.metadata.builder.connection.CDCConnection)2 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)2