This commit is contained in:
Lucio Lelii 2009-01-09 16:41:20 +00:00
parent 4e405bc958
commit 47253bb217
1 changed files with 22 additions and 18 deletions

View File

@ -143,7 +143,7 @@ public class XMLUtil {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Hashtable<Element, ArrayList<Element>> MDFHash= new Hashtable<Element, ArrayList<Element>>();
Hashtable<String, Couple<Element, ArrayList<Element>>> MDFHash= new Hashtable<String, Couple<Element, ArrayList<Element>>>();
Element mflEl= doc.createElement("MFL");
ArrayList<Element> tempArray;
@ -184,11 +184,11 @@ public class XMLUtil {
});
}
//logger.debug("MDFProva: "+keyTemp+" "+temp);
if(MDFHash.contains(tmpKeyEl)) MDFHash.get(tmpKeyEl).add(tmpEl);
if(MDFHash.contains(resNative.getString(1))) MDFHash.get(resNative.getString(1)).second.add(tmpEl);
else{
tempArray=new ArrayList<Element>();
tempArray.add(tmpEl);
MDFHash.put(tmpKeyEl, tempArray );
MDFHash.put(resNative.getString(1), new Couple<Element, ArrayList<Element>>(tmpKeyEl, tempArray) );
}
//logger.debug("MDFProva: Native "+MDFHash.get(keyTemp).size());
}
@ -217,11 +217,11 @@ public class XMLUtil {
});
}
//logger.debug("MDFProva: Derivable "+keyTemp+" "+temp);
if(MDFHash.contains(tmpKeyEl)) MDFHash.get(tmpKeyEl).add(tmpEl);
if(MDFHash.contains(resNative.getString(1))) MDFHash.get(resNative.getString(1)).second.add(tmpEl);
else{
tempArray=new ArrayList<Element>();
tempArray.add(tmpEl);
MDFHash.put(tmpKeyEl, tempArray );
MDFHash.put(resNative.getString(1), new Couple<Element, ArrayList<Element>>(tmpKeyEl, tempArray) );
}
}
@ -232,15 +232,15 @@ public class XMLUtil {
}
Element collectionListEl= doc.createElement("CollectionList");
Element key;
Enumeration<Element> k=MDFHash.keys();
String key;
Enumeration<String> k=MDFHash.keys();
while (k.hasMoreElements()){
key= k.nextElement();
ArrayList<Element> tempMD=MDFHash.get(key);
Couple<Element, ArrayList<Element>> tempMD=MDFHash.get(key);
//logger.debug("ArrayProva"+tempMD.size());
collectionListEl.appendChild(addElements(doc, "Collection", new Element[]{
key, addElements(doc, "MetadataFormatList", tempMD.toArray(new Element[0]))
}));
tempMD.first.appendChild(addElements(doc, "MetadataFormatList", tempMD.second.toArray(new Element[0])));
collectionListEl.appendChild(tempMD.first);
}
doc.appendChild(addElements(doc, "ResultSet", new Element[]{mflEl, collectionListEl}));
@ -293,23 +293,22 @@ public class XMLUtil {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("ResultSet");
Element root= doc.createElement("Resultset");
try {
while(res.next()){
Element functionalityEl= createTextElement(doc, "Functionality", null, new Couple<String, String>("id", res.getInt(1)+""),
new Couple<String, String>("name", res.getString(2)),
new Couple<String, String>("enableCS", res.getInt(1)==10 ? "true" : "false"),
new Couple<String, String>("enableCS", res.getInt(1)==10 ? "true": "false"),
new Couple<String, String>("selected", selectedFunct.contains(res.getInt(1)) ? "true" : "false")
);
);
functionalityEl.appendChild(createTextElement(doc, "FunctionalityDescription", res.getString(3)));
ResultSet subFunctRes=DBInterface.queryDB("select * from FUNCTIONALITY where father='"+res.getInt(1)+"';");
while(subFunctRes.next()){
Element subFunctEl=createTextElement(doc,"Functionality" , null, new Couple<String, String>("id", subFunctRes.getInt(1)+""),
new Couple<String, String>("name", subFunctRes.getString(2)),
new Couple<String, String>("enableCS", subFunctRes.getInt(1)==10 ? "true" : "false"),
new Couple<String, String>("selected", selectedFunct.contains(subFunctRes.getInt(1)) ? "true" : "false"));
subFunctEl.appendChild(createTextElement(doc, "FunctionalityDescription", subFunctRes.getString(3)));
@ -359,6 +358,7 @@ public class XMLUtil {
if (res.next()){
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Name",res.getString(1)),
createTextElement(doc, "Description",res.getString(2)),
createTextElement(doc, "VREDesigner",res.getString(3)),
createTextElement(doc, "VREManager",res.getString(4)),
@ -368,6 +368,7 @@ public class XMLUtil {
}else{
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Name",null),
createTextElement(doc, "Description",null),
createTextElement(doc, "VREDesigner",null),
createTextElement(doc, "VREManager",null),
@ -426,6 +427,9 @@ public class XMLUtil {
logger.error("transformation to String Error");
e.printStackTrace();
}
System.out.println("----------------------------------------------------------------------");
System.out.println(temp);
System.out.println("----------------------------------------------------------------------");
return temp;
}
/**
@ -450,8 +454,8 @@ public class XMLUtil {
* @param text the text to add at the element
* @return the result element
*/
public static Element createTextElement(Document doc, String Tag, String text, Couple<String, String> ... attributes ){
Element returnEl= doc.createElement("UpTime");
public static Element createTextElement(Document doc, String tag, String text, Couple<String, String> ... attributes ){
Element returnEl= doc.createElement(tag);
if (attributes!=null){
for (Couple<String, String> attribute : attributes){
returnEl.setAttribute(attribute.first, attribute.second);