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

  1. 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.
  2. In ArgoUML, select the Logical Model package -> right click -> select Add Package.
  3. 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.
  4. The simple data service will follow a similar package hierarchy edu.uab.uabgrid.cacoresdk.domain
  5. Repeat steps 2-3 until the fully qualified package hierarchy has been created
  6. 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,

  1. Select the package domain -> right click -> Create Model Element -> New Class.
  2. 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.
  3. Select the Namespace from the drop down as domain [Model::Logical View::Logical Model::edu::uab::uabgrid::cacoresdk]
  4. Save the project CTRL-S

Create Class Attributes

We will create three attributes for the class Person

  1. Select the Person class -> right click -> Create Model Element -> New Attribute
  2. 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]
  3. 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]
  4. 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

  1. Select the Person class -> right click -> Create Model Element -> New Operation
  2. The Operation Properties tab in the Detail pane becomes active for the new method. Enter name as setName
  3. 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
  4. Repeat step 3 to add a second parameter ln
  5. Repeat step 2 to add another method getName
  6. 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
  7. 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

  1. In ArgoUML, select Data Model -> right click -> Create Model Element -> New Class
  2. 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 (_).
  3. Select the Namespace from the drop down as Data Model [Model::Logical View]
  4. Go to the Stereotype tab, from the Available Stereotypes, select table[classifier] and add to the Applied Stereotypes
  5. Save the project CTRL-S

Create Data Model Columns

We will create three columns for the table PERSON

  1. Select the PERSON class -> right click -> Create Model Element -> New Attribute
  2. 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]
  3. Repeat steps 1-2 to create columns FIRST_NAME and LAST_NAME. Select the type for these two columns as VARCHAR2
  4. Save the project CTRL-S

Create Data Model to Object Model Mapping

Define Data Source (Object Class)

Create New Stereotype

  1. In ArgoUML, select your top-level model, which is by default named Model -> right click -> Create Model Element -> New Stereotype
  2. The Stereotype Properties tab in the Detail pane becomes active for the new stereotype.
  3. Enter name as DataSource
  4. 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
  5. Save the project CTRL-S

Create New Dependency

  1. Drag the PERSON Class (Data Model) and Person Class (Logical Model) to the Diagram Editor.
  2. Select the Dependency icon (up arrow with no subscripts)
  3. 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
  4. 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]
  5. Go to the Stereotype tab, from the Available Stereotypes, select DataSource[Dependency] and add to the Applied Stereotypes
  6. Save the project CTRL-S.
  7. The project file with the above created data, object models, and dependency will look as follows in ArgoUML

source:exp/sds/exp1/images/sds11/ArgoUML-ObjModel.png

Map Attributes to Columns

  1. Launch caAdapter, either from a
  2. Click File -> New -> Model Mapping Service -> Object Model to Data Model Map Specification
  3. 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
  4. Due to the creation of the above new dependency, You will see a green line from Person Object class to PERSON Data Class.
  5. 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.

source:exp/sds/exp1/images/sds11/caAdapter-Model-Mapping.png

  1. Through drag-and-drop map firstName -> FIRST_NAME, lastName -> LAST_NAME, id -> ID.
  2. On the Person attribute id right click -> select set as Primary key
  3. Save the mapping
  4. 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

source:exp/sds/exp1/images/sds11/DomainClassBrowser.png

  • The following image shows the query result

source:exp/sds/exp1/images/sds11/ResultDataTable.png

Continue to creating a Java application for querying the data service

References