Package org.sbml.jsbml

Examples of org.sbml.jsbml.Constraint


    assertEquals(M.getCompartmentType(0), c);
  }

  @Test
  public void test_Model_createConstraint() {
    Constraint c = M.createConstraint();
    assertTrue(c != null);
    assertTrue(M.getConstraintCount() == 1);
    assertEquals(M.getConstraint(0), c);
  }
View Full Code Here


    o3 = null;
  }

  @Test
  public void test_Model_removeConstraint() {
    Constraint o1, o2, o3;
    o1 = M.createConstraint(); // TODO: document diff: cannot add twice the same element
    o1.setMetaId("c1");
    o2 = M.createConstraint();
    o2.setMetaId("c2");
    o3 = M.createConstraint();
    o3.setMetaId("c3");
    assertTrue(M.removeConstraint(0).equals(o1));
View Full Code Here

   */
  public XMLNode readNotes(String notesXHTML, TreeNodeChangeListener listener)
    throws XMLStreamException {
    Object object = readXMLFromString(notesXHTML, listener);
    if ((object != null) && (object instanceof Constraint)) {
      Constraint constraint = ((Constraint) object);
     
      if (constraint.isSetNotes()) {
        XMLNode notes = constraint.getNotes();
        if (notes != null) {
          return notes;
        }
      } else if (constraint.isSetMessage()) {
        XMLNode message = constraint.getMessage();
        if (message != null) {
          return message;
        }
      }
    }
View Full Code Here

          {
            sbmlElements.push(astNodeParent);
          }
          else
          {
            Constraint constraint = new Constraint(3,1);
            sbmlElements.push(constraint);
          }
         
        } else if (currentNode.getLocalPart().equals("annotation")) {
View Full Code Here

            elementIsNested = true;
          }
          isClosedMathContainer = true;
        }
        if (nextObjectToWrite instanceof Constraint) {
          Constraint constraint = (Constraint) nextObjectToWrite;
          if (constraint.isSetMessage()) {
            writeMessage(constraint, newOutPutElement,
                streamWriter, newOutPutElement
                .getNamespace().getURI(),
                indent + indentCount);
            elementIsNested = true;
View Full Code Here

            } else if (elementName.equals("constraint")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfConstraints)
                && ((model.getLevel() == 2 && model
                    .getVersion() > 1) || model.getLevel() >= 3)) {
              Constraint constraint = (Constraint) newContextObject;
              model.addConstraint(constraint);

              return constraint;
            } else if (elementName.equals("reaction")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfReactions)) {
              Reaction reaction = (Reaction) newContextObject;
              model.addReaction(reaction);
              reaction.initDefaults();

              return reaction;
            } else if (elementName.equals("event")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfEvents)
                && model.getLevel() > 1) {
              Event event = (Event) newContextObject;
              model.addEvent(event);
              event.initDefaults();

              return event;
            } else if (elementName.equals("compartmentType")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfCompartmentTypes)
                && (model.getLevel() == 2 && model.getVersion() > 1)) {
              CompartmentType compartmentType = (CompartmentType) newContextObject;
              model.addCompartmentType(compartmentType);

              return compartmentType;
            } else if (elementName.equals("speciesType")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfSpeciesTypes)
                && (model.getLevel() == 2 && model.getVersion() > 1)) {
              SpeciesType speciesType = (SpeciesType) newContextObject;
              model.addSpeciesType(speciesType);

              return speciesType;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof UnitDefinition) {
            UnitDefinition unitDefinition = (UnitDefinition) list
                .getParentSBMLObject();

            if (elementName.equals("unit")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfUnits)) {
              Unit unit = (Unit) newContextObject;
              unit.initDefaults();
              unitDefinition.addUnit(unit);

              return unit;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof Reaction) {
            Reaction reaction = (Reaction) list
                .getParentSBMLObject();

            if (elementName.equals("speciesReference")
                && (reaction.getLevel() > 1 || (reaction
                    .getLevel() == 1 && reaction
                    .getVersion() == 2))) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName.equals("specieReference")
                && reaction.getLevel() == 1) {
              SpeciesReference speciesReference = (SpeciesReference) newContextObject;
              speciesReference.initDefaults();

              if (list.getSBaseListType().equals(
                  ListOf.Type.listOfReactants)) {
                reaction.addReactant(speciesReference);

                return speciesReference;
              } else if (list.getSBaseListType().equals(
                  ListOf.Type.listOfProducts)) {
                reaction.addProduct(speciesReference);

                return speciesReference;
              } else {
                log4jLogger.warn("The element " + elementName + " is not recognized");
              }
            } else if (elementName
                .equals("modifierSpeciesReference")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfModifiers)
                && reaction.getLevel() > 1) {
              ModifierSpeciesReference modifierSpeciesReference = (ModifierSpeciesReference) newContextObject;
              reaction.addModifier(modifierSpeciesReference);

              return modifierSpeciesReference;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof KineticLaw) {
            KineticLaw kineticLaw = (KineticLaw) list
                .getParentSBMLObject();
            // Level 3: parameter and listOfParameters =>
            // localParameter and listOfLocalParameter
            if (elementName.equals("localParameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.getLevel() >= 3) {
              LocalParameter localParameter = (LocalParameter) newContextObject;
              kineticLaw.addLocalParameter(localParameter);

              return localParameter;
            } else if (elementName.equals("parameter")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfLocalParameters)
                && kineticLaw.isSetLevel()
                && kineticLaw.getLevel() < 3) {
              LocalParameter localParameter = new LocalParameter(
                  (Parameter) newContextObject);
              kineticLaw.addLocalParameter(localParameter);

              return localParameter;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else if (list.getParentSBMLObject() instanceof Event) {
            Event event = (Event) list.getParentSBMLObject();

            if (elementName.equals("eventAssignment")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfEventAssignments)
                && event.getLevel() > 1) {
              EventAssignment eventAssignment = (EventAssignment) newContextObject;
              event.addEventAssignment(eventAssignment);

              return eventAssignment;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
            }
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof UnitDefinition) {
          UnitDefinition unitDefinition = (UnitDefinition) contextObject;

          if (elementName.equals("listOfUnits")) {
            ListOf<Unit> listOfUnits = (ListOf<Unit>) newContextObject;
            unitDefinition.setListOfUnits(listOfUnits);

            return listOfUnits;
          }
        } else if (contextObject instanceof Event) {
          Event event = (Event) contextObject;

          if (elementName.equals("listOfEventAssignments")) {
            ListOf<EventAssignment> listOfEventAssignments = (ListOf<EventAssignment>) newContextObject;
            event.setListOfEventAssignments(listOfEventAssignments);

            return listOfEventAssignments;
          } else if (elementName.equals("trigger")) {
            Trigger trigger = (Trigger) newContextObject;
            event.setTrigger(trigger);

            return trigger;
          } else if (elementName.equals("delay")) {
            Delay delay = (Delay) newContextObject;
            event.setDelay(delay);

            return delay;
          } else if (elementName.equals("priority")) {
            Priority priority = (Priority) newContextObject;
            event.setPriority(priority);

            return priority;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof Reaction) {
          Reaction reaction = (Reaction) contextObject;
          if (elementName.equals("listOfReactants")) {
            ListOf<SpeciesReference> listOfReactants = (ListOf<SpeciesReference>) newContextObject;
            reaction.setListOfReactants(listOfReactants);

            return listOfReactants;
          } else if (elementName.equals("listOfProducts")) {
            ListOf<SpeciesReference> listOfProducts = (ListOf<SpeciesReference>) newContextObject;
            reaction.setListOfProducts(listOfProducts);

            return listOfProducts;
          } else if (elementName.equals("listOfModifiers")
              && reaction.getLevel() > 1) {
            ListOf<ModifierSpeciesReference> listOfModifiers = (ListOf<ModifierSpeciesReference>) newContextObject;
            reaction.setListOfModifiers(listOfModifiers);

            return listOfModifiers;
          } else if (elementName.equals("kineticLaw")) {
            KineticLaw kineticLaw = (KineticLaw) newContextObject;
            reaction.setKineticLaw(kineticLaw);

            return kineticLaw;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof SpeciesReference) {
          SpeciesReference speciesReference = (SpeciesReference) contextObject;

          if (elementName.equals("stoichiometryMath")) {
            StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject;
            speciesReference.setStoichiometryMath(stoichiometryMath);

            return stoichiometryMath;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof KineticLaw) {
          KineticLaw kineticLaw = (KineticLaw) contextObject;

          if (elementName.equals("listOfLocalParameters")
              && kineticLaw.getLevel() >= 3) {
            ListOf<LocalParameter> listOfLocalParameters = (ListOf<LocalParameter>) newContextObject;
            kineticLaw.setListOfLocalParameters(listOfLocalParameters);
            listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters);

            return listOfLocalParameters;
          } else if (elementName.equals("listOfParameters")
              && kineticLaw.isSetLevel() && kineticLaw.getLevel() < 3) {
            ListOf<LocalParameter> listOfLocalParameters = (ListOf<LocalParameter>) newContextObject;
            kineticLaw.setListOfLocalParameters(listOfLocalParameters);
            listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters);

            return listOfLocalParameters;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
        } else if (contextObject instanceof Constraint) {
          Constraint constraint = (Constraint) contextObject;

          if (elementName.equals("message")
              && ((constraint.getLevel() == 2 && constraint
                  .getVersion() > 1) || constraint.getLevel() >= 3))
          {
            constraint.setMessage(new XMLNode(new XMLTriple("message", null, null), new XMLAttributes()));

            return constraint;
          } else {
            log4jLogger.warn("The element " + elementName + " is not recognized");
          }
View Full Code Here

    assertEquals(M.getCompartmentType(0), c);
  }

  @Test
  public void test_Model_createConstraint() {
    Constraint c = M.createConstraint();
    assertTrue(c != null);
    assertTrue(M.getNumConstraints() == 1);
    assertEquals(M.getConstraint(0), c);
  }
View Full Code Here

    o3 = null;
  }

  @Test
  public void test_Model_removeConstraint() {
    Constraint o1, o2, o3;
    o1 = M.createConstraint(); // TODO : document diff : cannot add twice the same element
    o1.setMetaId("c1");
    o2 = M.createConstraint();
    o2.setMetaId("c2");
    o3 = M.createConstraint();
    o3.setMetaId("c3");
    assertTrue(M.removeConstraint(0).equals(o1));
View Full Code Here

   */
  public XMLNode readNotes(String notesXHTML, TreeNodeChangeListener listener)
    throws XMLStreamException {
    Object object = readXMLFromString(notesXHTML, listener);
    if ((object != null) && (object instanceof Constraint)) {
      Constraint constraint = ((Constraint) object);
     
      if (constraint.isSetNotes()) {
        XMLNode notes = constraint.getNotes();
        if (notes != null) {
          return notes;
        }
      } else if (constraint.isSetMessage()) {
        XMLNode message = constraint.getMessage();
        if (message != null) {
          return message;
        }
      }
    }
View Full Code Here

         
          // TODO : will not work with arbitrary SBML part
          // TODO : we need to be able, somehow, to set the Model element in the Constraint
          // to be able to have a fully functional parsing. Without it the functionDefinition, for examples, are
          // not properly recognized.
          Constraint constraint = new Constraint(3,1);
          sbmlElements.push(constraint);
         
        } else if (currentNode.getLocalPart().equals("annotation")) {

          // get the sbml namespace as some element can have similar names in different namespaces
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.