Merge branch '70-scene-has-not-a-customizable-icon' into 'dev'
Resolve "scene has not a customizable icon" Closes #70 See merge request sa4-2020/the-sanmarinoes/backend!110
This commit is contained in:
commit
297fe5f9b3
7 changed files with 135 additions and 107 deletions
|
@ -75,7 +75,7 @@ public class RoomController {
|
||||||
final String username = principal.getName();
|
final String username = principal.getName();
|
||||||
final Long userId = userRepository.findByUsername(username).getId();
|
final Long userId = userRepository.findByUsername(username).getId();
|
||||||
final String img = r.getImage();
|
final String img = r.getImage();
|
||||||
final Room.Icon icon = r.getIcon();
|
final Icon icon = r.getIcon();
|
||||||
|
|
||||||
final Room newRoom = new Room();
|
final Room newRoom = new Room();
|
||||||
newRoom.setUserId(userId);
|
newRoom.setUserId(userId);
|
||||||
|
@ -95,7 +95,7 @@ public class RoomController {
|
||||||
.findByIdAndUsername(id, principal.getName())
|
.findByIdAndUsername(id, principal.getName())
|
||||||
.orElseThrow(NotFoundException::new);
|
.orElseThrow(NotFoundException::new);
|
||||||
final String img = r.getImage();
|
final String img = r.getImage();
|
||||||
final Room.Icon icon = r.getIcon();
|
final Icon icon = r.getIcon();
|
||||||
|
|
||||||
if (r.getName() != null) {
|
if (r.getName() != null) {
|
||||||
newRoom.setName(r.getName());
|
newRoom.setName(r.getName());
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class SceneController {
|
||||||
newScene.setUserId(userId);
|
newScene.setUserId(userId);
|
||||||
newScene.setName(s.getName());
|
newScene.setName(s.getName());
|
||||||
newScene.setGuestAccessEnabled(s.isGuestAccessEnabled());
|
newScene.setGuestAccessEnabled(s.isGuestAccessEnabled());
|
||||||
|
newScene.setIcon(s.getIcon());
|
||||||
|
|
||||||
return sceneRepository.save(newScene);
|
return sceneRepository.save(newScene);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +85,8 @@ public class SceneController {
|
||||||
newScene.setName(s.getName());
|
newScene.setName(s.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newScene.setIcon(s.getIcon());
|
||||||
|
|
||||||
newScene.setGuestAccessEnabled(s.isGuestAccessEnabled());
|
newScene.setGuestAccessEnabled(s.isGuestAccessEnabled());
|
||||||
|
|
||||||
return sceneRepository.save(newScene);
|
return sceneRepository.save(newScene);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.dto;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.dto;
|
||||||
|
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Room;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Icon;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public class RoomSaveRequest {
|
||||||
/** Room identifier */
|
/** Room identifier */
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@NotNull private Room.Icon icon;
|
@NotNull private Icon icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image is to be given as byte[]. In order to get an encoded string from it, the
|
* Image is to be given as byte[]. In order to get an encoded string from it, the
|
||||||
|
@ -38,11 +38,11 @@ public class RoomSaveRequest {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room.Icon getIcon() {
|
public Icon getIcon() {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIcon(Room.Icon icon) {
|
public void setIcon(Icon icon) {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.dto;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.dto;
|
||||||
|
|
||||||
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Icon;
|
||||||
import com.sun.istack.NotNull;
|
import com.sun.istack.NotNull;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
|
||||||
|
@ -11,6 +12,8 @@ public class SceneSaveRequest {
|
||||||
/** The user given name of this room (e.g. 'Master bedroom') */
|
/** The user given name of this room (e.g. 'Master bedroom') */
|
||||||
@NotNull private String name;
|
@NotNull private String name;
|
||||||
|
|
||||||
|
@NotNull private Icon icon;
|
||||||
|
|
||||||
/** Determines whether a guest can access this scene */
|
/** Determines whether a guest can access this scene */
|
||||||
@Column @NotNull private boolean guestAccessEnabled;
|
@Column @NotNull private boolean guestAccessEnabled;
|
||||||
|
|
||||||
|
@ -33,4 +36,12 @@ public class SceneSaveRequest {
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Icon getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(Icon icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/** A collection of Semantic UI icons */
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public enum Icon {
|
||||||
|
@SerializedName("home")
|
||||||
|
HOME("home"),
|
||||||
|
@SerializedName("coffee")
|
||||||
|
COFFEE("coffee"),
|
||||||
|
@SerializedName("beer")
|
||||||
|
BEER("beer"),
|
||||||
|
@SerializedName("glass martini")
|
||||||
|
GLASS_MARTINI("glass martini"),
|
||||||
|
@SerializedName("film")
|
||||||
|
FILM("film"),
|
||||||
|
@SerializedName("video")
|
||||||
|
VIDEO("video"),
|
||||||
|
@SerializedName("music")
|
||||||
|
MUSIC("music"),
|
||||||
|
@SerializedName("headphones")
|
||||||
|
HEADPHONES("headphones"),
|
||||||
|
@SerializedName("fax")
|
||||||
|
FAX("fax"),
|
||||||
|
@SerializedName("phone")
|
||||||
|
PHONE("phone"),
|
||||||
|
@SerializedName("laptop")
|
||||||
|
LAPTOP("laptop"),
|
||||||
|
@SerializedName("bath")
|
||||||
|
BATH("bath"),
|
||||||
|
@SerializedName("shower")
|
||||||
|
SHOWER("shower"),
|
||||||
|
@SerializedName("bed")
|
||||||
|
BED("bed"),
|
||||||
|
@SerializedName("child")
|
||||||
|
CHILD("child"),
|
||||||
|
@SerializedName("warehouse")
|
||||||
|
WAREHOUSE("warehouse"),
|
||||||
|
@SerializedName("car")
|
||||||
|
CAR("car"),
|
||||||
|
@SerializedName("bicycle")
|
||||||
|
BICYCLE("bicycle"),
|
||||||
|
@SerializedName("motorcycle")
|
||||||
|
MOTORCYCLE("motorcycle"),
|
||||||
|
@SerializedName("archive")
|
||||||
|
ARCHIVE("archive"),
|
||||||
|
@SerializedName("boxes")
|
||||||
|
BOXES("boxes"),
|
||||||
|
@SerializedName("cubes")
|
||||||
|
CUBES("cubes"),
|
||||||
|
@SerializedName("chess")
|
||||||
|
CHESS("chess"),
|
||||||
|
@SerializedName("gamepad")
|
||||||
|
GAMEPAD("gamepad"),
|
||||||
|
@SerializedName("futbol")
|
||||||
|
FUTBOL("futbol"),
|
||||||
|
@SerializedName("table tennis")
|
||||||
|
TABLE_TENNIS("table tennis"),
|
||||||
|
@SerializedName("server")
|
||||||
|
SERVER("server"),
|
||||||
|
@SerializedName("tv")
|
||||||
|
TV("tv"),
|
||||||
|
@SerializedName("heart")
|
||||||
|
HEART("heart"),
|
||||||
|
@SerializedName("camera")
|
||||||
|
CAMERA("camera"),
|
||||||
|
@SerializedName("trophy")
|
||||||
|
TROPHY("trophy"),
|
||||||
|
@SerializedName("wrench")
|
||||||
|
WRENCH("wrench"),
|
||||||
|
@SerializedName("image")
|
||||||
|
IMAGE("image"),
|
||||||
|
@SerializedName("book")
|
||||||
|
BOOK("book"),
|
||||||
|
@SerializedName("university")
|
||||||
|
UNIVERSITY("university"),
|
||||||
|
@SerializedName("medkit")
|
||||||
|
MEDKIT("medkit"),
|
||||||
|
@SerializedName("paw")
|
||||||
|
PAW("paw"),
|
||||||
|
@SerializedName("tree")
|
||||||
|
TREE("tree"),
|
||||||
|
@SerializedName("utensils")
|
||||||
|
UTENSILS("utensils"),
|
||||||
|
@SerializedName("male")
|
||||||
|
MALE("male"),
|
||||||
|
@SerializedName("female")
|
||||||
|
FEMALE("female"),
|
||||||
|
@SerializedName("life ring outline")
|
||||||
|
LIFE_RING_OUTLINE("life ring outline");
|
||||||
|
|
||||||
|
private String iconName;
|
||||||
|
|
||||||
|
Icon(String s) {
|
||||||
|
this.iconName = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return iconName;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -12,106 +11,6 @@ import javax.validation.constraints.NotNull;
|
||||||
@Entity
|
@Entity
|
||||||
public class Room {
|
public class Room {
|
||||||
|
|
||||||
/** A collection of Semantic UI icons */
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public enum Icon {
|
|
||||||
@SerializedName("home")
|
|
||||||
HOME("home"),
|
|
||||||
@SerializedName("coffee")
|
|
||||||
COFFEE("coffee"),
|
|
||||||
@SerializedName("beer")
|
|
||||||
BEER("beer"),
|
|
||||||
@SerializedName("glass martini")
|
|
||||||
GLASS_MARTINI("glass martini"),
|
|
||||||
@SerializedName("film")
|
|
||||||
FILM("film"),
|
|
||||||
@SerializedName("video")
|
|
||||||
VIDEO("video"),
|
|
||||||
@SerializedName("music")
|
|
||||||
MUSIC("music"),
|
|
||||||
@SerializedName("headphones")
|
|
||||||
HEADPHONES("headphones"),
|
|
||||||
@SerializedName("fax")
|
|
||||||
FAX("fax"),
|
|
||||||
@SerializedName("phone")
|
|
||||||
PHONE("phone"),
|
|
||||||
@SerializedName("laptop")
|
|
||||||
LAPTOP("laptop"),
|
|
||||||
@SerializedName("bath")
|
|
||||||
BATH("bath"),
|
|
||||||
@SerializedName("shower")
|
|
||||||
SHOWER("shower"),
|
|
||||||
@SerializedName("bed")
|
|
||||||
BED("bed"),
|
|
||||||
@SerializedName("child")
|
|
||||||
CHILD("child"),
|
|
||||||
@SerializedName("warehouse")
|
|
||||||
WAREHOUSE("warehouse"),
|
|
||||||
@SerializedName("car")
|
|
||||||
CAR("car"),
|
|
||||||
@SerializedName("bicycle")
|
|
||||||
BICYCLE("bicycle"),
|
|
||||||
@SerializedName("motorcycle")
|
|
||||||
MOTORCYCLE("motorcycle"),
|
|
||||||
@SerializedName("archive")
|
|
||||||
ARCHIVE("archive"),
|
|
||||||
@SerializedName("boxes")
|
|
||||||
BOXES("boxes"),
|
|
||||||
@SerializedName("cubes")
|
|
||||||
CUBES("cubes"),
|
|
||||||
@SerializedName("chess")
|
|
||||||
CHESS("chess"),
|
|
||||||
@SerializedName("gamepad")
|
|
||||||
GAMEPAD("gamepad"),
|
|
||||||
@SerializedName("futbol")
|
|
||||||
FUTBOL("futbol"),
|
|
||||||
@SerializedName("table tennis")
|
|
||||||
TABLE_TENNIS("table tennis"),
|
|
||||||
@SerializedName("server")
|
|
||||||
SERVER("server"),
|
|
||||||
@SerializedName("tv")
|
|
||||||
TV("tv"),
|
|
||||||
@SerializedName("heart")
|
|
||||||
HEART("heart"),
|
|
||||||
@SerializedName("camera")
|
|
||||||
CAMERA("camera"),
|
|
||||||
@SerializedName("trophy")
|
|
||||||
TROPHY("trophy"),
|
|
||||||
@SerializedName("wrench")
|
|
||||||
WRENCH("wrench"),
|
|
||||||
@SerializedName("image")
|
|
||||||
IMAGE("image"),
|
|
||||||
@SerializedName("book")
|
|
||||||
BOOK("book"),
|
|
||||||
@SerializedName("university")
|
|
||||||
UNIVERSITY("university"),
|
|
||||||
@SerializedName("medkit")
|
|
||||||
MEDKIT("medkit"),
|
|
||||||
@SerializedName("paw")
|
|
||||||
PAW("paw"),
|
|
||||||
@SerializedName("tree")
|
|
||||||
TREE("tree"),
|
|
||||||
@SerializedName("utensils")
|
|
||||||
UTENSILS("utensils"),
|
|
||||||
@SerializedName("male")
|
|
||||||
MALE("male"),
|
|
||||||
@SerializedName("female")
|
|
||||||
FEMALE("female"),
|
|
||||||
@SerializedName("life ring outline")
|
|
||||||
LIFE_RING_OUTLINE("life ring outline");
|
|
||||||
|
|
||||||
private String iconName;
|
|
||||||
|
|
||||||
Icon(String s) {
|
|
||||||
this.iconName = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return iconName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@Column(name = "id", updatable = false, nullable = false, unique = true)
|
@Column(name = "id", updatable = false, nullable = false, unique = true)
|
||||||
|
|
|
@ -39,9 +39,21 @@ public class Scene {
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@NotNull
|
||||||
|
private Icon icon;
|
||||||
|
|
||||||
/** Determines whether a guest can access this scene */
|
/** Determines whether a guest can access this scene */
|
||||||
@Column private boolean guestAccessEnabled;
|
@Column private boolean guestAccessEnabled;
|
||||||
|
|
||||||
|
public Icon getIcon() {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(Icon icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isGuestAccessEnabled() {
|
public boolean isGuestAccessEnabled() {
|
||||||
return guestAccessEnabled;
|
return guestAccessEnabled;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue