Search in sources :

Example 1 with XmlFileConnection

use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.

the class ImportTreeFromRepository method run.

@Override
public void run() {
    targetAbsolutePath = null;
    loopNode = null;
    xpathAndOrder.clear();
    RepositoryXmlSelectionDialog reviewDialog = new RepositoryXmlSelectionDialog(shell, new String[] { "XML", "MDM" });
    if (reviewDialog.open() == Window.OK) {
        TreeNode treeNodeRoot = XmlMapUtil.getTreeNodeRoot(schemaNode);
        XmlMapUtil.detachNodeConnections(treeNodeRoot, mapperManager.getExternalData(), true);
        RepositoryNode repositoryNode = reviewDialog.getResult();
        Item item = repositoryNode.getObject().getProperty().getItem();
        String detailedMessage = "";
        try {
            if (item instanceof XmlFileConnectionItem) {
                XmlFileConnectionItem xmlitem = (XmlFileConnectionItem) item;
                XmlFileConnection connection = (XmlFileConnection) xmlitem.getConnection();
                prepareEmfTreeFromXml(connection);
            } else if (item instanceof MDMConnectionItem) {
                String selectedSchema = (String) repositoryNode.getProperties(EProperties.LABEL);
                MDMConnection connection = (MDMConnection) ((MDMConnectionItem) item).getConnection();
                prepareEmfTreeFromMdm(connection, selectedSchema);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
            StringBuffer sb = new StringBuffer();
            sb.append(e.toString());
            sb.append("\n");
            if (e.getStackTrace() != null) {
                for (StackTraceElement trace : e.getStackTrace()) {
                    sb.append(trace.toString());
                    sb.append("\n");
                }
            }
            detailedMessage = sb.toString();
        }
        boolean childrenEmpty = false;
        if (schemaNode.getChildren().isEmpty()) {
            childrenEmpty = true;
            TreeNode rootNode = createModel();
            rootNode.setName("root");
            rootNode.setNodeType(NodeType.ELEMENT);
            rootNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
            rootNode.setXpath(XmlMapUtil.getXPath(schemaNode.getXpath(), "root", NodeType.ELEMENT));
            schemaNode.getChildren().add(rootNode);
            if (loopNode == null) {
                schemaNode.getChildren().get(0).setLoop(true);
                schemaNode.getChildren().get(0).setMain(true);
            }
        }
        if (childrenEmpty || (detailedMessage != null && !"".equals(detailedMessage))) {
            showError(detailedMessage);
        }
        AbstractInOutTree tree = null;
        if (schemaNode.eContainer() instanceof InputXmlTree) {
            XmlMapConnectionBuilder connectionBuilder = new XmlMapConnectionBuilder();
            connectionBuilder.setCheckRootNodePrefix(true);
            connectionBuilder.rebuildLinks(schemaNode, mapperManager.getExternalData());
            mapperManager.refreshTreeSchemaEditor((InputXmlTree) schemaNode.eContainer());
            // mapperManager.inputTreeSchemaBeanListModified();
            tree = (InputXmlTree) schemaNode.eContainer();
        } else if (schemaNode.eContainer() instanceof OutputXmlTree) {
            // mapperManager.outputTreeSchemaBeanListModified();
            mapperManager.refreshTreeSchemaEditor((OutputXmlTree) schemaNode.eContainer());
            tree = (OutputXmlTree) schemaNode.eContainer();
        }
        if (tree != null) {
            mapperManager.getProblemsAnalyser().checkProblems(tree);
            mapperManager.getMapperUI().updateStatusBar();
        }
    }
}
Also used : RepositoryXmlSelectionDialog(org.talend.designer.xmlmap.ui.dialog.RepositoryXmlSelectionDialog) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) XmlMapConnectionBuilder(org.talend.designer.xmlmap.util.XmlMapConnectionBuilder) FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 2 with XmlFileConnection

use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.

