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