use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class MetadataSchemaExt method initializeOneColumn.
@Override
@SuppressWarnings("unchecked")
protected IMetadataColumn initializeOneColumn(final IMetadataColumn metadataColumn, final NamedNodeMap nodeMap) {
IMetadataColumn column = super.initializeOneColumn(metadataColumn, nodeMap);
MetadataColumnExt columnExt = new MetadataColumnExt((MetadataColumn) column);
//$NON-NLS-1$
Node function = nodeMap.getNamedItem("function");
if (function != null) {
//$NON-NLS-1$
Node parameter = nodeMap.getNamedItem("parameter");
//$NON-NLS-1$
Node preview = nodeMap.getNamedItem("preview");
Function function2 = funManager.getCurrentFunction(function.getNodeValue(), columnExt);
List<Parameter> parms = function2.getParameters();
//$NON-NLS-1$
String[] paraStr = parameter.getNodeValue().split(";");
for (String string : paraStr) {
//$NON-NLS-1$
String[] nv = string.split("=>");
for (Parameter para : parms) {
if (para.getName().equals(nv[0].trim())) {
para.setValue(nv[1]);
break;
}
}
}
columnExt.setFunction(function2);
columnExt.setPreview(preview.getNodeValue());
} else {
Function function2 = funManager.getDefaultFunction(columnExt, columnExt.getTalendType());
columnExt.setFunction(function2);
//$NON-NLS-1$
columnExt.setPreview("");
}
return columnExt;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class RowGenProcessMain method initPerlArray.
/**
* qzhang Comment method "initPerlArray".
*/
private void initPerlArray() {
List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
MetadataTable table = (MetadataTable) this.component.getMetadataList().get(0);
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);
}
this.component.setTableElementParameter(map);
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class RowGeneratorUI method createSchemaComposite.
/**
* qzhang Comment method "createSchemaComposite".
*/
private void createSchemaComposite() {
outputMetaTable = externalNode.getMetadataList().get(0);
uiManager.convert(externalNode, outputMetaTable, functionManager);
//$NON-NLS-1$
metadataTableEditor = new MetadataTableEditorExt(outputMetaTable, "", this.functionManager);
metadataTableEditor.setRowGenUI(this);
inputReadOnly = this.externalNode.getProcess().isReadOnly();
if (this.externalNode.getOriginalNode().getJobletNode() != null) {
inputReadOnly = this.externalNode.getOriginalNode().isReadOnly();
} else if (this.externalNode.getOriginalNode().getJunitNode() != null) {
inputReadOnly = true;
}
dataTableView = new MetadataTableEditorViewExt(datasFlowViewSashForm, SWT.BORDER, metadataTableEditor, inputReadOnly, !inputReadOnly, externalNode, functionManager);
dataTableView.getExtendedTableViewer().setCommandStack(generatorManager.getCommandStack());
dataTableView.setGeneratorUI(this);
dataTableView.setShowDbTypeColumn(true, true, false);
dataTableView.setShowDbColumnName(false, false);
metadataTableEditor.setModifiedBeanListenable(dataTableView.getTableViewerCreator());
// see bug 7471,record the modification of the column value.
metadataTableEditor.addModifiedBeanListener(new IModifiedBeanListener<IMetadataColumn>() {
@Override
public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId())) {
IMetadataColumn modifiedObject = event.bean;
if (modifiedObject != null) {
String originalLabel = changedNameColumns.get(modifiedObject);
if (originalLabel == null) {
changedNameColumns.put(modifiedObject.getLabel(), (String) event.previousValue);
}
}
}
}
});
// resize all the columns but not the table
for (int i = 0; i < dataTableView.getTable().getColumnCount(); i++) {
dataTableView.getTable().getColumn(i).pack();
}
dataTableView.getTable().getColumn(0).setWidth(0);
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class MetadataExtPasteCommand method createPastableBeansList.
@Override
public List createPastableBeansList(ExtendedTableModel extendedTable, List copiedObjectsList) {
ArrayList list = new ArrayList();
ArrayList countList = new ArrayList();
ArrayList<String> labelsExisted = getLabelsExisted(extendedTable);
for (Object current : copiedObjectsList) {
if (current instanceof IMetadataColumn) {
IMetadataColumn copy = ((IMetadataColumn) current).clone();
String nextGeneratedColumnName = ((MetadataTableEditor) extendedTable).getNextGeneratedColumnName(copy.getLabel());
if (labelsExisted.contains(nextGeneratedColumnName)) {
nextGeneratedColumnName = validateColumnName(nextGeneratedColumnName, labelsExisted);
}
labelsExisted.add(nextGeneratedColumnName);
copy.setLabel(nextGeneratedColumnName);
if (copy instanceof MetadataColumnExt) {
list.add(copy);
} else {
MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
list.add(metadataColumnExt);
}
} else if (current instanceof org.talend.core.model.metadata.builder.connection.MetadataColumn) {
MetadataTableEditor tableEditor = (MetadataTableEditor) extendedTable;
org.talend.core.model.metadata.builder.connection.MetadataColumn metadataColumn = (org.talend.core.model.metadata.builder.connection.MetadataColumn) current;
String nextGeneratedColumnName = metadataColumn.getLabel();
//$NON-NLS-1$
String tempNewColumnName = "";
boolean iMetaColumnUnique = false;
boolean metaColumnUnique = false;
while (iMetaColumnUnique == false || metaColumnUnique == false) {
nextGeneratedColumnName = tableEditor.getNextGeneratedColumnName(nextGeneratedColumnName, null);
iMetaColumnUnique = true;
metaColumnUnique = false;
if (list.size() == 0)
metaColumnUnique = true;
else {
tempNewColumnName = this.getUniqueString(list, nextGeneratedColumnName);
if (tempNewColumnName.equals(nextGeneratedColumnName))
metaColumnUnique = true;
else {
metaColumnUnique = false;
nextGeneratedColumnName = tempNewColumnName;
}
}
}
org.talend.core.model.metadata.builder.connection.MetadataColumn newColumnCopy = new ConnectionFactoryImpl().copy(metadataColumn, nextGeneratedColumnName);
IMetadataColumn copy = (ConvertionHelper.convertToIMetaDataColumn(newColumnCopy)).clone();
copy.setLabel(nextGeneratedColumnName);
MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
list.add(metadataColumnExt);
countList.add(nextGeneratedColumnName);
}
}
return list;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class JSONFileOutputStep2Form method initLinker.
private void initLinker(TreeItem node, TableItem[] tableItems) {
FOXTreeNode treeNode = (FOXTreeNode) node.getData();
IMetadataColumn column = treeNode.getColumn();
Properties prop = System.getProperties();
String os = prop.getProperty("os.name");
boolean isLastOne = false;
if (column != null) {
for (int i = 0; i < tableItems.length; i++) {
MetadataColumn metadataColumn = (MetadataColumn) tableItems[i].getData();
if (metadataColumn.getLabel().equals(column.getLabel())) {
// "isLastOne" directly to false
if (os.startsWith("Linux")) {
isLastOne = true;
}
linker.addLoopLink(tableItems[i], tableItems[i].getData(), JSONViewer.getTree(), treeNode, isLastOne);
break;
}
}
}
TreeItem[] children = node.getItems();
for (int i = 0; i < children.length; i++) {
initLinker(children[i], tableItems);
}
}
Aggregations