Search in sources :

Example 1 with MetadataTableRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdi-studio-se by Talend.

the class ComponentChooseDialog method getSAPCommand.

/**
     * Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
     *
     * @param object
     * @param connectionItem
     * @param table
     * @param node
     * @return
     */
private void getSAPCommand(CompoundCommand cc, IRepositoryViewObject object, ConnectionItem connectionItem, MetadataTable table, Node node) {
    SAPFunctionUnit functionUnit = null;
    if (object instanceof MetadataTableRepositoryObject) {
        IElementParameter schemaParam = null;
        List<IElementParameter> schemaTypeList = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
        for (IElementParameter param : schemaTypeList) {
            if (param.getName().equals("SCHEMA")) {
                //$NON-NLS-1$
                schemaParam = param;
                break;
            }
        }
        if (table.eContainer() instanceof SAPFunctionUnit) {
            // function parameter table
            functionUnit = (SAPFunctionUnit) table.eContainer();
            // To judge what the current node is, tSAPOutput or tSAPInput component.
            String sapComponentName = node.getComponent().getName();
            if ("tSAPBapi".equals(sapComponentName)) {
                //$NON-NLS-1$
                RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, (SAPFunctionUnit) table.eContainer(), ConvertionHelper.convert(table), null);
                cc.add(command);
            } else {
                if (schemaParam != null) {
                    // repository id should be connectionid - sapfunctionName/type/tableName
                    String type = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
                    String value = connectionItem.getProperty().getId() + " - " + functionUnit.getLabel() + "/" + type + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    table.getLabel();
                    RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
                    schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
                    cc.add(changeValueCmd);
                }
                IElementParameter schemasParam = node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
                if (schemasParam != null) {
                    Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table), functionUnit);
                    cc.add(sapCmd);
                }
            }
        } else {
            // Sap Table : keep repository id as before
            if (schemaParam != null) {
                //$NON-NLS-1$
                String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
                RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
                schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection(), table);
                cc.add(changeValueCmd);
            }
        }
    } else if (object instanceof SAPFunctionRepositoryObject) {
        functionUnit = (SAPFunctionUnit) ((SAPFunctionRepositoryObject) object).getAbstractMetadataObject();
        if (node.getComponent() != null && node.getComponent().getName().equals("tSAPBapi")) {
            //$NON-NLS-1$
            RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, functionUnit, null, null);
            cc.add(command);
        } else {
            for (MetadataTable metadataTable : functionUnit.getTables()) {
                Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, metadataTable.getLabel(), ConvertionHelper.convert(metadataTable), functionUnit);
                cc.add(sapCmd);
            }
        }
    }
}
Also used : RepositoryChangeMetadataForSAPBapi(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPBapi) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) 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) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 2 with MetadataTableRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject 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 3 with MetadataTableRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdi-studio-se by Talend.

the class ComponentChooseDialog method setSAPSpecailValueForCommand.

private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
    // Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
    // Table node, if so, set up the table name to command.
    IRepositoryViewObject object = selectedNode.getObject();
    if (object instanceof MetadataColumnRepositoryObject) {
        object = selectedNode.getParent().getParent().getObject();
    }
    SAPFunctionUnit unit = null;
    if (object != null) {
        if (object instanceof MetadataTableRepositoryObject) {
            MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
            MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
            if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
                unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
                command.setSapFunctionLabel(unit.getLabel());
                // set table name to functionName/type/tablename;
                String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
                unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
                command.setCurrentTableName(currentTableName);
            } else if (abstractMetadataObject instanceof SAPTable) {
                command.setCurrentTableName(abstractMetadataObject.getLabel());
            }
        } else if (object instanceof SAPFunctionRepositoryObject) {
            SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
            unit = sapObj.getModelElement();
            command.setSapFunctionLabel(unit.getLabel());
        } else if (object instanceof SAPIDocRepositoryObject) {
            SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
            command.setSapIDocLabel(sapObj.getLabel());
        }
    }
}
Also used : SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPTable(org.talend.core.model.metadata.builder.connection.SAPTable) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 4 with MetadataTableRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdq-studio-se by Talend.

the class OverviewResultPage method wapperInput.

/**
 * DOC klliu Comment method "wapperInput". relations
 *
 * @param indicatorTableList
 * @param parentNode
 * @return
 */
