Creating your own ATG Repository - Beginners- I

ATG Repository supports data anywhere architecture. We will begin creating simple repository from requirements. For further more technical aspects related to repository, ATG Repository Guide is helpful.

Few Must read points:
1. Every XML Definition file should begin with <gsa-template> tag.
2. <gsa-template> can contain N number of <item-descriptor>'s.
3. <item-descriptor> can contain only one Primary Table, N number of Auxillary and Multi tables.

Step 1. Analyse the Requirement.


From Above diagram, following points are collected.
  1. There are two separate OBJECTS, which can be clubbed together. So now these two Objects "Author" and "Book" will treated as Items(<item-descriptor>) under the one repository XML definition file.
  2. Identify the each Property under the each Object. Identify the Data Types of each. 

Step 2: Drawing in line repository structure.



Above diagram is pretty self explanatory.

Step 3: Creating the XML Definition file(with minimal required attributes)

File Name: /my/library.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE gsa-template
        PUBLIC "-//Art Technology Group, Inc.//DTD General SQL Adapter//EN"
        "http://www.atg.com/dtds/gsa/gsa_1.0.dtd">

<gsa-template>

  <header>
    <name>Library Repository</name>
    <author>Iranna</author>
  </header>
   
<item-descriptor name="author" display-name="author" >
   
    <table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
        <property name="id" column-name="author_id"/>
        <property name="firstName" column-name="first_name" display-name="firstName" data-type="string"/>
        <property name="lastName" column-name="last_name" display-name="lastName" data-type="string"/>
        <property name="dob" column-name="dob" display-name="dateOfBirth" data-type="date"/>
        <property name="gender" column-name="gender" display-name="gender" data-type="enumerated">
            <attribute name="useCodeForValue" value="true"/>
            <option value="Male" code="101"/>
            <option value="Female" code="202"/>
            <option value="DontSpecify" code="303"/>
             </property>
    </table>
</item-descriptor>

<item-descriptor name="book" display-name="book" >
   
    <table name="BOOK_MASTER" type="primary" id-column-name="book_id">
        <property name="id" column-name="book_id"/>
        <property name="name" column-name="name" display-name="name" data-type="string"/>
        <property name="description" column-name="description" display-name="description" data-type="big string"/>
        <property name="price" column-name="price" display-name="price" data-type="double"/>

        <property name="pages" column-name="pages" display-name="pages" data-type="int"/>
       <property name="available" column-name="available" display-name="available" data-type="boolean"/>
    </table>
</item-descriptor>
</gsa-template>


Step 4: Creating the Component for XML Definition file.

Path: /my/Library.properties

$class=atg.adapter.gsa.GSARepository
$scope=global
repositoryName=Library

# database access- for making repositry as versioned, use SwitchingDataSource else use JTDataSource
dataSource=/atg/dynamo/service/jdbc/SwitchingDataSource
transactionManager=/atg/dynamo/transaction/TransactionManager

# our XML definitionFile
definitionFiles=/my/library.xml

# XML parsing
XMLToolsFactory=/atg/dynamo/service/xml/XMLToolsFactory

# id generation
idGenerator=/atg/dynamo/service/IdGenerator

30 comments:

  1. Nice explanation

    ReplyDelete
  2. Awesome Excellent please dont stop posting.....

    ReplyDelete
  3. Excellent information for learners

    ReplyDelete
  4. Thanks for explaining...

    Could you please give any explanations about table relationships, DML operations in ATG as well.

    It will be helpfulfor me.

    Thanks in advance

    ReplyDelete
  5. Helpful ,thanks

    ReplyDelete
  6. Could you please explain PropertyDescriptor in ATG in detail. Thanks In advance.

    ReplyDelete
    Replies
    1. Yes. That's one of my to-do. I will be posting soon about "Derived properties and User-defined properties".

      Delete
  7. how I will use a custom repository in a java class
    for eg,suppose i have a repository like SongRepository and there is a java class SongList.java Now my question is How will i create instance of this songrepository in the Songlist.java

    ReplyDelete
    Replies
    1. You need to create property of type 'Repository' in your class. And then create setter and getter for the same. And in SongList.properties, map the property to SongRepository. Then you have access to SongRepository in SongList.java

      Regards,
      Iranna

      Delete
  8. what is item and item descriptor ? and what is repository item can any one explain?

    ReplyDelete
    Replies
    1. Item descriptor is a collection of tables and repository item is a row in table.

      Delete