Commit 22d1ec92 authored by Matija Obreza's avatar Matija Obreza
Browse files

Added type 3 UUIDs to Metadata, Method and Parameter

parent 42431a7d
......@@ -19,12 +19,14 @@ package org.genesys2.server.model.genesys;
import static javax.persistence.GenerationType.IDENTITY;
import java.text.MessageFormat;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.model.AclAwareModel;
......@@ -42,18 +44,50 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
*
*/
private static final long serialVersionUID = -7551263239168816406L;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Meta_id")
@DocumentId
private Long id;
@Column(length = 7)
private String institute;
@Column(nullable = false, length = 128)
@Field(name = "title", store = Store.NO)
private String title;
@Column(name = "S_Date", length = 10)
private String SDate;
@Column(name = "E_Date", length = 10)
private String EDate;
@Column(length = 128)
@Field(store = Store.NO)
private String location;
@Column(name = "\"Long\"")
private Double longitude;
@Column(name = "Lat")
private Double latitude;
@Column(name = "Alt")
private Double altitude;
@Lob
@Field(store = Store.NO)
private String citation;
@Lob
@Field(name = "body", store = Store.NO)
private String description;
@Column(length = 36, unique = true, nullable = false)
private String uuid;
public Metadata() {
}
......@@ -74,11 +108,14 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.citation = citation;
this.description = description;
}
@PrePersist
void ensureUUID() {
if (this.uuid == null) {
this.uuid = UUID.nameUUIDFromBytes(title.getBytes()).toString();
}
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "Meta_id")
@DocumentId
public Long getId() {
return this.id;
}
......@@ -87,7 +124,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.id = metaId;
}
@Column(length = 7)
public String getInstitute() {
return this.institute;
}
......@@ -96,8 +132,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.institute = institute;
}
@Column(nullable = false, length = 128)
@Field(name = "title", store = Store.NO)
public String getTitle() {
return this.title;
}
......@@ -106,7 +140,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.title = title;
}
@Column(name = "S_Date", length = 10)
public String getSDate() {
return this.SDate;
}
......@@ -115,7 +148,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.SDate = SDate;
}
@Column(name = "E_Date", length = 10)
public String getEDate() {
return this.EDate;
}
......@@ -124,8 +156,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.EDate = EDate;
}
@Column(length = 128)
@Field(store = Store.NO)
public String getLocation() {
return this.location;
}
......@@ -134,7 +164,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.location = location;
}
@Column(name = "\"Long\"")
public Double getLongitude() {
return this.longitude;
}
......@@ -143,7 +172,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.longitude = longitude;
}
@Column(name = "Lat")
public Double getLatitude() {
return this.latitude;
}
......@@ -152,7 +180,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.latitude = latitude;
}
@Column(name = "Alt")
public Double getAltitude() {
return this.altitude;
}
......@@ -161,8 +188,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.altitude = alt;
}
@Lob
@Field(store = Store.NO)
public String getCitation() {
return this.citation;
}
......@@ -171,8 +196,6 @@ public class Metadata implements java.io.Serializable, AclAwareModel {
this.citation = citation;
}
@Lob
@Field(name = "body", store = Store.NO)
public String getDescription() {
return this.description;
}
......
......@@ -16,11 +16,14 @@
package org.genesys2.server.model.genesys;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Transient;
......@@ -37,6 +40,8 @@ public class Method extends BusinessModel implements AclAwareModel {
private static final long serialVersionUID = -1084675112110837714L;
// private Language language;
@Column(length = 36, unique = true, nullable = false)
private String uuid;
@Column(nullable = false)
@Lob
......@@ -59,12 +64,18 @@ public class Method extends BusinessModel implements AclAwareModel {
@Column(name = "\"range\"", length = 32)
private String range;
@ManyToOne(cascade = {}, optional = true)
@JoinColumn(name = "parameterId", nullable = true)
private Parameter parameter;
@PrePersist
void ensureUUID() {
if (this.uuid == null) {
this.uuid = UUID.nameUUIDFromBytes(method.getBytes()).toString();
}
}
public String getMethod() {
return this.method;
}
......
......@@ -16,10 +16,13 @@
package org.genesys2.server.model.genesys;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.model.AclAwareModel;
......@@ -33,6 +36,8 @@ public class Parameter extends BusinessModel implements AclAwareModel {
private static final long serialVersionUID = -4831244149317371274L;
// private Language language;
@Column(length = 36, unique = true, nullable = false)
private String uuid;
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "Crop_Id")
......@@ -55,6 +60,14 @@ public class Parameter extends BusinessModel implements AclAwareModel {
// this.language = language;
// }
@PrePersist
void ensureUUID() {
if (this.uuid == null) {
this.uuid = UUID.nameUUIDFromBytes(title.getBytes()).toString();
}
}
public Crop getCrop() {
return this.crop;
}
......
......@@ -88,7 +88,7 @@ public class User extends BusinessModel {
@PrePersist
void ensureUUID() {
if (this.uuid == null) {
this.uuid = UUID.randomUUID().toString();
this.uuid = UUID.nameUUIDFromBytes(email.getBytes()).toString();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment