final DocumentBuilder documentBuilder = factory.newDocumentBuilder();
final DataSetQuery[] objects = queries.values().toArray(new DataSetQuery[queries.size()]);
for (int i = 0; i < objects.length; i++)
{
final DataSetQuery object = objects[i];
final String text = object.getQuery();
if (StringUtils.isEmpty(text, true))
{
continue;
}
try
{
final Document doc = documentBuilder.parse(new InputSource(new StringReader(text)));
final NodeList list = doc.getDocumentElement().getElementsByTagName("domain_id");
if (list.getLength() == 0)
{
continue;
}
list.item(0).setTextContent(domainIdTextField.getText());
final TransformerFactory tfactory = TransformerFactory.newInstance();
final StringWriter stringWriter = new StringWriter();
final StreamResult result = new StreamResult();
result.setWriter(stringWriter);
tfactory.newTransformer().transform(new DOMSource(doc), result);
object.setQuery(stringWriter.getBuffer().toString());
}
catch (Exception e)
{
context.error(e);
}
}
}
catch (Exception e)
{
context.error(e);
}
final Object o = queryNameList.getSelectedValue();
if (o != null)
{
final DataSetQuery q = (DataSetQuery) o;
queryTextArea.setText(q.getQuery());
}
}