use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method detachLookupSource.
public static void detachLookupSource(TreeNode treeNode, XmlMapData mapData, boolean detachChildren) {
for (LookupConnection connection : treeNode.getLookupIncomingConnections()) {
TreeNode source = (TreeNode) connection.getSource();
if (source.getLookupOutgoingConnections().contains(connection)) {
source.getLookupOutgoingConnections().remove(connection);
mapData.getConnections().remove(connection);
}
}
treeNode.getLookupIncomingConnections().clear();
if (detachChildren) {
if (!treeNode.getChildren().isEmpty()) {
for (TreeNode child : treeNode.getChildren()) {
detachLookupSource(child, mapData, detachChildren);
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method detachLookupTarget.
public static void detachLookupTarget(TreeNode treeNode, XmlMapData mapData, boolean detachChildren) {
for (LookupConnection connection : treeNode.getLookupOutgoingConnections()) {
if (connection.getTarget() instanceof TreeNode) {
TreeNode target = (TreeNode) connection.getTarget();
if (target.getLookupIncomingConnections().contains(connection)) {
target.getLookupIncomingConnections().remove(connection);
mapData.getConnections().remove(connection);
}
}
}
treeNode.getLookupOutgoingConnections().clear();
if (detachChildren) {
if (!treeNode.getChildren().isEmpty()) {
for (TreeNode child : treeNode.getChildren()) {
detachLookupTarget(child, mapData, detachChildren);
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method updateXPathAndExpression.
public static void updateXPathAndExpression(XmlMapData mapperData, XmlMapExpressionManager expressionManager, TreeNode treeNode, String newName, int xpathReplaceLocation, boolean updateTargetExpression) {
String xpath = treeNode.getXpath();
int xPathLength = getXPathLength(xpath);
String newXPath = "";
// tree child xpath eg : row1.newColum:/class/student/name
if (xpath.split(CHILDREN_SEPARATOR).length == 2) {
String[] split = xpath.split(CHILDREN_SEPARATOR);
// change the root node part eg : row1.newColum
if (xpathReplaceLocation <= 2) {
String[] subSplit = split[0].split(EXPRESSION_SEPARATOR_SPLIT);
if (subSplit.length == 2 && xpathReplaceLocation - 1 >= 0) {
subSplit[xpathReplaceLocation - 1] = newName;
newXPath = subSplit[0] + EXPRESSION_SEPARATOR + subSplit[1] + CHILDREN_SEPARATOR + split[1];
}
} else {
// change the child part eg : class/student/name
String[] subSplit = split[1].split(XPATH_SEPARATOR);
if (xpathReplaceLocation == xPathLength) {
String typeString = "";
if (NodeType.ATTRIBUT.equals(treeNode.getNodeType())) {
typeString = XPATH_ATTRIBUTE;
} else if (NodeType.NAME_SPACE.equals(treeNode.getNodeType())) {
typeString = XPATH_NAMESPACE;
}
subSplit[xpathReplaceLocation - 2 - 1] = typeString + newName;
} else {
subSplit[xpathReplaceLocation - 2 - 1] = newName;
}
newXPath = split[0] + CHILDREN_SEPARATOR;
for (String string : subSplit) {
newXPath = newXPath + string + XPATH_SEPARATOR;
}
newXPath = newXPath.substring(0, newXPath.length() - 1);
}
} else if (xpath.split(XPATH_SEPARATOR).length == 2) {
// normal column
String[] split = xpath.split(XPATH_SEPARATOR);
if (xpathReplaceLocation <= xPathLength && xpathReplaceLocation - 1 >= 0) {
split[xpathReplaceLocation - 1] = newName;
}
newXPath = split[0] + XPATH_SEPARATOR + split[1];
} else {
throw new IllegalArgumentException("Invalid xpath");
}
treeNode.setXpath(newXPath);
if (updateTargetExpression) {
updateTargetExpression(treeNode, xpath, expressionManager);
} else {
if (mapperData == null) {
return;
}
XmlMapUtil.detachNodeConnections(treeNode, mapperData, true);
}
if (!treeNode.getChildren().isEmpty()) {
for (TreeNode child : treeNode.getChildren()) {
updateXPathAndExpression(mapperData, expressionManager, child, newName, xpathReplaceLocation, updateTargetExpression);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method cleanGroup.
public static boolean cleanGroup(List<? extends TreeNode> nodes) {
boolean changed = false;
for (TreeNode obj : nodes) {
OutputTreeNode outputNode = (OutputTreeNode) obj;
if (outputNode.isGroup()) {
outputNode.setGroup(false);
changed = true;
}
if (!outputNode.getChildren().isEmpty()) {
changed = cleanGroup(outputNode.getChildren()) || changed;
}
}
return changed;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method cleanSubGroup.
public static void cleanSubGroup(TreeNode node, List<TreeNode> newLoopUpGroups) {
for (TreeNode treeNode : node.getChildren()) {
TreeNode child = treeNode;
if (child.isGroup()) {
if (newLoopUpGroups == null || newLoopUpGroups.isEmpty()) {
child.setGroup(false);
} else {
boolean found = false;
for (TreeNode group : newLoopUpGroups) {
if (child == group) {
found = true;
break;
}
}
if (!found) {
child.setGroup(false);
}
}
}
cleanSubGroup(child, newLoopUpGroups);
}
}
Aggregations