-
Notifications
You must be signed in to change notification settings - Fork 84
Adding a Model (Data Entity)
CURRENTLY IN DEVELOPMENT
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].
The following is a step-by-step instructional on creating/implementing a new Model. It does not describe the API Adapter implementation.
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.
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.
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.
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)