/** * 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; } }