Search in sources :

Example 96 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class DbGenerationManager method getConnectionContextList.

protected List<String> getConnectionContextList(DbMapComponent component) {
    List<String> contextList = new ArrayList<String>();
    List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
    List<Map<String, String>> itemNameList = null;
    for (IConnection iconn : inputConnections) {
        String connName = iconn.getName();
        if (!ContextParameterUtils.containContextVariables(connName)) {
            continue;
        }
        //$NON-NLS-1$
        MapExpressionParser mapParser1 = new MapExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
        itemNameList = mapParser1.parseInTableEntryLocations(connName);
        if (itemNameList == null) {
            return contextList;
        }
        IMetadataTable metadataTable = iconn.getMetadataTable();
        for (Map<String, String> itemNamemap : itemNameList) {
            Set<Entry<String, String>> set = itemNamemap.entrySet();
            Iterator<Entry<String, String>> ite = set.iterator();
            while (ite.hasNext()) {
                Entry<String, String> entry = ite.next();
                String tableValue = entry.getKey();
                String schemaValue = entry.getValue();
                if (metadataTable != null && tableValue.equals(metadataTable.getLabel())) {
                    if (!contextList.contains(schemaValue)) {
                        contextList.add(schemaValue);
                    }
                }
            }
        }
    }
    return contextList;
}
Also used : ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 97 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class ChangeActivateStatusElementCommand method dummyMiddleElement.

