Table of Contents
This HowTo will take you through the creation of a domain model and publish the domain model to a web server
Prerequisites
The tools needed for the following steps are:
- MySQL-5.0 (Oracle is also supported by caCORESDK-4.x. The following tutorial assumes MySQL as the underlying database)
- ArgoUML-0.26
- caCORESDK-4.1
- caAdapter (Model Mapping Services Tool only)
- Apache-Tomcat-5.5 (Jboss is also supported by caCORESDK-4.x.The following tutorial assumes Tomcat as the web server)
Create a Database Schema
Any database schema would do. You can make it as simple or complicated with many associations.
- Here is one to get you started. A single table, Person with columns first name, last name and id.
- Create the database and inject test data with the sql script as follows (replace <dbname>, <db_user>, and <db_password> in the sql script)
mysql -u root -p < MySql_DB_Creation.sql
Create an Object Model
Enterprise Architect and ArgoUML are the two modeling tools supported by caCORESDK, with which one can create data and object models. EA is a licensed software, whereas ArgoUML is open-source. We will use ArgoUML-0.26 version, the latest version 0.28 is not yet supported by caCORESDK-4.x
- To start with, there is a template model file at caCORE/models/SDKArgoTemplate.uml. Open this in ArgoUML and save it by renaming it as SDKArgoPeople and ensure that the file type is ArgoUML *.uml.
- In ArgoUML, select the Logical Model package -> right click -> select Add Package.
- The Properties tab in the Detail pane becomes active for the new package. Type in the Name field to add the package name. NOTE: Package names should follow Java package naming conventions; i.e., Java packages are defined using a hierarchical, lowercase, naming pattern, with levels in the hierarchy separated by periods (.) . Furthermore, package names are typically the organization’s domain name backwards. An example, taken from the SDK sample model, is gov.nih.nci.cacoresdk.domain.
- The simple data service will follow a similar package hierarchy edu.uab.uabgrid.cacoresdk.domain
- Repeat steps 2-3 until the fully qualified package hierarchy has been created
- To create a package within another package (as a sub-package/folder), select the existing package first, and then follow steps 2-3 above.
Create an Object Model Class
New classes are added in the context of a class diagram within the selected package. To add a Logical Model class to a package,
- Select the package domain -> right click -> Create Model Element -> New Class.
- The properties tab in the Detail pane opens up. Enter the class name as Person in the Name field NOTE: class name should be according to the Java class naming conventions; i.e., class names should start with a capital letter, with embedded words capitalized.
- Select the Namespace from the drop down as domain [Model::Logical View::Logical Model::edu::uab::uabgrid::cacoresdk]
- Save the project CTRL-S
Create Class Attributes
We will create three attributes for the class Person
- Select the Person class -> right click -> Create Model Element -> New Attribute
- The Attribute Properties tab in the Detail pane becomes active for the new attribute. Name the first attribute as id and select type as int [Model]
- Repeat steps 1-2 to create attributes firstName and lastName. Select the type for these two attributes as String [Model::Logical View::Logical Model::java::lang]
- Save the project CTRL-S
NOTE: Ensure that you follow the Namespace convention for the column and attribute data types as mentioned here.
Selecting any other Namespace convention results in this error.
Create Class Methods
NOTE: When using caCORESDK, methods for an object model need not be defined in a UML tool. caCORESDK generates Java Beans (constructor+getter-setter methods) for the object class. Demonstrating here a way to define methods inside of ArgoUML.
We will create two methods for the class Person
- Select the Person class -> right click -> Create Model Element -> New Operation
- The Operation Properties tab in the Detail pane becomes active for the new method. Enter name as setName
- Add a new parameter by clicking the New Parameter icon above the Name field. Name this as fn, Type as String and Direction Kind as In
- Repeat step 3 to add a second parameter ln
- Repeat step 2 to add another method getName
- Repeat step 3 to add the following two parameters to the getName method
- Name - id, Type - Integer, Direction Kind - In
- Name - return, Type - String, Direction Kind - return
- Save the project CTRL-S
Create a Data Model
The package hierarchy convention is not followed for creating data model classes (tables). Classes are added directly within the Data Model package.
Create Data Model Table
- In ArgoUML, select Data Model -> right click -> Create Model Element -> New Class
- The properties tab in the Detail pane opens up. Enter the class name as PERSON in the Name field NOTE: Enter a table name according to the Table naming conventions; i.e., table names should be all uppercase, with embedded words separated by an underscore (_).
- Select the Namespace from the drop down as Data Model [Model::Logical View]
- Go to the Stereotype tab, from the Available Stereotypes, select table[classifier] and add to the Applied Stereotypes
- Save the project CTRL-S
Create Data Model Columns
We will create three columns for the table PERSON
- Select the PERSON class -> right click -> Create Model Element -> New Attribute
- The Attribute Properties tab in the Detail pane becomes active for the new attribute. Name the first attribute as ID and select type as int [Model]
- Repeat steps 1-2 to create columns FIRST_NAME and LAST_NAME. Select the type for these two columns as VARCHAR2
- Save the project CTRL-S
Create Data Model to Object Model Mapping
Define Data Source (Object Class)
Create New Stereotype
- In ArgoUML, select your top-level model, which is by default named Model -> right click -> Create Model Element -> New Stereotype
- The Stereotype Properties tab in the Detail pane becomes active for the new stereotype.
- Enter name as DataSource
- To the right of the Detail pane is the Base Class space; Right click in this space -> select Add -> From the choices, select Dependency -> Add to the Selected -> click OK
- Save the project CTRL-S
Create New Dependency
- Drag the PERSON Class (Data Model) and Person Class (Logical Model) to the Diagram Editor.
- Select the Dependency icon (up arrow with no subscripts)
- Drag the Dependency icon onto the Diagram Editor and connect the Data Model and Logical Model i.e., the arrow should originate at Data Model and point towards Logical Model, PERSON -> Person
- The Dependency Properties tab in the Detail pane becomes active for the new dependency. Enter name for the new dependency as PERSON -> Person. Select Namespace as Data Model [Model::Logical View]
- Go to the Stereotype tab, from the Available Stereotypes, select DataSource[Dependency] and add to the Applied Stereotypes
- Save the project CTRL-S.
- The project file with the above created data, object models, and dependency will look as follows in ArgoUML
Map Attributes to Columns
- Launch caAdapter, either from a
- local installation dir with
java -jar caadapter_ui.jar
- or the online caAdapter service (requires Java Web Start)
- local installation dir with
- Click File -> New -> Model Mapping Service -> Object Model to Data Model Map Specification
- Click Open XMI File. In the Dialog box that opens, select the FileType as All Files and select project file as SDKArgoPeople.uml created above with ArgoUML
- Due to the creation of the above new dependency, You will see a green line from Person Object class to PERSON Data Class.
- Drag the attribute from the object class on the right to the corresponding column in the data class on the left. The following fig shows this mapping.
- Through drag-and-drop map firstName -> FIRST_NAME, lastName -> LAST_NAME, id -> ID.
- On the Person attribute id right click -> select set as Primary key
- Save the mapping
- For your reference, check your object model with this one.
Configure caCORESDK
For this HowTo, Tomcat will be the Application Server to publish our data service.
- Copy the deploy.properties to caCORE/conf/
- In the above deploy.properties file, replace the db_name in the DB_CONNECTION_URL, db_user in DB_USERNAME, db_password in DB_PASSWORD, to those you had defined when you created the database schema.
- Copy your saved object model, SDKArgoPeopel.uml to caCORE/models
Build Data Service
- Go to caCORE install dir
- Run the following ant targets to build various artifacts for your data service
ant clean-all ant build-system
- After successful build, copy the war file at caCORE/output/people/package/webapp/people.war to $CATALINA_HOME/webapps/
- Start tomcat
- In a browser type the following to navigate to the caCORESDK generated web-interface for your People Data Service.
http://localhost:9080/people
- Click Continue
- Expand the single object listed, to see your Person class.
- Click Submit and you will be able to see your data in the PERSON table. The following image shows the data service
- The following image shows the query result
Continue to creating a Java application for querying the data service
References




