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);
}
}
}
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);
}
}
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();
}
}
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);
}
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);
}
Aggregations