Search in sources :

Example 61 with MetadataTable

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

the class DBTreeProvider method createTables.

/**
     * tguiu Comment method "createTables".
     * 
     * @param node
     * @param iMetadataConnection
     * @param metadataConnection
     */
private void createTables(RepositoryNode node, final IRepositoryViewObject repObj, Connection metadataConnection, boolean isBuildIn) {
    for (Object currentTable : ConnectionHelper.getTables(metadataConnection)) {
        org.talend.core.model.metadata.builder.connection.MetadataTable metadataTable = (org.talend.core.model.metadata.builder.connection.MetadataTable) currentTable;
        if (metadataTable.getSourceName() != null) {
            RepositoryNode tableNode = createMetatable(node, repObj, metadataTable, isBuildIn);
            if (TableHelper.isDeleted(metadataTable)) {
            // ignore recycle node
            } else if (metadataTable.getSourceName().equals(" ")) {
            // TDI-23826:ignore drop table in the query
            } else {
                node.getChildren().add(tableNode);
            }
            if (connectionParameters.getMetadataTable() != null && metadataTable.getLabel().equals(connectionParameters.getMetadataTable().getLabel())) {
                this.selectedExtReposiotryNode = tableNode;
            }
            // create columns
            createColumns(tableNode, repObj, currentTable, isBuildIn);
        }
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 62 with MetadataTable

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

the class DBTreeProvider method createColumns.

private void createColumns(RepositoryNode tableNode, IRepositoryViewObject repObj, Object currentTable, boolean isBuildIn) {
    for (Object currentColumn : ((MetadataTable) currentTable).getColumns()) {
        MetadataColumn metadataColumn = (MetadataColumn) currentColumn;
        RepositoryNode columnNode = createMetacolumn(tableNode, repObj, metadataColumn, isBuildIn);
        tableNode.getChildren().add(columnNode);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 63 with MetadataTable

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

the class DBTreeProvider method getChildren.

//$NON-NLS-1$
@SuppressWarnings("static-access")
public Object[] getChildren(Object parentElement) {
    RepositoryNode repositoryNode = (RepositoryNode) parentElement;
    RepositoryNode rootNode = repositoryNodeManager.getRoot(repositoryNode);
    boolean isBuildIn = ((SqlBuilderRepositoryObject) rootNode.getObject()).isBuildIn();
    if (isRefresh) {
        refreshRootNode(rootNode);
        rootNode.getChildren().clear();
        DatabaseConnection metadataConnection = (DatabaseConnection) ((ConnectionItem) rootNode.getObject().getProperty().getItem()).getConnection();
        createTables(rootNode, rootNode.getObject(), metadataConnection, isBuildIn);
        createQueries(rootNode, rootNode.getObject(), metadataConnection, isBuildIn);
        isRefresh = false;
        return repositoryNode.getChildren().toArray();
    } else {
        // if intialized already > same as now, retrieve the childrens
        if (!repositoryNode.isInitialized()) {
            // retrieve columns of the specified table
            RepositoryNodeType type = (RepositoryNodeType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            if (type == RepositoryNodeType.TABLE) {
                try {
                    MetadataTable table = ((MetadataTableRepositoryObject) repositoryNode.getObject()).getTable();
                    DatabaseConnectionItem connItem = repositoryNodeManager.getItem(repositoryNode);
                    DatabaseConnection dbConn = (DatabaseConnection) connItem.getConnection();
                    IMetadataConnection iMetadataConnection = ConvertionHelper.convert(dbConn);
                    repositoryNode.getChildren().clear();
                    repositoryNodeManager.modifyOldRepositoryNode(dbConn, iMetadataConnection, repositoryNode);
                    createColumns(repositoryNode, rootNode.getObject(), table, isBuildIn);
                    // set node intialized to true.
                    repositoryNode.setInitialized(true);
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
        return repositoryNode.getChildren().toArray();
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 64 with MetadataTable

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

the class JSONFileWizardPage method createControl.

/**
     * 
     * @see IDialogPage#createControl(Composite)
     */
public void createControl(final Composite parent) {
    currentComposite = null;
    if (step == 1) {
        currentComposite = new JSONFileStep1Form(creation, parent, connectionItem, existingNames, (JSONWizard) getWizard());
    } else if (step == 2) {
        currentComposite = new JSONFileStep2Form(parent, connectionItem, (JSONWizard) getWizard());
    } else if (step == 3) {
        MetadataTable metadataTable = ConnectionHelper.getTables(connectionItem.getConnection()).toArray(new MetadataTable[0])[0];
        currentComposite = new JSONFileStep3Form(parent, connectionItem, metadataTable, (JSONWizard) getWizard(), TableHelper.getTableNames(((JSONFileConnection) connectionItem.getConnection()), metadataTable.getLabel()));
    }
    currentComposite.setReadOnly(!isRepositoryObjectEditable);
    currentComposite.setPage(this);
    AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {

        public void checkPerformed(final AbstractForm source) {
            if (source.isStatusOnError()) {
                JSONFileWizardPage.this.setPageComplete(false);
                setErrorMessage(source.getStatus());
            } else {
                JSONFileWizardPage.this.setPageComplete(isRepositoryObjectEditable);
                setErrorMessage(null);
                setMessage(source.getStatus());
            }
        }
    };
    currentComposite.setListener(listener);
    setControl((Composite) currentComposite);
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) AbstractForm(org.talend.metadata.managment.ui.wizard.AbstractForm)

Example 65 with MetadataTable

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

the class JSONFileOutputWizardPage method createControl.

public void createControl(final Composite parent) {
    currentComposite = null;
    if (step == 1) {
        currentComposite = new JSONFileOutputStep1Form(creation, parent, connectionItem, existingNames);
    } else if (step == 2) {
        currentComposite = new JSONFileOutputStep2Form(creation, parent, connectionItem);
    } else if (step == 3) {
        MetadataTable metadataTable = (MetadataTable) ConnectionHelper.getTables((JSONFileConnection) connectionItem.getConnection()).toArray(new MetadataTable[0])[0];
        currentComposite = new JSONFileOutputStep3Form(parent, connectionItem, metadataTable, TableHelper.getTableNames(((JSONFileConnection) connectionItem.getConnection()), metadataTable.getLabel()));
    }
    currentComposite.setReadOnly(!isRepositoryObjectEditable);
    currentComposite.setPage(this);
    AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {

        public void checkPerformed(final AbstractForm source) {
            if (source.isStatusOnError()) {
                JSONFileOutputWizardPage.this.setPageComplete(false);
                setErrorMessage(source.getStatus());
            } else {
                JSONFileOutputWizardPage.this.setPageComplete(isRepositoryObjectEditable);
                setErrorMessage(null);
                setMessage(source.getStatus());
            }
        }
    };
    currentComposite.setListener(listener);
    setControl((Composite) currentComposite);
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) AbstractForm(org.talend.metadata.managment.ui.wizard.AbstractForm)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)76 ArrayList (java.util.ArrayList)26 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)24 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)18 List (java.util.List)14 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)13 PersistenceException (org.talend.commons.exception.PersistenceException)11 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)10 RepositoryNode (org.talend.repository.model.RepositoryNode)10 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)9 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)9 HashMap (java.util.HashMap)8 Schema (org.apache.avro.Schema)7 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)7 IElementParameter (org.talend.core.model.process.IElementParameter)7 Map (java.util.Map)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6