From 3921fe13308f54b61f22cd81f032766120e2d1b6 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Fri, 17 Apr 2020 14:58:26 +0200 Subject: [PATCH] started invitation relationship --- .../sanmarinoes/smarthut/models/Invited.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java new file mode 100644 index 0000000..d56a55b --- /dev/null +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java @@ -0,0 +1,38 @@ +package ch.usi.inf.sa4.sanmarinoes.smarthut.models; + +import java.util.Set; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.validation.constraints.NotNull; + +/** Represents a recursive invitation relationship between two users. */ +@Entity +public class Invited { + + /** A host user who can invite guests to their smart house */ + @OneToMany private Set host; + + /** Guests that have been invited to the host's house */ + @OneToMany(mappedBy = "host", orphanRemoval = true) + private Set guest; + + /** Host ID */ + @Id + @Column(nullable = false) + private int hostId; + + /** + * Probably unnecessary, Invited can be identified through the Host ID and the IDs from the + * guests collection which we can query for + */ + // @Id @Column + // private int guestId; + + /** Determines whether a guest can access security cameras */ + @Column @NotNull private boolean cameraEnabled; + + /** Determines whether a guest can access scenes */ + @Column @NotNull private boolean sceneEnabled; +}