I have created some ArrayLists after parsing an xml. Each element of these ArrayList is a map>, so I have now 8 ArrayLists of multimaps, Now I want to check all keys in first ArraList map to a specific value in second ArrayList. If there is a match, taking the value beside this one and search to find this value in keys of third one and so on. At last I can find out that for example key1 in arrayList one is related to key in arrayList 6. basically i want to loop through key and values of each arrayList.
Do you have any suggestions what is the best way doing this.
regards
Iman
Here is part of code:
here is a graph to show what i want to build:
![figure 1][1]
in findFunctionOrg method i want to loop through either multimaps and find a key of map_Aufgabe in values of map_AufAufOrgVerbindung. If i find a match there, i will take the value which appears next to it and will compare it to keys of map_AufOrgKombination, and again look to find a match for this key in values of map_OrgAufOrgVerbindung.
public class Test {
private int countAufgabe = 0;
private int countOrganisationseinheit = 0;
@SuppressWarnings("rawtypes")
private ArrayList<TreeMap> List_Map_Aufgabe = new ArrayList<>();
@SuppressWarnings("rawtypes")
private ArrayList<TreeMap> List_Map_Org = new ArrayList<>();
@SuppressWarnings("rawtypes")
private ArrayList<TreeMap> List_Map_AufAufOrgVerbindung = new ArrayList<>();
private ArrayList<TreeMap> List_Map_AufOrgKombination = new ArrayList<>();
private ArrayList<TreeMap> List_Map_OrgAufOrgVerbindung = new ArrayList<>();
private ArrayList<TreeMap> List_Map_AwbkAufOrgVerbindung = new ArrayList<>();
private ArrayList<TreeMap> List_Map_ABKonfiguration = new ArrayList<>();
private ArrayList<TreeMap> List_Map_AwbAwbkVerbindung = new ArrayList<>();
private ArrayList<TreeMap> List_Map_RechAnwendungsbaustein = new ArrayList<>();
private ArrayList<TreeMap> List_Map_KonAnwendungsbaustein = new ArrayList<>();
private ArrayList<TreeMap> List_Map_AufAufVerbindung = new ArrayList<>();
private TreeMap<String, List<String>> map_Auf = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_Org = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_AufAufOrgVerbindung = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_AufOrgKombination = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_OrgAufOrgVerbindung = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_AwbkAufOrgVerbindung = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_ABKonfiguration = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_AwbAwbkVerbindung = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_RechAnwendungsbaustein = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_KonAnwendungsbaustein = new TreeMap<String, List<String>>();
private TreeMap<String, List<String>> map_AufAufVerbindung = new TreeMap<String, List<String>>();
public int getCountAufgabe() {
return countAufgabe;
}
public int getCountOrganisationseinheit() {
return countOrganisationseinheit;
}
public void pars3LGM(String pfadzumLesen) {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(pfadzumLesen);
NodeList elementList = doc.getElementsByTagName("element");
for (int i = 0; i < elementList.getLength(); i++) {
Node el = elementList.item(i);
if (el.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) el;
String nameClass = element.getAttribute("class");
/*
* find Aufgaben
*/
if (nameClass.equals("Aufgabe")) {
countAufgabe++;
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("Aufgabe");
valSet.add(element.getElementsByTagName("field")
.item(1).getTextContent());// name of function
valSet.add(element.getElementsByTagName("field")
.item(2).getTextContent()); // Description
map_Auf.put(element.getAttribute("hash"), valSet);
}// end if Aufgabe
/*
* find Organizations
*/
else if (nameClass.equals("Organisationseinheit")) {
countOrganisationseinheit++;
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("Organisation");
valSet.add(element.getElementsByTagName("field")
.item(1).getTextContent());// name of Org
valSet.add(element.getElementsByTagName("field")
.item(2).getTextContent()); // Description
map_Org.put(element.getAttribute("hash"), valSet);
}
/*
* find AufAufOrgVerbindung
*/
else if (nameClass.equals("AufAufOrgVerbindung")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("AufAufOrgVerbindung");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
valSet.add(element.getElementsByTagName("field")
.item(3).getTextContent());
valSet.add(element.getElementsByTagName("field")
.item(4).getTextContent());
map_AufAufOrgVerbindung.put(
element.getAttribute("hash"), valSet);
} else if (nameClass.equals("AufOrgKombination")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("AufOrgKombination");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name of
valSet.add(el.getLastChild().getTextContent());
map_AufOrgKombination.put(element.getAttribute("hash"),
valSet);
} else if (nameClass.equals("OrgAufOrgVerbindung")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("OrgAufOrgVerbindung");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
valSet.add(element.getElementsByTagName("field")
.item(3).getTextContent());
valSet.add(element.getElementsByTagName("field")
.item(4).getTextContent());
map_OrgAufOrgVerbindung.put(
element.getAttribute("hash"), valSet);
} else if (nameClass.equals("AwbkAufOrgVerbindung")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("AwbkAufOrgVerbindung");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
valSet.add(element.getElementsByTagName("field")
.item(3).getTextContent());// start
valSet.add(element.getElementsByTagName("field")
.item(4).getTextContent());// end
map_AwbkAufOrgVerbindung.put(
element.getAttribute("hash"), valSet);
} else if (nameClass.equals("ABKonfiguration")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("ABKonfiguration");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
map_ABKonfiguration.put(element.getAttribute("hash"),
valSet);
} else if (nameClass.equals("AwbAwbkVerbindung")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("AwbAwbkVerbindung");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
valSet.add(element.getElementsByTagName("field")
.item(3).getTextContent());// start
valSet.add(element.getElementsByTagName("field")
.item(4).getTextContent());// end
map_AwbAwbkVerbindung.put(element.getAttribute("hash"),
valSet);
} else if (nameClass.equals("RechAnwendungsbaustein")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("RechAnwendungsbaustein");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
map_RechAnwendungsbaustein.put(
element.getAttribute("hash"), valSet);
} else if (nameClass.equals("KonAnwendungsbaustein")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("KonAnwendungsbaustein");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
map_KonAnwendungsbaustein.put(
element.getAttribute("hash"), valSet);
} else if (nameClass.equals("AufAufVerbindung")) {
ArrayList<String> valSet = new ArrayList<String>(100);
valSet.add("AufAufVerbindung");
// valSet.add(element.getElementsByTagName("field").item(1).getTextContent());//
// name
valSet.add(element.getElementsByTagName("field")
.item(3).getTextContent());// start
valSet.add(element.getElementsByTagName("field")
.item(4).getTextContent());// end
map_AufAufVerbindung.put(element.getAttribute("hash"),
valSet);
}
}
}
List_Map_Org.add(map_Org);
List_Map_AufAufOrgVerbindung.add(map_AufAufOrgVerbindung);
List_Map_Aufgabe.add(map_Auf);
List_Map_AufOrgKombination.add(map_AufOrgKombination);
List_Map_OrgAufOrgVerbindung.add(map_OrgAufOrgVerbindung);
List_Map_AwbkAufOrgVerbindung.add(map_AwbkAufOrgVerbindung);
List_Map_ABKonfiguration.add(map_ABKonfiguration);
List_Map_AwbAwbkVerbindung.add(map_AwbAwbkVerbindung);
List_Map_RechAnwendungsbaustein.add(map_RechAnwendungsbaustein);
List_Map_KonAnwendungsbaustein.add(map_KonAnwendungsbaustein);
List_Map_AufAufVerbindung.add(map_AufAufVerbindung);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void findFunctionOrg() {
String aufgabe = null;
List<String> aufauforg_value;
String auforgkom = null;
List<String> orgauforg_value = null;
//System.out.println(List_Map_Aufgabe.get(0));
//System.out.println(List_Map_AufAufOrgVerbindung);
for (Entry<String, List<String>> entryAuf : map_Auf.entrySet()) {
for (Entry<String, List<String>> entryAufAuforg : map_AufAufOrgVerbindung
.entrySet()) {
for (Entry<String, List<String>> entryAufOrgKom : map_AufOrgKombination
.entrySet()) {
for (Entry<String, List<String>> entryorgauforg : map_OrgAufOrgVerbindung
.entrySet()) {
orgauforg_value = entryorgauforg.getValue();
}
//h
auforgkom = entryAufOrgKom.getKey();
aufgabe = entryAuf.getKey();
aufauforg_value = entryAufAuforg.getValue();
if (aufauforg_value.get(2).contains(aufgabe)
& aufauforg_value.get(3).contains(auforgkom))
System.out.println(aufauforg_value.get(2) + " "
+ aufgabe + " " + aufauforg_value.get(3)
+ " " + auforgkom);
}
}
}
}