use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ShadowNode method getMetadataList.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.INode#getMetaDataList()
*/
@Override
public List<IMetadataTable> getMetadataList() {
List<IMetadataTable> metadataList = super.getMetadataList();
if (metadataList != null) {
return metadataList;
}
List<IMetadataTable> metadatas = new ArrayList<IMetadataTable>();
MetadataTable metadata = new MetadataTable();
metadata.setTableName(this.getUniqueName());
List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
for (int i = 0; i < columnNumber; i++) {
MetadataColumn col = new MetadataColumn();
//$NON-NLS-1$
col.setLabel("row" + i);
//$NON-NLS-1$
col.setTalendType("id_String");
//$NON-NLS-1$
col.setType("String");
columns.add(col);
}
metadata.setListColumns(columns);
metadatas.add(metadata);
return metadatas;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method createInputMetadataColumn.
private void createInputMetadataColumn(String sourceTreeName, String targetTreeName, TreeNode sourceNode, String targetNodeName, int index) {
String sourceNodeName = sourceNode.getName();
IMetadataTable metadataTarget = null;
List<IODataComponent> inputs = manager.getMapperComponent().getIODataComponents().getInputs();
for (IODataComponent incoming : inputs) {
if (targetTreeName != null && targetTreeName.equals(incoming.getConnection().getName())) {
metadataTarget = incoming.getTable();
}
}
if (metadataTarget != null) {
IMetadataColumn columnSource = null;
if (sourceTreeName != null) {
columnSource = getSourceColumn(sourceTreeName, sourceNodeName);
}
creatMeatadataColumn(columnSource, targetNodeName, sourceNode, metadataTarget, index);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method createOutputMetadataColumn.
private void createOutputMetadataColumn(String sourceTreeName, String targetTreeName, AbstractNode sourceNode, String targetNodeName, int index) {
String sourceNodeName = sourceNode.getName();
IMetadataTable metadataTarget = null;
List<IMetadataTable> metadataTargets = manager.getMapperComponent().getMetadataList();
if (metadataTargets != null) {
for (IMetadataTable target : metadataTargets) {
if (target.getTableName().equals(targetTreeName)) {
metadataTarget = target;
}
}
}
if (metadataTarget != null) {
IMetadataColumn columnSource = null;
if (sourceTreeName != null) {
columnSource = getSourceColumn(sourceTreeName, sourceNodeName);
}
creatMeatadataColumn(columnSource, targetNodeName, sourceNode, metadataTarget, index);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class MapDataHelper method rebuildInputTree.
public void rebuildInputTree(InputXmlTree inputTree, IMetadataTable metadataTable, XmlMapData mapData) {
if (metadataTable != null && metadataTable.getListColumns() != null) {
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
EList<TreeNode> nodes = inputTree.getNodes();
for (int i = 0; i < listColumns.size(); i++) {
IMetadataColumn column = listColumns.get(i);
TreeNode found = null;
int j = 0;
for (; j < nodes.size(); j++) {
TreeNode node = nodes.get(j);
if (node.getName() != null && node.getName().equals(column.getLabel())) {
found = node;
break;
}
}
if (found != null) {
// set in case talend type changed in metadata
found.setType(column.getTalendType());
if (i != j) {
// do switch to keep the same sequence
TreeNode temp = nodes.get(j);
nodes.remove(j);
nodes.add(i, temp);
}
} else {
found = XmlmapFactory.eINSTANCE.createTreeNode();
found.setName(column.getLabel());
found.setType(column.getTalendType());
found.setNullable(column.isNullable());
found.setXpath(XmlMapUtil.getXPath(inputTree.getName(), found.getName(), found.getNodeType()));
nodes.add(i, found);
}
// add a default root for document
if (XmlMapUtil.DOCUMENT.equals(found.getType())) {
EList<TreeNode> children = found.getChildren();
// if type is changed from a non-document to document
if (children.isEmpty()) {
XmlMapUtil.detachNodeConnections(found, mapData, true);
TreeNode treeRoot = XmlmapFactory.eINSTANCE.createTreeNode();
treeRoot.setName("root");
treeRoot.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
treeRoot.setNodeType(NodeType.ELEMENT);
treeRoot.setXpath(XmlMapUtil.getXPath(found.getXpath(), treeRoot.getName(), treeRoot.getNodeType()));
treeRoot.setLoop(true);
treeRoot.setMain(true);
children.add(treeRoot);
}
} else // remove children and connections for children if not document
{
EList<TreeNode> children = found.getChildren();
if (!children.isEmpty()) {
XmlMapUtil.detachNodeConnections(found, mapData, true);
List<TreeNode> copyOfChildren = new ArrayList<TreeNode>(found.getChildren());
found.getChildren().clear();
if (!inputTree.isLookup() && inputTree.isMultiLoops()) {
List<TreeNode> oldLoops = new ArrayList<TreeNode>();
XmlMapUtil.getChildLoops(oldLoops, copyOfChildren);
inputTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(inputTree));
XmlMapUtil.removeloopInOutputTree(mapData, inputTree, oldLoops);
}
}
}
}
if (nodes.size() > listColumns.size()) {
List unUsed = new ArrayList();
for (int i = listColumns.size(); i < nodes.size(); i++) {
XmlMapUtil.detachNodeConnections(nodes.get(i), mapData, true);
unUsed.add(nodes.get(i));
}
nodes.removeAll(unUsed);
}
}
// be deleted
if (inputTree.isLookup()) {
rebuildInputNodesConnections(inputTree.getNodes(), mapData);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class Connection method initTraceFilterParameters.
/**
* just keep this method in case we need it again in some day, or we can delete it dirrectly, since it is never
* used.
*/
private void initTraceFilterParameters() {
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
IMetadataTable metadataTable = this.getMetadataTable();
if (metadataTable != null) {
for (IMetadataColumn metaColumn : metadataTable.getListColumns()) {
Map<String, Object> line = new HashMap<String, Object>();
line.put(IConnection.TRACE_SCHEMA_COLUMN, metaColumn.getLabel());
line.put(IConnection.TRACE_SCHEMA_COLUMN_CHECKED, true);
line.put(IConnection.TRACE_SCHEMA_COLUMN_CONDITION, null);
values.add(line);
}
}
if (getElementParameter(EParameterName.TRACES_CONNECTION_FILTER.getName()) != null && values != null) {
getElementParameter(EParameterName.TRACES_CONNECTION_FILTER.getName()).setValue(values);
}
}
Aggregations