コード例 #1
0
  /**
   * Returns a collection of bounds for reactions included in the given's model metabolism. Note
   * that it has to be a sum of bounds of the parent model (if the given model has a parent) and the
   * bounds directly associated with current model.
   *
   * @param model
   * @return collection of bounds for the given model
   */
  Collection<EBounds> getBoundsForModel(EModel model, EntityManager em) {

    if (model.getParent() == null) {
      return model.getEBoundsCollection();
    } else {
      /*
       * There are two sources of bounds for each model.
       * First, we retrieve bounds that have been defined for this model
       */
      List<EBounds> res1 =
          em.createQuery("SELECT e FROM EBounds e WHERE e.model = :model")
              .setParameter("model", model)
              .getResultList();

      /*
       * The remaining bounds are taken from the parent model
       */
      List<EBounds> res2 =
          em.createQuery(
                  " SELECT b FROM EModel m, EBounds b WHERE "
                      + " m.id = :modelID AND m.parent IS NOT NULL AND "
                      + " b.model = m.parent AND NOT EXISTS (SELECT c "
                      + " FROM EBounds c WHERE c.model = :model AND "
                      + " b.reaction = c.reaction )")
              .setParameter("modelID", model.getId())
              .setParameter("model", model)
              .getResultList();
      res1.addAll(res2);
      return res1;
    }
  }
コード例 #2
0
 /** Removes @model from database. */
 public void removeModel(EModel model) {
   EntityManager em = getEntityManager();
   try {
     em.getTransaction().begin();
     EModel modelx = em.find(EModel.class, model.getId());
     removeModel(em, modelx);
     // !!1tu jest błąd
     // Internal Exception: java.sql.SQLIntegrityConstraintViolationException: Obiekt DELETE w
     // tabeli 'ETASK' spowodował naruszenie reguły ograniczającej klucz obcy 'ECOMMONRESULTSTASK'
     // dla klucza (1). Instrukcja została wycofana.
     em.getTransaction().commit();
   } finally {
     em.close();
   }
 }
コード例 #3
0
 /**
  * Finds and returns @model.
  *
  * @return - @model
  */
 public EModel getModel(EModel model) {
   EntityManager em = getEntityManager();
   try {
     em.getTransaction().begin();
     EModel modelx =
         (EModel)
             em.createNamedQuery("EModel.findById")
                 .setParameter("id", model.getId())
                 .setHint("eclipselink.refresh", true)
                 .getSingleResult();
     em.getTransaction().commit();
     return modelx;
   } finally {
     em.close();
   }
 }
コード例 #4
0
 public List<ESpecies> getSpecies(int modelId) {
   EntityManager em = getEntityManager();
   try {
     em.getTransaction().begin();
     EModel model = em.find(EModel.class, modelId);
     List<ESpecies> species =
         em.createQuery(
                 "SELECT s FROM ESpecies s, EModel m WHERE s.compartment.metabolism.id = m.metabolism.id AND m.id = :modelId")
             .setParameter("modelId", model.getId())
             .getResultList();
     em.getTransaction().commit();
     return species;
   } finally {
     em.close();
   }
 }