the class ChangeValuesFromRepository method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    // Force redraw of Commponents propoerties
    elem.setPropertyValue(updataComponentParamName, new Boolean(true));
    boolean allowAutoSwitch = true;
    IElementParameter elemParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
    if (elemParam != null) {
        // add for TDI-8053
        elemParam.setValue(Boolean.FALSE);
        allowAutoSwitch = (Boolean) elemParam.getValue();
    }
    if (!allowAutoSwitch && (elem instanceof Node)) {
        // force the autoSwitch to true if the schema is empty and if the
        // query is not set.
        Node node = (Node) elem;
        boolean isSchemaEmpty = false;
        if (node.getMetadataList().size() > 0) {
            isSchemaEmpty = node.getMetadataList().get(0).getListColumns().size() == 0;
        } else {
            isSchemaEmpty = true;
        }
        for (IElementParameter curParam : node.getElementParameters()) {
            if (curParam.getFieldType().equals(EParameterFieldType.MEMO_SQL)) {
                if (curParam.getDefaultValues().size() > 0) {
                }
            }
        }
        if (isSchemaEmpty) {
            allowAutoSwitch = true;
        }
        if (((INode) elem).getComponent().getName().equals("tWebService")) {
            //$NON-NLS-1$
            allowAutoSwitch = true;
        }
    }
    if (propertyName.split(":")[1].equals(propertyTypeName)) {
        //$NON-NLS-1$
        elem.setPropertyValue(propertyName, value);
        if (allowAutoSwitch) {
            // Update spark mode to YARN_CLIENT if repository
            if (elem instanceof IProcess) {
                if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(((IProcess) elem).getComponentsType()) || ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(((IProcess) elem).getComponentsType())) {
                    if (EmfComponent.REPOSITORY.equals(value)) {
                        IElementParameter sparkLocalParam = ((IProcess) elem).getElementParameter(HadoopConstants.SPARK_LOCAL_MODE);
                        IElementParameter sparkParam = ((IProcess) elem).getElementParameter(HadoopConstants.SPARK_MODE);
                        if (sparkLocalParam != null && (Boolean) (sparkLocalParam.getValue())) {
                            sparkLocalParam.setValue(false);
                        }
                        if (sparkParam != null && !HadoopConstants.SPARK_MODE_YARN_CLIENT.equals(sparkParam.getValue())) {
                            sparkParam.setValue(HadoopConstants.SPARK_MODE_YARN_CLIENT);
                        }
                    }
                }
            }
            setOtherProperties();
        }
    } else {
        oldMetadata = (String) elem.getPropertyValue(propertyName);
        elem.setPropertyValue(propertyName, value);
        if (allowAutoSwitch) {
            setOtherProperties();
        }
    }
    String propertyParamName = null;
    if (elem.getElementParameter(propertyName).getParentParameter() != null) {
        IElementParameter param = elem.getElementParameter(propertyName).getParentParameter();
        if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
            propertyParamName = param.getName();
        }
    }
    if (propertyName.split(":")[1].equals(propertyTypeName) && (EmfComponent.BUILTIN.equals(value))) {
        //$NON-NLS-1$
        for (IElementParameter param : elem.getElementParameters()) {
            if (param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
                continue;
            }
            boolean paramFlag = JobSettingsConstants.isExtraParameter(param.getName());
            //$NON-NLS-1$
            boolean extraFlag = JobSettingsConstants.isExtraParameter(propertyName.split(":")[0]);
            if (paramFlag == extraFlag) {
                // for memo sql
                if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
                    IElementParameter querystoreParam = elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE, param.getCategory());
                    if (querystoreParam != null) {
                        Map<String, IElementParameter> childParam = querystoreParam.getChildParameters();
                        if (childParam != null) {
                            IElementParameter queryTypeParam = childParam.get(EParameterName.QUERYSTORE_TYPE.getName());
                            if (queryTypeParam != null && EmfComponent.REPOSITORY.equals(queryTypeParam.getValue())) {
                                continue;
                            }
                        }
                    }
                }
                if (param.getRepositoryValue() != null) {
                    param.setReadOnly(false);
                    // for job settings extra.(feature 2710)
                    param.setRepositoryValueUsed(false);
                }
            }
        }
    } else {
        oldValues.clear();
        List<ComponentProperties> componentProperties = null;
        IGenericWizardService wizardService = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
            wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
        }
        if (wizardService != null && wizardService.isGenericConnection(connection)) {
            componentProperties = wizardService.getAllComponentProperties(connection, null);
        }
        IElementParameter propertyParam = elem.getElementParameter(propertyName);
        List<IElementParameter> elementParameters = new ArrayList<>(elem.getElementParameters());
        for (IElementParameter param : elementParameters) {
            String repositoryValue = param.getRepositoryValue();
            if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                continue;
            }
            boolean isGenericRepositoryValue = RepositoryToComponentProperty.isGenericRepositoryValue(connection, componentProperties, param.getName());
            if (repositoryValue == null && isGenericRepositoryValue) {
                repositoryValue = param.getName();
                param.setRepositoryValue(repositoryValue);
                param.setRepositoryValueUsed(true);
            }
            if (repositoryValue == null || param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
                continue;
            }
            String componentName = elem instanceof INode ? (((INode) elem).getComponent().getName()) : null;
            boolean b = elem instanceof INode && (//$NON-NLS-1$
            ((INode) elem).getComponent().getName().equals("tHL7Input") || //$NON-NLS-1$
            ((INode) elem).getComponent().getName().equals("tAdvancedFileOutputXML") || ((INode) elem).getComponent().getName().equals("tMDMOutput") || ((INode) elem).getComponent().getName().equals("tWebService") || ((INode) elem).getComponent().getName().equals("tCreateTable") || //$NON-NLS-1$
            ((INode) elem).getComponent().getName().equals("tWriteJSONField"));
            if ((//$NON-NLS-1$
            "TYPE".equals(repositoryValue) || (isGenericRepositoryValue || param.isShow(elem.getElementParameters())) || b) && (!param.getName().equals(propertyTypeName))) {
                if (param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(propertyParamName)) {
                    continue;
                }
                Object objectValue = null;
                if (connection instanceof XmlFileConnection && this.dragAndDropAction == true && repositoryValue.equals("FILE_PATH") && reOpenXSDBool == true) {
                    objectValue = RepositoryToComponentProperty.getXmlAndXSDFileValue((XmlFileConnection) connection, repositoryValue);
                } else if (connection instanceof SalesforceSchemaConnection && "MODULENAME".equals(repositoryValue)) {
                    //$NON-NLS-1$
                    if (this.moduleUnit != null) {
                        objectValue = moduleUnit.getModuleName();
                    } else {
                        objectValue = null;
                    }
                } else // module which was the last one be retrived
                if (connection instanceof SalesforceSchemaConnection && "CUSTOM_MODULE_NAME".equals(repositoryValue)) {
                    //$NON-NLS-1$
                    if (this.moduleUnit != null) {
                        objectValue = moduleUnit.getModuleName();
                    } else {
                        objectValue = null;
                    }
                } else if (connection instanceof MDMConnection) {
                    if (table == null) {
                        IMetadataTable metaTable = null;
                        if (((Node) elem).getMetadataList().size() > 0) {
                            metaTable = ((Node) elem).getMetadataList().get(0);
                        }
                        objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, metaTable);
                    } else {
                        objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, table);
                    }
                } else if (connection instanceof WSDLSchemaConnection && "USE_PROXY".equals(repositoryValue)) {
                    //$NON-NLS-1$
                    objectValue = ((WSDLSchemaConnection) connection).isUseProxy();
                } else {
                    IMetadataTable metaTable = table;
                    if (metaTable == null && elem instanceof Node) {
                        INodeConnector conn = ((Node) elem).getConnectorFromType(EConnectionType.FLOW_MAIN);
                        if (conn != null && conn.getMaxLinkOutput() == 1) {
                            metaTable = ((Node) elem).getMetadataFromConnector(conn.getName());
                        }
                    }
                    objectValue = RepositoryToComponentProperty.getValue(connection, repositoryValue, metaTable, componentName);
                }
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IJsonFileService.class)) {
                    IJsonFileService jsonService = (IJsonFileService) GlobalServiceRegister.getDefault().getService(IJsonFileService.class);
                    boolean paramChanged = jsonService.changeFilePathFromRepository(connection, param, elem, objectValue);
                    if (paramChanged) {
                        continue;
                    }
                }
                if (objectValue != null) {
                    oldValues.put(param.getName(), param.getValue());
                    if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("TYPE")) {
                        //$NON-NLS-1$
                        String dbVersion = "";
                        if (connection instanceof DatabaseConnection) {
                            dbVersion = ((DatabaseConnection) connection).getDbVersionString();
                        }
                        boolean found = false;
                        String[] list = param.getListRepositoryItems();
                        for (int i = 0; (i < list.length) && (!found); i++) {
                            if (objectValue.equals(list[i])) {
                                found = true;
                                elem.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
                            }
                        }
                        IElementParameter elementParameter = null;
                        IElementParameter elementParameter2 = null;
                        if (EParameterName.DB_TYPE.getName().equals(param.getName())) {
                            elementParameter = elem.getElementParameter(EParameterName.DB_VERSION.getName());
                            elementParameter2 = elem.getElementParameter(EParameterName.SCHEMA_DB.getName());
                        } else {
                            elementParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName()));
                            elementParameter2 = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
                        }
                        String dbType = "";
                        if (param.getValue() != null) {
                            int indexOfItemFromList = param.getIndexOfItemFromList(param.getValue().toString());
                            if (indexOfItemFromList != -1) {
                                dbType = param.getListItemsDisplayCodeName()[indexOfItemFromList];
                            }
                        }
                        // Some DB not need fill the schema parameter for the JobSetting View "Extra" ,"Stats&Logs"
                        if (elementParameter2 != null && !elementParameter2.isShow(elem.getElementParameters()) && !elementParameter2.getValue().equals("")) {
                            elementParameter2.setValue("");
                        }
                        if (StatsAndLogsConstants.JDBC.equals(dbType)) {
                            IElementParameter dbNameParm = elem.getElementParameter(EParameterName.DBNAME.getName());
                            if (dbNameParm != null) {
                                dbNameParm.setValue("");
                            }
                        } else {
                            IElementParameter rulParam = elem.getElementParameter(EParameterName.URL.getName());
                            if (rulParam != null) {
                                rulParam.setValue("");
                            }
                            IElementParameter classParam = elem.getElementParameter(EParameterName.DRIVER_CLASS.getName());
                            if (classParam != null) {
                                classParam.setValue("");
                            }
                            IElementParameter jarParam = elem.getElementParameter(EParameterName.DRIVER_JAR.getName());
                            if (jarParam != null) {
                                jarParam.setValue(new ArrayList<Map<String, Object>>());
                            }
                        }
                        JobSettingVersionUtil.setDbVersion(elementParameter, dbVersion, false);
                        DesignerUtilities.setSchemaDB(elementParameter2, param.getValue());
                    } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("FRAMEWORK_TYPE")) {
                        //$NON-NLS-1$
                        String[] list = param.getListItemsDisplayName();
                        for (int i = 0; i < list.length; i++) {
                            if (objectValue.equals(list[i])) {
                                elem.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
                            }
                        }
                    } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("EDI_VERSION")) {
                        String[] list = param.getListItemsDisplayName();
                        for (String element : list) {
                            if (objectValue.toString().toUpperCase().equals(element)) {
                                elem.setPropertyValue(param.getName(), objectValue);
                            }
                        }
                    } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("DRIVER")) {
                        String[] list = param.getListItemsDisplayCodeName();
                        for (String element : list) {
                            if (objectValue.toString().toUpperCase().equals(element)) {
                                elem.setPropertyValue(param.getName(), objectValue);
                            }
                        }
                    } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && param.getRepositoryValue().equals("CONNECTION_MODE")) {
                        //$NON-NLS-1$
                        if (!objectValue.equals(param.getValue())) {
                            //$NON-NLS-1$
                            PropertyChangeCommand cmd = new PropertyChangeCommand(elem, "CONNECTION_MODE", objectValue);
                            cmd.execute();
                        }
                    } else {
                        if (repositoryValue.equals("ENCODING")) {
                            //$NON-NLS-1$
                            IElementParameter paramEncoding = param.getChildParameters().get(EParameterName.ENCODING_TYPE.getName());
                            if (connection instanceof FTPConnection) {
                                if (((FTPConnection) connection).getEcoding() != null) {
                                    paramEncoding.setValue(((FTPConnection) connection).getEcoding());
                                } else {
                                    paramEncoding.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
                                }
                            } else {
                                if (objectValue instanceof String) {
                                    String str = TalendTextUtils.removeQuotes((String) objectValue);
                                    if (str.equals(EmfComponent.ENCODING_TYPE_UTF_8)) {
                                        paramEncoding.setValue(EmfComponent.ENCODING_TYPE_UTF_8);
                                    } else if (str.equals(EmfComponent.ENCODING_TYPE_ISO_8859_15)) {
                                        paramEncoding.setValue(EmfComponent.ENCODING_TYPE_ISO_8859_15);
                                    } else {
                                        paramEncoding.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
                                    // paramEncoding.setRepositoryValueUsed(true);
                                    }
                                }
                            }
                        } else if (repositoryValue.equals("CSV_OPTION")) {
                            //$NON-NLS-1$
                            setOtherProperties();
                        }
                        if (repositoryValue.equals("MODULENAME")) {
                            //$NON-NLS-1$
                            List list = new ArrayList();
                            Object[] listItemsValue = elem.getElementParameter("MODULENAME").getListItemsValue();
                            for (Object element : listItemsValue) {
                                list.add(element);
                            }
                            if (list != null && !list.contains(objectValue)) {
                                //$NON-NLS-1$
                                objectValue = "CustomModule";
                            }
                        }
                        // hywang add for excel 2007
                        if (repositoryValue.equals(EParameterName.FILE_PATH.getName())) {
                            String filePath = "";
                            if (connection.isContextMode()) {
                                ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
                                if (contextItem != null) {
                                    String selectedContext = contextItem.getDefaultContext();
                                    final ContextType contextTypeByName = ContextUtils.getContextTypeByName(contextItem, selectedContext, true);
                                    filePath = ConnectionContextHelper.getOriginalValue(contextTypeByName, objectValue.toString());
                                }
                            } else {
                                filePath = TalendTextUtils.removeQuotes(objectValue.toString());
                            }
                            boolean versionCheckFor2007 = false;
                            if (filePath != null && filePath.endsWith(".xlsx")) {
                                versionCheckFor2007 = true;
                            }
                            if (elem.getElementParameter("VERSION_2007") != null) {
                                elem.setPropertyValue("VERSION_2007", versionCheckFor2007);
                            }
                        }
                        if (param.getFieldType().equals(EParameterFieldType.FILE)) {
                            if (objectValue != null) {
                                objectValue = objectValue.toString().replace("\\", "/");
                            }
                        }
                        elem.setPropertyValue(param.getName(), objectValue);
                    }
                    param.setRepositoryValueUsed(true);
                } else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("XML_MAPPING")) {
                    //$NON-NLS-1$
                    List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
                    if (((Node) elem).getMetadataList().size() > 0) {
                        IMetadataTable metaTable = ((Node) elem).getMetadataList().get(0);
                        //$NON-NLS-1$
                        RepositoryToComponentProperty.getTableXmlFileValue(//$NON-NLS-1$
                        connection, //$NON-NLS-1$
                        "XML_MAPPING", //$NON-NLS-1$
                        param, table, metaTable);
                        param.setRepositoryValueUsed(true);
                    }
                } else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("WSDL_PARAMS") && connection != null) {
                    //$NON-NLS-1$
                    List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
                    table.clear();
                    ArrayList parameters = ((WSDLSchemaConnection) connection).getParameters();
                    if (parameters != null) {
                        for (Object object : parameters) {
                            Map<String, Object> map2 = new HashMap<String, Object>();
                            //$NON-NLS-1$
                            map2.put("VALUE", TalendTextUtils.addQuotes(object.toString()));
                            table.add(map2);
                        }
                    }
                    param.setRepositoryValueUsed(true);
                } else if (param.getFieldType().equals(EParameterFieldType.TEXT) && "XPATH_QUERY".equals(param.getRepositoryValue())) {
                    //$NON-NLS-1$
                    param.setRepositoryValueUsed(true);
                } else {
                    // For SAP
                    String paramName = param.getName();
                    if ("SAP_PROPERTIES".equals(paramName) || "MAPPING_INPUT".equals(paramName) || // INPUT_PARAMS should be MAPPING_INPUT,bug16426
                    "SAP_FUNCTION".equals(paramName) || "OUTPUT_PARAMS".equals(paramName) || "SAP_ITERATE_OUT_TYPE".equals(paramName) || "SAP_ITERATE_OUT_TABLENAME".equals(paramName)) {
                        SAPParametersUtils.retrieveSAPParams(elem, connection, param, getSapFunctionLabel());
                    }
                    if ("GATEWAYSERVICE".equals(paramName) || "PROGRAMID".equals(paramName) || "FORMAT_XML".equals(paramName) || "FILE_IDOC_XML".equals(paramName) || "FORMAT_HTML".equals(paramName) || "FILE_IDOC_HTML".equals(paramName)) {
                        SAPParametersUtils.getSAPIDocParams(elem, connection, param, getSapIDocLabel());
                    }
                }
                if (param.isRepositoryValueUsed()) {
                    if (("GENERATION_MODE").equals(param.getName())) {
                        param.setReadOnly(true);
                    } else {
                        param.setReadOnly(false);
                    }
                }
            }
        }
        // (bug 5198)
        IElementParameter parentParameter = propertyParam.getParentParameter();
        if (parentParameter != null) {
            IElementParameter param = parentParameter.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            if (param != null && propertyParam == param) {
                // avoid to process twice.
                ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId((String) param.getValue());
                if (connItem != null) {
                    if (elem instanceof Node) {
                        ConnectionContextHelper.addContextForNodeParameter((Node) elem, connItem, ignoreContextMode);
                    } else if (elem instanceof Process) {
                        ConnectionContextHelper.addContextForProcessParameter((Process) elem, connItem, param.getCategory(), ignoreContextMode);
                    }
                }
            }
        }
    }
    toUpdate = false;
    // change AS400 value
    for (IElementParameter curParam : elem.getElementParameters()) {
        if (curParam.getFieldType().equals(EParameterFieldType.AS400_CHECK)) {
            setOtherProperties();
        }
        // change the HL7 Version
        if (connection instanceof HL7Connection) {
            if (curParam.getName().equals("HL7_VER")) {
                String hl7VersionString = connection.getVersion();
                if (hl7VersionString != null) {
                    hl7VersionString = hl7VersionString.replace(".", "");
                    curParam.setValue(hl7VersionString);
                }
            }
        }
        setDefaultValues(curParam, elem);
    }
    if (elem instanceof Node) {
        // Xstream Cdc Type Mode
        boolean isXstreamCdcTypeMode = false;
        if (connection != null && connection instanceof DatabaseConnection) {
            String cdcTypeMode = ((DatabaseConnection) connection).getCdcTypeMode();
            if (CDCTypeMode.XSTREAM_MODE == CDCTypeMode.indexOf(cdcTypeMode)) {
                isXstreamCdcTypeMode = true;
            }
        }
        if (isXstreamCdcTypeMode && ((Node) elem).getComponent().getName().equals("tOracleCDC")) {
            //$NON-NLS-1$
            IMetadataTable table = ((Node) elem).getMetadataList().get(0);
            IElementParameter schemaParam = elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
            schemaParam.setValueToDefault(elem.getElementParameters());
            table.setListColumns((((IMetadataTable) schemaParam.getValue()).clone(true)).getListColumns());
        }
        ((Process) ((Node) elem).getProcess()).checkProcess();
        // Added TDQ-11688 show regex when "built-in"
        ITDQPatternService service = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
            service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
        }
        if (service != null && service.isSinglePatternNode(elem)) {
            IElementParameter regexParameter = ((Node) elem).getElementParameter("PATTERN_REGEX");
            if (regexParameter != null) {
                regexParameter.setShow(EmfComponent.BUILTIN.equals(this.value));
            }
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) INode(org.talend.core.model.process.INode) ComponentProperties(org.talend.components.api.properties.ComponentProperties) HashMap(java.util.HashMap) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector) IElementParameter(org.talend.core.model.process.IElementParameter) IGenericWizardService(org.talend.core.runtime.services.IGenericWizardService) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) List(java.util.List) ArrayList(java.util.ArrayList) ITDQPatternService(org.talend.core.ITDQPatternService) IProcess(org.talend.core.model.process.IProcess) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) IJsonFileService(org.talend.core.service.IJsonFileService) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Map(java.util.Map) HashMap(java.util.HashMap) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Example 3 with XmlFileConnection

