Wiki

Imprimir Propiedades
Cantiga_CRUD

Cantiga Project

  

Third step: Adding CRUD classes

 

At the first step, we have added the jpox persistence module, now we have to create the CRUD (create, read, update and delete) classes. Firstly, we define in the src/org.romulus.cantiga.domain.package.jdo file which classes will be treated as persistent.
 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE jdo PUBLIC

"-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"

"jdo.dtd">

<jdo>

<package name="org.romulus.cantiga.domain">

<class name="Person" detachable="true"></class>

<class name="Composition" detachable="true">

<field name="forms" default-fetch-group="true" detachable="false" >

<collection element-type="String" dependent-element="false" />

</field>

<field name="compositors" default-fetch-group="true" detachable="true" >

<collection element-type="Person" dependent-element="false" />

</field>

<field name="associatedComposition" default-fetch-group="true" detachable="true" >

<collection element-type="Composition" dependent-element="false" />

</field>

</class>

...

</jdo>

 

In this example, Person and Composition classes are persistent. Collection and domain class attributes must be defined explicitly as persistent. The next step is to create the CRUD classes using the roma console:

./roma crud org.romulus.cantiga.domain.<DomainClass>

It must be executed for each domain class.

 

These commands create a new package “org.romulus.cantiga.repository”. It contains repository classes of the domain entities that extends of PersistenceAspectRepository<>. For example, the repository class for Person entities is as follow:

 

public class PersonRepository extends PersistenceAspectRepository<Person> { }

 

Also, a new package “org.romulus.cantiga.view.domain.<DomainClass>” is created for each domain class with these associated classes:

 

<DomainClass>Main.java: handle CRUD for <DomainClass> instances.

<DomainClass>Filter.java: is used in <DomainClass>Main to filter searches

<DomainClass>Instance.java: used to display <DomainClass> instances on CRUD reading, creation and updating.

<DomainClass>Listable.java: used to display <DomainClass> instances as result set of the searches executed in <DomainClass>Main.

<DomainClass>Select.java: Derived from PersonMain allows to select instances listed as result sets.

 

These classes will be modified in order to customize the view. Now, we must compile using the ant script: build.xml
 

Last Update: 2008-08-11

 

 

<< Prev Cantiga Next>>
1221 Accesos, 0 Ficheros adjuntos 0 Ficheros adjuntos

  • Comentarios