From 9e992a8f611358c55809738d94b31c38e2d91a7a Mon Sep 17 00:00:00 2001 From: Claudio Barril Date: Mon, 14 Apr 2014 18:09:34 -0300 Subject: [PATCH] add label icons back-end (model and database) --- config/database/hsql/apopulate-schemas.sql | 6 +++--- config/database/hsql/create-schemas.sql | 3 ++- config/database/mysql/apopulate-schemas.sql | 6 +++--- config/database/mysql/create-schemas.sql | 1 + .../src/main/java/com/wisemapping/model/Label.java | 11 +++++++++++ .../java/com/wisemapping/rest/model/RestLabel.java | 8 ++++++++ .../resources/com/wisemapping/model/Label.hbm.xml | 1 + 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/config/database/hsql/apopulate-schemas.sql b/config/database/hsql/apopulate-schemas.sql index d1cd5912..092acc82 100644 --- a/config/database/hsql/apopulate-schemas.sql +++ b/config/database/hsql/apopulate-schemas.sql @@ -30,7 +30,7 @@ INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_i INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (2, 1, '{zoom:0.8}'); INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (2, 2, 2, 1, 1); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (1, 'test label', 1, NULL, '#ff0000'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (1, 'test label', 1, NULL, '#ff0000', 'glyphicon glyphicon-tag'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (1,1); INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id) @@ -38,9 +38,9 @@ INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (3, 1, '{zoom:0.8}'); INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (3, 2, 3, 2, 0); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (2, 'admin label', 2, NULL, '#0000ff'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (2, 'admin label', 2, NULL, '#0000ff', 'glyphicon glyphicon-star'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (2,2); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00', 'glyphicon glyphicon-share'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (3,1); COMMIT; diff --git a/config/database/hsql/create-schemas.sql b/config/database/hsql/create-schemas.sql index ca5ec213..92322877 100644 --- a/config/database/hsql/create-schemas.sql +++ b/config/database/hsql/create-schemas.sql @@ -37,7 +37,8 @@ CREATE TABLE LABEL ( title VARCHAR(30), creator_id INTEGER NOT NULL, parent_label_id INTEGER, - color VARCHAR(7) NOT NULL + color VARCHAR(7) NOT NULL, + icon VARCHAR(255) NOT NULL --FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id) ); diff --git a/config/database/mysql/apopulate-schemas.sql b/config/database/mysql/apopulate-schemas.sql index aee90b96..076cf61d 100644 --- a/config/database/mysql/apopulate-schemas.sql +++ b/config/database/mysql/apopulate-schemas.sql @@ -34,7 +34,7 @@ INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_i INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (2, 1, '{zoom:0.8}'); INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (2, 2, 2, 1, 1); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (1, 'test label', 1, NULL, '#ff0000'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (1, 'test label', 1, NULL, '#ff0000', 'glyphicon glyphicon-tag'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (1,1); INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition_date, creator_id, tags, last_editor_id) @@ -42,9 +42,9 @@ INSERT INTO MINDMAP (id, title, xml, description, public, creation_date, edition INSERT INTO COLLABORATION_PROPERTIES (id, starred, mindmap_properties) VALUES (3, 1, '{zoom:0.8}'); INSERT INTO COLLABORATION (id, colaborator_id, properties_id, mindmap_id, role_id) VALUES (3, 2, 3, 2, 0); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (2, 'admin label', 2, NULL, '#0000ff'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (2, 'admin label', 2, NULL, '#0000ff', 'glyphicon glyphicon-star'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (2,2); -INSERT INTO LABEL (id, title, creator_id, parent_label_id, color) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00'); +INSERT INTO LABEL (id, title, creator_id, parent_label_id, color, icon) VALUES (3, 'mindmap shared', 2, NULL, '#00ff00', 'glyphicon glyphicon-share'); INSERT INTO R_LABEL_MINDMAP (label_id, mindmap_id) VALUES (3,1); COMMIT; diff --git a/config/database/mysql/create-schemas.sql b/config/database/mysql/create-schemas.sql index bf12dbf1..8aaaf0db 100644 --- a/config/database/mysql/create-schemas.sql +++ b/config/database/mysql/create-schemas.sql @@ -58,6 +58,7 @@ CREATE TABLE LABEL ( creator_id INTEGER NOT NULL, parent_label_id INTEGER, color VARCHAR(7) NOT NULL, + icon VARCHAR(255) NOT NULL, FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id), FOREIGN KEY (parent_label_id) REFERENCES LABEL (id) ON DELETE CASCADE diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Label.java b/wise-webapp/src/main/java/com/wisemapping/model/Label.java index ca8dad6b..654bbaf9 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Label.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Label.java @@ -12,6 +12,7 @@ public class Label { @NotNull private User creator; @Nullable private Label parent; @NotNull private String color; + @NotNull private String icon; public void setParent(@Nullable Label parent) { this.parent = parent; @@ -57,6 +58,15 @@ public class Label { this.color = color; } + @NotNull + public String getIcon() { + return icon; + } + + public void setIcon(@NotNull String icon) { + this.icon = icon; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -76,4 +86,5 @@ public class Label { result = 31 * result + (parent != null ? parent.hashCode() : 0); return result; } + } diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabel.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabel.java index 65bc29bb..14ad2abc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabel.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestLabel.java @@ -65,10 +65,18 @@ public class RestLabel { label.setColor(color); } + public void setIcon(@NotNull final String icon) { + label.setIcon(icon); + } + @Nullable public String getColor() { return label.getColor(); } + @Nullable public String getIcon() { + return label.getIcon(); + } + @JsonIgnore public Label getDelegated() { return label; diff --git a/wise-webapp/src/main/resources/com/wisemapping/model/Label.hbm.xml b/wise-webapp/src/main/resources/com/wisemapping/model/Label.hbm.xml index 11602ec6..b0589623 100644 --- a/wise-webapp/src/main/resources/com/wisemapping/model/Label.hbm.xml +++ b/wise-webapp/src/main/resources/com/wisemapping/model/Label.hbm.xml @@ -11,6 +11,7 @@ +