@SuppressWarnings("unchecked") @Override public boolean check(ValidationContext ctx, SBMLDocument d) { // loop through the whole document to search for any unknown attributes or elements. sbaseWithUnknownXML = (List<SBase>) d.filter(new Filter() { @Override public boolean accepts(Object o) { if (o instanceof SBase) { SBase sbase = (SBase) o; // System.out.println(sbase.getElementName() + " - " + sbase); // TODO - for 10102-fail-01-25-sev2-l3v1.xml, we go over 4 ListOf which should not be defined ! if (sbase.isSetUserObjects() && sbase.getUserObject(JSBML.UNKNOWN_XML) != null) { // if the user object is set, we know they are some unknown XML // we return true to add it to the list of sbaseWithUnknownXML return true; } } return false; } }); // System.out.println(d.getModel()); // if we found at least one element with unknown XML, fail the constraint if (sbaseWithUnknownXML.size() > 0) { return false; } return true; }
@Override public SBMLDocument convert(SBMLDocument doc) throws SBMLException { SBMLDocument resultdoc = doc; Model m = doc.getModel(); if (m == null || m.getFunctionDefinitionCount() == 0) { // In this case, we cannot do anything about the FunctionDefinition or there is nothing to do return doc; } try { resultdoc = doc.clone(); resultdoc.filter(new Filter() { @Override public boolean accepts(Object o) { if (o instanceof MathContainer) { // call an utility that will replace the FDs expandFunctionDefinition((MathContainer) o); } return false; } }); } catch (Exception e) { // something went wrong during cloning. It can happen with malformed FunctionDefinition math // just returning the original unmodified document } return resultdoc; }
sbmlDocument.filter(new Filter() {