use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class MapperManager method addOutput.
/**
* DOC amaumont Comment method "addOutput".
*/
public void addOutput() {
String tableName = uiManager.openNewOutputCreationDialog();
if (tableName == null) {
return;
}
IProcess process = mapperComponent.getProcess();
//$NON-NLS-1$
String uniqueName = process.generateUniqueConnectionName("table");
process.addUniqueConnectionName(uniqueName);
MetadataTable metadataTable = new MetadataTable();
metadataTable.setTableName(uniqueName);
// metadataTable.setId(uniqueName);
metadataTable.setLabel(tableName);
List<DataMapTableView> outputsTablesView = getUiManager().getOutputsTablesView();
int sizeOutputsView = outputsTablesView.size();
Control lastChild = null;
if (sizeOutputsView - 1 >= 0) {
lastChild = outputsTablesView.get(sizeOutputsView - 1);
}
IDataMapTable abstractDataMapTable = new OutputTable(this, metadataTable, uniqueName, tableName);
TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewOutputs.layout();
uiManager.moveOutputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
tablesZoneViewOutputs.layout();
uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class ChangeMultiSchemasCommand method addSchemasMap.
private void addSchemasMap(List<Map<String, String>> newValueList, List<IMetadataTable> newTables, SchemasKeyData keyData) {
if (keyData == null) {
return;
}
if (keyData.getParent() != null) {
// not root
//
Map<String, String> map = new HashMap<String, String>();
final String uniqueRecord = keyData.getUniqueRecord();
final String recordType = keyData.getRecordType();
map.put(IMultiSchemaConstant.SCHEMA, uniqueRecord);
map.put(IMultiSchemaConstant.RECORD, TalendTextUtils.addQuotes(recordType));
map.put(IMultiSchemaConstant.PARENT_RECORD, TalendTextUtils.addQuotes(keyData.getParent().getRecordType()));
map.put(IMultiSchemaConstant.CARDINALITY, keyData.getCard());
map.put(IMultiSchemaConstant.FIELDDELIMITED, TalendTextUtils.addQuotes(keyData.getSeparator()));
newValueList.add(map);
//
String connectionBaseName = MetadataToolHelper.validateColumnName(MultiSchemasUtil.getConnectionBaseName(uniqueRecord), 0);
String uniqueConnName = node.getProcess().generateUniqueConnectionName(connectionBaseName);
MetadataTable table = new MetadataTable();
table.setLabel(uniqueRecord);
table.setTableName(uniqueConnName);
//$NON-NLS-1$
String keyIndex = "";
boolean first = true;
List<MultiMetadataColumn> metadataColumnsInModel = keyData.getMetadataColumnsInModel();
for (int i = 0; i < metadataColumnsInModel.size(); i++) {
MultiMetadataColumn column = metadataColumnsInModel.get(i);
table.getListColumns().add(column.clone(true));
if (column.isKey()) {
if (first) {
keyIndex += i;
} else {
//$NON-NLS-1$
keyIndex += "," + i;
}
first = false;
}
}
map.put(IMultiSchemaConstant.KEY_COLUMN_INDEX, TalendTextUtils.addQuotes(keyIndex));
newTables.add(table);
}
for (SchemasKeyData child : keyData.getChildren()) {
addSchemasMap(newValueList, newTables, child);
}
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class UIManager method getCurrentColumnData.
/**
* ftang Comment method "saveAllData".
*/
private List<Map<String, Object>> getCurrentColumnData() {
List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
MetadataTable table = (MetadataTable) rgManager.getRowGeneratorComponent().getMetadataList().get(0);
convert(rgManager.getRowGeneratorComponent(), table, generatorUI.getFunctionManager());
for (IMetadataColumn col : table.getListColumns()) {
MetadataColumnExt ext = (MetadataColumnExt) col;
Map<String, Object> value = new HashMap<String, Object>();
value.put(RowGeneratorComponent.COLUMN_NAME, ext.getLabel());
value.put(RowGeneratorComponent.ARRAY, FunctionManagerExt.getOneColData(ext));
map.add(value);
}
return map;
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class UIManager method closeRowGenerator.
/**
* yzhang Comment method "closeRowGenerator".
*
* @param response
*/
public void closeRowGenerator(int response, boolean fromDialog) {
setRowGenResponse(response);
Composite parent = generatorUI.getRowGenUIParent();
saveCurrentUIProperties();
MetadataTable table = (MetadataTable) rgManager.getRowGeneratorComponent().getMetadataList().get(0);
boolean hasColumns = (table != null) && (table.getListColumns() != null && (table.getListColumns().size() != 0));
List<Map<String, Object>> originalColumnDataList = this.getRowGenManager().getRowGeneratorComponent().getMapList();
List<Map<String, Object>> currentColumnDataList = getCurrentColumnData();
boolean containsAll1 = originalColumnDataList.containsAll(currentColumnDataList);
boolean containsAll2 = currentColumnDataList.containsAll(originalColumnDataList);
boolean containsAll = containsAll1 && containsAll2;
if (hasColumns && !containsAll && response == SWT.CANCEL) {
boolean isNotSaveSetting = MessageDialog.openQuestion(parent.getShell(), Messages.getString("UIManager.MessageBox.title"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("UIManager.MessageBox.Content"));
if (!isNotSaveSetting) {
response = SWT.NONE;
setRowGenResponse(response);
}
return;
}
if (response == SWT.OK) {
saveAllData(currentColumnDataList);
}
if (parent instanceof Shell && !fromDialog) {
((Shell) parent).close();
}
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class RowGeneratorComponent method reinitColumnValues.
public void reinitColumnValues(List<Map<String, Object>> map) {
MetadataTable tableExt = (MetadataTable) this.getMetadataList().get(0);
List<String> columnNames = new ArrayList<String>();
for (IMetadataColumn column : tableExt.getListColumns()) {
columnNames.add(column.getLabel());
}
if (map.size() > tableExt.getListColumns().size()) {
for (int i = 0; i < map.size(); i++) {
Map<String, Object> line = map.get(i);
if (!columnNames.contains(line.get(COLUMN_NAME))) {
map.remove(line);
}
}
}
}
Aggregations