ATG-Repository

一:定义文件的相关 tag 和属性

Item-descriptor:

每一个Repository Item 类型都是在<item-descriptor> 下描述的。

Name:在整个定义文件中都是唯一的。

Cache-mode: Item-descriptor 级别默认就是simple .如果item某一个具体的属性不想使用cache。可以设置为disable,这样会覆盖Item-descriptor的缓cache-model

<item-descriptor name="user" cache-mode="simple">

  <table name="dps_user">

    <property name="password" cache-mode="

disabled">

    ...

  </table>

  ...

</item-descriptor>

但是希望小心使用disable。因为去取这个item的时候,都回去数据库查询。那么会显著的降低应用的性能。

Simple每一个server维护属于自己的内存中的缓存。

Lock: 这个缓存模式适用于有多台server的应用。解决多台server同时update一个item

======================

他需要有几个先决条件:

1 Item-descriptor的查询缓存必须disable,通过设置query-cache-size=0

2 必须配置ClientLockManager component

=====================

我们可以设置缓存到期时间

Item-expire-timeout: item缓存到期时间

Query-expire-timeout: 查询缓存到期时间

 

还有分布式缓存,这个暂不予介绍。

Default缺省值是false.如果设为true,那么就是这repository的默认的item-descriptor.

Display-name;一般用在ACC.

Id-separator: id的分隔符,默认是:。适用于多个列作为id.

Item-cache-size: 缓存的item的数量。如果超过设定值。那么就会把最近访问较少的额item删除掉。

Sub-type-value: 如果这个item是一个sub-type.那么需要指定这个属性。就是自己的值。

Super-type:并且需要指定他所继承的父类。

 

Property如果在item-descriptor tag下直接使用Property,那么这个属性是瞬时属性,既不会持久化到数据库。但是可读,可写不能查询。

==========================================

Table

Name:表名

Id-column-names:数据库表的id

Type:指定表的类型primary/auxiliary/multi

 

==========================================

Property

Name: 指定属性名字。

Cache-mode:可以重载Parent级别的cache-mode.

Cascade:级联insert/update/delete.

Category:对相似的属性进行分组。一般适用于BCC.使用

propertySortPriority去指定这个组属性的显示顺序。

 

<property category="Basics" name="firstName"

         data-type="string" display-name="First name">

   <attribute name="propertySortPriority" value="-3"/>

</property>

<property category="Basics" name="middleName"

       data-type="string“ display-name="Middle name">

   <attribute name="propertySortPriority" value="-2"/>

</property>

<property category="Basics" name="lastName"

       data-type="string"  display-name="Last name">

   <attribute name="propertySortPriority" value="-1"/>

</property>

Column-name: 对应的数据库的表名。

Component-data-type:如果一个属性的数据类型是list, array, Set, map . 那么它必须有一个component-data 去指定的这个数据类型的基本数据类型。

<property name=”xxx” data-type=”list” component-data=”int”>

Component-item-data: 如果data-typelist, array,

Map, set ,他们的基本数据类型是item-descriptor. Component-item-data 它就是用来指定这个item的类型。而且这个集合所装的item类型必须一致。

Item-type: 就是直接对另外一个item的引用。

Repository: 指定这个属性所在的repository 定义文件

<property name="siteGroup"

column-name="SITE_ID" category="NGP"

item-type="enterpriseSiteGroup" required="true"

repository="/atg/multisite/SiteRepository"

display-name="Enterprise Site Group" >

   <attribute value="11" name="propertySortPriority"/>

   <attribute name="uiStringIdType"

   value="/atg/multisite/SiteRepository:enterpriseSiteGroup"/>

</property>

=================================================

Derivation

它的父节点是property。子节点是expression.

这个节点或者标签主要用于派生属性。什么意思呢?就是从其他re

Pository item 或者 property衍生出一些属性值。

他有几个要求:

1 派生属性必须是transient 属性。

2 通过<derivation >定义,内部可以包含一个或者多个<ex-

Pression>

那么<expression>里面有装的是property name

<item-descriptor name="employee">

   <property name="department" item-type="department"/>

   <property name="empSpendingLimit" data-type="int"/>

   <property name="spendingLimit" writable="false">

      <derivation method=“firstNonNull”>

       <expression>empSpendingLimit</expression>

       <expression>department.deptSpendingLimit

</expression>

      </derivation>

</property>

</item-descriptor>

<item-descriptor name="department">

   ...

   <property name="deptSpendingLimit" data-type="int"/>

</item-descriptor>

比如以上的例子引用的就是某一个item的属性和某一个自己item的属性。并且使用哪一个并不是随意决定的,在derivation有一个method的属性。这个属性用于指定使用哪一个expressionproperty. 上述例子就是firstNonNull,如果第一个不为空,就使用empSpendingLimit.否则就使用department这个itemdeptSpendingLimit属性。

而且这个method用户可以自己定制。使用user-method就可以完成定制。

============================================

Option

没有子节点,只有父节点property.

使用情况:当某一个属性的数据类型是枚举,那么枚举的可能的值就需要用到<option>

<property name="gender" data-type="enumerated">

      <option value="male" code="0"/>

      <option value="female" code="1"/>

</property>

===============================================

Attribute

没有子节点只有父节点。可能的父节点包括item-descriptor,

Property, table

它的作用就是以键值对的形式为属性描述器提供一些参数。这些属性描述器可以是OOTB,也可以是我们自己定制的。

=============================================

Name-query

item-descriptor的子节点,有<rql-query><sql-

Query>子节点。

<rql-query>父节点是<name-query>子节点是rql-filter

Or <query-name> or <rql>

<rql>没有子节点。他所包装的内容就是一个rql的查询语句。

<named-query>

   <rql-query>

      <query-name>staticPageBySeoName</query-name>

      <rql>seoName EQUALS IGNORECASE ?0 AND sites includes ?1</rql>

   </rql-query>

</named-query>

Query-name指的就是这个rql命名查询的名称。Rql就是查询语句。

如果我们想直接在dyn/admin下面直接查询rql.我们可以在<query-

Items>下面直接使用这个rql and 提供相关的参数。

Sql-query同样是这样的用法,只不过需要提供的是sql语句。

======================================================

Add-item,update-item,remove-item,print-item,query-items等等这些我们经常用于dyn/admin

item-descriptor你所需要添加或者修改或者删除或者查询的item.

Id 你这个item所对应的repository id.

子标签包括set-property.

 

 

二:用户自定义属性类型

首先,我们必须明确,这个属性是不是需要持久化到数据库。

其次,我们需要创建一个Java类去描述property.根据属性是否持久化到数据库。我们需要继承的Java class也不一样。

如果需要持久化到数据库:

Java class 需要继承GSAPropertyDescriptor

如果不需要持久化到数据库,即临时属性,那么

Java class 需要继承RepositoryPropertyDescriptor

我们需要在这个类中重载getPropertyValue()setPropertyValue()。我们可以在这个处理类去定义一些属性。这些属性的属性值我们可以在xml文件中通过<attribute name=”” value=””/>

传进来。比如

<property name="SEOName" property-type="com.ngp.commerce.

        repository.NGPSEOFriendlyPropertyDescriptor"

        writable="false" data-type="string">

   <attribute name="basePropertyName" value="displayName"/>

   <attribute name="uiwritable" value="false" />

</property>

Writable=”false” 表示不可写。但是可以读。

Uiwritable=”false” 表示不能通过ACC去修改或者设置值。

最后,去Repository 定义文件去set这个property-type

为你书写的子类。

 

 

 

猜你喜欢

转载自nicky19870612.iteye.com/blog/1973609
今日推荐