use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class MapperUI method prepareClosing.
public void prepareClosing(int response) {
List<IMetadataTable> newMetadatas = new ArrayList<IMetadataTable>();
EList<OutputXmlTree> outputTrees = null;
if (response == SWT.OK || response == SWT.APPLICATION_MODAL) {
// fix for bug TDI-18185
mapperManager.fireCurrentDirectEditApply();
// if press ok or apply , use copyOfMapData to check the metadata list
outputTrees = copyOfMapData.getOutputTrees();
} else {
// if press cancel , use the original mapData
outputTrees = ((XmlMapData) mapperComponent.getExternalEmfData()).getOutputTrees();
}
List<IMetadataTable> copyOfMetadata = new ArrayList<IMetadataTable>(mapperComponent.getMetadataList());
for (OutputXmlTree outputTree : outputTrees) {
IMetadataTable found = null;
for (IMetadataTable table : mapperComponent.getMetadataList()) {
if (outputTree.getName().equals(table.getTableName())) {
found = table;
}
}
if (found != null) {
newMetadatas.add(found);
} else {
// create a new metadata if needed
MetadataTable metadataTable = new MetadataTable();
metadataTable.setTableName(outputTree.getName());
mapperComponent.getProcess().addUniqueConnectionName(outputTree.getName());
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (OutputTreeNode treeNode : outputTree.getNodes()) {
MetadataColumn column = new MetadataColumn();
column.setLabel(treeNode.getName());
column.setKey(treeNode.isKey());
column.setTalendType(treeNode.getType());
column.setNullable(treeNode.isNullable());
column.setPattern(treeNode.getPattern());
listColumns.add(column);
}
metadataTable.setListColumns(listColumns);
newMetadatas.add(metadataTable);
}
}
mapperComponent.setMetadataList(newMetadatas);
copyOfMetadata.removeAll(newMetadatas);
List<IODataComponent> outputs = mapperComponent.getIODataComponents().getOuputs();
List<String> connectionNames = new ArrayList<String>();
for (IODataComponent output : outputs) {
connectionNames.add(output.getUniqueName());
}
for (IMetadataTable leftTree : copyOfMetadata) {
if (!connectionNames.contains(leftTree.getTableName())) {
mapperComponent.getProcess().removeUniqueConnectionName(leftTree.getTableName());
}
}
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ChangeOutputConnectionOrderCommandTest method createMetadataTable.
private IMetadataTable createMetadataTable(String tableName) {
IMetadataTable table = new MetadataTable();
table.setTableName(tableName);
MetadataColumn newColumn = new MetadataColumn();
newColumn.setLabel("newColumn");
newColumn.setTalendType("id_String");
table.getListColumns().add(newColumn);
return table;
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ConnectionCreateCommandTest method createSimpleMetadata2.
private IMetadataTable createSimpleMetadata2() {
IMetadataTable table = new MetadataTable();
IMetadataColumn column2 = new MetadataColumn();
//$NON-NLS-1$
column2.setLabel("C2");
//$NON-NLS-1$
column2.setTalendType("id_String");
table.getListColumns().add(column2);
IMetadataColumn column3 = new MetadataColumn();
//$NON-NLS-1$
column3.setLabel("C3");
//$NON-NLS-1$
column3.setTalendType("id_Integer");
table.getListColumns().add(column3);
return table;
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class MetadataEmfFactoryTest method createTestTable.
private IMetadataTable createTestTable() {
IMetadataTable table = new MetadataTable();
IMetadataColumn column = new MetadataColumn();
//$NON-NLS-1$
column.setLabel("C1");
column.setTalendType(JavaTypesManager.INTEGER.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
//$NON-NLS-1$
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
//$NON-NLS-1$
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
return table;
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ConnectionCreateCommandTest method createSimpleMetadata1.
private IMetadataTable createSimpleMetadata1() {
IMetadataTable table = new MetadataTable();
IMetadataColumn column1 = new MetadataColumn();
//$NON-NLS-1$
column1.setLabel("C1");
//$NON-NLS-1$
column1.setTalendType("id_String");
table.getListColumns().add(column1);
IMetadataColumn column2 = new MetadataColumn();
//$NON-NLS-1$
column2.setLabel("C2");
//$NON-NLS-1$
column2.setTalendType("id_String");
table.getListColumns().add(column2);
IMetadataColumn column3 = new MetadataColumn();
//$NON-NLS-1$
column3.setLabel("C3");
//$NON-NLS-1$
column3.setTalendType("id_Integer");
table.getListColumns().add(column3);
return table;
}
Aggregations