每一個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-type爲list, 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>
=================================================
它的父節點是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的屬性。這個屬性用於指定使用哪一個expression的property. 上述例子就是firstNonNull,如果第一個不爲空,就使用empSpendingLimit.否則就使用department這個item的deptSpendingLimit屬性。
而且這個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
爲你書寫的子類。