use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class UIManager method convert.
/**
* qzhang Comment method "convert".
*
* @param outputMetaTable2
* @return TODO
*/
public void convert(RowGeneratorComponent externalNode, IMetadataTable outputMetaTable2, FunctionManagerExt functionManager) {
List<IMetadataColumn> exts = new ArrayList<IMetadataColumn>();
for (int j = 0; j < outputMetaTable2.getListColumns().size(); j++) {
IMetadataColumn column = outputMetaTable2.getListColumns().get(j);
if (column instanceof MetadataColumnExt) {
exts.add(column.clone());
} else if (column instanceof MetadataColumn) {
MetadataColumnExt ext = new MetadataColumnExt((MetadataColumn) column);
List<Function> funs = functionManager.getFunctionsByType(ext.getTalendType());
ext.setArrayFunctions(functionManager.getFunctionArrays(funs));
if (!funs.isEmpty()) {
Function funtion = functionManager.getFunctionFromColumn(ext);
if (funtion == null) {
funtion = functionManager.getFuntionFromArray(ext, externalNode, j);
}
ext.setFunction(funtion);
}
exts.add(ext);
}
}
outputMetaTable2.setListColumns(exts);
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ValidationRulesUtil method updateRejectMetatable.
public static void updateRejectMetatable(INode node, INode refNode) {
if (!isHasValidationRule(node)) {
return;
}
List<IMetadataTable> metadatas = node.getMetadataList();
if (metadatas != null && metadatas.size() > 0) {
IMetadataTable table = null;
boolean isHasRejectTable = false;
for (IMetadataTable metadataTable : metadatas) {
if ("VALIDATION_REJECT".equals(metadataTable.getTableName())) {
//$NON-NLS-1$
isHasRejectTable = true;
table = metadataTable;
break;
}
}
if (!isHasRejectTable) {
table = new MetadataTable();
}
//$NON-NLS-1$
table.setAttachedConnector("VALIDATION_REJECT");
//$NON-NLS-1$
table.setTableName("VALIDATION_REJECT");
table.setReadOnly(true);
List<? extends IConnection> mainConnection = null;
if (refNode != null) {
mainConnection = refNode.getIncomingConnections(EConnectionType.FLOW_MAIN);
} else {
mainConnection = node.getIncomingConnections(EConnectionType.FLOW_MAIN);
}
IConnection connection = null;
if (mainConnection != null && mainConnection.size() > 0) {
table.getListColumns().clear();
connection = mainConnection.get(0);
} else {
List<? extends IConnection> outgoingConnections;
if (refNode != null) {
//$NON-NLS-1$
outgoingConnections = refNode.getOutgoingConnections("FLOW");
} else {
//$NON-NLS-1$
outgoingConnections = node.getOutgoingConnections("FLOW");
}
if (outgoingConnections != null && outgoingConnections.size() > 0) {
connection = outgoingConnections.get(0);
}
}
if (connection != null) {
IMetadataTable inputTable = connection.getMetadataTable();
if (inputTable != null) {
MetadataToolHelper.copyTable(null, inputTable, table);
}
}
List<IMetadataColumn> listColumns = table.getListColumns();
boolean isHasErrorMsgCol = false;
for (IMetadataColumn metadataColumn : listColumns) {
if ("errorMessage".equals(metadataColumn.getLabel())) {
//$NON-NLS-1$
isHasErrorMsgCol = true;
break;
}
}
if (!isHasErrorMsgCol) {
MetadataColumn column = new MetadataColumn();
//$NON-NLS-1$
column.setId("30");
column.setKey(false);
//$NON-NLS-1$
column.setLabel("errorMessage");
column.setLength(255);
//$NON-NLS-1$
column.setOriginalDbColumnName("errorMessage");
column.setPrecision(0);
column.setCustom(true);
column.setReadOnly(true);
column.setNullable(true);
//$NON-NLS-1$
column.setTalendType("id_String");
table.getListColumns().add(column);
if (!isHasRejectTable) {
node.getMetadataList().add(table);
}
}
}
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class CompleteDropTargetTableListener method insertNewOutputEntryFromVarEntry.
private void insertNewOutputEntryFromVarEntry(ArrayList<ITableEntry> sources, ArrayList<IMetadataColumn> metadataColumnsBeingAdded, ITableEntry tableEntrySource, String columnName) {
MetadataColumn metadataColumn = new MetadataColumn();
metadataColumn.setLabel(columnName);
metadataColumn.setTalendType(((VarTableEntry) tableEntrySource).getType());
metadataColumn.setNullable(((VarTableEntry) tableEntrySource).isNullable());
metadataColumnsBeingAdded.add(metadataColumn);
sources.add(tableEntrySource);
}
use of org.talend.core.model.metadata.MetadataColumn in project tesb-studio-se by Talend.
the class RestResponseSchemaController method createComboCommand.
@Override
public Command createComboCommand(SelectionEvent event) {
// Change the body type according to selected return body type
Command changePropertyCommand = super.createComboCommand(event);
Object newReturnType = null;
if (changePropertyCommand != null) {
newReturnType = ((PropertyChangeCommand) changePropertyCommand).getNewValue();
}
if (newReturnType == null) {
return null;
}
// get old metadata column
List<IMetadataTable> metadataList = ((INode) elem).getMetadataList();
IMetadataTable oldMetadataTable = null;
if (metadataList != null && metadataList.size() > 0) {
oldMetadataTable = metadataList.get(0);
} else {
metadataList = new ArrayList<IMetadataTable>();
((INode) elem).setMetadataList(metadataList);
}
// create new metadata column
IMetadataTable newMetadataTable = oldMetadataTable == null ? new MetadataTable() : oldMetadataTable.clone();
List<IMetadataColumn> listColumns = newMetadataTable.getListColumns();
if (listColumns == null) {
listColumns = new ArrayList<IMetadataColumn>();
newMetadataTable.setListColumns(listColumns);
}
IMetadataColumn bodyColumn = listColumns.size() > 0 ? listColumns.get(0) : new MetadataColumn();
bodyColumn.setId("body");
bodyColumn.setTalendType(newReturnType.toString());
listColumns.clear();
listColumns.add(bodyColumn);
metadataList.clear();
metadataList.add(newMetadataTable);
// construct change metadata command
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand((INode) elem, null, oldMetadataTable, newMetadataTable);
// construct compound command by combining above 2 commands
CompoundCommand compoundCommand = new CompoundCommand();
compoundCommand.add(changePropertyCommand);
compoundCommand.add(changeMetadataCommand);
return compoundCommand;
}
Aggregations