private List<OverviewIndUIElement> wapperInput(EList<TableIndicator> indicatorTableList, IRepositoryNode parentNode) {
    List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
    List<IRepositoryNode> children = parentNode.getChildren();
    for (IRepositoryNode folderNode : children) {
        if (folderNode instanceof DBTableFolderRepNode) {
            List<IRepositoryNode> tableNodes = folderNode.getChildren();
            // MOD 20120315 klliu&yyin TDQ-2391, avoid getting many times for table nodes.
            for (TableIndicator indicator : indicatorTableList) {
                boolean equals = false;
                for (IRepositoryNode tableNode : tableNodes) {
                    MetadataTable table = ((MetadataTableRepositoryObject) tableNode.getObject()).getTable();
                    String name = table.getName();
                    String tableName = indicator.getTableName();
                    // String connUuid = ResourceHelper.getUUID(table);
                    // String anaUuid = ResourceHelper.getUUID(indicator.getAnalyzedElement());
                    equals = name.equals(tableName);
                    if (equals) {
                        OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
                        tableUIEle.setNode(tableNode);
                        tableUIEle.setOverviewIndicator(indicator);
                        if (DqRepositoryViewService.isComeFromRefrenceProject(getTdDataProvider()) && ColumnSetHelper.getColumns((ColumnSet) table).isEmpty()) {
                            tableUIEle.setVirtualNode(true);
                        }
                        cataUIEleList.add(tableUIEle);
                        break;
                    }
                }
                if (!equals) {
                    OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
                    tableUIEle.setOverviewIndicator(indicator);
                    tableUIEle.setVirtualNode(true);
                    cataUIEleList.add(tableUIEle);
                }
            }
        }
    }
    return cataUIEleList;
}
Also used : DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) TableIndicator(org.talend.dataquality.indicators.schema.TableIndicator) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) OverviewIndUIElement(org.talend.dataprofiler.core.model.OverviewIndUIElement) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 5 with MetadataTableRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method canDrop.

@Override
public boolean canDrop(IRepositoryNode metadataRepositoryNode) {
    IRepositoryViewObject metadataRepObject = metadataRepositoryNode.getObject();
    ConnectionItem connItem = (ConnectionItem) metadataRepObject.getProperty().getItem();
    // MOD qiongli 2010-8-19,bug 14436:could not come from diffrent connection
    Connection tdProvider = connItem.getConnection();
    if (tdProvider == null) {
        return false;
    } else if (this.getAnalysis().getContext().getConnection() != null && !ResourceHelper.areSame(tdProvider, this.getAnalysis().getContext().getConnection())) {
        return false;
    }
    // MOD mzhao, 2010-07-23 bug 14014: If the editor is dirty, save it firstly before drag and drop an elements.
    if (masterPage.isDirty()) {
        masterPage.doSave(new NullProgressMonitor());
        return false;
    }
    List<ModelElement> existModelElements = new ArrayList<ModelElement>();
    for (ModelElementIndicator modelElementIndicator : this.getAllTheElementIndicator()) {
        ModelElement me = RepositoryNodeHelper.getModelElementFromRepositoryNode(modelElementIndicator.getModelElementRepositoryNode());
        existModelElements.add(me);
    }
    // MOD mzhao 9848 2010-01-14, allowing to drag and drop table.
    if (metadataRepObject instanceof MetadataTableRepositoryObject) {
        MetadataTableRepositoryObject tableRepObject = (MetadataTableRepositoryObject) metadataRepObject;
        return !existModelElements.containsAll(ColumnSetHelper.getColumns((TdTable) tableRepObject.getTable()));
    }
    if (metadataRepObject instanceof MetadataColumnRepositoryObject) {
        if (existModelElements.contains(((MetadataColumnRepositoryObject) metadataRepObject).getTdColumn())) {
            return false;
        }
    }
    if (metadataRepObject instanceof MetadataXmlElementTypeRepositoryObject) {
        return !metadataRepositoryNode.hasChildren();
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Aggregations

MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)21 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)11 ArrayList (java.util.ArrayList)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)8 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)7 ConnectionItem (org.talend.core.model.properties.ConnectionItem)7 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)5 Command (org.eclipse.gef.commands.Command)4 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 IElementParameter (org.talend.core.model.process.IElementParameter)4 SAPConnectionItem (org.talend.core.model.properties.SAPConnectionItem)4 SAPFunctionRepositoryObject (org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject)4 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)4 List (java.util.List)3 Map (java.util.Map)3 EList (org.eclipse.emf.common.util.EList)3