Search in sources :

Example 11 with MetadataColumn

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

the class MetadataColumnComparator method isDiff.

/**
     * dev Comment method "isDiff".
     * 
     * @param node
     * @return
     */
@SuppressWarnings("unchecked")
public boolean[] isDiff(RepositoryNode node) {
    boolean isDiffDivergency = false;
    boolean isDiffSyschronize = false;
    boolean isDiffGray = false;
    Object type = node.getProperties(EProperties.CONTENT_TYPE);
    if (type.equals(RepositoryNodeType.DATABASE)) {
        DatabaseConnection connection = (DatabaseConnection) getItem(node).getConnection();
        Set<MetadataTable> tables = ConnectionHelper.getTables(connection);
        for (MetadataTable table : tables) {
            List<MetadataColumn> columns = table.getColumns();
            for (MetadataColumn column : columns) {
                if (column.isDivergency()) {
                    isDiffDivergency = true;
                }
                if (column.isSynchronised()) {
                    isDiffSyschronize = true;
                }
                if (column.getLabel() == null || "".equals(column.getLabel())) {
                    //$NON-NLS-1$
                    isDiffGray = true;
                }
            }
            if (table.isDivergency()) {
                isDiffDivergency = true;
            }
            if (table.getLabel() == null || "".equals(table.getLabel())) {
                //$NON-NLS-1$
                isDiffGray = true;
            }
        }
    } else if (type.equals(RepositoryNodeType.TABLE)) {
        MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) node.getObject();
        MetadataTable table = object.getTable();
        List<MetadataColumn> columns = table.getColumns();
        for (MetadataColumn column : columns) {
            if (column.isDivergency()) {
                isDiffDivergency = true;
            }
            if (column.isSynchronised()) {
                isDiffSyschronize = true;
            }
            if (column.getLabel() == null || "".equals(column.getLabel())) {
                //$NON-NLS-1$
                isDiffGray = true;
            }
        }
        if (table.isDivergency()) {
            isDiffDivergency = true;
        }
    }
    return new boolean[] { isDiffGray, isDiffDivergency, isDiffSyschronize };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) SqlBuilderRepositoryObject(org.talend.sqlbuilder.dbstructure.SqlBuilderRepositoryObject) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) MetadataColumnRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataColumnRepositoryObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) List(java.util.List) ArrayList(java.util.ArrayList) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject)

Example 12 with MetadataColumn

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

the class MetadataColumnComparator method modifyOldOneColumnFromEMF.

/**
     * dev Comment method "modifyOldOneColumnFromEMF".
     * 
     * @param cloumnsFromEMF
     * @param db
     */
