private void printClassificationFilterRule(ClassificationFilterRule rule)
     throws IOException, RaplaException {
   Attribute attribute = rule.getAttribute();
   Assert.notNull(attribute);
   String[] operators = rule.getOperators();
   Object[] values = rule.getValues();
   openTag("rapla:rule");
   att("attribute", attribute.getKey());
   closeTag();
   for (int i = 0; i < operators.length; i++) {
     openTag("rapla:orCond");
     att("operator", operators[i]);
     closeTagOnLine();
     if (values[i] != null) printAttributeValue(attribute, values[i]);
     closeElementOnLine("rapla:orCond");
     println();
   }
   closeElement("rapla:rule");
 }
Exemplo n.º 2
0
  public static void validate(DynamicType dynamicType, I18nBundle i18n) throws RaplaException {
    Assert.notNull(dynamicType);
    if (dynamicType.getName(i18n.getLocale()).length() == 0)
      throw new RaplaException(i18n.getString("error.no_name"));

    if (dynamicType.getKey().equals("")) {
      throw new RaplaException(i18n.format("error.no_key", ""));
    }
    checkKey(i18n, dynamicType.getKey());
    Attribute[] attributes = dynamicType.getAttributes();
    for (int i = 0; i < attributes.length; i++) {
      String key = attributes[i].getKey();
      if (key == null || key.trim().equals(""))
        throw new RaplaException(i18n.format("error.no_key", "(" + i + ")"));
      checkKey(i18n, key);
      for (int j = i + 1; j < attributes.length; j++) {
        if ((key.equals(attributes[j].getKey()))) {
          throw new UniqueKeyException(i18n.format("error.not_unique", key));
        }
      }
    }
  }
Exemplo n.º 3
0
  @Override
  public void processElement(String namespaceURI, String localName, RaplaSAXAttributes atts)
      throws RaplaSAXParseException {
    if (namespaceURI.equals(DYNATT_NS) || namespaceURI.equals(EXTENSION_NS)) {
      dynAttHandler.setClassifiable(reservation);
      delegateElement(dynAttHandler, namespaceURI, localName, atts);
      return;
    }

    if (!namespaceURI.equals(RAPLA_NS)) return;

    if (localName.equals("permission")) {
      permissionHandler.setContainer(reservation);
      delegateElement(permissionHandler, namespaceURI, localName, atts);
      return;
    }
    if (localName.equals("reservation")) {
      TimestampDates ts = readTimestamps(atts);
      reservation = new ReservationImpl(ts.createTime, ts.changeTime);
      reservation.setResolver(store);
      currentAnnotatable = reservation;
      setId(reservation, atts);
      setLastChangedBy(reservation, atts);
      setOwner(reservation, atts);
    }

    if (localName.equals("appointment")) {
      String id = atts.getValue("id");
      String startDate = atts.getValue("start-date");
      String endDate = atts.getValue("end-date");
      if (endDate == null) endDate = startDate;

      String startTime = atts.getValue("start-time");
      String endTime = atts.getValue("end-time");

      Date start;
      Date end;
      if (startTime != null && endTime != null) {
        start = parseDateTime(startDate, startTime);
        end = parseDateTime(endDate, endTime);
      } else {
        start = parseDate(startDate, false);
        end = parseDate(endDate, true);
      }

      appointment = new AppointmentImpl(start, end);
      appointment.setWholeDays(startTime == null && endTime == null);
      if (id != null) {
        setId(appointment, atts);
      } else {
        setNewId(appointment);
      }
      addAppointment(appointment);
    }

    if (localName.equals("repeating")) {
      String type = atts.getValue("type");
      String interval = atts.getValue("interval");
      String enddate = atts.getValue("end-date");
      String number = atts.getValue("number");
      appointment.setRepeatingEnabled(true);
      repeating = appointment.getRepeating();
      repeating.setType(RepeatingType.findForString(type));
      if (interval != null) {
        repeating.setInterval(Integer.valueOf(interval).intValue());
      }
      if (enddate != null) {
        repeating.setEnd(parseDate(enddate, true));
      } else if (number != null) {
        repeating.setNumber(Integer.valueOf(number).intValue());
      } else {
        repeating.setEnd(null);
      }
      /*
      if (getLogger().enabled(6))
          getLogger().log(6, "Repeating " + repeating.toString() );
      */
    }

    if (localName.equals("allocate")) {
      String id = getString(atts, "idref");
      allocatableId = getId(Allocatable.TYPE, id);
      reservation.addId("resources", allocatableId);
      if (appointment != null) {
        reservation.addRestrictionForId(allocatableId, appointment.getId());
      }
    }

    if (localName.equals("annotation") && namespaceURI.equals(RAPLA_NS)) {
      annotationKey = atts.getValue("key");
      Assert.notNull(annotationKey, "key attribute cannot be null");
      startContent();
    }

    if (localName.equals("exception")) {}

    if (localName.equals("date")) {
      String dateString = atts.getValue("date");
      if (dateString != null && repeating != null)
        repeating.addException(parseDate(dateString, false));
    }
  }