use of org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection in project tdi-studio-se by Talend.
the class UpdateFilterExpressionCommand method execute.
@Override
public void execute() {
AbstractInOutTree targetTree = (AbstractInOutTree) targetEditPart.getModel();
String expression = targetTree.getExpressionFilter();
if (objects.getToTransfer() != null) {
for (Object obj : objects.getToTransfer()) {
AbstractNode sourceNode = null;
// INPUT == FILTER
if (objects.getType() == TransferdType.INPUT) {
TreeNodeEditPart part = (TreeNodeEditPart) obj;
sourceNode = (TreeNode) part.getModel();
if (expression == null) {
expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
} else {
expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
}
} else // VARE == FILTER
if (objects.getType() == TransferdType.VAR) {
String tableName = "Var";
VarNodeEditPart part = (VarNodeEditPart) obj;
sourceNode = (VarNode) part.getModel();
if (sourceNode.eContainer() instanceof VarTable) {
tableName = ((VarTable) sourceNode.eContainer()).getName();
}
if (expression == null) {
expression = tableName + "." + sourceNode.getName();
} else {
expression = expression + " " + tableName + "." + sourceNode.getName();
}
}
if (sourceNode != null) {
targetTree.setExpressionFilter(expression);
FilterConnection connection = XmlmapFactory.eINSTANCE.createFilterConnection();
connection.setSource(sourceNode);
connection.setTarget(targetTree);
targetTree.getFilterIncomingConnections().add(connection);
sourceNode.getFilterOutGoingConnections().add(connection);
xmlMapData.getConnections().add(connection);
}
// check if need update outputTree InputLoopNodesTable
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection in project tdi-studio-se by Talend.
the class XmlMapFilterConnectionPart method calculateConnOffset.
protected int calculateConnOffset() {
FilterConnection model = (FilterConnection) getModel();
if (model.getSource() == null) {
return 0;
}
TreeNode sourceTreeNode = (TreeNode) model.getSource();
AbstractInOutTree inputTreeNodeRoot = XmlMapUtil.getAbstractInOutTree(sourceTreeNode);
List<IConnection> outConns = new ArrayList<IConnection>();
if (inputTreeNodeRoot instanceof InputXmlTree) {
outConns.addAll(XmlMapUtil.getInputTreeFilterConnections((InputXmlTree) inputTreeNodeRoot));
}
int indexOf = outConns.indexOf(model);
if (indexOf != -1) {
return -(indexOf + 1) * XmlMapUtil.DEFAULT_OFFSET_FILTER;
}
return 0;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection in project tdi-studio-se by Talend.
the class XmlMapDataImplTest method createSparkData.
private XmlMapData createSparkData(String inputDiff, String outputDiff, String varDiff) {
XmlMapData data = XmlmapFactory.eINSTANCE.createXmlMapData();
//
InputXmlTree inputTree = XmlmapFactory.eINSTANCE.createInputXmlTree();
inputTree.setName("input_1");
inputTree.setLookup(true);
inputTree.setInnerJoin(false);
inputTree.setLookupMode("LOAD_ONCE");
inputTree.setMatchingMode("ALL_ROWS");
inputTree.setMinimized(false);
inputTree.setMultiLoops(false);
inputTree.setPersistent(false);
data.getInputTrees().add(inputTree);
TreeNode treeNode = XmlmapFactory.eINSTANCE.createTreeNode();
treeNode.setName("inputTreeNode");
treeNode.setXpath("row1/newColumn");
treeNode.setExpression(inputDiff);
treeNode.setType("id_String");
treeNode.setLoop(false);
treeNode.setPattern(inputDiff);
treeNode.setKey(false);
treeNode.setGroup(false);
treeNode.setMain(false);
treeNode.setDefaultValue("value");
treeNode.setNullable(false);
treeNode.setChoice(false);
treeNode.setSubstitution(false);
treeNode.setOptional(false);
treeNode.setNodeType(org.talend.designer.xmlmap.model.emf.xmlmap.NodeType.ATTRIBUT);
inputTree.getNodes().add(treeNode);
OutputXmlTree outputTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
outputTree.setName("output_1");
outputTree.setReject(false);
outputTree.setRejectInnerJoin(false);
outputTree.setErrorReject(false);
outputTree.setAllInOne(false);
outputTree.setEnableEmptyElement(false);
data.getOutputTrees().add(outputTree);
OutputTreeNode treeNode2 = XmlmapFactory.eINSTANCE.createOutputTreeNode();
treeNode2.setName("outputTreeNode");
treeNode2.setXpath("out/newColumn");
treeNode2.setType("id_String");
treeNode2.setAggregate(false);
treeNode2.setLoop(false);
treeNode2.setPattern(outputDiff);
treeNode2.setExpression(outputDiff);
treeNode2.setKey(false);
treeNode2.setGroup(false);
treeNode2.setMain(false);
treeNode2.setDefaultValue("value");
treeNode2.setNullable(false);
treeNode2.setChoice(false);
treeNode2.setSubstitution(false);
treeNode2.setOptional(false);
treeNode2.setNodeType(org.talend.designer.xmlmap.model.emf.xmlmap.NodeType.ATTRIBUT);
outputTree.getNodes().add(treeNode2);
VarTable vatTable = XmlmapFactory.eINSTANCE.createVarTable();
vatTable.setName("varTable");
vatTable.setMinimized(true);
VarNode varNode = XmlmapFactory.eINSTANCE.createVarNode();
varNode.setName("varNode");
varNode.setNullable(false);
varNode.setType("id_String");
varNode.setExpression(varDiff);
vatTable.getNodes().add(varNode);
data.getVarTables().add(vatTable);
Connection connection = XmlmapFactory.eINSTANCE.createConnection();
connection.setSource(treeNode);
connection.setTarget(treeNode2);
data.getConnections().add(connection);
treeNode.getOutgoingConnections().add(connection);
treeNode2.getIncomingConnections().add(connection);
FilterConnection fc = XmlmapFactory.eINSTANCE.createFilterConnection();
fc.setSource(treeNode);
fc.setTarget(outputTree);
data.getConnections().add(fc);
treeNode.getFilterOutGoingConnections().add(fc);
outputTree.getFilterIncomingConnections().add(fc);
return data;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection in project tdi-studio-se by Talend.
the class XmlMapConnectionBuilder method createFilterConnection.
public void createFilterConnection(AbstractNode sourceNode, AbstractInOutTree targetTree, XmlMapData mapData) {
FilterConnection connection = XmlmapFactory.eINSTANCE.createFilterConnection();
connection.setSource(sourceNode);
connection.setTarget(targetTree);
targetTree.getFilterIncomingConnections().add(connection);
sourceNode.getFilterOutGoingConnections().add(connection);
mapData.getConnections().add(connection);
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection in project tdi-studio-se by Talend.
the class XmlMapUtil method detachFilterTarget.
public static void detachFilterTarget(AbstractNode abstractNode, XmlMapData mapData, boolean detachChildren) {
for (FilterConnection connection : abstractNode.getFilterOutGoingConnections()) {
AbstractInOutTree target = connection.getTarget();
if (target.getFilterIncomingConnections().contains(connection)) {
target.getFilterIncomingConnections().remove(connection);
mapData.getConnections().remove(connection);
}
}
abstractNode.getFilterOutGoingConnections().clear();
if (detachChildren && abstractNode instanceof TreeNode) {
TreeNode treeNode = (TreeNode) abstractNode;
if (!treeNode.getChildren().isEmpty()) {
for (TreeNode child : treeNode.getChildren()) {
detachFilterTarget(child, mapData, detachChildren);
}
}
}
}
Aggregations