public void addModel(
      EMetabolism metabolism,
      EModel model,
      Map<String, ECompartment> compartment_map,
      Map<String, ESpecies> species_map,
      List<EReaction> reaction_list,
      List<EReactant> reactant_list,
      List<EProduct> product_list,
      List<EBounds> bounds_list) {
    EntityManager em = getEntityManager();
    try {
      em.getTransaction().begin();

      em.persist(metabolism);
      em.persist(model);

      model.getMetabolism().getEModelCollection().add(model);

      for (ECompartment c : compartment_map.values()) {
        em.persist(c);
        c.getMetabolism().getECompartmentCollection().add(c);
      }

      for (ESpecies sp : species_map.values()) {
        em.persist(sp);
        sp.getCompartment().getESpeciesCollection().add(sp);
      }

      for (EReaction r : reaction_list) {
        em.persist(r);
        r.getMetabolism().getEReactionCollection().add(r);
      }

      for (EReactant r : reactant_list) {
        em.persist(r);
        r.getSpecies().getEReactantCollection().add(r);
        /* r.getReaction().getEReactantCollection().add(r); */
      }

      for (EProduct p : product_list) {
        em.persist(p);
        p.getSpecies().getEProductCollection().add(p);
        /* p.getReaction().getEProductCollection().add(p); */
      }

      for (EBounds b : bounds_list) {
        em.persist(b);
        b.getModel().getEBoundsCollection().add(b);
        /* b.getReaction().getEBoundsCollection().add(b); */
      }

      em.merge(metabolism);

      em.getTransaction().commit();
    } finally {
      em.close();
    }
  }
 /** Removes @bounds. */
 public void removeBounds(EModel model) {
   EntityManager em = getEntityManager();
   try {
     em.getTransaction().begin();
     for (EBounds bounds : model.getEBoundsCollection()) {
       EBounds boundsx = em.find(EBounds.class, bounds.getId());
       em.remove(boundsx);
     }
     em.getTransaction().commit();
   } finally {
     em.close();
   }
 }
 /**
  * @param modelId
  * @return creactions
  */
 public Collection<EReaction> getDetachedReactions(int modelId) {
   ArrayList<EReaction> detachedReactions = new ArrayList<EReaction>(0);
   EModel model = getModel(modelId);
   EntityManager em = getEntityManager();
   try {
     em.getTransaction().begin();
     Collection<EBounds> eboundColl = model.getEBoundsCollection();
     for (EBounds bounds : eboundColl) {
       if (bounds.getLowerBound() == 0 && bounds.getUpperBound() == 0) {
         detachedReactions.add(bounds.getReaction());
       }
     }
     em.getTransaction().commit();
   } catch (NoResultException ex) {
     em.getTransaction().rollback();
   } finally {
     em.close();
   }
   return detachedReactions;
 }