Major restructure
This commit is contained in:
parent
a35d259fd8
commit
9d0efb2a68
6 changed files with 117 additions and 95 deletions
|
@ -46,53 +46,52 @@ public class Model {
|
|||
* Füllt das Model mit Beispieldaten.
|
||||
*/
|
||||
public void fillMockData() {
|
||||
Group g1, g2, g3;
|
||||
|
||||
// Studierende
|
||||
this.add(new Student("students/jotto5", "Jocelyn", "Otto"));
|
||||
this.add(new Student("students/vnachn", "Vorname", "Nachname"));
|
||||
this.add(new Student("students/alovel", "Ada", "Lovelace"));
|
||||
this.add(new Student("students/aturin", "Alan", "Turing"));
|
||||
this.add(new Student("students/dknuth", "Donald", "Knuth"));
|
||||
this.add(new Student("students/ltorva", "Linus", "Torvalds"));
|
||||
this.add(new Student("students/dritch", "Dennis", "Ritchie"));
|
||||
this.add(new Student("students/jotto5", "Jocelyn", "Otto", "0001"));
|
||||
this.add(new Student("students/vnachn", "Vorname", "Nachname", "0002"));
|
||||
this.add(new Student("students/alovel", "Ada", "Lovelace", "0003"));
|
||||
this.add(new Student("students/aturin", "Alan", "Turing", "0004"));
|
||||
this.add(new Student("students/dknuth", "Donald", "Knuth", "0005"));
|
||||
this.add(new Student("students/ltorva", "Linus", "Torvalds", "0006"));
|
||||
this.add(new Student("students/dritch", "Dennis", "Ritchie", "0007"));
|
||||
|
||||
// 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");
|
||||
this.add(new Group("groups/IF24wS2-B", "Softwareentwicklung WiSe 24/25 Seminargruppe 2"));
|
||||
this.add(new Group("groups/admins", "Administrator:innen"));
|
||||
this.add(new Group("groups/alumni", "Alumni"));
|
||||
this.add(new Group("groups/leer", "Leere Gruppe"));
|
||||
this.add(g1);
|
||||
this.add(g2);
|
||||
this.add(g3);
|
||||
g1.addMember("students/jotto5");
|
||||
g2.addMember("students/vnachn");
|
||||
g2.addMember("students/ltorva");
|
||||
g3.addMember("students/alovel");
|
||||
g3.addMember("students/aturin");
|
||||
g3.addMember("students/ltorva");
|
||||
|
||||
this.addRelation("groups/if24ws2-b", "students/jotto5");
|
||||
this.addRelation("groups/admins", "students/vnachn");
|
||||
this.addRelation("groups/admins", "students/ltorva");
|
||||
this.addRelation("groups/alumni", "students/alovel");
|
||||
this.addRelation("groups/alumni", "students/aturin");
|
||||
this.addRelation("groups/alumni", "students/ltorva");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt ein neues DataObject hinzu, also bindet es an das Model.
|
||||
* Fügt ein neues DataObject hinzu.
|
||||
*/
|
||||
public void add(DataObject a) {
|
||||
// TODO: Auf doppelte UIDs überprüfen!
|
||||
this.objs.put(a.uid, a);
|
||||
a.setModel(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Folgende Funktionen sind nur durch die DataObject-Objekte
|
||||
* zu verwenden, und sind daher protected.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fügt eine neue Objekt-Beziehung hinzu.
|
||||
*/
|
||||
protected void addRelation(String a, String b) {
|
||||
public void addRelation(String a, String b) {
|
||||
// TODO: Prüfen ob die Objekte existieren!
|
||||
this.relations.put(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das DataObject mit der angegebenen UID zurück
|
||||
* oder null wenn es keines gibt.
|
||||
*/
|
||||
public DataObject get(String path) {
|
||||
if ( !objs.containsKey(path) ) return null;
|
||||
return objs.get(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue