コード例 #1
0
 public Encounter getSpecificEncounter(int index) {
   init();
   if (index < 0) {
     index = 0;
   }
   if (index > (data.size() - 1)) {
     index = data.size() - 1;
   }
   Encounter obj = data.get(index);
   Long id = obj.getId();
   return encounterService.findEncounter(id);
 }
コード例 #2
0
  public void init() {
    int from = 0;
    int to = 10;
    data = encounterService.findEncounterEntries(from, to);
    if (data == null) {
      throw new IllegalStateException(
          "Find entries implementation for 'Encounter' illegally returned null");
    }
    if (!data.isEmpty()) {
      return;
    }

    data = new ArrayList<Encounter>();
    for (int i = 0; i < 10; i++) {
      Encounter obj = getNewTransientEncounter(i);
      try {
        encounterService.saveEncounter(obj);
      } catch (final ConstraintViolationException e) {
        final StringBuilder msg = new StringBuilder();
        for (Iterator<ConstraintViolation<?>> iter = e.getConstraintViolations().iterator();
            iter.hasNext(); ) {
          final ConstraintViolation<?> cv = iter.next();
          msg.append("[")
              .append(cv.getRootBean().getClass().getName())
              .append(".")
              .append(cv.getPropertyPath())
              .append(": ")
              .append(cv.getMessage())
              .append(" (invalid value = ")
              .append(cv.getInvalidValue())
              .append(")")
              .append("]");
        }
        throw new IllegalStateException(msg.toString(), e);
      }
      encounterRepository.flush();
      data.add(obj);
    }
  }
コード例 #3
0
 public Encounter getRandomEncounter() {
   init();
   Encounter obj = data.get(rnd.nextInt(data.size()));
   Long id = obj.getId();
   return encounterService.findEncounter(id);
 }