@Override
 public Collection<Appointment> eval(EvalContext context) {
   if (context instanceof ReservationEvalContext) {
     Reservation reservation = ((ReservationEvalContext) context).getReservation();
     List<Appointment> asList = Arrays.asList(reservation.getAppointments());
     return asList;
   }
   return Collections.emptyList();
 }
Example #2
0
 public void testRefresh() throws Exception {
   changeInSecondFacade("bowling");
   facade.refresh();
   Reservation resAfter = findReservation(facade, "bowling");
   Appointment appointment = resAfter.getAppointments()[0];
   Calendar cal = Calendar.getInstance(DateTools.getTimeZone());
   cal.setTime(appointment.getStart());
   assertEquals(17, cal.get(Calendar.HOUR_OF_DAY));
   assertEquals(Calendar.MONDAY, cal.get(Calendar.DAY_OF_WEEK));
   cal.setTime(appointment.getEnd());
   assertEquals(19, cal.get(Calendar.HOUR_OF_DAY));
   assertEquals(Calendar.MONDAY, cal.get(Calendar.DAY_OF_WEEK));
 }
 private int getAppointmentNumber(AppointmentBlock appointmentBlock) {
   final long blockStart = appointmentBlock.getEnd();
   final Date end = new Date(blockStart);
   final Appointment appointment = appointmentBlock.getAppointment();
   final Reservation reservation = appointment.getReservation();
   final Date start = reservation.getFirstDate();
   SortedSet<AppointmentBlock> blocks = new TreeSet<AppointmentBlock>();
   for (Appointment app : reservation.getAppointments()) {
     app.createBlocks(start, end, blocks);
   }
   final SortedSet<AppointmentBlock> headSet = blocks.headSet(appointmentBlock);
   final int size = headSet.size();
   //                final long appoimtmentStart = reservation.getFirstDate().getTime();
   //                if (appoimtmentStart ==  start)
   //                {
   //                    return 1;
   //                }
   return size + 1;
 }
Example #4
0
 void insertAllAppointments(Reservation reservation, StringBuffer buf) {
   buf.append("<table cellpadding=\"2\">");
   buf.append("<tr>\n");
   buf.append("<td colspan=\"2\" class=\"label\">");
   String appointmentLabel = getString("appointments");
   encode(appointmentLabel, buf);
   buf.append(":");
   buf.append("</td>\n");
   buf.append("</tr>\n");
   Appointment[] appointments = reservation.getAppointments();
   for (int i = 0; i < appointments.length; i++) {
     buf.append("<tr>\n");
     buf.append("<td valign=\"top\">\n");
     if (appointments[i].getRepeating() != null) {
       buf.append("<img width=\"16\" height=\"16\" src=\"org/rapla/gui/images/repeating.png\">");
     } else {
       buf.append("<img width=\"16\" height=\"16\" src=\"org/rapla/gui/images/single.png\">");
     }
     buf.append("</td>\n");
     buf.append("<td>\n");
     String appointmentSummary = getAppointmentFormater().getSummary(appointments[i]);
     encode(appointmentSummary, buf);
     Repeating repeating = appointments[i].getRepeating();
     if (repeating != null) {
       buf.append("<br>");
       buf.append("<small>");
       List<Period> periods = getPeriodModel().getPeriodsFor(appointments[i].getStart());
       String repeatingSummary = getAppointmentFormater().getSummary(repeating, periods);
       encode(repeatingSummary, buf);
       if (repeating.hasExceptions()) {
         buf.append("<br>");
         buf.append(getAppointmentFormater().getExceptionSummary(repeating));
       }
       buf.append("</small>");
     }
     buf.append("</td>\n");
     buf.append("<td></td>");
     buf.append("</tr>\n");
   }
   buf.append("</table>\n");
 }
Example #5
0
 public void testClone() throws Exception {
   ClassificationFilter filter = facade.getDynamicType("event").newClassificationFilter();
   filter.addEqualsRule("name", "power planting");
   Reservation orig =
       facade
           .getReservationsForAllocatable(null, null, null, new ClassificationFilter[] {filter})[
           0];
   Reservation clone = facade.clone(orig);
   Appointment a = clone.getAppointments()[0];
   Date newStart = new SerializableDateTimeFormat().parseDateTime("2005-10-10", "10:20:00");
   Date newEnd = new SerializableDateTimeFormat().parseDateTime("2005-10-12", null);
   a.move(newStart);
   a.getRepeating().setEnd(newEnd);
   facade.store(clone);
   Reservation[] allPowerPlantings =
       facade.getReservationsForAllocatable(null, null, null, new ClassificationFilter[] {filter});
   assertEquals(2, allPowerPlantings.length);
   Reservation[] onlyClones =
       facade.getReservationsForAllocatable(
           null, newStart, null, new ClassificationFilter[] {filter});
   assertEquals(1, onlyClones.length);
 }
Example #6
0
  // Make some Changes to the Reservation in another client
  private void changeInSecondFacade(String name) throws Exception {
    ClientFacade facade2 = raplaContainer.lookup(ClientFacade.class, "local-facade2");
    facade2.login("homer", "duffs".toCharArray());
    UserModule userMod2 = facade2;
    QueryModule queryMod2 = facade2;
    ModificationModule modificationMod2 = facade2;
    boolean bLogin = userMod2.login("homer", "duffs".toCharArray());
    assertTrue(bLogin);
    Reservation reservation = findReservation(queryMod2, name);
    Reservation mutableReseravation = modificationMod2.edit(reservation);
    Appointment appointment = mutableReseravation.getAppointments()[0];

    RaplaLocale loc = getRaplaLocale();
    Calendar cal = loc.createCalendar();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    Date startTime = loc.toTime(17, 0, 0);
    Date startTime1 = loc.toDate(cal.getTime(), startTime);
    Date endTime = loc.toTime(19, 0, 0);
    Date endTime1 = loc.toDate(cal.getTime(), endTime);
    appointment.move(startTime1, endTime1);

    modificationMod2.store(mutableReseravation);
    // userMod2.logout();
  }