Skip to content
Snippets Groups Projects
Commit 03e26d9a authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Cleanups and documentation.

parent 0290550d
No related branches found
No related tags found
No related merge requests found
# DB-based persistence of domain data # DB-based persistence of domain data
DB-based persistence is provided by (an implementation of) the **IDbAccess** interface. It includes life-cycle methods corresponding to CRUD operations, so by using these methods, the corresponding DB operations may be performed to keep the DB in sync with the local domain model object structure.
The implementation is split in three:
* **AbstractDbAccessImpl**: Implements the DB-independent logic, i.e. life-cycle of collections of linked domain objects.
* **DbAccessImpl**: Inherits from **AbstractDbAccessImpl** and adds DB logic using SQL.
* **DbAccessHelper**: Helper class for the DB access.
Note that identifiers are not part of the domain model and are handled by the **IdMap** class, which provides a pair of maps from a String identifier to/from domain objects of some type.
A class diagram of the main classes related to db-based persistence is shown below. A class diagram of the main classes related to db-based persistence is shown below.
<img src="db-persistence-classes.png" alt="DB-based persistence" style="width: 800px;"/> <img src="db-persistence-classes.png" alt="DB-based persistence" style="width: 800px;"/>
tdt4140-gr1800/app.core/doc/json-persistence-classes.png

146 KiB

# JSON-based persistence of domain data # JSON-based persistence of domain data
A class diagram of the main classes related to JSON-based persistence is shown below. JSON support is provided by means of the [Jackson library](https://github.com/FasterXML/jackson), and uses its technique for serializing/deserializing domain objects.
<img src="json-persistence-classes.png" alt="JSON-based persistence" style="width: 800px;"/>
...@@ -9,32 +9,99 @@ import tdt4140.gr1800.app.core.GeoLocations; ...@@ -9,32 +9,99 @@ import tdt4140.gr1800.app.core.GeoLocations;
import tdt4140.gr1800.app.core.Person; import tdt4140.gr1800.app.core.Person;
/* /*
* CRUD interface for our domain: * class diagram:
* *
* @startuml * @startuml
* class GeoLocationsOwner { * class GeoLocationsOwner {
* String id
* } * }
*
* class Person { * class Person {
* String name * String name
* String email * String email
* } * }
*
* class TimedTaggedImpl {
* LocalDate date
* LocalTime time
* ZoneId zone
* String[] tags
* }
*
* GeoLocationsOwner <|-- Person * GeoLocationsOwner <|-- Person
*
* GeoLocationsOwner *-- GeoLocations: owner
*
* class GeoLocations { * class GeoLocations {
* String name * String name
* String description * String description
* LocalDate date
* LocalTime time
* ZoneId zone
* String[] tags
* } * }
* GeoLocationsOwner *-- GeoLocations: owner *
* GeoLocations --|> TimedTaggedImpl
*
* class GeoLocation { * class GeoLocation {
* int elevation * int elevation
* LocalTime time * LocalTime time
* String name * String name
* String description * String description
* } * }
* GeoLocation --|> TimedTaggedImpl
*
* GeoLocations *-- GeoLocation * GeoLocations *-- GeoLocation
* GeoLocation *-- LatLong * GeoLocation *-- LatLong
* @enduml * @enduml
*/ */
/*
* ER diagram interface for our domain:
*
* @startuml
* entity person {
* * id INTEGER GENERATED
* * name varchar(80)
* * email varchar(80)
* }
*
* entity geoLocations {
* * id INTEGER GENERATED
* path boolean
* name varchar(80)
* description varchar(200)
* date date
* time time
* zone varchar(20)
* }
*
* person --{ geoLocations: ownerId
*
* entity geoLocation {
* * id INTEGER GENERATED
* name varchar(80)
* description varchar(200)
* * latitude decimal
* * longitude decimal
* elevation int
* date date
* time time
* zone varchar(20)
* }
*
* geoLocations --{ geoLocation: ownerId
*
* entity tags {
* * ownerType char(3)
* * tag varchar(15)
* }
*
* geoLocations --{ tags: ownerId
* geoLocation --{ tags: ownerId
*
* @enduml
*/
public interface IDbAccess { public interface IDbAccess {
public IdProvider<Person> getPersonIdProvider(); public IdProvider<Person> getPersonIdProvider();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment