Search in sources :

Example 1 with HL7ConnectionItem

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

the class TalendDndHelper method filterNeededComponents.

public static List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (name == null) {
        return neededComponents;
    }
    String productNameWanted = filterProductNameWanted(name, item);
    boolean hl7Related = false;
    boolean hl7Output = false;
    if (item instanceof HL7ConnectionItem) {
        hl7Related = true;
        EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
        if (list != null && list.size() > 0) {
            hl7Output = true;
        }
    }
    // for mdm
    MdmConceptType mdmType = null;
    if (item instanceof MDMConnectionItem) {
        MDMConnectionItem mdmItem = (MDMConnectionItem) item;
        if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) {
            MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject();
            if (mdmItem.getConnection() instanceof MDMConnection) {
                MDMConnection connection = (MDMConnection) mdmItem.getConnection();
                for (Object obj : connection.getSchemas()) {
                    if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) {
                        mdmType = ((Concept) obj).getConceptType();
                    }
                }
            }
        }
    }
    Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
    EmfComponent emfComponent = null;
    for (IComponent component : components) {
        if (component instanceof EmfComponent) {
            emfComponent = (EmfComponent) component;
            String componentProductname = emfComponent.getRepositoryType();
            boolean value = true;
            if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
                if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
                    value = false;
                }
            }
            if (hl7Output && !component.getName().equals("tHL7Output")) {
                //$NON-NLS-1$
                value = false;
            } else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
                //$NON-NLS-N$ bug15632
                value = false;
            }
            boolean flag = filterComponent(component, name, type);
            if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
                Pattern pattern = Pattern.compile("^.*oracle.*$", Pattern.CASE_INSENSITIVE);
                if (pattern.matcher(name.getDBType()).matches() && (emfComponent.getName().equals("tAmazonOracleInput") || emfComponent.getName().equals("tAmazonOracleOutput"))) {
                    continue;
                }
                if (item instanceof MDMConnectionItem) {
                    if (MdmConceptType.INPUT.equals(mdmType) && emfComponent.getName().endsWith(INPUT)) {
                        neededComponents.add(emfComponent);
                    } else if (MdmConceptType.OUTPUT.equals(mdmType) && emfComponent.getName().endsWith(OUTPUT)) {
                        neededComponents.add(emfComponent);
                    } else if (MdmConceptType.RECEIVE.equals(mdmType) && emfComponent.getName().endsWith(RECEIVE)) {
                        neededComponents.add(emfComponent);
                    }
                } else {
                    neededComponents.add(emfComponent);
                }
            }
        }
    }
    return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
}
Also used : Concept(org.talend.core.model.metadata.builder.connection.Concept) Pattern(java.util.regex.Pattern) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) MDMConnectionItem(org.talend.core.model.properties.MDMConnectionItem) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) EList(org.eclipse.emf.common.util.EList) MdmConceptType(org.talend.core.model.metadata.builder.connection.MdmConceptType) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) EmfComponent(org.talend.designer.core.model.components.EmfComponent) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Example 2 with HL7ConnectionItem

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

the class ValidationRulesUtil method filterNeededComponents.

public static List<IComponent> filterNeededComponents(Item item, ERepositoryObjectType type) {
    EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
    String productNameWanted = filterProductNameWanted(name, item);
    boolean hl7Related = false;
    boolean hl7Output = false;
    if (item instanceof HL7ConnectionItem) {
        hl7Related = true;
        EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
        if (list != null && list.size() > 0) {
            hl7Output = true;
        }
    }
    Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    EmfComponent emfComponent = null;
    for (IComponent component : components) {
        if (component instanceof EmfComponent) {
            emfComponent = (EmfComponent) component;
            String componentProductname = emfComponent.getRepositoryType();
            boolean value = true;
            if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
                if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
                    value = false;
                }
            }
            if (hl7Output && !component.getName().equals("tHL7Output")) {
                //$NON-NLS-1$
                value = false;
            } else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
                // bug15632
                value = false;
            }
            boolean flag = filterComponent(component, name, type);
            if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
                neededComponents.add(emfComponent);
            }
        }
    }
    return sortFilteredComponnents(item, type, neededComponents);
}
Also used : EDatabaseComponentName(org.talend.designer.core.ui.editor.process.EDatabaseComponentName) EList(org.eclipse.emf.common.util.EList) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) EmfComponent(org.talend.designer.core.model.components.EmfComponent) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Example 3 with HL7ConnectionItem

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

the class HL7RepositoryComponentDndFilter method valid.

@Override
public boolean valid(Item item, ERepositoryObjectType type, RepositoryNode seletetedNode, IComponent component, String repositoryType) {
    if (!(item instanceof HL7ConnectionItem) || component == null || repositoryType == null) {
        return false;
    }
    boolean hl7Related = false;
    boolean hl7Output = false;
    if (item instanceof HL7ConnectionItem) {
        hl7Related = true;
        EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
        if (list != null && list.size() > 0) {
            hl7Output = true;
        }
    }
    String componentProductname = component.getRepositoryType();
    boolean filter = true;
    if (hl7Output && !component.getName().equals(HL7_OUTPUT)) {
        filter = false;
    } else if (hl7Related && !hl7Output && !component.getName().equals(HL7_INPUT)) {
        // bug15632
        filter = false;
    }
    if (componentProductname != null && repositoryType.endsWith(componentProductname) && filter && validSub(item, type, seletetedNode, component, repositoryType)) {
        return true;
    }
    return false;
}
Also used : EList(org.eclipse.emf.common.util.EList) HL7ConnectionItem(org.talend.core.model.properties.HL7ConnectionItem) HL7Connection(org.talend.core.model.metadata.builder.connection.HL7Connection)

Example 4 with HL7ConnectionItem

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

the class ComponentChooseDialog method getChangeMetadataCommand.

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

Aggregations

HL7ConnectionItem (org.talend.core.model.properties.HL7ConnectionItem)4 EList (org.eclipse.emf.common.util.EList)3 HL7Connection (org.talend.core.model.metadata.builder.connection.HL7Connection)3 ArrayList (java.util.ArrayList)2 IComponent (org.talend.core.model.components.IComponent)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 EmfComponent (org.talend.designer.core.model.components.EmfComponent)2 Pattern (java.util.regex.Pattern)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)1 Concept (org.talend.core.model.metadata.builder.connection.Concept)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 MDMConnection (org.talend.core.model.metadata.builder.connection.MDMConnection)1 MdmConceptType (org.talend.core.model.metadata.builder.connection.MdmConceptType)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 MDMConnectionItem (org.talend.core.model.properties.MDMConnectionItem)1 SAPConnectionItem (org.talend.core.model.properties.SAPConnectionItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1