use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class FOXManager method orderNode.
/**
*
* wzhang Comment method "orderNode".
*
* @param node
*/
public void orderNode(FOXTreeNode node) {
// reset the order.
if (node != null) {
List<FOXTreeNode> firstSubChildren = node.getChildren();
FOXTreeNode foundNode = null;
for (FOXTreeNode childen : firstSubChildren) {
if (childen.isLoop()) {
foundNode = childen;
sortOrder(foundNode, node);
break;
} else if (childen.isGroup()) {
foundNode = childen;
sortOrder(foundNode, node);
orderNode(childen);
} else {
orderNode(childen);
}
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class FOXManager method tableLoader.
protected void tableLoader(Element element, String parentPath, List<Map<String, String>> table, String defaultValue) {
Map<String, String> newMap = new HashMap<String, String>();
//$NON-NLS-1$
String currentPath = parentPath + "/" + element.getLabel();
newMap.put(FileOutputXMLComponent.PATH, currentPath);
newMap.put(FileOutputXMLComponent.COLUMN, element.getColumnLabel());
//$NON-NLS-1$ //$NON-NLS-2$
newMap.put(FileOutputXMLComponent.ATTRIBUTE, element.isMain() ? "main" : "branch");
//$NON-NLS-1$
newMap.put(FileOutputXMLComponent.VALUE, defaultValue);
newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(element)));
table.add(newMap);
for (FOXTreeNode att : element.getAttributeChildren()) {
newMap = new HashMap<String, String>();
newMap.put(FileOutputXMLComponent.PATH, att.getLabel());
newMap.put(FileOutputXMLComponent.COLUMN, att.getColumnLabel());
//$NON-NLS-1$
newMap.put(FileOutputXMLComponent.ATTRIBUTE, "attri");
//$NON-NLS-1$
newMap.put(FileOutputXMLComponent.VALUE, att.getDefaultValue());
newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(att)));
table.add(newMap);
}
for (FOXTreeNode att : element.getNameSpaceChildren()) {
newMap = new HashMap<String, String>();
newMap.put(FileOutputXMLComponent.PATH, att.getLabel());
newMap.put(FileOutputXMLComponent.COLUMN, att.getColumnLabel());
//$NON-NLS-1$
newMap.put(FileOutputXMLComponent.ATTRIBUTE, "ns");
//$NON-NLS-1$
newMap.put(FileOutputXMLComponent.VALUE, att.getDefaultValue());
newMap.put(FileOutputXMLComponent.ORDER, String.valueOf(getNodeOrder(att)));
table.add(newMap);
}
List<FOXTreeNode> children = element.getElementChildren();
for (FOXTreeNode child : children) {
if (!child.isGroup() && !child.isLoop()) {
tableLoader((Element) child, currentPath, table, child.getDefaultValue());
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class FOXManager method addElement.
protected FOXTreeNode addElement(FOXTreeNode current, String currentPath, String newPath, String defaultValue) {
//$NON-NLS-1$
String name = newPath.substring(newPath.lastIndexOf("/") + 1);
//$NON-NLS-1$
String parentPath = newPath.substring(0, newPath.lastIndexOf("/"));
FOXTreeNode temp = new Element(name, defaultValue);
if (current == null) {
// root node
return temp;
}
if (currentPath.equals(parentPath)) {
current.addChild(temp);
} else {
//$NON-NLS-1$
String[] nods = currentPath.split("/");
//$NON-NLS-1$
String[] newNods = parentPath.split("/");
int parentLevel = 0;
int checkLength = nods.length < newNods.length ? nods.length : newNods.length;
for (int i = 1; i < checkLength; i++) {
if (nods[i].equals(newNods[i])) {
parentLevel = i;
}
}
FOXTreeNode parent = current;
for (int i = 0; i < nods.length - (parentLevel + 1); i++) {
FOXTreeNode tmpParent = parent.getParent();
if (tmpParent == null) {
break;
}
parent = tmpParent;
}
if (parent != null)
parent.addChild(temp);
}
return temp;
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class MultiFOXManager method initNodeOrder.
public void initNodeOrder(FOXTreeNode node) {
if (node == null) {
return;
}
FOXTreeNode parent = node.getParent();
if (parent == null) {
node.setOrder(1);
String path = TreeUtil.getPath(node);
Map<String, Integer> xpathMap = orderMap.get(node.getRow());
if (xpathMap == null) {
xpathMap = new HashMap<String, Integer>();
orderMap.put(node.getRow(), xpathMap);
}
xpathMap.put(path, order);
order++;
}
List<FOXTreeNode> childNode = node.getChildren();
for (FOXTreeNode child : childNode) {
child.setOrder(order);
String path = TreeUtil.getPath(child);
Map<String, Integer> xpathMap = orderMap.get(child.getRow());
if (xpathMap == null) {
xpathMap = new HashMap<String, Integer>();
orderMap.put(child.getRow(), xpathMap);
}
xpathMap.put(path, order);
order++;
if (child.getChildren().size() > 0) {
initNodeOrder(child);
}
}
}
use of org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode in project tdi-studio-se by Talend.
the class MultiFOXManager method getLoopTable.
@Override
public List<Map<String, String>> getLoopTable() {
List<Map<String, String>> result = new ArrayList<Map<String, String>>();
for (FOXTreeNode rootNode : this.getOriginalNodes()) {
Element loopNode = (Element) org.talend.metadata.managment.ui.wizard.metadata.xml.utils.TreeUtil.getLoopNode(rootNode);
if (loopNode != null) {
String path = TreeUtil.getPath(loopNode);
//$NON-NLS-1$
tableLoader(loopNode, path.substring(0, path.lastIndexOf("/")), result, loopNode.getDefaultValue());
}
}
return result;
}
Aggregations