use of org.jdom.output.XMLOutputter in project vcell by virtualcell.
the class RulebasedTransformer method compareOperations.
private static void compareOperations(Element eTheirs, Element eOurs) {
XMLOutputter outp = new XMLOutputter();
Set<String> theirOperations = new HashSet<String>();
Set<String> ourOperations = new HashSet<String>();
Element le = eTheirs.getChild("ListOfOperations", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
List<Element> children = new ArrayList<Element>();
children = le.getChildren();
for (Element e : children) {
String s = outp.outputString(e);
s = s.replace("xmlns=\"http://www.sbml.org/sbml/level3\"", "");
s = s.replaceAll("\\s+", "");
if (theirOperations.add(s) == false) {
System.out.println("Duplicate their operation: " + s);
}
System.out.println(s);
}
le = eOurs.getChild("ListOfOperations");
children = le.getChildren();
for (Element e : children) {
String s = outp.outputString(e);
s = s.replace(".0", "");
s = s.replaceAll("\\s+", "");
if (ourOperations.add(s) == false) {
System.out.println("Duplicate our operation: " + s);
}
System.out.println(s);
}
List<String> theirUnmatched = new ArrayList<String>();
for (String their : theirOperations) {
if (!ourOperations.contains(their)) {
theirUnmatched.add(their);
}
}
List<String> ourUnmatched = new ArrayList<String>();
for (String our : ourOperations) {
if (!theirOperations.contains(our)) {
ourUnmatched.add(our);
}
}
if (!theirUnmatched.isEmpty() || !ourUnmatched.isEmpty()) {
String s1 = "theirs: ";
String s2 = "ours : ";
for (String their : theirUnmatched) {
s1 += their + "' ";
}
for (String our : ourUnmatched) {
s2 += our + "' ";
}
throw new RuntimeException("Operations not matching for rule\n" + s1 + "\n" + s2 + "\n");
} else {
System.out.println("Operations matching for rule");
}
}
use of org.jdom.output.XMLOutputter in project vcell by virtualcell.
the class RulebasedTransformer method parseObservablesBngOutput.
private void parseObservablesBngOutput(SimulationContext simContext, BNGOutput bngOutput) {
Model model = simContext.getModel();
Document bngNFSimXMLDocument = bngOutput.getNFSimXMLDocument();
bngRootElement = bngNFSimXMLDocument.getRootElement();
Element modelElement = bngRootElement.getChild("model", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
Element listOfObservablesElement = modelElement.getChild("ListOfObservables", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
XMLOutputter outp = new XMLOutputter();
String sTheirs = outp.outputString(listOfObservablesElement);
sTheirs = sTheirs.replace("xmlns=\"http://www.sbml.org/sbml/level3\"", "");
// System.out.println("==================== Their Observables ===================================================================");
// System.out.println(sTheirs);
// System.out.println("=======================================================================================");
saveAsText("c:\\TEMP\\ddd\\theirObservables.txt", sTheirs);
// sTheirs = sTheirs.replaceAll("\\s+","");
}
use of org.jdom.output.XMLOutputter in project vcell by virtualcell.
the class ExportRawTimeSeriesToVFrapOp method exportToVFRAP.
public void exportToVFRAP(File vfrapFile, ImageTimeSeries<UShortImage> imageTimeSeries, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
Xmlproducer vcellXMLProducer = new Xmlproducer(false);
boolean bSaveCompressed = true;
ImageDataset imageData = new ImageDataset(imageTimeSeries.getAllImages(), imageTimeSeries.getImageTimeStamps(), imageTimeSeries.getSizeZ());
Element root = new Element(MicroscopyXMLTags.FRAPStudyTag);
Element next = new Element(MicroscopyXMLTags.FRAPDataTag);
root.addContent(next);
Element imageDataXML = MicroscopyXmlproducer.getXML(imageData, vcellXMLProducer, clientTaskStatusSupport, bSaveCompressed);
next.addContent(imageDataXML);
java.io.FileOutputStream fileOutStream = new java.io.FileOutputStream(vfrapFile);
BufferedOutputStream bufferedStream = new BufferedOutputStream(fileOutStream);
// XmlUtil.writeXmlToStream(root, false, bufferedStream);
XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
xmlOut.getFormat().setTextMode(Format.TextMode.PRESERVE);
xmlOut.output(root, bufferedStream);
bufferedStream.flush();
fileOutStream.flush();
fileOutStream.close();
}
use of org.jdom.output.XMLOutputter in project vcell by virtualcell.
the class BiomodelsDB_TestSuite method writeSupportedModelsReport.
public static Document writeSupportedModelsReport(File supportInfoDir, File saveSupportedXMLPathname) throws Exception {
if (!supportInfoDir.isDirectory()) {
throw new IllegalArgumentException("File " + supportInfoDir.getAbsolutePath() + " must be a directory.");
}
File[] xmlReportFiles = supportInfoDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isFile()) {
if (pathname.getName().endsWith("_report.xml")) {
return true;
}
}
return false;
}
});
Document supportedDocument = new Document(new Element("Supported_BioModelsNet"));
List<Element> supportedElements = new ArrayList<Element>();
for (int i = 0; i < xmlReportFiles.length; i++) {
byte[] xmlBytes = new byte[(int) xmlReportFiles[i].length()];
FileInputStream fis = new FileInputStream(xmlReportFiles[i]);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
dis.readFully(xmlBytes);
dis.close();
Document document = XmlUtil.stringToXML(new String(xmlBytes), null);
Element bioModelElement = document.getRootElement().getChild(BioModelsNetPanel.BIOMODELINFO_ELEMENT_NAME);
Attribute supportedAttribute = bioModelElement.getAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME);
if (supportedAttribute.getBooleanValue()) {
Element newBioModelElement = new Element(BioModelsNetPanel.BIOMODELINFO_ELEMENT_NAME);
@SuppressWarnings("unchecked") List<Attribute> attrList = bioModelElement.getAttributes();
Iterator<Attribute> iterAttr = attrList.iterator();
while (iterAttr.hasNext()) {
newBioModelElement.setAttribute((Attribute) iterAttr.next().clone());
}
supportedElements.add(newBioModelElement);
}
}
// Collections.sort(supportedElements, new ElementComparer());
Element root = supportedDocument.getRootElement();
for (Element e : supportedElements) {
root.addContent(e);
}
if (saveSupportedXMLPathname != null) {
try (FileWriter fw = new FileWriter(saveSupportedXMLPathname.getAbsolutePath())) {
Format format = Format.getPrettyFormat();
XMLOutputter out = new XMLOutputter(format);
out.output(supportedDocument, fw);
}
}
return supportedDocument;
}
use of org.jdom.output.XMLOutputter in project yamcs-studio by yamcs.
the class XMLUtil method getXMLOutputter.
/**
* Create and configure an XMLOutputter object.
*
* @param prettyFormat
* @return the XMLOutputter
*/
private static XMLOutputter getXMLOutputter(boolean prettyFormat) {
Format format = Format.getRawFormat();
if (prettyFormat)
// $NON-NLS-1$
format.setIndent(" ");
// Always use Unix-style line endings.
format.setLineSeparator("\n");
XMLOutputter xmlOutputter = new XMLOutputter();
xmlOutputter.setFormat(format);
return xmlOutputter;
}
Aggregations