use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.

the class FileController method setDragAndDropActionBool.

private void setDragAndDropActionBool() {
    IElementParameter propertyParam = elem.getElementParameter("PROPERTY:REPOSITORY_PROPERTY_TYPE");
    try {
        if (propertyParam != null && propertyParam.getValue() != null && !"".equals(propertyParam.getValue())) {
            Item linkedRepositoryItem = null;
            IRepositoryViewObject repository = DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion(propertyParam.getValue().toString());
            if (repository != null && repository.getProperty() != null) {
                linkedRepositoryItem = repository.getProperty().getItem();
            }
            if (linkedRepositoryItem != null && linkedRepositoryItem instanceof XmlFileConnectionItem) {
                XmlFileConnectionItem xci = (XmlFileConnectionItem) linkedRepositoryItem;
                XmlFileConnection cc = (XmlFileConnection) xci.getConnection();
                String xmlFilePath = cc.getXmlFilePath();
                if (xmlFilePath != null && XmlUtil.isXSDFile(TalendQuoteUtils.removeQuotes(xmlFilePath))) {
                    dragAndDropActionBool = true;
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem)

Example 4 with XmlFileConnection

use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.

the class UpdateNodeParameterCommand method updateProperty.

@SuppressWarnings("unchecked")
private void updateProperty() {
    Object updateObject = result.getUpdateObject();
    if (updateObject == null) {
        return;
    }
    if (updateObject instanceof Node) {
        // opened job
        Node node = (Node) updateObject;
        boolean update = false;
        // added by wzhang for bug 9302
        boolean isXsdPath = false;
        Object parameter = result.getParameter();
        IElementParameter curPropertyParam = null;
        //$NON-NLS-1$
        String parentParamName = "PROPERTY";
        ConnectionItem connectionItem = null;
        if (parameter instanceof ConnectionItem) {
            if (parameter instanceof XmlFileConnectionItem) {
                String filePath = ((XmlFileConnection) ((XmlFileConnectionItem) parameter).getConnection()).getXmlFilePath();
                if (filePath != null) {
                    if (XmlUtil.isXSDFile(filePath)) {
                        isXsdPath = true;
                    }
                }
            }
            connectionItem = (ConnectionItem) result.getParameter();
            for (IElementParameter param : node.getElementParameters()) {
                if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue().equals(connectionItem.getProperty().getId())) {
                    curPropertyParam = param;
                    parentParamName = curPropertyParam.getName();
                    if (connectionItem != null) {
                        ConnectionContextHelper.addContextForNodeParameter(node, connectionItem, false);
                    }
                    break;
                }
            }
        }
        if (result.getResultType() == EUpdateResult.UPDATE) {
            // upgrade from repository
            if (result.isChecked() && connectionItem != null) {
                List<? extends IElementParameter> elemParameters = new ArrayList<>(node.getElementParameters());
                for (IElementParameter param : elemParameters) {
                    String repositoryValue = param.getRepositoryValue();
                    if (param.getRepositoryValue() == null || (curPropertyParam != null && param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(curPropertyParam.getName()))) {
                        continue;
                    }
                    if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                        continue;
                    }
                    if ((repositoryValue != null) && (param.isShow(node.getElementParameters()) || node.getComponentProperties() != null || (node instanceof INode && ((INode) node).getComponent().getName().equals("tAdvancedFileOutputXML")) || (node instanceof INode && ((INode) node).getComponent().getName().equals("tESBProviderRequest")))) {
                        //$NON-NLS-1$
                        if (param.getName().equals(EParameterName.PROPERTY_TYPE.getName()) || param.getFieldType() == EParameterFieldType.MEMO_SQL) {
                            continue;
                        }
                        if (param.getFieldType().equals(EParameterFieldType.FILE) && isXsdPath) {
                            continue;
                        }
                        IMetadataTable table = null;
                        if (!node.getMetadataList().isEmpty()) {
                            table = node.getMetadataList().get(0);
                        }
                        Object objectValue = RepositoryToComponentProperty.getValue(connectionItem.getConnection(), repositoryValue, table);
                        if (objectValue == null || "".equals(objectValue)) {
                            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                                IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
                                if (service != null) {
                                    String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                                    if (node.getComponent().getName().startsWith("tESB")) {
                                        if (propertyValue.contains(" - ")) {
                                            propertyValue = propertyValue.split(" - ")[0];
                                        }
                                    }
                                    IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
                                    if (lastVersion != null) {
                                        Item item = lastVersion.getProperty().getItem();
                                        if (item != null) {
                                            Object objectValueFromESB = service.getValue(item, repositoryValue, node);
                                            if (objectValueFromESB != null) {
                                                objectValue = objectValueFromESB;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (param.getName().equals(EParameterName.CDC_TYPE_MODE.getName())) {
                            //
                            String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                            Item item = null;
                            IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
                            if (lastVersion != null) {
                                item = lastVersion.getProperty().getItem();
                            }
                            if (item != null && PluginChecker.isCDCPluginLoaded()) {
                                ICDCProviderService service = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
                                if (service != null) {
                                    try {
                                        List<IRepositoryViewObject> all;
                                        all = CorePlugin.getDefault().getProxyRepositoryFactory().getAll(ERepositoryObjectType.METADATA_CONNECTIONS);
                                        for (IRepositoryViewObject obj : all) {
                                            Item tempItem = obj.getProperty().getItem();
                                            if (tempItem instanceof DatabaseConnectionItem) {
                                                String cdcLinkId = service.getCDCConnectionLinkId((DatabaseConnectionItem) tempItem);
                                                if (cdcLinkId != null && item.getProperty().getId().equals(cdcLinkId)) {
                                                    objectValue = RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) tempItem).getConnection(), repositoryValue, node.getMetadataList().get(0));
                                                }
                                            }
                                        }
                                    } catch (PersistenceException e) {
                                        ExceptionHandler.process(e);
                                    }
                                }
                            }
                        }
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(IJsonFileService.class)) {
                            IJsonFileService jsonService = (IJsonFileService) GlobalServiceRegister.getDefault().getService(IJsonFileService.class);
                            boolean paramChanged = jsonService.changeFilePathFromRepository(connectionItem.getConnection(), param, node, objectValue);
                            if (paramChanged) {
                                continue;
                            }
                        }
                        if (objectValue != null) {
                            if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && repositoryValue.equals(UpdatesConstants.TYPE)) {
                                boolean found = false;
                                String[] items = param.getListRepositoryItems();
                                for (int i = 0; (i < items.length) && (!found); i++) {
                                    if (objectValue.equals(items[i])) {
                                        found = true;
                                        node.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
                                    }
                                }
                            } else {
                                // update tFileInputExcel job
                                if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
                                    String name = param.getName();
                                    if (name.equals("ROOT") || name.equals("LOOP") || name.equals("GROUP") && objectValue instanceof List) {
                                        param.setValue(objectValue);
                                    } else if (param.getName().equals("SHEETLIST") && objectValue instanceof List) {
                                        List<Map<String, Object>> paramMaps = (List<Map<String, Object>>) param.getValue();
                                        if (paramMaps == null) {
                                            paramMaps = new ArrayList<Map<String, Object>>();
                                            node.setPropertyValue(param.getName(), paramMaps);
                                        } else {
                                            // hywang add for 9537
                                            List<Map<String, Object>> objectValueList = (List<Map<String, Object>>) objectValue;
                                            if (paramMaps.size() < objectValueList.size()) {
                                                paramMaps.clear();
                                                for (int i = 0; i < objectValueList.size(); i++) {
                                                    Map<String, Object> map = objectValueList.get(i);
                                                    paramMaps.add(map);
                                                }
                                            } else {
                                                String value = null;
                                                List<String> repNames = new ArrayList<String>();
                                                for (int i = 0; i < objectValueList.size(); i++) {
                                                    repNames.add(objectValueList.get(i).get("SHEETNAME").toString());
                                                }
                                                for (int j = 0; j < paramMaps.size(); j++) {
                                                    Map<String, Object> map = paramMaps.get(j);
                                                    value = map.get("SHEETNAME").toString();
                                                    if (!repNames.contains(value)) {
                                                        paramMaps.remove(j);
                                                    }
                                                }
                                            }
                                        }
                                    } else if ((name.equals("HADOOP_ADVANCED_PROPERTIES") || name.equals("ADVANCED_PROPERTIES") || name.equals("HBASE_PARAMETERS") || name.equals("SAP_PROPERTIES") && objectValue instanceof List)) {
                                        List<HashMap<String, Object>> oldValue = (List<HashMap<String, Object>>) param.getValue();
                                        for (HashMap<String, Object> map : oldValue) {
                                            if (map.get("BUILDIN") != null && !map.get("BUILDIN").equals("") && Boolean.valueOf(String.valueOf(map.get("BUILDIN")))) {
                                                ((List<HashMap<String, Object>>) objectValue).add(map);
                                            }
                                        }
                                        param.setValue(objectValue);
                                    } else // it in jobs
                                    if (param.getName().equals("DRIVER_JAR") && objectValue instanceof List) {
                                        param.setValue(objectValue);
                                    }
                                } else {
                                    node.setPropertyValue(param.getName(), objectValue);
                                }
                            }
                        } else if (param.getFieldType().equals(EParameterFieldType.TABLE) && UpdatesConstants.XML_MAPPING.equals(repositoryValue)) {
                            RepositoryToComponentProperty.getTableXMLMappingValue(connectionItem.getConnection(), (List<Map<String, Object>>) param.getValue(), node);
                        } else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getName().equals("PARAMS")) {
                            objectValue = RepositoryToComponentProperty.getValue(connectionItem.getConnection(), "PARAMS", node.getMetadataList().get(0));
                            List<Map<String, Object>> paramMaps = (List<Map<String, Object>>) param.getValue();
                            if (paramMaps == null) {
                                paramMaps = new ArrayList<Map<String, Object>>();
                            } else {
                                paramMaps.clear();
                            }
                            if (objectValue != null) {
                                List<String> objectValueList = (List<String>) objectValue;
                                for (int i = 0; i < objectValueList.size(); i++) {
                                    Map<String, Object> map = new HashedMap();
                                    map.put("VALUE", TalendTextUtils.addQuotes(objectValueList.get(i)));
                                    paramMaps.add(map);
                                }
                            }
                        } else if (node.getComponentProperties() != null && objectValue == null) {
                            // for new framework, still save the null value in component
                            node.setPropertyValue(param.getName(), objectValue);
                        }
                        if (!("tMDMReceive".equals(node.getComponent().getName()) && "XPATH_PREFIX".equals(//$NON-NLS-1$ //$NON-NLS-2$
                        param.getRepositoryValue()))) {
                            param.setRepositoryValueUsed(true);
                            param.setReadOnly(true);
                            update = true;
                        }
                    }
                }
            } else {
                // Added TDQ-11688 20170309 yyin
                ITDQPatternService service = null;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
                    service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
                }
                if (service != null && (service.isSinglePatternNode(node) || service.isMultiPatternNode(node)) && parameter != null && parameter instanceof IElementParameter) {
                    IElementParameter elementParameter = node.getElementParameter(((IElementParameter) parameter).getName());
                    if (elementParameter != null && !elementParameter.getValue().equals(((IElementParameter) parameter).getValue())) {
                        elementParameter.setValue(((IElementParameter) parameter).getValue());
                    }
                    update = true;
                    Object regexValue = null;
                    Object parameterValue = ((IElementParameter) parameter).getValue();
                    if ("PATTERN_REGEX".equals(((IElementParameter) parameter).getName())) {
                        regexValue = parameterValue;
                    } else if ("SCHEMA_PATTERN_CHECK".equals(((IElementParameter) parameter).getName())) {
                        List<Map<String, String>> multiPatternList = ((List<Map<String, String>>) parameterValue);
                        for (Map<String, String> patternMap : multiPatternList) {
                            regexValue = patternMap.get("PATTERN_REGEX");
                            if (regexValue == null) {
                                patternMap.put("PATTERN_PROPERTY", EmfComponent.BUILTIN);
                            }
                        }
                    }
                    if (regexValue == null || regexValue.toString().isEmpty()) {
                        update = false;
                    }
                }
            }
        }
        if (!update) {
            // bult-in
            String propertyName = parentParamName + ":" + EParameterName.PROPERTY_TYPE.getName();
            if (this.result.getParameter() instanceof IElementParameter) {
                IElementParameter parentParam = ((IElementParameter) this.result.getParameter()).getParentParameter();
                if (parentParam != null) {
                    parentParamName = parentParam.getName();
                    propertyName = parentParam.getName() + ":" + parentParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getName();
                }
            }
            node.setPropertyValue(propertyName, EmfComponent.BUILTIN);
            for (IElementParameter param : node.getElementParameters()) {
                if (param.getRepositoryValue() == null || param.getRepositoryProperty() != null && !param.getRepositoryProperty().equals(parentParamName)) {
                    continue;
                }
                if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
                    continue;
                }
                if (param.isShow(node.getElementParameters())) {
                    if (param.getName().equals(EParameterName.PROPERTY_TYPE.getName()) || param.getFieldType() == EParameterFieldType.MEMO_SQL) {
                        continue;
                    }
                    param.setRepositoryValueUsed(false);
                    param.setReadOnly(false);
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) Item(org.talend.core.model.properties.Item) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) ITDQPatternService(org.talend.core.ITDQPatternService) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) IJsonFileService(org.talend.core.service.IJsonFileService) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IESBService(org.talend.core.IESBService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) HashedMap(org.apache.commons.collections.map.HashedMap) ICDCProviderService(org.talend.core.ui.ICDCProviderService) Map(java.util.Map) HashedMap(org.apache.commons.collections.map.HashedMap) HashMap(java.util.HashMap)

