This commit is contained in:
Lucio Lelii 2009-01-09 10:57:38 +00:00
parent c3fd4dbe0e
commit 4e405bc958
1 changed files with 43 additions and 34 deletions

View File

@ -348,51 +348,60 @@ public class XMLUtil {
@SuppressWarnings("deprecation")
public static String PrepareVREModelXML(ResultSet res) throws Exception{
StringBuilder toReturn=new StringBuilder();
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root;
if (res.next()){
toReturn.append("<Resultset><Name>");
toReturn.append(res.getString(2));
toReturn.append("</Name><Description>");
toReturn.append(res.getString(3));
toReturn.append("</Description><VREDesigner>");
toReturn.append(res.getString(4));
toReturn.append("</VREDesigner><VREManager>");
toReturn.append(res.getString(5));
toReturn.append("</VREManager><StartTime>");
toReturn.append(res.getDate(6).getTime());
toReturn.append("</StartTime><EndTime>");
toReturn.append(res.getDate(7).getTime());
toReturn.append("</EndTime></Resultset>");
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Description",res.getString(2)),
createTextElement(doc, "VREDesigner",res.getString(3)),
createTextElement(doc, "VREManager",res.getString(4)),
createTextElement(doc, "StartTime",res.getString(5)),
createTextElement(doc, "EndTime",res.getString(6)),
});
}else{
Date dateFrom=new Date();
Date dateTo=new Date();
dateTo.setYear(dateTo.getYear()+1);
toReturn=new StringBuilder("<Resultset><Name></Name><Description></Description><VREDesigner></VREDesigner><VREManager></VREManager><StartTime>"+dateFrom.getTime()+"</StartTime><EndTime>"+dateTo.getTime()+"</EndTime></Resultset>");
root= addElements(doc, "Resultset", new Element[]{
createTextElement(doc, "Description",null),
createTextElement(doc, "VREDesigner",null),
createTextElement(doc, "VREManager",null),
createTextElement(doc, "StartTime",null),
createTextElement(doc, "EndTime",null)
});
}
return toReturn.toString();
doc.appendChild(root);
return docToString(doc);
}
public static String PrepareAllVREsXML(ResultSet res) throws Exception{
StringBuilder toReturn=new StringBuilder();
toReturn.append("<ResultSet>");
Document doc= null;
try {
doc= DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e1) {
logger.error("Error creating XML Message");
e1.printStackTrace();
}
Element root= doc.createElement("ResultSet");
Element vreEl;
while (res.next()){
toReturn.append("<VRE><Name>");
toReturn.append(res.getString(1));
toReturn.append("</Name><Description>");
toReturn.append(res.getString(2));
toReturn.append("</Description><State>");
toReturn.append(res.getString(3));
toReturn.append("</State><EPR>");
toReturn.append(res.getString(4));
toReturn.append("</EPR></VRE>");
vreEl= addElements(doc, "VRE", new Element[]{
createTextElement(doc, "Name",res.getString(1)),
createTextElement(doc, "Description",res.getString(2)),
createTextElement(doc, "State",res.getString(3)),
createTextElement(doc, "EPR",res.getString(4))
});
root.appendChild(vreEl);
}
toReturn.append("</ResultSet>");
return toReturn.toString();
doc.appendChild(root);
return docToString(doc);
}
/**