コード例 #1
0
  public void init() {
    System.out.println("Getting child list");
    childList = new ArrayList<>();
    // return ejbFacade.getEntityManager().createNamedQuery("Child.findAllSorted").getResultList();
    String queryString =
        "SELECT e FROM Child e " + buildWhereClause() + " ORDER BY e.surname ASC, e.firstname ASC";

    List<Child> lc = ejbFacade.getEntityManager().createQuery(queryString).getResultList();
    for (Child c : lc) {
      boolean add = false;
      if (searchKS1 != true || searchKS2 != true || searchKS3 != true || searchKS4 != true) {
        // Check year.
        int childYear = settings.getSchoolYearFor(c, 0);
        if ((searchKS1 && childYear >= 0 && childYear <= 2)
            || (searchKS2 && childYear >= 3 && childYear <= 6)
            || (searchKS3 && childYear >= 7 && childYear <= 9)
            || (searchKS4 && childYear >= 10 && childYear <= 11)) {
          add = true;
        }
      } else {
        add = true;
      }
      if (add && c.getExtraItems() != null && c.getExtraItems().size() > 0) {
        // Create a child container for each one.
        childList.add(new ChildContainer(c));
      }
    }
  }
コード例 #2
0
 public ChildContainer(Child child) {
   this.child = child;
   tickets = new ArrayList<>();
   List<ExtraItemEntry> extras = child.getExtraItems();
   int size = extras.size();
   List<String> rowEntries = new ArrayList<>();
   for (int i = 0; i < size; ++i) {
     int itemCount = extras.get(i).getItemCount();
     for (int j = 0; j < itemCount; ++j) {
       rowEntries.add(extras.get(i).getItem().getName());
     }
   }
   size = rowEntries.size();
   for (int i = 0; i < size; i += 3) {
     List<String> row = new ArrayList<>();
     for (int j = 0; j < 3; ++j) {
       if (i + j < size) {
         row.add(rowEntries.get(i + j));
       } else {
         row.add(null);
       }
     }
     tickets.add(new TicketRow(row));
   }
 }