Example 5 with XmlFileConnection

use of org.talend.core.model.metadata.builder.connection.XmlFileConnection in project tdi-studio-se by Talend.

the class DynamicComposite method updateRepositoryListExtra.

/**
     * for job settings extra (feature 2710).
     * 
     */
private void updateRepositoryListExtra(IElementParameter param, List<String> repositoryConnectionNameList, List<String> repositoryConnectionValueList, boolean extra) {
    String repositoryValue = param.getParentParameter().getRepositoryValue();
    if (repositoryValue != null) {
        List<String> connectionNamesList = new ArrayList<String>();
        List<String> connectionValuesList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            Connection connection = connectionItem.getConnection();
            String name = //$NON-NLS-1$
            getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel();
            if ((connection instanceof DelimitedFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.DELIMITED.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof PositionalFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.POSITIONAL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof RegexpFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.REGEX.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof XmlFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.XML.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof FileExcelConnection) && (repositoryValue.equals(ERepositoryCategoryType.EXCEL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof GenericSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.GENERIC.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof LDAPSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.LDAP.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof SalesforceSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.SALESFORCE.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof WSDLSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.WSDL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof DatabaseConnection) && (repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName()))) {
                //$NON-NLS-1$
                String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
                if (repositoryValue.contains(":")) {
                    // database //$NON-NLS-1$
                    // is
                    // specified
                    // //$NON-NLS-1$
                    //$NON-NLS-1$
                    String neededDbType = repositoryValue.substring(repositoryValue.indexOf(":") + 1);
                    if (neededDbType.equals(currentDbType)) {
                        addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                    }
                } else {
                    addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                }
            }
        }
        repositoryConnectionNameList.addAll(connectionNamesList);
        repositoryConnectionValueList.addAll(connectionValuesList);
    } else {
        List<String> connectionValuesList = new ArrayList<String>();
        List<String> connectionStringList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            String name = connectionItem.getProperty().getLabel();
            addOrderDisplayNames(connectionValuesList, connectionStringList, key, name);
        }
        repositoryConnectionNameList.addAll(connectionStringList);
        repositoryConnectionValueList.addAll(connectionValuesList);
    }
    param.setListItemsDisplayName(repositoryConnectionNameList.toArray(new String[0]));
    param.setListItemsValue(repositoryConnectionValueList.toArray(new String[0]));
    if (!repositoryConnectionItemMap.keySet().contains(param.getValue())) {
        if (repositoryConnectionNameList.size() > 0) {
            param.setValue(repositoryConnectionValueList.get(0));
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection)

Aggregations

XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)9 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 ArrayList (java.util.ArrayList)5 IElementParameter (org.talend.core.model.process.IElementParameter)5 Item (org.talend.core.model.properties.Item)5 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4 SalesforceSchemaConnection (org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 List (java.util.List)3 Map (java.util.Map)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 XmlFileConnectionItem (org.talend.core.model.properties.XmlFileConnectionItem)3 HashMap (java.util.HashMap)2 ComponentProperties (org.talend.components.api.properties.ComponentProperties)2 ITDQPatternService (org.talend.core.ITDQPatternService)2 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)2 FileExcelConnection (org.talend.core.model.metadata.builder.connection.FileExcelConnection)2 GenericSchemaConnection (org.talend.core.model.metadata.builder.connection.GenericSchemaConnection)2