diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java index 8703719..da47e62 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/ClubEvent.java @@ -9,7 +9,9 @@ import java.util.Set; import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.ManyToMany; +import javax.persistence.OneToOne; import javax.persistence.Transient; import org.vaadin.addon.calendar.item.BasicItem; @@ -29,6 +31,9 @@ public class ClubEvent extends BasicItem implements EntityAccessor { @ManyToMany private Set persons; private Set altersgruppen; + @OneToOne + @JoinColumn(name = "id", nullable = true) + private CompetitionType competitionType; ClubEvent() { } diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/CompetitionType.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/CompetitionType.java new file mode 100644 index 0000000..a39cd69 --- /dev/null +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/CompetitionType.java @@ -0,0 +1,34 @@ +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "clubevent_addon") +public class CompetitionType { + + @Id + private String id; + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Type getType() { + return Type.valueOf(type); + } + + public void setType(Type type) { + this.type = type.name(); + } + + public static enum Type { + EINZEL, SYNCHRON, DOPPELMINI, MANNSCHAFT, LIGA + } +} diff --git a/src/main/resources/schema/version1.sql b/src/main/resources/schema/version1.sql index 39b2ac2..cca51b2 100644 --- a/src/main/resources/schema/version1.sql +++ b/src/main/resources/schema/version1.sql @@ -53,4 +53,13 @@ CREATE TABLE `event_has_altersgruppe` ( ON UPDATE NO ACTION); ALTER TABLE `person` ADD COLUMN `gender` SMALLINT(1) NULL AFTER `birth`; +CREATE TABLE `clubhelper`.`clubevent_addon` ( + `id` VARCHAR(250) NOT NULL, + `competition_type` VARCHAR(45) NOT NULL, + PRIMARY KEY (`id`), + CONSTRAINT `fk_event_addon_id` + FOREIGN KEY (`id`) + REFERENCES `clubhelper`.`clubevent` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION); diff --git a/src/test/resources/truncateTables.sql b/src/test/resources/truncateTables.sql new file mode 100644 index 0000000..c3463cb --- /dev/null +++ b/src/test/resources/truncateTables.sql @@ -0,0 +1,21 @@ +SET FOREIGN_KEY_CHECKS=0; + +TRUNCATE TABLE clubevent_addon; +TRUNCATE TABLE event_has_altersgruppe; +TRUNCATE TABLE altersgruppe; +TRUNCATE TABLE pflichten; +TRUNCATE TABLE clubevent_has_person; +TRUNCATE TABLE ClubEvent; +TRUNCATE TABLE persongroup; +TRUNCATE TABLE startpass_startrechte; +TRUNCATE TABLE deleted_entries; +TRUNCATE TABLE clubevent; +TRUNCATE TABLE relative; +TRUNCATE TABLE groupdef; +TRUNCATE TABLE startpaesse; +TRUNCATE TABLE contact; +TRUNCATE TABLE adress; +TRUNCATE TABLE attendance; +TRUNCATE TABLE person; + +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file