Commit 3802f5c9 authored by Matija Obreza's avatar Matija Obreza

Refactored model for app-blocks

VersionedModel to app-blocks#VersionedModel
VersionedAuditedModel to app-blocks#AuditedVersionedModel
BusinessModel to app-blocks.BasicModel
ClassPK from app-blocks
parent d6341217
/**
* Copyright 2014 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.genesys2.server.model;
import java.io.Serializable;
/**
* Interface label for those classes, which is supposed to be
*/
public interface AclAwareModel extends Serializable, EntityId {
}
......@@ -21,13 +21,14 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.genesys.blocks.model.BasicModel;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
@MappedSuperclass
public abstract class AuditedModel extends BusinessModel {
public abstract class AuditedModel extends BasicModel {
private static final long serialVersionUID = -5927214471682331909L;
@CreatedBy
......
/**
* Copyright 2014 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.genesys2.server.model;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public abstract class BusinessModel implements EntityId, HibernateModel {
private static final long serialVersionUID = 1059280831389222969L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false, length = 20)
protected Long id;
@Override
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
}
/**
* Copyright 2014 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.genesys2.server.model;
public interface EntityId {
Long getId();
}
......@@ -21,6 +21,8 @@ import javax.persistence.MappedSuperclass;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.genesys.blocks.model.AuditedVersionedModel;
/**
* This superclass adds a Resource Description Framework (RDF) Uniform Resource
* Identifier (URI) to records to link them with semantic web linked open
......@@ -30,7 +32,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*
*/
@MappedSuperclass
public abstract class GlobalVersionedAuditedModel extends VersionedAuditedModel {
public abstract class GlobalVersionedAuditedModel extends AuditedVersionedModel {
private static final long serialVersionUID = 1771989294484858302L;
......
/**
* Copyright 2014 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.genesys2.server.model;
import java.io.Serializable;
public interface HibernateModel extends Serializable {
}
package org.genesys2.server.model;
import java.util.UUID;
public interface IdUUID {
UUID getUuid();
}
/**
* Copyright 2015 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.genesys2.server.model;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
@MappedSuperclass
public abstract class UuidModel implements HibernateModel {
/**
*
*/
private static final long serialVersionUID = 6341297185411654489L;
@Id
@Column(name = "uuid", unique = true, nullable = false, updatable = false)
protected UUID uuid;
public UUID getUuid() {
return uuid;
}
protected void setUuid(UUID uuid) {
this.uuid = uuid;
}
@PrePersist
protected void pre() {
if (uuid == null)
uuid = UUID.randomUUID();
}
}
/**
* Copyright 2014 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.genesys2.server.model;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
@MappedSuperclass
public abstract class VersionedAuditedModel extends AuditedModel {
private static final long serialVersionUID = 8415401512360230669L;
@Version
private long version = 0;
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
}
/**
* Copyright 2014 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.genesys2.server.model;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
@MappedSuperclass
public abstract class VersionedModel extends BusinessModel {
private static final long serialVersionUID = 8415401512360230669L;
@Version
private long version = 0;
public long getVersion() {
return version;
}
public void setVersion(long version) {
this.version = version;
}
}
......@@ -20,11 +20,11 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "acl_class")
public class AclClass extends BusinessModel {
public class AclClass extends BasicModel {
private static final long serialVersionUID = 7634040355879912092L;
......
......@@ -25,11 +25,11 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "acl_entry", uniqueConstraints = @UniqueConstraint(columnNames = { "acl_object_identity", "ace_order" }))
public class AclEntry extends BusinessModel {
public class AclEntry extends BasicModel {
private static final long serialVersionUID = -1047000445685485825L;
......
......@@ -29,11 +29,12 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "acl_object_identity", uniqueConstraints = @UniqueConstraint(columnNames = { "object_id_class", "object_id_identity" }))
public class AclObjectIdentity extends BusinessModel {
public class AclObjectIdentity extends BasicModel {
private static final long serialVersionUID = -8987281958564243010L;
......
......@@ -26,11 +26,12 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "acl_sid")
public class AclSid extends BusinessModel {
public class AclSid extends BasicModel {
private static final long serialVersionUID = -8665345718313672678L;
......
......@@ -10,11 +10,11 @@ import javax.persistence.OrderBy;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "ds2")
public class DS extends BusinessModel {
public class DS extends BasicModel {
/**
*
*/
......
......@@ -6,7 +6,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.genesys2.server.model.impl.Descriptor;
/**
......@@ -14,7 +14,7 @@ import org.genesys2.server.model.impl.Descriptor;
*/
@Entity
@Table(name = "ds2descriptor")
public class DSDescriptor extends BusinessModel {
public class DSDescriptor extends BasicModel {
/**
*
......
......@@ -6,7 +6,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.genesys2.server.model.impl.Descriptor;
/**
......@@ -14,7 +14,7 @@ import org.genesys2.server.model.impl.Descriptor;
*/
@Entity
@Table(name = "ds2qualifier")
public class DSQualifier extends BusinessModel {
public class DSQualifier extends BasicModel {
/**
*
......@@ -58,6 +58,6 @@ public class DSQualifier extends BusinessModel {
@Override
public String toString() {
return "DSQ " + this.id + " [" + this.getId() + "]";
return "DSQ " + this.getId() + " [" + this.getId() + "]";
}
}
......@@ -15,7 +15,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.EntityId;
import org.genesys.blocks.model.EntityId;
@Entity
@Table(name = "ds2row", uniqueConstraints = { @UniqueConstraint(columnNames = { "md5", "sha1" }) })
......
......@@ -17,7 +17,7 @@ package org.genesys2.server.model.elastic;
import java.util.Date;
import org.genesys2.server.model.impl.ClassPK;
import org.genesys.blocks.model.ClassPK;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
......
......@@ -24,14 +24,14 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
/**
* Accession "alias"
*/
@Entity
@Table(name = "accessionalias")
public class AccessionAlias extends BusinessModel implements AccessionRelated {
public class AccessionAlias extends BasicModel implements AccessionRelated {
private static final long serialVersionUID = 4990299133164025782L;
......
......@@ -26,7 +26,7 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.apache.commons.lang.StringUtils;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.hibernate.annotations.Type;
/**
......@@ -34,7 +34,7 @@ import org.hibernate.annotations.Type;
*/
@Entity
@Table(name = "accessionbreeding")
public class AccessionBreeding extends BusinessModel implements AccessionRelated {
public class AccessionBreeding extends BasicModel implements AccessionRelated {
private static final long serialVersionUID = 7659867116143459074L;
......
......@@ -26,7 +26,7 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.apache.commons.lang.StringUtils;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.hibernate.annotations.Type;
/**
......@@ -34,7 +34,7 @@ import org.hibernate.annotations.Type;
*/
@Entity
@Table(name = "accessioncollect")
public class AccessionCollect extends BusinessModel implements AccessionRelated {
public class AccessionCollect extends BasicModel implements AccessionRelated {
private static final long serialVersionUID = 6848317825287346724L;
......
......@@ -38,7 +38,7 @@ import javax.persistence.PreUpdate;
import javax.persistence.Transient;
import javax.persistence.Version;
import org.genesys2.server.model.IdUUID;
import org.genesys.blocks.model.IdUUID;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
......
......@@ -25,14 +25,14 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.apache.commons.lang.StringUtils;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
/**
* AllAcqExchange generated by hbm2java
*/
@Entity
@Table(name = "accessionexchange")
public class AccessionExchange extends BusinessModel implements AccessionRelated {
public class AccessionExchange extends BasicModel implements AccessionRelated {
private static final long serialVersionUID = -2509737429801931061L;
......
......@@ -25,12 +25,12 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.apache.commons.lang.StringUtils;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.genesys2.server.model.impl.GeoReferencedEntity;
@Entity
@Table(name = "accessiongeo")
public class AccessionGeo extends BusinessModel implements GeoReferencedEntity, AccessionRelated {
public class AccessionGeo extends BasicModel implements GeoReferencedEntity, AccessionRelated {
private static final long serialVersionUID = 8046638388176612388L;
......
......@@ -33,8 +33,8 @@ import javax.persistence.OneToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import org.genesys2.server.model.IdUUID;
import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.IdUUID;
import org.genesys2.server.model.impl.AccessionList;
/**
......@@ -43,7 +43,7 @@ import org.genesys2.server.model.impl.AccessionList;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "acce")
public class AccessionId extends VersionedAuditedModel implements IdUUID {
public class AccessionId extends AuditedVersionedModel implements IdUUID {
/**
*
......
......@@ -25,7 +25,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.hibernate.annotations.Type;
/**
......@@ -33,7 +33,7 @@ import org.hibernate.annotations.Type;
*/
@Entity
@Table(name = "accessionremark")
public class AccessionRemark extends BusinessModel implements AccessionRelated {
public class AccessionRemark extends BasicModel implements AccessionRelated {
/**
*
......
......@@ -23,11 +23,11 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
@Entity
@Table(name = "accessiontrait", uniqueConstraints = { @UniqueConstraint(name = "UQ_accessiontrait_all", columnNames = { "metadataId", "accessionId", "methodId" }) })
public class AccessionTrait extends BusinessModel {
public class AccessionTrait extends BasicModel {
private static final long serialVersionUID = -240056837800843686L;
@ManyToOne(cascade = {}, optional = false)
......
......@@ -25,7 +25,7 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.genesys.blocks.model.BasicModel;
import org.hibernate.annotations.Type;
/**
......@@ -33,7 +33,7 @@ import org.hibernate.annotations.Type;
*/
@Entity
@Table(name = "accessionname")
public class AllAccnames extends BusinessModel {