Skip to content

Adding a Model (Data Entity)

tmwack edited this page Nov 4, 2012 · 3 revisions

CURRENTLY IN DEVELOPMENT

Model Overview

In WPI Suite TNG, a Model is a representation of database contents (or data from another persistent data source). Examples of Model data might be: A Defect in the DefectTracker module, a Project in the Core module. Models offers persistence and extensible functionality to the data layer.

The classes implementing each Model's attributes live in edu.wpisuitetng.modules.core.database.

For more implementation details and other information, visit the Model page [to be written].


How to add a Model

The following is a step-by-step instructional on creating/implementing a new Model. It does not describe the API Adapter implementation.

1. Server (Core Module): Create your Model class

Within the module's /models/ folder, create new class for your Model that implements the edu.wpi.cs.wpisuitetng.modules.Model interface. The member variables of the Model class represent the attributes of the data you would like to persist in the database. Each model class should specify an attribute as the Model's 'unique identifier'. For example, the User Model has the 'username' field as its unique identifier attribute.

2. Server (Core Module): Create EntityManager for the Model

Within the the module's /entityManager/ folder, create an implementation of the edu.wpi.cs.wpisuitetng.modules.core.EntityManager<T, C> interface for the Model. The generic fields for the EntityManager<T, C> correspond to the following: (T) Model Class, (C) Datatype of the Model's unique identifier field.

3. Server (Core Module): Register Model's EntityManager with the ManagerLayer

Data manipulation of the Model class is handled through the EntityManager package. Currently, the EntityManager keeps track of Models using the ManagerLayer map in edu.wpi.cs.wpisuitetng.modules.core.ManagerLayer.

3. Client: Create API Adapter for the Model

The API serves the Model classes as JSON strings [format defined in Model.toJSON()]. The client implementation will need to provide an API Adapter for these JSON strings. No standard as of now (10/29/12)