Search in sources :

Example 1 with FilterConnection

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
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart)

Example 2 with FilterConnection

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;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)

Example 3 with FilterConnection

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;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 4 with FilterConnection

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);
}
Also used : FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)

Example 5 with FilterConnection

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);
            }
        }
    }
}
Also used : FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)

Aggregations

FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)10 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)8 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)6 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)5 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)5 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)4 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)4 ArrayList (java.util.ArrayList)3 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)3 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)3 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)3 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)3 IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)2 INodeConnection (org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection)2 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)2 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)2 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)2 TableEntryLocation (org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation)2 HashMap (java.util.HashMap)1 List (java.util.List)1