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;
}
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);
}
// }
}
}
}
}
}
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;
}
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;
}
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);
}
}
}
Aggregations