private void dummyMiddleElement(boolean undo) {
    Map<List<INode>, List<IConnection>> middConnMap = getAllMiddleConnections();
    Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
    Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
    List<IConnection> notSameForConn = new ArrayList<IConnection>();
    List<INode> notSameForNode = new ArrayList<INode>();
    List<Node> connNodeList = new ArrayList<Node>();
    while (middIte.hasNext()) {
        Entry<List<INode>, List<IConnection>> entry = middIte.next();
        List<INode> nodeList = entry.getKey();
        List<IConnection> connList = entry.getValue();
        if (nodeList.size() == 2) {
            INode firNode = nodeList.get(0);
            INode secNode = nodeList.get(1);
            if (!notSameForNode.contains(firNode)) {
                notSameForNode.add(firNode);
            }
            if (!notSameForNode.contains(secNode)) {
                notSameForNode.add(secNode);
            }
            for (IConnection conn : connList) {
                if (!notSameForConn.contains(conn)) {
                    notSameForConn.add(conn);
                } else {
                    continue;
                }
                Node source = (Node) conn.getSource();
                if (source.getUniqueName() != firNode.getUniqueName() && (source.getUniqueName() != secNode.getUniqueName())) {
                    if (isSameSchemaInputOutput(source)) {
                        conn.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
                        source.setPropertyValue(EParameterName.DUMMY.getName(), true);
                        // source.setPropertyValue(EParameterName.ACTIVATE.getName(), source.isActivate());
                        connNodeList.add(source);
                    }
                }
                Node target = (Node) conn.getTarget();
                if (target.getUniqueName() != firNode.getUniqueName() && (target.getUniqueName() != secNode.getUniqueName())) {
                    if (isSameSchemaInputOutput(target)) {
                        conn.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
                        target.setPropertyValue(EParameterName.DUMMY.getName(), true);
                        // target.setPropertyValue(EParameterName.ACTIVATE.getName(), target.isActivate());
                        connNodeList.add(target);
                    }
                }
            }
        }
    }
    for (Node node : connNodeList) {
        node.setPropertyValue(EParameterName.ACTIVATE.getName(), node.isActivate());
    }
    if (!value) {
        for (Node node : nodeList) {
            if (node.isActivate()) {
                continue;
            }
            Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
            Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
            Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
            while (outIte.hasNext()) {
                Entry<IConnection, Node> en = outIte.next();
                IConnection enConn = en.getKey();
                if (!notSameForConn.contains(enConn)) {
                    // if (enConn.isActivate()) {
                    enConn.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
                    if (!notSameForNode.contains(enConn.getTarget()) && !hasActivateInputOutput((Node) enConn.getTarget())) {
                        enConn.getTarget().setPropertyValue(EParameterName.DUMMY.getName(), value);
                    }
                // }
                }
            }
            Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
            while (inIte.hasNext()) {
                Entry<IConnection, Node> en = inIte.next();
                IConnection enConn = en.getKey();
                if (!notSameForConn.contains(enConn)) {
                    // if (enConn.isActivate()) {
                    enConn.setPropertyValue(EParameterName.ACTIVATE.getName(), value);
                    if (!notSameForNode.contains(enConn.getSource()) && !hasActivateInputOutput((Node) enConn.getSource())) {
                        enConn.getSource().setPropertyValue(EParameterName.DUMMY.getName(), value);
                    }
                // }
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List)

Example 98 with Entry

use of java.util.Map.Entry in project tdi-studio-se by Talend.

the class ChangeActivateStatusElementCommand method getAllMiddleConnections.

private Map<List<INode>, List<IConnection>> getAllMiddleConnections() {
    Map<List<INode>, List<IConnection>> middConnMap = new HashMap<List<INode>, List<IConnection>>();
    Process process;
    if (nodeList.size() > 0) {
        process = (Process) nodeList.get(0).getProcess();
    } else {
        process = (Process) connectionList.get(0).getSource().getProcess();
    }
    List<? extends INode> nodes = process.getGraphicalNodes();
    List<INode> jobletandnodeList = new ArrayList<INode>();
    for (INode node : nodes) {
        if (((Node) node).isJoblet() && !((Node) node).getNodeContainer().isCollapsed() && (((Node) node).getNodeContainer() instanceof AbstractJobletContainer)) {
            for (NodeContainer nc : ((AbstractJobletContainer) ((Node) node).getNodeContainer()).getNodeContainers()) {
                jobletandnodeList.add(nc.getNode());
            }
        } else {
            jobletandnodeList.add(node);
        }
    }
    for (INode node : jobletandnodeList) {
        if (node.isActivate()) {
            Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
            Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
            Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
            boolean haveActivateTarget = false;
            List<INode> nodeList = new ArrayList<INode>();
            List<IConnection> connList = new ArrayList<IConnection>();
            while (outIte.hasNext()) {
                Entry<IConnection, Node> en = outIte.next();
                Node enNode = en.getValue();
                IConnection enConn = en.getKey();
                if (enNode != null) {
                    haveActivateTarget = true;
                    if (!nodeList.contains(node)) {
                        nodeList.add(node);
                    }
                    if (!nodeList.contains(enNode)) {
                        nodeList.add(enNode);
                    }
                }
                if (enConn != null && !connList.contains(enConn)) {
                    connList.add(enConn);
                }
            }
            if (!haveActivateTarget) {
                outMiddleNodes.clear();
            }
            if (!nodeList.isEmpty() && !connList.isEmpty()) {
                Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
                Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
                boolean exist = false;
                while (middIte.hasNext()) {
                    Entry<List<INode>, List<IConnection>> entry = middIte.next();
                    List<INode> enNodeList = entry.getKey();
                    if (enNodeList.size() == 2 && nodeList.size() == 2) {
                        if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
                            exist = true;
                        } else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
                            exist = true;
                        }
                    }
                }
                if (!exist) {
                    middConnMap.put(nodeList, connList);
                }
            }
            Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
            Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
            boolean haveActivateSource = false;
            nodeList = new ArrayList<INode>();
            connList = new ArrayList<IConnection>();
            while (inIte.hasNext()) {
                Entry<IConnection, Node> en = inIte.next();
                Node enNode = en.getValue();
                IConnection enConn = en.getKey();
                if (enNode != null) {
                    haveActivateSource = true;
                    if (!nodeList.contains(node)) {
                        nodeList.add(node);
                    }
                    if (!nodeList.contains(enNode)) {
                        nodeList.add(enNode);
                    }
                }
                if (enConn != null && !connList.contains(enConn)) {
                    connList.add(enConn);
                }
            }
            if (!haveActivateSource) {
                inMiddleNodes.clear();
            }
            if (!nodeList.isEmpty() && !connList.isEmpty()) {
                Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
                Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
                boolean exist = false;
                while (middIte.hasNext()) {
                    Entry<List<INode>, List<IConnection>> entry = middIte.next();
                    List<INode> enNodeList = entry.getKey();
                    if (enNodeList.size() == 2 && nodeList.size() == 2) {
                        if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
                            exist = true;
                        } else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
                            exist = true;
                        }
                    }
                }
                if (!exist) {
                    middConnMap.put(nodeList, connList);
                }
            }
        }
    }
    return middConnMap;
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Process(org.talend.designer.core.ui.editor.process.Process) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List)

Example 99 with Entry

use of java.util.Map.Entry in project zm-mailbox by Zimbra.

the class ZoneInfoParser method analyze.