private void modifyOldOneColumnFromEMF(List<MetadataColumn> cloumnsFromEMF, MetadataColumn db) {
    boolean flag = true;
    for (MetadataColumn emf : cloumnsFromEMF) {
        if (db.getOriginalField().equals(emf.getOriginalField())) {
            flag = false;
            break;
        }
    }
    if (flag) {
        MetadataColumn column = ConnectionFactory.eINSTANCE.createMetadataColumn();
        column.setOriginalField(db.getOriginalField());
        //$NON-NLS-1$
        column.setLabel("");
        cloumnsFromEMF.add(column);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn)

Example 13 with MetadataColumn

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

the class MetadataColumnComparator method modifyOldOneColumnFromDB.

/**
     * dev Comment method "modifyOldOneColumnFromDB".
     * 
     * @param columnsFromDB
     * @param connAndTableLabel
     * @param emf
     */
private void modifyOldOneColumnFromDB(List<MetadataColumn> columnsFromDB, MetadataColumn emf) {
    boolean flag = true;
    for (MetadataColumn db : columnsFromDB) {
        if (db.getOriginalField().equals(emf.getOriginalField())) {
            flag = false;
            if (emf.getLabel().length() != 0) {
                boolean is = !isEquivalent(db, emf);
                emf.setDivergency(is);
                emf.setSynchronised(is);
            }
        }
    }
    if (flag) {
        //$NON-NLS-1$
        emf.setOriginalField(" ");
        emf.setDivergency(true);
        emf.setSynchronised(false);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn)

Example 14 with MetadataColumn

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

the class RepositoryUpdateTest method prepareTableForTest.

private MetadataTable prepareTableForTest(String id) {
    MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
    table.setLabel("myTableTest");
    MetadataColumn col1 = ConnectionFactory.eINSTANCE.createMetadataColumn();
    col1.setLabel("myColumn1");
    col1.setTalendType(JavaTypesManager.STRING.getId());
    col1.setLength(25);
    table.getColumns().add(col1);
    Schema avroSchema = MetadataToolAvroHelper.convertToAvro(table);
    TaggedValue tv = CoreFactory.eINSTANCE.createTaggedValue();
    tv.setTag(IComponentConstants.COMPONENT_PROPERTIES_TAG);
    SalesforceModuleProperties smp = new SalesforceModuleProperties("test");
    smp.connection.init();
    // because we should get connection always from the main
    smp.connection.userPassword.userId.setValue("old");
    // SalesforceConnectionProperties
    smp.moduleName.setStoredValue("myModule");
    smp.main.schema.setStoredValue(avroSchema);
    GenericRepository gr = new GenericRepository();
    gr.storeProperties(smp, table.getLabel(), id + "#", "main.schema");
    return table;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) SalesforceModuleProperties(org.talend.components.salesforce.SalesforceModuleProperties) GenericRepository(org.talend.repository.generic.persistence.GenericRepository) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) Schema(org.apache.avro.Schema) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 15 with MetadataColumn

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

the class ImportTreeFromRepository method isMappedChild.

private boolean isMappedChild(String tempXpath) {
    if (targetAbsolutePath == null) {
        targetAbsolutePath = new HashMap<String, String>();
        targetDatePattern = new HashMap<String, String>();
        targetAbsolutePath.put(absoluteXPathQuery, null);
        Pattern regex = Pattern.compile(RELATIVE_PATH_PATTERN, Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
        for (int n = 0; n < schemaTargets.size(); n++) {
            Object obj = schemaTargets.get(n);
            String relativeXPathQuery = "";
            if (obj instanceof SchemaTarget) {
                relativeXPathQuery = ((SchemaTarget) obj).getRelativeXPathQuery();
            } else if (obj instanceof ConceptTarget) {
                relativeXPathQuery = ((ConceptTarget) obj).getRelativeLoopExpression();
            }
            StringBuffer tempAbsolute = new StringBuffer();
            tempAbsolute.append(absoluteXPathQuery);
            tempAbsolute.append(XmlMapUtil.XPATH_SEPARATOR);
            tempAbsolute.append(relativeXPathQuery);
            if (relativeXPathQuery.startsWith(RELATIVE_PATH)) {
                Matcher regexMatcher = regex.matcher(relativeXPathQuery);
                int relativeLength = 0;
                while (regexMatcher.find()) {
                    relativeLength++;
                }
                if (relativeLength > 0) {
                    String subRelativeQuery = relativeXPathQuery.substring(relativeLength * RELATIVE_PATH.length(), relativeXPathQuery.length());
                    String[] absoluteSplit = absoluteXPathQuery.split(XmlMapUtil.XPATH_SEPARATOR);
                    if (absoluteSplit.length > relativeLength) {
                        tempAbsolute = new StringBuffer();
                        for (int i = 0; i < absoluteSplit.length - relativeLength; i++) {
                            tempAbsolute.append(absoluteSplit[i]);
                            tempAbsolute.append(XmlMapUtil.XPATH_SEPARATOR);
                        }
                        tempAbsolute.append(subRelativeQuery);
                    }
                }
            }
            if (metadataTable != null && n < metadataTable.getColumns().size()) {
                MetadataColumn column = metadataTable.getColumns().get(n);
                targetAbsolutePath.put(tempAbsolute.toString(), column.getTalendType());
                targetDatePattern.put(tempAbsolute.toString(), column.getPattern());
            } else {
                targetAbsolutePath.put(tempAbsolute.toString(), null);
                targetDatePattern.put(tempAbsolute.toString(), null);
            }
        }
    }
    for (String absTarget : targetAbsolutePath.keySet()) {
        if (absTarget.startsWith(tempXpath)) {
            return true;
        }
    }
    return false;
}
Also used : Pattern(java.util.regex.Pattern) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Matcher(java.util.regex.Matcher) EObject(org.eclipse.emf.ecore.EObject) SchemaTarget(org.talend.core.model.metadata.builder.connection.SchemaTarget) ConceptTarget(org.talend.core.model.metadata.builder.connection.ConceptTarget)

Aggregations

MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)59 ArrayList (java.util.ArrayList)27 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)22 List (java.util.List)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 MetadataEmfTableEditor (org.talend.core.ui.metadata.editor.MetadataEmfTableEditor)10 IModel (org.talend.designer.hl7.model.IModel)9 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)8 Command (org.eclipse.gef.commands.Command)7 EList (org.eclipse.emf.common.util.EList)6 HashMap (java.util.HashMap)5 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)5 ExtendedTableResetDBTypesCommand (org.talend.core.ui.metadata.extended.command.ExtendedTableResetDBTypesCommand)5 MetadataEmfExportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfExportXmlCommand)5 MetadataEmfImportXmlCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfImportXmlCommand)5 MetadataEmfPasteCommand (org.talend.core.ui.metadata.extended.command.MetadataEmfPasteCommand)5 HL7MultiSchemaUI (org.talend.designer.hl7.ui.HL7MultiSchemaUI)5 Iterator (java.util.Iterator)4 Map (java.util.Map)4