diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index eac9f6c6..b273e6c5 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -31,6 +31,7 @@ 5.3.14 5.3.5.RELEASE 5.6.3.Final + 6.0.21.Final @@ -93,7 +94,7 @@ org.hibernate.validator hibernate-validator - 6.0.21.Final + ${hibernate-validator.version} org.springframework @@ -193,14 +194,13 @@ mysql mysql-connector-java - 8.0.22 + 8.0.27 runtime - commons-dbcp - commons-dbcp - 1.4 - runtime + org.apache.commons + commons-dbcp2 + 2.9.0 commons-fileupload @@ -208,6 +208,21 @@ 1.2.1 runtime + + org.hibernate + hibernate-ehcache + ${hibernate.version} + + + javax.cache + cache-api + 1.0.0 + + + org.ehcache + ehcache + 3.9.9 + log4j log4j @@ -218,7 +233,7 @@ org.hsqldb hsqldb - 2.5.1 + 2.6.1 runtime @@ -282,7 +297,7 @@ org.hsqldb hsqldb - 2.2.8 + 2.6.1 @@ -357,6 +372,27 @@ + + org.hibernate.orm.tooling + hibernate-enhance-maven-plugin + ${hibernate.version} + + + compile + + true + true + true + true + false + false + + + enhance + + + + org.codehaus.mojo native2ascii-maven-plugin diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java index e6b3bb9f..6483af7f 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManager.java @@ -29,9 +29,9 @@ public interface MindmapManager { Collaborator findCollaborator(@NotNull String email); - Collaborator findCollaborator(long id); + Collaborator findCollaborator(int id); - List findCollaboration(final long collaboratorId); + List findCollaboration(final int collaboratorId); List findCollaboration(final CollaborationRole userRole); @@ -46,15 +46,15 @@ public interface MindmapManager { void addCollaborator(Collaborator collaborator); - void addMindmap(User user, Mindmap mindMap); + void addMindmap(User user, Mindmap mindmap); - void saveMindmap(Mindmap mindMap); + void saveMindmap(Mindmap mindmap); - void updateMindmap(@NotNull Mindmap mindMap, boolean saveHistory); + void updateMindmap(@NotNull Mindmap mindmap, boolean saveHistory); void removeCollaborator(@NotNull Collaborator collaborator); - void removeMindmap(Mindmap mindap); + void removeMindmap(Mindmap mindmap); void removeCollaboration(Collaboration collaboration); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java index 1d0de164..d9a17c8b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/MindmapManagerImpl.java @@ -150,12 +150,12 @@ public class MindmapManagerImpl } @Override - public Collaborator findCollaborator(long id) { + public Collaborator findCollaborator(int id) { return getHibernateTemplate().get(Collaborator.class, id); } @Override - public List findCollaboration(final long collaboratorId) { + public List findCollaboration(final int collaboratorId) { Query query = currentSession().createQuery("from com.wisemapping.model.Collaboration collaboration where colaborator_id=:colaboratorId"); query.setParameter("colaboratorId", collaboratorId); return query.list(); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java index 1dac8d62..cd351ff5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManager.java @@ -31,7 +31,7 @@ public interface UserManager { User getUserBy(String email); - User getUserBy(long id); + User getUserBy(int id); void createUser(User user); diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index dbc4a369..1729aea8 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -83,7 +83,8 @@ public class UserManagerImpl } @Nullable - public User getUserBy(long id) { + @Override + public User getUserBy(int id) { User user = null; try { user = getHibernateTemplate().get(User.class, id); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java b/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java index 40073401..7df24301 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/AccessAuditory.java @@ -1,33 +1,43 @@ /* -* Copyright [2015] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright [2015] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.wisemapping.model; import org.jetbrains.annotations.NotNull; +import javax.persistence.*; import java.io.Serializable; import java.util.Calendar; +@Entity +@Table(name = "ACCESS_AUDITORY") public class AccessAuditory implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + + @Column(name = "login_Date") private Calendar loginDate = null; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = true) private User user = null; public AccessAuditory() { diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 723cdad4..f33c9a95 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -18,15 +18,33 @@ package com.wisemapping.model; -import org.jetbrains.annotations.NotNull; -public class Collaboration { +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.io.Serializable; - private long id; +@Entity +@Table(name = "COLLABORATION") +public class Collaboration implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id;; + + @Column(name = "role_id",unique = true,nullable = true) private CollaborationRole role; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="mindmap_id",nullable = false) private Mindmap mindMap; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="colaborator_id",nullable = false) private Collaborator collaborator; - private CollaborationProperties collaborationProperties; + + @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL) + @JoinColumn(name="properties_id",nullable = false, unique = true) + private CollaborationProperties collaborationProperties = new CollaborationProperties();; public Collaboration() { } @@ -41,11 +59,11 @@ public class Collaboration { collaborator.addCollaboration(this); } - public long getId() { + public int getId() { return id; } - public void setId(long id) { + public void setId(int id) { this.id = id; } @@ -84,12 +102,7 @@ public class Collaboration { @NotNull public CollaborationProperties getCollaborationProperties() { - CollaborationProperties result = collaborationProperties; - if (result == null) { - collaborationProperties = new CollaborationProperties(); - result = collaborationProperties; - } - return result; + return this.collaborationProperties; } public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { diff --git a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java index 94c2da8b..a71c58eb 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/CollaborationProperties.java @@ -20,10 +20,19 @@ package com.wisemapping.model; import org.jetbrains.annotations.NotNull; -public class CollaborationProperties { +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "COLLABORATION_PROPERTIES") +public class CollaborationProperties implements Serializable { public static final String DEFAULT_JSON_PROPERTIES = "{zoom:0.8}"; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + private boolean starred; + @Column(name = "mindmap_properties") private String mindmapProperties; public CollaborationProperties() { diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java index 6defdfca..de3a28f6 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaborator.java @@ -18,20 +18,33 @@ package com.wisemapping.model; +import org.hibernate.annotations.CacheConcurrencyStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.persistence.*; import java.io.Serializable; import java.util.Calendar; import java.util.HashSet; import java.util.Set; +@Entity +@Table(name = "COLLABORATOR") +@Inheritance(strategy = InheritanceType.JOINED) +@Cacheable +@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Collaborator implements Serializable { - private long id; + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + private int id; private String email; + + @Column(name = "creation_date") private Calendar creationDate; - private Set collaborations = new HashSet(); + + @OneToMany(mappedBy="collaborator") + private Set collaborations = new HashSet<>(); public Collaborator() { } @@ -52,11 +65,11 @@ public class Collaborator implements Serializable { return collaborations; } - public long getId() { + public int getId() { return id; } - public void setId(long id) { + public void setId(int id) { this.id = id; } @@ -89,7 +102,7 @@ public class Collaborator implements Serializable { @Override public int hashCode() { - long id = this.getId(); + int id = this.getId(); String email = this.getEmail(); int result = (int) (id ^ (id >>> 32)); 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 a2319771..28198bdc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Label.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Label.java @@ -4,16 +4,28 @@ package com.wisemapping.model; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class Label { +import javax.persistence.*; +import java.io.Serializable; - //~ Instance fields ...................................................................................... +@Entity +@Table(name = "LABEL") +public class Label implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + @NotNull private String title; - @NotNull private User creator; - @Nullable private Label parent; @NotNull private String color; @NotNull private String iconName; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="creator_id",nullable = true,unique = true) + @NotNull private User creator; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name="parent_label_id",nullable = true) + @Nullable private Label parent; + public void setParent(@Nullable Label parent) { this.parent = parent; } @@ -80,11 +92,11 @@ public class Label { @Override public int hashCode() { - int result = id; + long result = id; result = 31 * result + title.hashCode(); result = 31 * result + creator.hashCode(); result = 31 * result + (parent != null ? parent.hashCode() : 0); - return result; + return (int) result; } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java index fca391ba..3b218764 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMapHistory.java @@ -22,15 +22,28 @@ import com.wisemapping.util.ZipUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.persistence.*; import java.io.IOException; import java.util.Calendar; +@Entity +@Table(name = "MINDMAP_HISTORY") public class MindMapHistory { - + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + + @Column(name = "creation_date") private Calendar creationTime; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "editor_id", nullable = true,unique = false) private User editor; + + @Column(name = "xml") private byte[] zippedXml; + + @Column(name = "mindmap_id") private int mindmapId; public MindMapHistory() { diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java index c70c5807..8aa1cbf1 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java @@ -1,20 +1,20 @@ /* -* Copyright [2015] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright [2015] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.wisemapping.model; @@ -25,29 +25,55 @@ import org.apache.commons.lang.StringEscapeUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.persistence.*; import java.io.IOException; +import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.*; -public class Mindmap { - private static final String UTF_8 = "UTF-8"; +@Entity +@Table(name = "MINDMAP") +public class Mindmap implements Serializable { - //~ Instance fields ...................................................................................... + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + + @Column(name = "creation_date") private Calendar creationTime; - private String description; - private boolean isPublic; + @Column(name = "edition_date") private Calendar lastModificationTime; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "creator_id", unique = true, nullable = true) + private User creator; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "last_editor_id", unique = false, nullable = false) private User lastEditor; - private Set collaborations = new HashSet(); + private String description; + + @Column(name = "public") + private boolean isPublic; + + @OneToMany(mappedBy="mindMap",orphanRemoval = true, cascade = {CascadeType.ALL},fetch = FetchType.LAZY) + private Set collaborations = new HashSet<>(); + + @ManyToMany + @JoinTable( + name = "R_LABEL_MINDMAP", + joinColumns = @JoinColumn(name = "mindmap_id"), + inverseJoinColumns = @JoinColumn(name = "label_id")) private Set