public void analyze() {
    // Link rules to zones.
    for (Iterator<Entry<String, Zone>> ziter = mZones.entrySet().iterator(); ziter.hasNext(); ) {
        Entry<String, Zone> zentry = ziter.next();
        Zone zone = zentry.getValue();
        Set<ZoneLine> zlines = zone.getZoneLines();
        for (ZoneLine zline : zlines) {
            if (zline.hasRule()) {
                String rname = zline.getRuleName();
                Rule rule = mRules.get(rname);
                if (rule == null) {
                    System.err.println("Unknown rule: " + rname);
                    continue;
                }
                zline.setRule(rule);
            }
        }
    }
    // Flatten links map.
    List<String> aliasesToRemove = new ArrayList<String>();
    Map<String, String> flattenedLinks = new HashMap<String, String>();
    for (Iterator<Entry<String, String>> liter = mLinks.entrySet().iterator(); liter.hasNext(); ) {
        Entry<String, String> lentry = liter.next();
        String alias = lentry.getKey();
        String real = lentry.getValue();
        if (!mZones.containsKey(real)) {
            aliasesToRemove.add(alias);
            while ((real = mLinks.get(real)) != null) {
                if (mZones.containsKey(real)) {
                    if (!alias.equals(real))
                        flattenedLinks.put(alias, real);
                    break;
                }
            }
        }
    }
    for (String alias : aliasesToRemove) {
        mLinks.remove(alias);
    }
    for (Iterator<Entry<String, String>> liter = flattenedLinks.entrySet().iterator(); liter.hasNext(); ) {
        Entry<String, String> lentry = liter.next();
        String alias = lentry.getKey();
        String real = lentry.getValue();
        mLinks.put(alias, real);
    }
    // Register the aliases to zones.
    for (Iterator<Entry<String, String>> liter = mLinks.entrySet().iterator(); liter.hasNext(); ) {
        Entry<String, String> lentry = liter.next();
        String alias = lentry.getKey();
        String real = lentry.getValue();
        Zone zone = mZones.get(real);
        if (zone != null)
            zone.addAlias(alias);
        else
            System.err.println("Invalid state!  Link \"" + alias + "\" points to a non-existent zone \"" + real + "\".");
    }
    mAnalyzed = true;
}
Also used : HashMap(java.util.HashMap) TimeZone(java.util.TimeZone) ArrayList(java.util.ArrayList) Entry(java.util.Map.Entry)

Example 100 with Entry

use of java.util.Map.Entry in project zm-mailbox by Zimbra.

the class CommandChanges method elementChangesWhereBaseIsWrapper.

private void elementChangesWhereBaseIsWrapper(Ancestry ancestry, SoapApiWrapperElement baseWrapper, SoapApiNamedElement currElem) {
    Map<String, SoapApiNamedElement> baseSubElems = makeSubElemMap(baseWrapper.getSubElements());
    if (currElem instanceof SoapApiWrapperElement) {
        // Both "base" and "curr" are wrappers.
        SoapApiWrapperElement currWrapper = (SoapApiWrapperElement) currElem;
        Map<String, SoapApiNamedElement> currSubElems = makeSubElemMap(currWrapper.getSubElements());
        findSubElementChanges(ancestry, baseSubElems, currSubElems);
    } else if (currElem instanceof SoapApiSimpleElement) {
        // "base" was a wrapper.
        SoapApiSimpleElement simpleCurr = (SoapApiSimpleElement) currElem;
        String currJaxbClass = simpleCurr.getJaxb();
        if (currJaxbClass == null) {
            // New class doesn't have children, so, have deleted elements which used to come under wrapper
            for (Entry<String, SoapApiNamedElement> entry : baseSubElems.entrySet()) {
                deletedElems.add(new NamedElem(ancestry.getXpath(), entry.getValue()));
            }
        } else {
            SoapApiType currType = currentTypes.get(currJaxbClass);
            // "base" is a wrapper, so any attributes in "curr" are new
            if (currType.getAttributes() != null) {
                for (SoapApiAttribute attr : currType.getAttributes()) {
                    newAttrs.add(new NamedAttr(ancestry.getXpath(), attr));
                }
            }
            Map<String, SoapApiNamedElement> currSubElems = makeSubElemMap(currType.getSubElements());
            findSubElementChanges(ancestry, baseSubElems, currSubElems);
        }
    }
}
Also used : SoapApiSimpleElement(com.zimbra.doc.soap.apidesc.SoapApiSimpleElement) SoapApiAttribute(com.zimbra.doc.soap.apidesc.SoapApiAttribute) Entry(java.util.Map.Entry) SoapApiNamedElement(com.zimbra.doc.soap.apidesc.SoapApiNamedElement) SoapApiWrapperElement(com.zimbra.doc.soap.apidesc.SoapApiWrapperElement) SoapApiType(com.zimbra.doc.soap.apidesc.SoapApiType) Map(java.util.Map)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103