Migrate hibernate xml annotation to annotations
This commit is contained in:
@@ -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() {
|
||||
|
@@ -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) {
|
||||
|
@@ -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() {
|
||||
|
@@ -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<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
|
||||
@OneToMany(mappedBy="collaborator")
|
||||
private Set<Collaboration> 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));
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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() {
|
||||
|
@@ -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<Collaboration> collaborations = new HashSet<Collaboration>();
|
||||
private String description;
|
||||
|
||||
@Column(name = "public")
|
||||
private boolean isPublic;
|
||||
|
||||
@OneToMany(mappedBy="mindMap",orphanRemoval = true, cascade = {CascadeType.ALL},fetch = FetchType.LAZY)
|
||||
private Set<Collaboration> collaborations = new HashSet<>();
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(
|
||||
name = "R_LABEL_MINDMAP",
|
||||
joinColumns = @JoinColumn(name = "mindmap_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "label_id"))
|
||||
private Set<Label> labels = new LinkedHashSet<>();
|
||||
|
||||
private User creator;
|
||||
private String tags;
|
||||
private String title;
|
||||
|
||||
@Column(name = "xml")
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
private byte[] zippedXml;
|
||||
|
||||
//~ Constructors .........................................................................................
|
||||
@@ -114,7 +140,8 @@ public class Mindmap {
|
||||
collaborations.add(collaboration);
|
||||
}
|
||||
|
||||
@NotNull public Set<Label> getLabels() {
|
||||
@NotNull
|
||||
public Set<Label> getLabels() {
|
||||
return labels;
|
||||
}
|
||||
|
||||
@@ -317,7 +344,7 @@ public class Mindmap {
|
||||
return result;
|
||||
|
||||
}
|
||||
//creo que no se usa mas
|
||||
|
||||
public boolean hasLabel(@NotNull final String name) {
|
||||
for (Label label : this.labels) {
|
||||
if (label.getTitle().equals(name)) {
|
||||
@@ -327,7 +354,8 @@ public class Mindmap {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable public Label findLabel(int labelId) {
|
||||
@Nullable
|
||||
public Label findLabel(int labelId) {
|
||||
Label result = null;
|
||||
for (Label label : this.labels) {
|
||||
if (label.getId() == labelId) {
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public enum ShapeStyle
|
||||
{
|
||||
LINE("line"),
|
||||
ROUNDED_RECTANGLE("rounded rectagle"),
|
||||
RECTANGLE("rectagle"),
|
||||
ELLIPSE("elipse"),
|
||||
IMAGE("image");
|
||||
|
||||
private final String style;
|
||||
|
||||
ShapeStyle(String style)
|
||||
{
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public String getStyle()
|
||||
{
|
||||
return style;
|
||||
}
|
||||
|
||||
public static ShapeStyle fromValue(String value) {
|
||||
for (ShapeStyle shapeStyle : ShapeStyle.values()) {
|
||||
if (shapeStyle.getStyle().equals(value)) {
|
||||
return shapeStyle;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Shape value \"" + value + "\" doesn't match with a value shape style.");
|
||||
}
|
||||
}
|
@@ -21,11 +21,15 @@ package com.wisemapping.model;
|
||||
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 = "USER")
|
||||
@PrimaryKeyJoinColumn(name="colaborator_id")
|
||||
public class User
|
||||
extends Collaborator
|
||||
implements Serializable {
|
||||
@@ -33,16 +37,28 @@ public class User
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String password;
|
||||
private long activationCode;
|
||||
private Calendar activationDate;
|
||||
private Set<String> tags = new HashSet<String>();
|
||||
private boolean allowSendEmail = false;
|
||||
private String locale;
|
||||
private AuthenticationType authenticationType;
|
||||
|
||||
@Column(name = "activation_code")
|
||||
private long activationCode;
|
||||
|
||||
@Column(name = "activation_date")
|
||||
private Calendar activationDate;
|
||||
|
||||
@Column(name = "allow_send_email")
|
||||
private boolean allowSendEmail = false;
|
||||
|
||||
@Column(name="authentication_type")
|
||||
private Character authenticationTypeCode = AuthenticationType.DATABASE.getCode();
|
||||
|
||||
@Column(name="authenticator_uri")
|
||||
private String authenticatorUri;
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "TAG", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Column(name = "name")
|
||||
private Set<String> tags = new HashSet<>();
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
@@ -118,25 +134,24 @@ public class User
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public char getAutheticationTypeCode() {
|
||||
// Default authentication is database ....
|
||||
return this.authenticationType != null ? this.authenticationType.getCode() : AuthenticationType.DATABASE.getCode();
|
||||
public char getAuthenticationTypeCode() {
|
||||
return this.authenticationTypeCode;
|
||||
}
|
||||
|
||||
public void setAutheticationTypeCode(char code) {
|
||||
this.authenticationType = AuthenticationType.valueOf(code);
|
||||
public void setAuthenticationTypeCode(char code) {
|
||||
this.authenticationTypeCode = code;
|
||||
}
|
||||
|
||||
public AuthenticationType getAuthenticationType() {
|
||||
return authenticationType;
|
||||
return authenticationTypeCode!=null ? AuthenticationType.valueOf(authenticationTypeCode):AuthenticationType.DATABASE;
|
||||
}
|
||||
|
||||
public void setAuthenticationType(@NotNull AuthenticationType authenticationType) {
|
||||
this.authenticationType = authenticationType;
|
||||
this.authenticationTypeCode = authenticationType.getCode();
|
||||
}
|
||||
|
||||
public boolean isDatabaseSchema(){
|
||||
return this.authenticationType == AuthenticationType.DATABASE;
|
||||
return this.getAuthenticationType() == AuthenticationType.DATABASE;
|
||||
}
|
||||
|
||||
public String getAuthenticatorUri() {
|
||||
|
Reference in New Issue
Block a user