Added even more stuff
This commit is contained in:
parent
29d3ec8268
commit
d6e88977ba
7 changed files with 102 additions and 21 deletions
|
@ -14,7 +14,8 @@ import java.util.HashMap;
|
|||
* Datenbank.
|
||||
* <p>
|
||||
* Die aktuelle Implementierung speichert alle DataObjects in einer HashMap, mit ihrer
|
||||
* UID als Key.
|
||||
* UID als Key. Das erlaubt schnelle forward-lookups (also Suche nach Obj mit gegebener UID),
|
||||
* was die deutlich häufiger ausgeführte Operation sein sollte.
|
||||
*/
|
||||
public class Model {
|
||||
|
||||
|
@ -29,12 +30,53 @@ public class Model {
|
|||
relations = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public void add(DataObject a) {
|
||||
/**
|
||||
* Füllt das Model mit Beispieldaten.
|
||||
*/
|
||||
public void fillMockData() {
|
||||
Group g1, g2, g3;
|
||||
|
||||
// Studierende
|
||||
new Student("students/jotto5", "Jocelyn", "Otto").bind(this);
|
||||
new Student("students/vnachn", "Vorname", "Nachname").bind(this);
|
||||
new Student("students/alovel", "Ada", "Lovelace").bind(this);
|
||||
new Student("students/aturin", "Alan", "Turing").bind(this);
|
||||
new Student("students/dknuth", "Donald", "Knuth").bind(this);
|
||||
new Student("students/ltorva", "Linus", "Torvalds").bind(this);
|
||||
new Student("students/dritch", "Dennis", "Ritchie").bind(this);
|
||||
|
||||
// Gruppen
|
||||
g1 = new Group("groups/IF24wS2-B", "Softwareentwicklung WiSe 24/25 Seminargruppe 2");
|
||||
g2 = new Group("groups/admins", "Administrator:innen");
|
||||
g3 = new Group("groups/alumni", "Alumni");
|
||||
new Group("groups/leer").bind(this);
|
||||
g1.bind(this);
|
||||
g2.bind(this);
|
||||
g3.bind(this);
|
||||
g1.addMember("students/jotto5");
|
||||
g2.addMember("students/vnachn");
|
||||
g2.addMember("students/ltorva");
|
||||
g3.addMember("alovel");
|
||||
g3.addMember("aturin");
|
||||
}
|
||||
|
||||
/*
|
||||
* Folgende Funktionen sind nur durch die DataObject-Objekte
|
||||
* zu verwenden, und sind daher protected.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fügt ein neues DataObject hinzu, also bindet es an das Model.
|
||||
*/
|
||||
protected void add(DataObject a) {
|
||||
// TODO: Auf doppelte UIDs überprüfen!
|
||||
this.objs.put(a.uid, a);
|
||||
}
|
||||
|
||||
public void addRelation(String a, String b) {
|
||||
/**
|
||||
* Fügt eine neue Objekt-Beziehung hinzu.
|
||||
*/
|
||||
protected 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