Search in sources :

Example 1 with MetadataColumn

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

the class HL7UI method initTableViewer.

private void initTableViewer() {
    List<IMetadataTable> tables = externalNode.getMetadataList();
    for (IMetadataTable table : tables) {
        MetadataTable loaded = ConvertionHelper.convert(table);
        List<MetadataColumn> columns = loaded.getColumns();
        String trueTableName = table.getLabel();
        if (trueTableName.split("_").length > 2) {
            // get true table name from node draged from repository
            //$NON-NLS-N$  
            trueTableName = trueTableName.split("_")[1];
        }
        if (hl7Manager.getSchemaRelationMap().get(trueTableName) != null) {
            hl7Manager.getSchemaRelationMap().remove(trueTableName);
            hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
        } else {
            hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
        }
        MetadataColumn[] array = new MetadataColumn[columns.size()];
        int i = 0;
        for (MetadataColumn column : columns) {
            MetadataColumn newColumn = copyColumn(column);
            array[i] = newColumn;
            i++;
        }
        if (this.getMetaTableViewer().getSelection() instanceof IStructuredSelection) {
            IStructuredSelection selection = (IStructuredSelection) this.getMetaTableViewer().getSelection();
            if (selection.getFirstElement() != null) {
                String name = ((IModel) selection.getFirstElement()).getDisplayName();
                if (name.equals(trueTableName)) {
                    for (int j = 0; j < array.length; j++) {
                        hl7SchemaEditorView.getMetadataEditor().add(array[j]);
                    }
                // hl7SchemaEditorView.getMetadataEditor().addAll(columns);
                }
            }
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with MetadataColumn

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

the class HL7UI method copyColumn.

protected MetadataColumn copyColumn(MetadataColumn column) {
    MetadataColumn newColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
    newColumn.setComment(column.getComment());
    newColumn.setDefaultValue(column.getDefaultValue());
    newColumn.setKey(column.isKey());
    newColumn.setLabel(column.getLabel());
    newColumn.setPattern(column.getPattern());
    if (column.getLength() < 0) {
        newColumn.setLength(0);
    } else {
        newColumn.setLength(column.getLength());
    }
    newColumn.setNullable(column.isNullable());
    if (column.getPrecision() < 0) {
        newColumn.setPrecision(0);
    } else {
        newColumn.setPrecision(column.getPrecision());
    }
    newColumn.setTalendType(column.getTalendType());
    newColumn.setSourceType(column.getSourceType());
    if (column.getOriginalField() == null || column.getOriginalField().equals("")) {
        //$NON-NLS-1$
        newColumn.setLabel(column.getLabel());
    } else {
        newColumn.setOriginalField(column.getOriginalField());
    }
    return newColumn;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn)

Example 3 with MetadataColumn

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

the class HL7MetadataEmfTableEditorView method getDbColumnNameAccessor.

@Override
protected IBeanPropertyAccessors<MetadataColumn, String> getDbColumnNameAccessor() {
    return new IBeanPropertyAccessors<MetadataColumn, String>() {

        public String get(MetadataColumn bean) {
            return bean.getOriginalField();
        }

        public void set(MetadataColumn bean, String value) {
            bean.setOriginalField(value);
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                linker.getManager().updateRelationMapping(key, bean, false);
            // if (columns.indexOf(bean) > 0) {
            // columns.get(columns.indexOf(bean)).setOriginalField(value);
            // }
            }
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with MetadataColumn

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

the class ErDiagramComposite method createErDiagram.

/**
     * admin Comment method "createErDiagram".
     * 
     * @return
     */
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
    erDiagram = new ErDiagram();
    erDiagram.setErDiagramComposite(this);
    if (isShowDesignerPage) {
        IRunnableWithProgress progress = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                //$NON-NLS-1$
                monitor.beginTask("", IProgressMonitor.UNKNOWN);
                try {
                    List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
                    List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
                    erDiagram.setMetadataTables(tables);
                    List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
                    for (MetadataTable metadataTable : tables) {
                        Table table = new Table();
                        table.setMetadataTable(metadataTable, selectedColumns);
                        table.setErDiagram(erDiagram);
                        erDiagram.addTable(table);
                    }
                    erDiagram.setRelations(fks);
                } finally {
                    monitor.done();
                }
            }
        };
        UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
    } else {
        erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
        erDiagram.setRelations(new ArrayList<String[]>());
    }
    return erDiagram;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 5 with MetadataColumn

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

the class MetadataColumnComparator method modifyOldOneTableFromDB.

/**
     * dev Comment method "modifyOldOneTableFromDB".
     * 
     * @param metaFromDB
     * @param connectionLabel
     * @param emf
     */
@SuppressWarnings("unchecked")
private boolean modifyOldOneTableFromDB(List<MetadataTable> metaFromDB, MetadataTable emf) {
    boolean flag = true;
    for (MetadataTable db : metaFromDB) {
        if (db.getSourceName().equals(emf.getSourceName())) {
            flag = false;
            if (!emf.getLabel().equals("") && !emf.getLabel().equals(db.getSourceName())) {
                //$NON-NLS-1$
                emf.setDivergency(true);
            }
        }
    }
    if (flag) {
        List<MetadataColumn> columns = emf.getColumns();
        for (MetadataColumn column : columns) {
            //$NON-NLS-1$
            column.setOriginalField(" ");
            column.setDivergency(true);
            column.setSynchronised(false);
        }
        //$NON-NLS-1$
        emf.setSourceName(" ");
        emf.setDivergency(true);
        emf.setSynchronised(false);
    }
    return flag;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Aggregations

MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)203 ArrayList (java.util.ArrayList)98 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)51 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)37 TdColumn (org.talend.cwm.relational.TdColumn)28 List (java.util.List)24 HashMap (java.util.HashMap)20 Test (org.junit.Test)15 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 EList (org.eclipse.emf.common.util.EList)12 Indicator (org.talend.dataquality.indicators.Indicator)12 IRepositoryNode (org.talend.repository.model.IRepositoryNode)12 File (java.io.File)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 NoSQLExtractSchemaException (org.talend.repository.nosql.exceptions.NoSQLExtractSchemaException)10 Map (java.util.Map)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 Iterator (java.util.Iterator)8 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)8