Here’s an example that defines a user defined property type in an XML repository definition file:

<item-descriptor name="images">
  <table name="book" id-column-names="book_id" type="primary">
    <property name="title"/>
    <property name="author"/>
    <property name="lastModifiedTime"/>
    <property name="contentFileName" data-type="string"/>
  </table>
  <property name="contentFile"
            property-type="atg.repository.FilePropertyDescriptor">
    <attribute name="pathNameProperty" value="contentFileName"/>
  </property>

</item-descriptor>

For the user defined property implementation used in this example, see the source code in:

<ATG9dir>/Das/src/Java/atg/repository/FilePropertyDescriptor.java

If you extend the GSAPropertyDescriptor class, you have two additional methods that you can override. These methods convert data between the type that is stored in the database and the type that is stored in the cache. These methods are called only when the data is loaded from or stored to the database. If a cached value is found, it is returned without calling these methods. Thus it is slightly more efficient to do conversion here than in the getPropertyValue or setPropertyValue methods.

//-------------------------------------
/**
 * Translate a raw property value to a real value. The real value is what
 * applications use. The raw value is what is stored in the DB.
 * @param pRawValue for a property
 * @return real value to use in applications for the property
 **/
public Object rawToReal(Object pRawValue)

//-------------------------------------
/**
 * Translate a property value to a raw value. The real value is what
 * applications use. The raw value is what is stored in the DB.
 * @param pRealValue for a property
 * @return raw value for storing this property in the DB
 **/
public Object realToRaw(Object pRealValue)

The following example, from the productCatalog.xml file in ATG Commerce defines two property descriptors:

<!-- Media, which is stored on the external file system -->
<item-descriptor name="media-external" display-name="Media - External"
                 super-type="media" sub-type-value="external"
                 item-cache-size="1000" query-cache-size="1000"
                 version-property="version" id-space-name="media"
                 content-property="data">
    <table name="dcs_media_ext" type="auxiliary" id-column-names="media_id">
       <property name="url" data-type="string" column-name="url"
                 required="true"/>
    </table>
    <property name="data" property-type="atg.repository.FilePropertyDescriptor"
              writable="false" queryable="false">
      <attribute name="pathNameProperty" value="url"/>
      <attribute name="pathPrefix" value="./docs"/>
    </property>
    <property name="mimeType"
              property-type="atg.repository.MimeTyperPropertyDescriptor"
              data-type="String" writable="false" queryable="false">
        <attribute name="identifier" value="url"/>
    </property>
</item-descriptor>

A new property type is defined by implementing a sub-class of the atg.repository.RepositoryPropertyDescriptor class. In this class, you can define values for the readable, writable, and queryable properties. They also have the following additional methods that are typically overridden by a user-defined property type:

//-------------------------------------
 // Ability to retrieve/save values to the repository item
 //-------------------------------------

 //-------------------------------------
 /**
  * This method is called to retrieve a read-only value for this property.
  *
  * Once a repository has computed the value it would like to return for
  * this property, this property descriptor gets a chance to modify it
  * based on how the property is defined.  For example, if null is to
  * be returned, we return the default value.
  */
 public Object getPropertyValue(RepositoryItemImpl pItem, Object pValue);

 //-------------------------------------
 /**
  * Sets the property of this type for the item descriptor provided.
  */
 public void setPropertyValue(RepositoryItemImpl pItem, Object pValue);

You can register user defined property types in a static registry so they can be defined with a simple name, like tag converters. List your user defined properties in the userPropertyDescriptors property of the GSARepository component.

 
loading table of contents...