use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method detachConnectionsTarget.
public static void detachConnectionsTarget(AbstractNode treeNode, XmlMapData mapData, boolean detachChildren) {
for (Connection connection : treeNode.getOutgoingConnections()) {
AbstractNode target = connection.getTarget();
if (target.getIncomingConnections().contains(connection)) {
target.getIncomingConnections().remove(connection);
mapData.getConnections().remove(connection);
}
}
treeNode.getOutgoingConnections().clear();
// TreeNode detach children's connections
if (treeNode instanceof TreeNode) {
TreeNode inputTreeNode = (TreeNode) treeNode;
if (detachChildren && !inputTreeNode.getChildren().isEmpty()) {
for (int i = 0; i < inputTreeNode.getChildren().size(); i++) {
TreeNode child = inputTreeNode.getChildren().get(i);
detachConnectionsTarget(child, mapData);
}
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method checkMultiLoopsStatus.
public static boolean checkMultiLoopsStatus(AbstractInOutTree tree) {
// set multiloops to true only if one doc schema have more then one loops , if a table have two doc schema but
// each one only have one loop,multiloops should be false
List<? extends TreeNode> children = new ArrayList<TreeNode>();
if (tree instanceof InputXmlTree) {
children = ((InputXmlTree) tree).getNodes();
} else if (tree instanceof OutputXmlTree) {
children = ((OutputXmlTree) tree).getNodes();
}
List<TreeNode> docChildren = new ArrayList<TreeNode>();
for (TreeNode child : children) {
if (DOCUMENT.equals(child.getType())) {
docChildren.add(child);
}
}
List<TreeNode> loopNodes = new ArrayList<TreeNode>();
for (TreeNode doc : docChildren) {
getChildLoops(loopNodes, doc.getChildren());
if (loopNodes.size() > 1) {
return true;
}
}
return false;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method getChildLookupConnections.
private static void getChildLookupConnections(List<IConnection> connections, List<? extends TreeNode> nodesList) {
for (TreeNode node : nodesList) {
EList<LookupConnection> outgoingConnections = node.getLookupOutgoingConnections();
connections.addAll(outgoingConnections);
if (!node.getChildren().isEmpty()) {
getChildLookupConnections(connections, node.getChildren());
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapUtil method removeloopInOutputTree.
/**
*
* DOC WCHEN Remove source loops refrenced from input main
*
* @param mapData
* @param mainInput
* @param oldLoopsFromInput
* @param checkProblem
*/
public static void removeloopInOutputTree(XmlMapData mapData, InputXmlTree mainInput, List<TreeNode> oldLoopsFromInput, boolean checkProblem) {
boolean isMainInputMultiLoop = mainInput == null ? false : mainInput.isMultiLoops();
EList<OutputXmlTree> outputTrees = mapData.getOutputTrees();
for (OutputXmlTree outputTree : outputTrees) {
if (isMainInputMultiLoop) {
for (TreeNode oldLoop : oldLoopsFromInput) {
EList<InputLoopNodesTable> inputLoopNodesTables = outputTree.getInputLoopNodesTables();
for (InputLoopNodesTable inputLoopTable : inputLoopNodesTables) {
inputLoopTable.getInputloopnodes().remove(oldLoop);
}
}
} else {
List<TreeNode> multiLoopsForXmlTree = getMultiLoopsForXmlTree(outputTree);
for (TreeNode loop : multiLoopsForXmlTree) {
((OutputTreeNode) loop).setInputLoopNodesTable(null);
}
outputTree.getInputLoopNodesTables().clear();
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapConnectionBuilder method rebuildLink.
private void rebuildLink(int inputTreeIndex, List<TreeNode> children, XmlMapData mapData) {
for (TreeNode treeNode : children) {
if (XmlMapUtil.isDragable(treeNode)) {
String expression = XmlMapUtil.convertToExpression(treeNode.getXpath());
XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
TableEntryLocation sourceLocation = expressionManager.parseTableEntryLocation(expression).get(0);
// LOOKUP ,FILTER
for (int i = inputTreeIndex; i < mapData.getInputTrees().size(); i++) {
InputXmlTree treeTarget = mapData.getInputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, treeTarget, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, treeTarget, mapData);
}
checkTargetChildren(expressionManager, treeTarget.getNodes(), treeNode, sourceLocation, mapData);
}
// VAR
for (VarNode varNode : mapData.getVarTables().get(0).getNodes()) {
if (hasMaptchedLocation(expressionManager, sourceLocation, varNode, ExpressionType.EXPRESSION)) {
createConnection(treeNode, varNode, mapData);
}
}
// OUTPUT,FILTER
for (int i = 0; i < mapData.getOutputTrees().size(); i++) {
OutputXmlTree outputTree = mapData.getOutputTrees().get(i);
if (hasMaptchedLocation(expressionManager, sourceLocation, outputTree, ExpressionType.EXPRESSION_FILTER)) {
createFilterConnection(treeNode, outputTree, mapData);
}
checkTargetChildren(expressionManager, outputTree.getNodes(), treeNode, sourceLocation, mapData);
}
}
if (!treeNode.getChildren().isEmpty()) {
rebuildLink(inputTreeIndex, treeNode.getChildren(), mapData);
}
}
}
Aggregations