ATG Repository is vast area in ATG box to explore. There are lot of hidden things, which gets unnoticed during the implementation. Though these points are covered in the ATG Repository, I will try to collect them and note down here.
Ex: <item-descriptor ..... >
<table name.... >
<property name="myEnum" data-type="enumerated">
<attribute name="useCodeForValue" value="false"/>
<option value="option1" code="101"/>
<option value="option2" code="102"/>
</property>
<option value="option1" code="101"/>
<option value="option2" code="102"/>
</property>
</table>
</item-descriptor>
In above example, Code Values 101 and 102 were stored in DB, in place of option1 and option2 respectively. The column type was INTEGER or NUMBER depending on type of DB.
From ATG 10, you can store code values which are String in DataBase. The data type of column has to be varchar or varchar2 of minimal size.
Approach 1:
Ex: <item-descriptor ..... >
<table name.... >
<property name="myStringEnum" data-type="enumerated String">
<attribute name="stringEnumProvider" value="/my/custom/MyStringEnumProvider"/>
</property>
</property>
</table>
</item-descriptor>
MyStringEnumProvider should implement atg.adapter.gsa.StringEnumProvider and override the following methods.
a. getCodes() - return the list of values to be stored to the databaseb. getResources() - returns the list of values to be displayed to front End: (Production, BCC)
Refer the following Classes for implementation.
- /atg/multisite/SiteTypesProvider: Specified by siteConfiguration.siteTypes, obtains a list of site types from the SiteManager.
- /atg/multisite/ShareableTypeStringEnumProvider: Specified by siteGroup.shareableTypes properties, obtains a list of shareable types from the SiteGroupManage
Ex: <item-descriptor ..... >
<table name.... >
<property name="myStringEnum" data-type="enumerated String" property-type="atg.adapter.gsa.StringEnumPropertyDescriptor">
<attribute name="useCodeForValue" value="false"/>
<option value="option1" code="String1"/>
<option value="option2" code="String2"/>
</property>
<option value="option1" code="String1"/>
<option value="option2" code="String2"/>
</property>
</table>
</item-descriptor>
Its very simple and easy approach. String1 and String2 will be stored in DataBase in place of option1 and option 2 respectively.
Advantages of using the Enumerated String.
- Gives the flexibility to understand the meaning of data present in Database. Meaningful string can be stored in DataBase instead of Integers.
- Gives the flexibility to display the Meaningful Options in BCC(specially in ATG 10 BCC).
When we use dynamic value in MyStringEnumProvider , does not get refreshed in BCC even cache mode disabled. We have to re-start the BCC to get the value
ReplyDelete