Ejemplo n.º 1
0
  public static void deleteByAccident(Accident accident) {
    List<Injurie> injuries = Injurie.byAccident(accident);

    for (Injurie injury : injuries) {
      injury.delete();
    }
  }
Ejemplo n.º 2
0
  public static void update(Accident accident, List<Injurie> injuries) {
    if (injuries == null) {
      return;
    }

    for (Injurie injury : injuries) {
      if (injury.id == null && injury.description.trim().isEmpty()) {
        continue;
      }

      if (injury.id != null && injury.description.trim().isEmpty()) {
        injury = injury.merge();
        injury.delete();
        continue;
      }

      injury = injury.merge();
      injury.accident = accident;
      injury.save();
    }
  }
Ejemplo n.º 3
0
 public static List<Injurie> byAccident(Accident accident) {
   return Injurie.find("accident = ?", accident).fetch();
 }