diff --git a/tdt4140-gr1800/app.core/doc/db-persistence.png b/tdt4140-gr1800/app.core/doc/db-persistence-classes.png similarity index 100% rename from tdt4140-gr1800/app.core/doc/db-persistence.png rename to tdt4140-gr1800/app.core/doc/db-persistence-classes.png diff --git a/tdt4140-gr1800/app.core/doc/db-persistence.md b/tdt4140-gr1800/app.core/doc/db-persistence.md index a5aca736d100973c4ccf66b25550af9c03a79a63..03088ce0a01bd521d8cc1fa579d6ca0b72518bd9 100644 --- a/tdt4140-gr1800/app.core/doc/db-persistence.md +++ b/tdt4140-gr1800/app.core/doc/db-persistence.md @@ -1,5 +1,14 @@ # 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. <img src="db-persistence-classes.png" alt="DB-based persistence" style="width: 800px;"/> diff --git a/tdt4140-gr1800/app.core/doc/json-persistence-classes.png b/tdt4140-gr1800/app.core/doc/json-persistence-classes.png deleted file mode 100644 index 2c258f0ea7777b87780c48a136a07c54757e5068..0000000000000000000000000000000000000000 Binary files a/tdt4140-gr1800/app.core/doc/json-persistence-classes.png and /dev/null differ diff --git a/tdt4140-gr1800/app.core/doc/json-persistence.md b/tdt4140-gr1800/app.core/doc/json-persistence.md index a986df21fafaa379743de05214b9468a3a95cc34..aa087698667d3cc5022340f774bae16bfd6bcee3 100644 --- a/tdt4140-gr1800/app.core/doc/json-persistence.md +++ b/tdt4140-gr1800/app.core/doc/json-persistence.md @@ -1,5 +1,3 @@ # JSON-based persistence of domain data -A class diagram of the main classes related to JSON-based persistence is shown below. - -<img src="json-persistence-classes.png" alt="JSON-based persistence" style="width: 800px;"/> +JSON support is provided by means of the [Jackson library](https://github.com/FasterXML/jackson), and uses its technique for serializing/deserializing domain objects. diff --git a/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/db/IDbAccess.java b/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/db/IDbAccess.java index f95822761946826245501bdc18f8362b291da391..5662635f1ab6a84c5557e97cb446d443c39e1683 100644 --- a/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/db/IDbAccess.java +++ b/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/db/IDbAccess.java @@ -9,32 +9,99 @@ import tdt4140.gr1800.app.core.GeoLocations; import tdt4140.gr1800.app.core.Person; /* - * CRUD interface for our domain: + * class diagram: * * @startuml * class GeoLocationsOwner { - * String id * } + * * class Person { * String name * String email * } + * + * class TimedTaggedImpl { + * LocalDate date + * LocalTime time + * ZoneId zone + * String[] tags + * } + * * GeoLocationsOwner <|-- Person + * + * GeoLocationsOwner *-- GeoLocations: owner + * * class GeoLocations { * String name * String description + * LocalDate date + * LocalTime time + * ZoneId zone + * String[] tags * } - * GeoLocationsOwner *-- GeoLocations: owner + * + * GeoLocations --|> TimedTaggedImpl + * * class GeoLocation { * int elevation * LocalTime time * String name * String description * } + + * GeoLocation --|> TimedTaggedImpl + * * GeoLocations *-- GeoLocation * GeoLocation *-- LatLong * @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 IdProvider<Person> getPersonIdProvider();