changed more stuff
This commit is contained in:
parent
cd9a49a19a
commit
29d3ec8268
8 changed files with 146 additions and 79 deletions
42
src/data/Model.java
Normal file
42
src/data/Model.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package hsmw.jotto5.beleg.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Das Model der Anwendung.
|
||||
*
|
||||
* Stellt einfache Abfragen bereit und verwaltet die Anbindung an ein Speicher-Backend.
|
||||
* Zugriff auf Daten ist Thread-sicher. Um ständiges Zusammenbauen von Objekten
|
||||
* zu vermeiden und um besser vom eigentlichen Backend zu abstrahieren sind viele
|
||||
* einfache Abfragen als Methode umgesetzt.
|
||||
* <p>
|
||||
* Denkbar ist zum Beispiel eine Implementation auf LDAP-Basis, oder in einer relationalen
|
||||
* Datenbank.
|
||||
* <p>
|
||||
* Die aktuelle Implementierung speichert alle DataObjects in einer HashMap, mit ihrer
|
||||
* UID als Key.
|
||||
*/
|
||||
public class Model {
|
||||
|
||||
private HashMap<String, DataObject> objs;
|
||||
private HashMap<String, String> relations;
|
||||
|
||||
/**
|
||||
* Initialisiert ein leeres Model.
|
||||
*/
|
||||
public Model() {
|
||||
objs = new HashMap<String, DataObject>();
|
||||
relations = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public void add(DataObject a) {
|
||||
// TODO: Auf doppelte UIDs überprüfen!
|
||||
this.objs.put(a.uid, a);
|
||||
}
|
||||
|
||||
public void addRelation(String a, String b) {
|
||||
// TODO: Prüfen ob die Objekte existieren!
|
||||
this.relations.put(a, b);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue