How can auto increment (id generator) a property value in ATG

955 views
Skip to first unread message

shashi

unread,
Jan 2, 2009, 12:36:26 AM1/2/09
to ATG_Tech
Hi Friends,

I have created a column in the database .and also i created
corresponding column property in the repository xml file.
How can i auto increment this property value.



In the below i explained my problem with example.


With in the oracle i have created the fallowing table.


CREATE TABLE "MANTENIMIENTO_MAESTRO"
( "ID" VARCHAR2(40) NOT NULL ENABLE,
"TABLECODE" NUMBER(*,0),
"CODIGO" VARCHAR2(400),
"DESCRIPCION" VARCHAR2(400),
"IDIOMA" VARCHAR2(400),
CONSTRAINT "MANTENIMIENTO_MAESTRO_PK" PRIMARY KEY ("ID") ENABLE
)

and i create the below code in the repository xml file.

<table name="Mantenimiento_Maestro" type="primary">
<property name="id" column-name="id" data-type="string"
required="true" />

</table>

How can i autoincrement the id column value .


Pls send me the example code for this.
Thanks in advance.


Kind &Regards
Kommalapati Shashidhar

Ronak

unread,
Jan 2, 2009, 11:19:41 AM1/2/09
to ATG_Tech
When you create the item via repository you can use this.

MutableRepositoryItem createItem(java.lang.String pDescriptorName)
Returns a new item using an auto-generated unique id
MutableRepositoryItem createItem(java.lang.String pId,
java.lang.String pDescriptorName)
Returns a new item populated with the supplied id.

Check API for atg.repository.*

-ronak

shashidhar kommalapati

unread,
Jan 3, 2009, 1:07:11 AM1/3/09
to atg_...@googlegroups.com
Hi Ronak,

                 Thanks for your reply.
                                         Can you pls help me  how can i write this logic in the repository xml file.

In the below i have copy  my xml file.

CREATE TABLE "MANTENIMIENTO_MAESTRO"

( "TABLECODE" NUMBER(*,0),

"CODIGO" VARCHAR2(400),

"DESCRIPCION" VARCHAR2(400),

"IDIOMA" VARCHAR2(400),

"ID" VARCHAR2(400),

CONSTRAINT "MANTENIMIENTO_MAESTRO_CON" PRIMARY KEY ("ID") ENABLE,

CONSTRAINT "MANTENIMIENTO_MAESTRO_CON2" FOREIGN KEY ("CODIGO")

REFERENCES "PELAYO_COLORES" ("CODIGO") ENABLE

)

/

 

- Sequence and trigger for auto incrementing the id column

 

SEQUENCE:

---------

CREATE SEQUENCE   "MANTENIMIENTO_MAESTRO_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999

INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE

 

TRIGGER:

-------

CREATE OR REPLACE TRIGGER "MANTENIMIENTO_MAESTRO_TRIGGER"

before insert on Mantenimiento_Maestro

for each row

begin

select Mantenimiento_Maestro_seq.nextval into :new.id from dual;

end;

/

 


 

CREATE TABLE "PELAYO_COLORES"

( "CODIGO" VARCHAR2(400),

"COLOR" VARCHAR2(40),

"ID" VARCHAR2(400),

CONSTRAINT "PELAYO_COLORES_CON" PRIMARY KEY ("CODIGO") ENABLE,

CONSTRAINT "PELAYO_COLORES_CON_FAN" FOREIGN KEY ("ID")

REFERENCES "MANTENIMIENTO_MAESTRO" ("ID") ENABLE

)

/

 

 

2. repository.xml as fallows:

 

<item-descriptor name="pelayo" sub-type-property="type" version-property="version" expert="true"  use-id-for-path="false" folder="false">

        <table name="Mantenimiento_Maestro" type="primary" id-column-name="id" >  

            <property name="type" data-type="enumerated" column-name="tablecode" hidden="true" xml-combine="append">

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

                <option  value="colores"/>

                <option value="profesiones"/>

                <option  value="Tiposdesegurosautomoviles"/>

                <option  value="Companiasaseguradoras"/>

               <!--in the same way remaining entidades-->

            </property>

        </table>

        </item-descriptor>

 

Note:Mantenimiento_Maestro table tablecode column stores different code for each entidades.

The below item descriptor is for one single entidades:(In the same way I developed the remaining 32 item descriptors)

<item-descriptor name="colores"  super-type="pelayo" sub-type-value="colores">

            <table name="Mantenimiento_Maestro" type="primary" id-column-names="id">

      

            <property name="descripcion" column-name="descripcion" data-type="string"  required="false" readable="true" writable="true" queryable="true" hidden="false" expert="false"  cache-mode="inherit"/>

            <property name="idioma" column-name="idioma" data-type="enumerated"  required="false" readable="true" writable="true" queryable="true" hidden="false" expert="false"  cache-mode="inherit">

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

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

            </property>

            </table>

            <table name="pelayo_colores" type="auxiliary" id-column-names="id">

                <property name="codigo" column-name="codigo" data-type="string"  required="false" readable="true" writable="false" queryable="true" hidden="false" expert="false"  cache-mode="inherit"/>

            <property name="color" column-name="color" data-type="string"  required="false" readable="true" writable="true" queryable="true" hidden="false" expert="false"  cache-mode="inherit"/>

            </table>

            </item-descriptor>

   
In the above i have used the one trigger and sequence for autoincremting of the id column purpose.But the actuval requirement is in the repository.xml level only i need to write the logic for autoincrementing the column id.
                                If it possible pls update my code and sent me.
                                          Thanks in advance.
Reply all
Reply to author
Forward
0 new messages