|
Lines 21-26
Link Here
|
| 21 |
import org.apache.xml.serialize.OutputFormat; |
21 |
import org.apache.xml.serialize.OutputFormat; |
| 22 |
import org.apache.xml.serialize.XMLSerializer; |
22 |
import org.apache.xml.serialize.XMLSerializer; |
| 23 |
import org.eclipse.tptp.monitoring.logui.internal.MonitoringLogUIPlugin; |
23 |
import org.eclipse.tptp.monitoring.logui.internal.MonitoringLogUIPlugin; |
|
|
24 |
import org.eclipse.tptp.monitoring.logui.internal.wizards.LogSetManager; |
| 24 |
|
25 |
|
| 25 |
import org.w3c.dom.Document; |
26 |
import org.w3c.dom.Document; |
| 26 |
import org.w3c.dom.Element; |
27 |
import org.w3c.dom.Element; |
|
Lines 43-57
Link Here
|
| 43 |
|
44 |
|
| 44 |
Document newDocument = builder.newDocument(); |
45 |
Document newDocument = builder.newDocument(); |
| 45 |
|
46 |
|
| 46 |
Element element = (Element) document.getElementsByTagName("logsets").item(0); |
47 |
Element element = (Element) document.getElementsByTagName(LogSetManager.FILTER_TAG).item(0); |
| 47 |
if(element != null) |
48 |
if(element != null) |
| 48 |
{ |
49 |
{ |
| 49 |
buildXMLDocument(element, null, newDocument); |
50 |
buildXMLDocument(element, null, newDocument); |
| 50 |
} |
51 |
} |
| 51 |
|
52 |
|
| 52 |
Node root = newDocument.getElementsByTagName("logsets").item(0); |
53 |
Node root = newDocument.getDocumentElement(); |
| 53 |
|
54 |
|
| 54 |
return toString(root); |
55 |
return toString(root,false); |
| 55 |
} |
56 |
} |
| 56 |
catch (Exception e) |
57 |
catch (Exception e) |
| 57 |
{ |
58 |
{ |
|
Lines 141-146
Link Here
|
| 141 |
} |
142 |
} |
| 142 |
} |
143 |
} |
| 143 |
} |
144 |
} |
|
|
145 |
|
| 146 |
public static String indentXML(String xml) |
| 147 |
{ |
| 148 |
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
| 149 |
try |
| 150 |
{ |
| 151 |
DocumentBuilder builder = factory.newDocumentBuilder(); |
| 152 |
|
| 153 |
Document document = builder.parse(new InputSource(new StringReader(xml))); |
| 154 |
|
| 155 |
return toString(document.getDocumentElement()); |
| 156 |
} |
| 157 |
catch (Exception e) |
| 158 |
{ |
| 159 |
MonitoringLogUIPlugin.log(e); |
| 160 |
return xml; |
| 161 |
} |
| 162 |
} |
| 144 |
|
163 |
|
| 145 |
public static String convertXmlToXmi(String xmlString) |
164 |
public static String convertXmlToXmi(String xmlString) |
| 146 |
{ |
165 |
{ |
|
Lines 153-165
Link Here
|
| 153 |
|
172 |
|
| 154 |
Document newDocument = builder.newDocument(); |
173 |
Document newDocument = builder.newDocument(); |
| 155 |
|
174 |
|
| 156 |
Element element = (Element) document.getElementsByTagName("logsets").item(0); |
175 |
Element element = (Element) document.getElementsByTagName(LogSetManager.FILTER_TAG).item(0); |
| 157 |
if(element != null) |
176 |
if(element != null) |
| 158 |
{ |
177 |
{ |
| 159 |
buildXmiDocument(element, null, newDocument); |
178 |
buildXmiDocument(element, null, newDocument); |
| 160 |
} |
179 |
} |
| 161 |
|
180 |
Node root = newDocument.getDocumentElement(); |
| 162 |
Node root = newDocument.getElementsByTagName("logsets").item(0); |
|
|
| 163 |
|
181 |
|
| 164 |
return toString(root); |
182 |
return toString(root); |
| 165 |
} |
183 |
} |
|
Lines 179-254
Link Here
|
| 179 |
nodeName = "HierarchyExtensions:SimpleSearchQuery"; |
197 |
nodeName = "HierarchyExtensions:SimpleSearchQuery"; |
| 180 |
} |
198 |
} |
| 181 |
|
199 |
|
| 182 |
Element newElement = newDocument.createElement(nodeName); |
200 |
if(nodeName.equals(LogSetManager.FILTER_TAG)) |
| 183 |
|
|
|
| 184 |
Node textChild = element.getFirstChild(); |
| 185 |
if(textChild != null && textChild instanceof Text) |
| 186 |
{ |
201 |
{ |
| 187 |
String data = ((Text)textChild).getData(); |
202 |
Element xmiElement = newDocument.createElement("xmi:XMI"); |
| 188 |
if(data != null) |
203 |
|
| 189 |
newElement.appendChild(newDocument.createTextNode(data)); |
204 |
xmiElement.setAttribute("xmi:version", "2.0"); |
|
|
205 |
xmiElement.setAttribute("xmlns:xmi", "http://www.omg.org/XMI"); |
| 206 |
xmiElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
| 207 |
xmiElement.setAttribute("xmlns:HierarchyExtensions", "http://www.eclipse.org/hyades/models/hierarchy-extensions.xmi"); |
| 208 |
xmiElement.setAttribute("xmlns:ecore", "http://www.eclipse.org/emf/2002/Ecore"); |
| 209 |
|
| 210 |
parent = xmiElement; |
| 211 |
newDocument.appendChild(parent); |
| 190 |
} |
212 |
} |
| 191 |
|
213 |
else |
| 192 |
NamedNodeMap attributes = element.getAttributes(); |
|
|
| 193 |
for(int i = 0; i < attributes.getLength(); i++) |
| 194 |
{ |
214 |
{ |
| 195 |
Node attribute = attributes.item(i); |
215 |
Element newElement = newDocument.createElement(nodeName); |
| 196 |
String name = attribute.getNodeName(); |
|
|
| 197 |
if(name.equals("category")) |
| 198 |
{ |
| 199 |
name = "xsi:type"; |
| 200 |
} |
| 201 |
else if(nodeName.equals("valueType") && name.equals("type")) |
| 202 |
{ |
| 203 |
name = "href"; |
| 204 |
} |
| 205 |
|
216 |
|
| 206 |
String value = attribute.getNodeValue(); |
217 |
Node textChild = element.getFirstChild(); |
| 207 |
if(value.startsWith("Hierarchial")) |
218 |
if(textChild != null && textChild instanceof Text) |
| 208 |
{ |
|
|
| 209 |
value = value.replaceFirst("Hierarchial", "HierarchyExtensions:"); |
| 210 |
} |
| 211 |
else if(value.startsWith("Event:")) |
| 212 |
{ |
| 213 |
value = value.replaceFirst("Event:", "ecore:E"); |
| 214 |
} |
| 215 |
else if(nodeName.equals("valueType") && name.equals("href")) |
| 216 |
{ |
219 |
{ |
| 217 |
value = "http://www.eclipse.org/emf/2002/Ecore#//E" + value; |
220 |
String data = ((Text)textChild).getData(); |
|
|
221 |
if(data != null) |
| 222 |
newElement.appendChild(newDocument.createTextNode(data)); |
| 218 |
} |
223 |
} |
| 219 |
else if(value.startsWith("ImportLogFilterType:")) |
224 |
|
|
|
225 |
NamedNodeMap attributes = element.getAttributes(); |
| 226 |
for(int i = 0; i < attributes.getLength(); i++) |
| 220 |
{ |
227 |
{ |
| 221 |
value = value.replaceFirst("ImportLogFilterType:", "org.eclipse.hyades.log.ui.ImportLogFilterType:"); |
228 |
Node attribute = attributes.item(i); |
|
|
229 |
String name = attribute.getNodeName(); |
| 230 |
if(name.equals("category")) |
| 231 |
{ |
| 232 |
name = "xsi:type"; |
| 233 |
} |
| 234 |
else if(nodeName.equals("valueType") && name.equals("type")) |
| 235 |
{ |
| 236 |
name = "href"; |
| 237 |
} |
| 238 |
|
| 239 |
String value = attribute.getNodeValue(); |
| 240 |
if(value.startsWith("Hierarchial")) |
| 241 |
{ |
| 242 |
value = value.replaceFirst("Hierarchial", "HierarchyExtensions:"); |
| 243 |
} |
| 244 |
else if(value.startsWith("Event:")) |
| 245 |
{ |
| 246 |
value = value.replaceFirst("Event:", "ecore:E"); |
| 247 |
} |
| 248 |
else if(nodeName.equals("valueType") && name.equals("href")) |
| 249 |
{ |
| 250 |
value = "http://www.eclipse.org/emf/2002/Ecore#//E" + value; |
| 251 |
} |
| 252 |
else if(value.startsWith("ImportLogFilterType:")) |
| 253 |
{ |
| 254 |
value = value.replaceFirst("ImportLogFilterType:", "org.eclipse.hyades.log.ui.ImportLogFilterType:"); |
| 255 |
} |
| 256 |
|
| 257 |
newElement.setAttribute(name, value); |
| 222 |
} |
258 |
} |
| 223 |
|
259 |
|
| 224 |
newElement.setAttribute(name, value); |
|
|
| 225 |
} |
| 226 |
|
| 227 |
if(parent == null) |
| 228 |
{ |
| 229 |
newDocument.appendChild(newElement); |
| 230 |
} |
| 231 |
else |
| 232 |
{ |
| 233 |
parent.appendChild(newElement); |
260 |
parent.appendChild(newElement); |
|
|
261 |
parent = newElement; |
| 234 |
} |
262 |
} |
| 235 |
parent = newElement; |
|
|
| 236 |
|
263 |
|
| 237 |
if(nodeName.equals("filters")) |
|
|
| 238 |
{ |
| 239 |
Element xmiElement = newDocument.createElement("xmi:XMI"); |
| 240 |
|
| 241 |
xmiElement.setAttribute("xmi:version", "2.0"); |
| 242 |
xmiElement.setAttribute("xmlns:xmi", "http://www.omg.org/XMI"); |
| 243 |
xmiElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
| 244 |
xmiElement.setAttribute("xmlns:HierarchyExtensions", "http://www.eclipse.org/hyades/models/hierarchy-extensions.xmi"); |
| 245 |
xmiElement.setAttribute("xmlns:ecore", "http://www.eclipse.org/emf/2002/Ecore"); |
| 246 |
|
| 247 |
parent.appendChild(xmiElement); |
| 248 |
|
| 249 |
parent = xmiElement; |
| 250 |
} |
| 251 |
|
| 252 |
NodeList children = element.getChildNodes(); |
264 |
NodeList children = element.getChildNodes(); |
| 253 |
for(int i = 0; i < children.getLength(); i++) |
265 |
for(int i = 0; i < children.getLength(); i++) |
| 254 |
{ |
266 |
{ |