Ejemplo n.º 1
0
  public void delete(Integer experimentId) {
    Experiment experiment = getExperiment(experimentId);
    clearSharedList(experiment);
    removeExperimentFromCopiedTo(experiment);
    for (Experimentable e : experiment.getExperimentables()) {
      log.info("Deleting experimentable: " + e.getId());
      if (e instanceof DataSet) {
        DataSet dataSet = (DataSet) e;
        dataSetService.delete(dataSet);
      }
      if (e instanceof ModelOutput) {
        ModelOutput mo = (ModelOutput) e;
        modelOutputService.deleteModelOutput(mo);
      }
      if (e instanceof Model) {
        Model model = (Model) e;
        modelService.delete(model);
      }
    }

    experiment = getExperiment(experimentId);
    for (Experimentable e : experiment.getExperimentables()) {
      log.info("NOT DELETED: " + e.getId());
    }

    remove(experiment);
  }
Ejemplo n.º 2
0
 public void removeCurrentExperimentFromExperimentables(Experiment experiment) {
   String queryString = "from Experimentable where experiment.id=:experimentId";
   Query query = dao.getEntityManager().createQuery(queryString);
   query.setParameter("experimentId", experiment.getId());
   List<Experimentable> experimentables = query.getResultList();
   for (Experimentable e : experimentables) {
     e.setExperiment(null);
     dao.getEntityManager().merge(e);
   }
 }
Ejemplo n.º 3
0
 public void removeExperimentFromCopiedTo(Experiment experiment) {
   for (Experimentable experimentable : experiment.getExperimentable()) {
     List<Experiment> newCopiedToList = new ArrayList<Experiment>();
     for (Experiment experimentCopiedTo : experimentable.getCopiedTo()) {
       if (experiment.getId() != experimentCopiedTo.getId()) {
         newCopiedToList.add(experiment);
       }
     }
     experimentable.setCopiedTo(newCopiedToList);
     dao.update(experimentable);
     dao.getEntityManager().flush();
   }
   experiment.setExperimentable(new ArrayList<Experimentable>());
   dao.update(experiment);
   dao.getEntityManager().flush();
 }