Search in sources :

Example 81 with MetadataTable

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

the class MetadataColumnComparator method fixedTables.

/**
     * fixed Table .
     * 
     * @param metaFromDB MetadataTable from Database
     * @param metaFromEMF MetadataTable from Emf
     * @param iMetadataConnection contain Connection.
     */
@SuppressWarnings("unchecked")
private void fixedTables(List<MetadataTable> metaFromDB, List<MetadataTable> metaFromEMF, IMetadataConnection iMetadataConnection, RepositoryNode oldNode) {
    List<MetadataTable> removeEmfDB = new ArrayList<MetadataTable>();
    for (MetadataTable emf : metaFromEMF) {
        boolean flag = modifyOldOneTableFromDB(metaFromDB, emf);
        if (flag) {
            removeEmfDB.add(emf);
        }
    }
    for (MetadataTable metadataTable : removeEmfDB) {
        if (metadataTable.getLabel() == null || "".equals(metadataTable.getLabel())) {
            //$NON-NLS-1$
            metaFromEMF.remove(metadataTable);
        }
    }
    // }
    int nbTables = 0;
    while (!metaFromDB.isEmpty() && nbTables < 500) {
        MetadataTable db = metaFromDB.remove(0);
        modifyOldOneTableFromEMF(metaFromEMF, iMetadataConnection, db);
        nbTables++;
    }
}
Also used : ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 82 with MetadataTable

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

the class CreateJSONSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    JSONFileConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        JSONFileConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (JSONFileConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == JSONRepositoryNodeType.JSON) {
            item = (JSONFileConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (JSONFileConnection) item.getConnection();
            metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
            String nextId = ProxyRepositoryFactory.getInstance().getNextId();
            metadataTable.setId(nextId);
            metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
            RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
            if (record != null) {
                // hywang
                PackageHelper.addMetadataTable(metadataTable, record);
            } else {
                RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
                ConnectionHelper.addPackage(newrecord, connection);
                PackageHelper.addMetadataTable(metadataTable, newrecord);
            }
            creation = true;
        } else {
            return;
        }
        initContextMode(item);
        openJSONSchemaWizard(item, metadataTable, false, creation);
    }
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) RecordFile(orgomg.cwm.resource.record.RecordFile) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 83 with MetadataTable

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

the class RepositoryUpdateTest method updateNode.

private void updateNode(String id, Node node, GenericConnection connection) {
    MetadataTable table = prepareTableForTest(id);
    updateNodeConnectionOnly(id, node, connection);
    IElementParameter schemaParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
    //$NON-NLS-1$
    String value = id + " - " + table.getLabel();
    RepositoryChangeMetadataCommand command2 = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
    schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connection);
    command2.execute(true);
}
Also used : RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 84 with MetadataTable

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

the class AddTablesComposite method createTableList.

/**
     * DOC admin Comment method "createTableList".
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private Composite createTableList() {
    Composite div1 = new Composite(tabFolder, SWT.NONE);
    div1.setLayout(new GridLayout());
    GridData lgid = new GridData();
    lgid.grabExcessHorizontalSpace = true;
    lgid.horizontalAlignment = GridData.FILL_BOTH;
    lgid.heightHint = 1;
    lgid.verticalIndent = 1;
    div1.setLayoutData(lgid);
    div1.setBackground(ColorConstants.white);
    listTables = new org.eclipse.swt.widgets.List(div1, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    listTables.setLayoutData(new GridData(GridData.FILL_BOTH));
    DatabaseConnectionItem item = SQLBuilderRepositoryNodeManager.getItem(getRootNode());
    tables = ConnectionHelper.getTables((DatabaseConnection) item.getConnection());
    for (MetadataTable table : tables) {
        if (table.getSourceName() != null) {
            listTables.add(table.getSourceName());
        }
    }
    return div1;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 85 with MetadataTable

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

the class AddTablesDialog method setRootNode.

//$NON-NLS-1$
@SuppressWarnings("unchecked")
public void setRootNode(RepositoryNode rootNode) {
    this.rootNode = rootNode;
    DatabaseConnectionItem item = SQLBuilderRepositoryNodeManager.getItem(getRootNode());
    tables = new HashSet<MetadataTable>();
    tables.addAll(ConnectionHelper.getTables((DatabaseConnection) item.getConnection()));
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)153 ArrayList (java.util.ArrayList)53 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)51 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)23 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)22 List (java.util.List)18 Test (org.junit.Test)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)14 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 Connection (org.talend.core.model.metadata.builder.connection.Connection)12 RepositoryNode (org.talend.repository.model.RepositoryNode)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 TdColumn (org.talend.cwm.relational.TdColumn)9 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)8 HashMap (java.util.HashMap)7