/**
  * Fügt einem iCal-Event den Termin-Namen aus dem übergebenen Appointment-Objekt hinzu.
  *
  * @param appointment
  */
 private void addEventNameToEvent(Appointment appointment, PropertyList properties) {
   Reservation reservation = appointment.getReservation();
   final Locale locale = raplaLocale.getLocale();
   String eventDescription = NameFormatUtil.getExportName(appointment, locale);
   if (reservation
           .getClassification()
           .getType()
           .getAnnotation(DynamicTypeAnnotations.KEY_NAME_FORMAT_EXPORT)
       == null) {
     eventDescription += getAttendeeString(appointment);
   }
   properties.add(new Summary(eventDescription));
 }
  private void addDescriptionToEvent(Appointment appointment, PropertyList properties) {

    Reservation reservation = appointment.getReservation();
    String eventDescription;
    if (reservation
            .getClassification()
            .getType()
            .getAnnotation(DynamicTypeAnnotations.KEY_DESCRIPTION_FORMAT_EXPORT)
        != null) {
      eventDescription =
          reservation.format(
              raplaLocale.getLocale(),
              DynamicTypeAnnotations.KEY_DESCRIPTION_FORMAT_EXPORT,
              appointment);
    } else {
      eventDescription = null;
    }
    if (eventDescription != null) {
      properties.add(new Description(eventDescription));
    }
  }
Exemplo n.º 3
0
  public void testConflicts() throws Exception {
    Conflict[] conflicts = facade.getConflicts();
    Reservation[] all = facade.getReservationsForAllocatable(null, null, null, null);
    facade.removeObjects(all);
    Reservation orig = facade.newReservation();
    orig.getClassification().setValue("name", "new");
    Date start = DateTools.fillDate(new Date());
    Date end = getRaplaLocale().toDate(start, getRaplaLocale().toTime(12, 0, 0));
    orig.addAppointment(facade.newAppointment(start, end));

    orig.addAllocatable(facade.getAllocatables()[0]);

    Reservation clone = facade.clone(orig);
    facade.store(orig);
    facade.store(clone);

    Conflict[] conflictsAfter = facade.getConflicts();
    assertEquals(1, conflictsAfter.length - conflicts.length);
    HashSet<Conflict> set = new HashSet<Conflict>(Arrays.asList(conflictsAfter));

    assertTrue(set.containsAll(new HashSet<Conflict>(Arrays.asList(conflicts))));
  }
Exemplo n.º 4
0
 public ReservationEvalContext(
     Locale locale, int callStackDepth, String annotationName, Reservation reservation) {
   super(locale, callStackDepth, annotationName, reservation.getClassification());
   this.reservation = reservation;
 }
Exemplo n.º 5
0
  public void testExampleEdit() throws Exception {

    String allocatableId;
    String eventId;
    {
      Allocatable nonPersistantAllocatable = getFacade().newResource();
      nonPersistantAllocatable.getClassification().setValue("name", "Bla");

      Reservation nonPeristantEvent = getFacade().newReservation();
      nonPeristantEvent.getClassification().setValue("name", "dummy-event");
      assertEquals("event", nonPeristantEvent.getClassification().getType().getKey());
      nonPeristantEvent.addAllocatable(nonPersistantAllocatable);
      nonPeristantEvent.addAppointment(getFacade().newAppointment(new Date(), new Date()));
      getFacade().storeObjects(new Entity[] {nonPersistantAllocatable, nonPeristantEvent});
      allocatableId = nonPersistantAllocatable.getId();
      eventId = nonPeristantEvent.getId();
    }
    Allocatable allocatable =
        facade.edit(facade.getOperator().resolve(allocatableId, Allocatable.class));

    // Store the allocatable it a second time to test if it is still modifiable after storing
    allocatable.getClassification().setValue("name", "Blubs");
    getFacade().store(allocatable);

    // query the allocatable from the store
    ClassificationFilter filter = getFacade().getDynamicType("room").newClassificationFilter();
    filter.addEqualsRule("name", "Blubs");
    Allocatable persistantAllocatable =
        getFacade().getAllocatables(new ClassificationFilter[] {filter})[0];

    // query the event from the store
    ClassificationFilter eventFilter =
        getFacade().getDynamicType("event").newClassificationFilter();
    eventFilter.addEqualsRule("name", "dummy-event");
    Reservation persistantEvent =
        getFacade()
            .getReservationsForAllocatable(
                null, null, null, new ClassificationFilter[] {eventFilter})[0];
    // Another way to get the persistant event would have been
    // Reservation persistantEvent = getFacade().getPersistant( nonPeristantEvent );

    // test if the ids of editable Versions are equal to the persistant ones
    assertEquals(persistantAllocatable, allocatable);
    Reservation event = facade.getOperator().resolve(eventId, Reservation.class);
    assertEquals(persistantEvent, event);
    assertEquals(persistantEvent.getAllocatables()[0], event.getAllocatables()[0]);

    //        // Check if the modifiable/original versions are different to the persistant versions
    //        assertTrue( persistantAllocatable !=  allocatable );
    //        assertTrue( persistantEvent !=  event );
    //        assertTrue( persistantEvent.getAllocatables()[0] != event.getAllocatables()[0]);

    // Test the read only constraints
    try {
      persistantAllocatable.getClassification().setValue("name", "asdflkj");
      fail("ReadOnlyException should have been thrown");
    } catch (ReadOnlyException ex) {
    }

    try {
      persistantEvent.getClassification().setValue("name", "dummy-event");
      fail("ReadOnlyException should have been thrown");
    } catch (ReadOnlyException ex) {
    }

    try {
      persistantEvent.removeAllocatable(allocatable);
      fail("ReadOnlyException should have been thrown");
    } catch (ReadOnlyException ex) {
    }

    // now we get a second edit copy of the event
    Reservation nonPersistantEventVersion2 = getFacade().edit(persistantEvent);
    assertTrue(nonPersistantEventVersion2 != event);

    // Both allocatables are persitant, so they have the same reference
    assertTrue(
        persistantEvent.getAllocatables()[0] == nonPersistantEventVersion2.getAllocatables()[0]);
  }