Commit 7b3cd252 authored by Matija Obreza's avatar Matija Obreza
Browse files

Data models extend BusinessModel

parent 2ace7b09
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.crophub.rest.common.model;
import java.util.Date;
import javax.persistence.MappedSuperclass;
import org.crophub.rest.common.model.impl.User;
@MappedSuperclass
public abstract class AuditedModel extends OwnedModel {
private static final long serialVersionUID = -5927214471682331909L;
private User createdBy;
private Date createdDate;
private User lastModifiedBy;
private Date lastModifiedDate;
public User getCreatedBy() {
return createdBy;
}
public void setCreatedBy(User createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public User getLastModifiedBy() {
return lastModifiedBy;
}
public void setLastModifiedBy(User lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
public Date getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
}
......@@ -33,7 +33,7 @@ public abstract class BusinessModel implements HibernateModel {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false, length = 20)
private Long id;
protected Long id;
public Long getId() {
return this.id;
......
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 org.crophub.rest.common.model;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import org.crophub.rest.common.model.impl.User;
@MappedSuperclass
public abstract class OwnedModel extends BusinessModel {
private static final long serialVersionUID = -6176890712426050571L;
@ManyToOne(cascade = {}, optional = false)
private User owner;
public User getOwner() {
return owner;
}
public void setOwner(User owner) {
this.owner = owner;
}
}
......@@ -16,23 +16,21 @@
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
@Entity
@Table(name = "dataset")
public class DataSet implements Serializable {
public class DataSet extends BusinessModel {
private static final long serialVersionUID = 4562288873039057125L;
private Long id;
private License license;
......@@ -42,16 +40,6 @@ public class DataSet implements Serializable {
private String mapping;
private Date uploadDate;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@ManyToOne(cascade = {}, optional = true)
public License getLicense() {
return license;
......
......@@ -16,16 +16,15 @@
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
/**
* A Descriptor represents a dimension of a sparse vector.
*
......@@ -33,22 +32,11 @@ import javax.persistence.Table;
*/
@Entity
@Table(name="descriptor")
public class Descriptor implements Serializable {
public class Descriptor extends BusinessModel {
private static final long serialVersionUID = 3832200593904442940L;
private Long id;
private String name;
private String description;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@Column(nullable = false, length = 500)
public String getName() {
return name;
......
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
/**
* A {@link License} entity represents one of the possible licenses in use by an
* {@link FaoInstitute}.
......@@ -17,14 +15,10 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "license")
public class License implements Serializable {
public class License extends BusinessModel {
private static final long serialVersionUID = -1240680237067019307L;
@Id
@GeneratedValue
private Long id;
@Column(length = 200, nullable = false)
private String name;
......@@ -34,14 +28,6 @@ public class License implements Serializable {
private float openess;
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getName() {
return name;
}
......
......@@ -16,17 +16,14 @@
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OrderColumn;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
import org.hibernate.annotations.Index;
/**
......@@ -40,24 +37,13 @@ import org.hibernate.annotations.Index;
@Index(columnNames = { "descriptorId", "stringId" }, name = "descriptorstring_SPARSEDATA"),
@Index(columnNames = { "sparseEntryId" }, name = "entry_SPARSEDATA"),
@Index(columnNames = { "descriptorId" }, name = "descriptor_SPARSEDATA") })
public class SparseData implements Serializable {
public class SparseData extends BusinessModel {
private static final long serialVersionUID = -2142036544458439223L;
private Long id;
private long sparseEntryId;
private long descriptorId;
private String value;
private SparseString sparseString;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@OrderColumn
public long getSparseEntryId() {
return sparseEntryId;
......
......@@ -16,15 +16,13 @@
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
/**
* Represents a sparse data vector, part of a {@link DataSet} in the system.
*
......@@ -32,21 +30,10 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "sparseentry")
public class SparseEntry implements Serializable {
public class SparseEntry extends BusinessModel {
private static final long serialVersionUID = 2430418022616359050L;
private Long id;
private DataSet dataSet;
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
@ManyToOne(cascade = {}, optional = false)
@JoinColumn(name = "dataSetId", nullable = false)
public DataSet getDataSet() {
......
......@@ -16,15 +16,14 @@
package org.crophub.rest.common.model.impl;
import java.io.Serializable;
import java.text.MessageFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.crophub.rest.common.model.BusinessModel;
/**
* Strings used in sparse tables
*
......@@ -32,9 +31,8 @@ import javax.persistence.Table;
*/
@Entity
@Table(name = "sparsestring")
public class SparseString implements Serializable {
public class SparseString extends BusinessModel {
private static final long serialVersionUID = 5896186555138979311L;
private Long id;
private String value;
public SparseString() {
......@@ -44,16 +42,6 @@ public class SparseString implements Serializable {
this.value = value;
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public int getHash() {
return this.value.hashCode();
}
......
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