Commit d1976590 by Tuukka Kivilahti Committed by Tuukka Kivilahti

database, first version

1 parent 8557d61a
......@@ -80,7 +80,6 @@ public class BootstrapBean implements BootstrapBeanLocal {
"alter table compos add hidden boolean default false not null"
});
dbUpdates.add(alterTables("ADD COLUMN meta json",
"account_events",
"actionlog_message_responses",
......@@ -152,6 +151,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
"user_notes",
"users"));
dbUpdates.add(new String[]{"CREATE TABLE network_associations (id SERIAL NOT NULL, create_time TIMESTAMPTZ NOT NULL, ip TEXT, mac TEXT, meta TEXT, modify_time TIMESTAMPTZ NOT NULL, status TEXT NOT NULL, event INTEGER, event_user INTEGER, place INTEGER, PRIMARY KEY (id))"});
dbUpdates.add(new String[] {
......@@ -189,6 +189,17 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] {
"ALTER TABLE network_associations ALTER COLUMN meta TYPE json USING (meta::json);"
});
dbUpdates.add(new String[] {"CREATE TABLE lecture_groups (id SERIAL NOT NULL, description TEXT, name TEXT, select_count INTEGER, PRIMARY KEY (id))",
"CREATE TABLE lectures (id SERIAL NOT NULL, description TEXT, end_time TIMESTAMPTZ, max_participants_count INTEGER, name TEXT, start_time TIMESTAMPTZ, lecture_group_id INTEGER, PRIMARY KEY (id))",
"CREATE TABLE lecture_roles (role_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (role_id, lecture_id))",
"CREATE TABLE lecture_participants (eventuser_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (eventuser_id, lecture_id))",
"ALTER TABLE lectures ADD CONSTRAINT FK_lectures_lecture_group_id FOREIGN KEY (lecture_group_id) REFERENCES lecture_groups (id)",
"ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)",
"ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)",
"ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_eventuser_id FOREIGN KEY (eventuser_id) REFERENCES event_users (id)",
"ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)"});
}
@EJB
......
......@@ -103,6 +103,10 @@ public class EventUser extends GenericEntity {
@OneToMany(mappedBy = "eventUser")
private List<GameID> gameIDs;
@ManyToMany(mappedBy = "participants")
private List<Lecture> lectures = new ArrayList<Lecture>();
public List<GameID> getGameIDs() {
return gameIDs;
......@@ -467,4 +471,12 @@ public class EventUser extends GenericEntity {
}
accountEvents.add(accountevent);
}
public List<Lecture> getLectures() {
return lectures;
}
public void setLectures(List<Lecture> lectures) {
this.lectures = lectures;
}
}
......@@ -79,6 +79,11 @@ public class Role extends GenericEntity {
joinColumns = { @JoinColumn(name = "role_id", referencedColumnName = Role.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "org_role_id", referencedColumnName = OrgRole.ID_COLUMN) })
private List<OrgRole> orgRoles;
@ManyToMany(mappedBy = "openForRoles")
private List<Lecture> lectures = new ArrayList<Lecture>();
public Role() {
super();
......@@ -203,4 +208,12 @@ public class Role extends GenericEntity {
this.orgRoles = orgRoles;
}
public List<Lecture> getLectures() {
return lectures;
}
public void setLectures(List<Lecture> lectures) {
this.lectures = lectures;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!