コード例 #1
0
  /**
   * add attenddees if system property ical4j.validation.relaxed is set ony
   *
   * @param appointment
   * @param properties
   */
  private void addAttendees(
      Appointment appointment,
      PropertyList properties,
      boolean doExportAsMeeting,
      String exportAttendeesParticipationStatus) {
    if (!doExportAsMeeting) return;

    Allocatable[] persons = appointment.getReservation().getAllocatablesFor(appointment);

    for (Allocatable person : persons) {
      if (!person.isPerson()) {
        continue;
      }
      String email = null;
      Attribute attr = person.getClassification().getAttribute(exportAttendeesAttribute);
      if (attr != null && person.getClassification().getValue(attr) != null)
        email = person.getClassification().getValue(attr).toString().trim();
      // determine if person has email attribute
      if (email != null && email.length() > 0) {
        try {
          Attendee attendee = new Attendee(new URI(email));
          attendee.getParameters().add(Role.REQ_PARTICIPANT);
          attendee.getParameters().add(new Cn(person.getName(raplaLocale.getLocale())));
          attendee.getParameters().add(new PartStat(exportAttendeesParticipationStatus));
          properties.add(attendee);
        } catch (URISyntaxException e) {
          throw new IllegalArgumentException(e);
        }
      }
    }
  }
コード例 #2
0
 /**
  * add organizer to properties
  *
  * @param appointment
  * @param properties
  */
 private void addOrganizer(
     Appointment appointment, PropertyList properties, boolean doExportAsMeeting) {
   // means we do not export attendees so we do not have a meeting
   if (!doExportAsMeeting) return;
   final User owner = appointment.getReservation().getOwner();
   try {
     Organizer organizer = null;
     if (owner.getEmail() != null && owner.getEmail().trim().length() > 0) {
       try {
         final URI uri = new URI("MAILTO:" + owner.getEmail().trim());
         organizer = new Organizer(uri);
       } catch (URISyntaxException e) {
       }
     }
     if (organizer == null) {
       organizer = new Organizer("MAILTO:" + URLEncoder.encode(owner.getUsername(), "UTF-8"));
     }
     if (!"".equals(owner.getName())) organizer.getParameters().add(new Cn(owner.getName()));
     properties.add(organizer);
   } catch (URISyntaxException e) {
     throw new IllegalArgumentException(e);
   } catch (UnsupportedEncodingException e) {
     throw new IllegalArgumentException(e);
   }
 }
コード例 #3
0
  /**
   * Prüfe, ob eine Ressource für ein bestimmten Appointment reserviert ist.
   *
   * @param alloc
   * @param when
   * @return <code>true</code>, wenn die Ressource reserviert ist. <code>false</code> sonst
   */
  private boolean isReserved(Allocatable alloc, Appointment when) {
    Reservation reservation = when.getReservation();
    Appointment[] restrictions = reservation.getRestriction(alloc);

    for (int restIt = 0, restLen = restrictions.length; restIt < restLen; restIt++) {
      if (when.equals(restrictions[restIt])) return true;
    }

    return (restrictions.length == 0);
  }
コード例 #4
0
 /**
  * F&uuml;gt einem iCal-Event den Termin-Namen aus dem &uuml;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));
 }
コード例 #5
0
  /**
   * F&uuml;gt einem iCal-Event den Ort aus dem &uuml;bergebenen Appointment-Objekt hinzu.
   *
   * @param appointment
   */
  private void addLocationToEvent(Appointment appointment, PropertyList properties) {
    Allocatable[] allocatables = appointment.getReservation().getAllocatablesFor(appointment);
    StringBuffer buffer = new StringBuffer();
    for (Allocatable alloc : allocatables) {
      if (hasLocationType) {
        if (alloc.getClassification().getType().getAnnotation(DynamicTypeAnnotations.KEY_LOCATION)
            == null) {
          continue;
        }
      } else if (alloc.isPerson()) {
        continue;
      }
      if (buffer.length() > 0) {
        buffer.append(", ");
      }
      buffer.append(alloc.getName(raplaLocale.getLocale()));
    }

    properties.add(new Location(buffer.toString()));
  }
コード例 #6
0
  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));
    }
  }
コード例 #7
0
  public String getAttendeeString(Appointment appointment) {

    String attendeeString = "";

    Reservation raplaReservation = appointment.getReservation();
    Allocatable[] raplaPersons = raplaReservation.getPersons();

    for (int i = 0; i < raplaPersons.length; i++) {
      if (!isReserved(raplaPersons[i], appointment)) continue;

      attendeeString += raplaPersons[i].getName(raplaLocale.getLocale());
      attendeeString = attendeeString.trim();

      if (i != raplaPersons.length - 1) {
        attendeeString += ", ";
      } else {
        attendeeString = " [" + attendeeString + "]";
      }
    }

    return attendeeString;
  }
コード例 #8
0
  /**
   * F&uuml;gt einem iCal-Event das Erstelldatum aus dem &uuml;bergebenen Appointment-Objekt hinzu.
   *
   * @param appointment
   */
  private void addCreateDateToEvent(Appointment appointment, PropertyList properties) {

    Date createTime = appointment.getReservation().getCreateTime();
    properties.add(new Created(convertRaplaLocaleToUTC(createTime)));
  }
コード例 #9
0
 /**
  * F&uuml;gt die Kategorien hinzu.
  *
  * @param appointment Ein Rapla Appointment.
  */
 private void addCategories(Appointment appointment, PropertyList properties) {
   Classification cls = appointment.getReservation().getClassification();
   Categories cat = new Categories();
   cat.getCategories().add(cls.getType().getName(raplaLocale.getLocale()));
   properties.add(cat);
 }
コード例 #10
0
 /**
  * Fuegt dem Termin den DTSTAMP hinzu lt. rfc muss dies dem Erstellungdatum des Objektes
  * entsprechen. Da dies jedoch den Import erschwert und sinnlos ist, wird es auf das letzte
  * Modifizierungsdatum geschrieben.
  */
 private void addLastModifiedDateToEvent(Appointment appointment, PropertyList properties) {
   Date lastChange = appointment.getReservation().getLastChanged();
   properties.add(new DtStamp(convertRaplaLocaleToUTC(lastChange)));
 }