Difference between revisions of "Customizing opentaps 2: an OSGi Tutorial"
(New page: In this tutorial, I will take you through the steps to customizing the opentaps 2 Notes application and show you how to work with the OSGi framework. Right now our notes application i...) |
m (Protected "Customizing opentaps 2: an OSGi Tutorial": Sysop page [edit=sysop:move=sysop]) |
(No difference)
|
Revision as of 00:06, 24 February 2012
In this tutorial, I will take you through the steps to customizing the opentaps 2 Notes application and show you how to work with the OSGi framework.
Right now our notes application is looking pretty good -- I can create notes from my html client application using the REST interface. I plan on using my notes application for comments from my different sites. To keep track of it, I'd like to add a new field to store where the notes are coming from.
The first step is to add the field to my entity definition. Our entities are part of the implementation of the repository (see Domain Driven Architecture to see how the repository/service concept works) for the notes application. The repository implementation is in modules/notes/impl/repository/, the Java source files are in the src/main/java sub-directory from there, and our NoteData entity is defined in org/opentaps/notes/entity/NoteData.java. Here I will add a new field:
@Column(name = "CLIENT_DOMAIN") private String clientDomain;
and use Eclipse to create get and set methods for it.
Just to make sure I did it correctly, I build opentaps 2 again with mvn clean install, use the Geronimo to uninstall the old org.opentaps.notes.eba and deploy the new one. Then I create another note from my html client and check the database:
mysql> show fields from NOTE_DATA; +--------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+--------------+------+-----+---------+-------+ | NOTE_ID | varchar(32) | NO | PRI | NULL | | | ATTRIBUTE_1 | varchar(255) | YES | | NULL | | | ATTRIBUTE_10 | varchar(255) | YES | | NULL | | | ATTRIBUTE_2 | varchar(255) | YES | | NULL | | | ATTRIBUTE_3 | varchar(255) | YES | | NULL | | | ATTRIBUTE_4 | varchar(255) | YES | | NULL | | | ATTRIBUTE_5 | varchar(255) | YES | | NULL | | | ATTRIBUTE_6 | varchar(255) | YES | | NULL | | | ATTRIBUTE_7 | varchar(255) | YES | | NULL | | | ATTRIBUTE_8 | varchar(255) | YES | | NULL | | | ATTRIBUTE_9 | varchar(255) | YES | | NULL | | | CREATED_BY_USER_ID | varchar(255) | YES | | NULL | | | DATE_TIME_CREATED | datetime | YES | | NULL | | | USER_ID_TYPE | varchar(255) | YES | | NULL | | | SEQUENCE_NUM | bigint(20) | YES | | NULL | | | NOTE_TEXT | text | YES | | NULL | | | CLIENT_DOMAIN | varchar(255) | YES | | NULL | | +--------------------+--------------+------+-----+---------+-------+ 17 rows in set (0.05 sec)
Yay! My new field was added automatically when I accessed the notes application.