Example #1
0
  /**
   * Persists this object to the database by storing its data as XML blobs.
   *
   * @throws PropertyException when the operations fails.
   */
  public void persist() throws PropertyException {
    try {
      // first check if we have to create/update the property defintion or merely
      // have to add an PropertyLookup entry for it.
      if (!existingPropertyDef) {
        // we are dealing with a property definition that was defined in this
        // uol. So create/up the definition and optionally add the property lookup
        try {
          // try to find find the property definition
          pdf = new PropertyDefFacade(uolId, propId);

          // update this definition
          pdf.setDto(dto);
        } catch (FinderException ex) {
          // no PropertyDef was found, so create a new PropertyDef
          pdf = new PropertyDefFacade(dto);

          // set the values for this definitions
          dto = pdf.getDto();

          // create an entry for this PropertyDefEntity the PropertyLookUp
          new PropertyLookUpFacade(uolId, propId, dto.getPropDefPK(), dto.getDataType());
        }
      } else {
        // The definition was created outside this uol so only the lookup table needs to be altered.
        PropertyLookUpFacade plf;
        // check if the lookup already exists
        try {
          plf = new PropertyLookUpFacade(uolId, propId);
          // found, remove the lookup record
          plf.remove();
        } catch (FinderException ex1) {
          // nothing needs to happen
        }

        // not found or removed, create an new entry for this existing PropertyDefEntity
        new PropertyLookUpFacade(uolId, propId, dto.getPropDefPK(), dto.getDataType());
      }
    } catch (CreateException ex) {
      throw new PropertyException(ex);
    } catch (RemoveException ex) {
      throw new PropertyException(ex);
    }
  }
Example #2
0
  /**
   * This constructor is used when the class is constructed on the basis of an global URI. This is
   * the case for an existing property.
   *
   * @param uolId int the uol id for the current UOL
   * @param propId String the prop id for the property alias to be used in the uol
   * @param dto PropertyDefDto the DTO of the foreign defined PropertyDef
   * @throws PropertyException
   */
  public PropertyDef(int uolId, String propId, PropertyDefDto dto) throws PropertyException {

    // the property defintion should be referenced only.
    // Persist should only update the lookup entries
    this.existingPropertyDef = true;
    this.uolId = uolId;
    this.propId = propId;

    // get the dto for future reference
    this.dto = dto;

    // inform about intitialization
    onInit();

    // create the data container for this definition
    unpack(uolId, dto.getDefaultValue());
  }
Example #3
0
  /**
   * This constructor creates a PropertyDef based on the parameters passed. If no corresponding
   * PropertyDef was persisted a FinderException was thrown.
   *
   * @param uolId int
   * @param propId String
   * @throws PropertyException
   */
  PropertyDef(int uolId, String propId) throws PropertyException {

    try {
      // the property defintion should be created/updated when persisiting
      this.existingPropertyDef = false;
      this.uolId = uolId;
      this.propId = propId;

      // try to find find the property definition
      pdf = new PropertyDefFacade(uolId, propId);

      // get the dto for future reference
      dto = pdf.getDto();

      // inform about intitialization
      onInit();

      // create the data container for this definition
      unpack(uolId, dto.getDefaultValue());
    } catch (FinderException ex) {
      throw new PropertyNotFoundException(ex);
    }
  }
Example #4
0
 /**
  * Returns the XML blob representing the default value in XML format to be used when initialising
  * properties based on this PropertyDefintion. This method is called when a new Property based on
  * this PropertyDefinition is created.
  *
  * @return String the XML default value to used when creating Property instances.
  */
 protected String getXmlBlobValue() {
   if (dto == null) {
     dto = pdf.getDto();
   }
   return dto.getDefaultValue();
 }
Example #5
0
 /**
  * Returns the scope of this property represented by an Integer value. The following values are
  * bitwise exclusive value representing the different scope aspects: GLOBAL = 0, LOCAL = 1,
  * PERSONAL = 2, ROLE = 4. So for example a local personal property would be represented by value
  * 3.
  *
  * @return int the integer value representing the scope of this Property.
  */
 public int getScope() {
   return dto.getScope();
 }
Example #6
0
 /**
  * Returns the data type of this property. Allowed data types are: activity-structure,
  * activity-tree, act, environment, environment-tree, expression, learning-activity,
  * learning-object, monitor, play, rolepart, roles-tree, send-mail, support-activity,
  * unit-of-learning, integer, real, string, text, datetime, duration, file, boolean and uri.
  *
  * @return String representing the data type of this PropertyDefinition
  */
 public String getDataType() {
   return dto.getDataType();
 }