Commit 332df0d0 authored by PECQUOT's avatar PECQUOT
Browse files

[enh] Refactoring VO and Entity: toString()

parent 3146f866
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.administration.programStrategy;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.referential.IItemReferentialEntity;
import net.sumaris.core.model.referential.Status;
......@@ -32,6 +33,7 @@ import java.util.Date;
import java.util.Objects;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Cacheable
......@@ -41,6 +43,7 @@ public class AcquisitionLevel implements IItemReferentialEntity {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "ACQUISITION_LEVEL_SEQ")
@SequenceGenerator(name = "ACQUISITION_LEVEL_SEQ", sequenceName="ACQUISITION_LEVEL_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
......@@ -56,6 +59,7 @@ public class AcquisitionLevel implements IItemReferentialEntity {
private Date updateDate;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_LABEL)
@ToString.Include
private String label;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_NAME)
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.administration.programStrategy;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.referential.IReferentialEntity;
......@@ -34,6 +35,7 @@ import java.util.ArrayList;
import java.util.List;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "applied_strategy")
......@@ -42,14 +44,17 @@ public class AppliedStrategy implements IEntity<Integer> {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "APPLIED_STRATEGY_SEQ")
@SequenceGenerator(name = "APPLIED_STRATEGY_SEQ", sequenceName="APPLIED_STRATEGY_SEQ", allocationSize = IReferentialEntity.SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "strategy_fk", nullable = false)
@ToString.Include
private Strategy strategy;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "location_fk", nullable = false)
@ToString.Include
private Location location;
@OneToMany(fetch = FetchType.LAZY, mappedBy = AppliedPeriod.Fields.APPLIED_STRATEGY)
......
......@@ -24,6 +24,7 @@ package net.sumaris.core.model.administration.programStrategy;
import com.google.common.collect.Sets;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.referential.IReferentialEntity;
......@@ -36,6 +37,7 @@ import javax.persistence.*;
import java.util.Set;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "pmfm_strategy")
......@@ -44,6 +46,7 @@ public class PmfmStrategy implements IEntity<Integer> {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "PMFM_STRATEGY_SEQ")
@SequenceGenerator(name = "PMFM_STRATEGY_SEQ", sequenceName="PMFM_STRATEGY_SEQ", allocationSize = IReferentialEntity.SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@Column(name = "acquisition_number", nullable = false)
......@@ -63,6 +66,7 @@ public class PmfmStrategy implements IEntity<Integer> {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "pmfm_fk", nullable = false)
@ToString.Include
private Pmfm pmfm;
@Column(name = "rank_order", nullable = false)
......@@ -70,10 +74,12 @@ public class PmfmStrategy implements IEntity<Integer> {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "strategy_fk", nullable = false)
@ToString.Include
private Strategy strategy;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "acquisition_level_fk", nullable = false)
@ToString.Include
private AcquisitionLevel acquisitionLevel;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
......
......@@ -24,10 +24,10 @@ package net.sumaris.core.model.administration.programStrategy;
import com.google.common.collect.Sets;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.referential.IItemReferentialEntity;
import net.sumaris.core.model.referential.Status;
import net.sumaris.core.model.referential.gear.Gear;
import net.sumaris.core.model.referential.gear.GearClassification;
import net.sumaris.core.model.referential.location.Location;
import net.sumaris.core.model.referential.location.LocationClassification;
......@@ -38,6 +38,7 @@ import javax.persistence.*;
import java.util.*;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Cacheable
......@@ -46,6 +47,7 @@ public class Program implements IItemReferentialEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROGRAM_SEQ")
@SequenceGenerator(name = "PROGRAM_SEQ", sequenceName="PROGRAM_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
......@@ -61,6 +63,7 @@ public class Program implements IItemReferentialEntity {
private Date updateDate;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_LABEL)
@ToString.Include
private String label;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_NAME)
......@@ -105,9 +108,4 @@ public class Program implements IItemReferentialEntity {
return Objects.hash(label);
}
public String toString() {
return String.format("Program{id=%s, label=%s}",
id,
label);
}
}
......@@ -23,6 +23,7 @@
package net.sumaris.core.model.administration.programStrategy;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.referential.IItemReferentialEntity;
import net.sumaris.core.model.referential.Status;
......@@ -31,6 +32,7 @@ import javax.persistence.*;
import java.util.Date;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Cacheable
......@@ -40,6 +42,7 @@ public class ProgramPrivilege implements IItemReferentialEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROGRAM_PRIVILEGE_SEQ")
@SequenceGenerator(name = "PROGRAM_PRIVILEGE_SEQ", sequenceName="PROGRAM_PRIVILEGE_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
......@@ -55,6 +58,7 @@ public class ProgramPrivilege implements IItemReferentialEntity {
private Date updateDate;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_LABEL)
@ToString.Include
private String label;
@Column(nullable = false, length = IItemReferentialEntity.LENGTH_NAME)
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.administration.programStrategy;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.referential.IItemReferentialEntity;
import net.sumaris.core.model.referential.Status;
......@@ -31,6 +32,7 @@ import javax.persistence.*;
import java.util.Date;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "program_property")
......@@ -39,12 +41,15 @@ public class ProgramProperty implements IItemReferentialEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROGRAM_PROPERTY_SEQ")
@SequenceGenerator(name = "PROGRAM_PROPERTY_SEQ", sequenceName="PROGRAM_PROPERTY_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@Column(nullable = false, length = 255)
@ToString.Include
private String label;
@Column(nullable = false, length = 255)
@ToString.Include
private String name;
@ManyToOne(fetch = FetchType.LAZY)
......
......@@ -24,6 +24,7 @@ package net.sumaris.core.model.administration.programStrategy;
import com.google.common.collect.Sets;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.referential.IItemReferentialEntity;
import net.sumaris.core.model.referential.Status;
......@@ -37,6 +38,7 @@ import java.util.List;
import java.util.Set;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "strategy")
......@@ -45,6 +47,7 @@ public class Strategy implements IItemReferentialEntity {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "STRATEGY_SEQ")
@SequenceGenerator(name = "STRATEGY_SEQ", sequenceName="STRATEGY_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
......@@ -60,9 +63,11 @@ public class Strategy implements IItemReferentialEntity {
private Date updateDate;
@Column(nullable = false, length = 50)
@ToString.Include
private String label;
@Column(nullable = false, length = 100)
@ToString.Include
private String name;
private String description;
......@@ -72,6 +77,7 @@ public class Strategy implements IItemReferentialEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "program_fk", nullable = false)
@ToString.Include
private Program program;
@OneToMany(fetch = FetchType.LAZY, targetEntity = PmfmStrategy.class, mappedBy = PmfmStrategy.Fields.STRATEGY)
......@@ -106,10 +112,4 @@ public class Strategy implements IItemReferentialEntity {
}
}
public String toString() {
return String.format("Strategy{id=%s, label=%s, programId=%s}",
id,
label,
program.getId());
}
}
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.administration.user;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.data.ImageAttachment;
import net.sumaris.core.model.referential.IItemReferentialEntity;
......@@ -34,6 +35,7 @@ import java.util.Date;
import java.util.Objects;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "department")
......@@ -58,6 +60,7 @@ public class Department implements IItemReferentialEntity {
private Date updateDate;
@Column(nullable = false, length = LENGTH_LABEL)
@ToString.Include
private String label;
@Column(nullable = false, length = LENGTH_NAME)
......@@ -79,10 +82,6 @@ public class Department implements IItemReferentialEntity {
@JoinColumn(name = "location_fk")
private Location location;
public String toString() {
return label;
}
public int hashCode() {
return Objects.hash(label);
}
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.administration.user;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.data.ImageAttachment;
import net.sumaris.core.model.referential.IReferentialWithStatusEntity;
......@@ -37,6 +38,7 @@ import java.util.Objects;
import java.util.Set;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "person")
......@@ -62,6 +64,7 @@ public class Person implements IReferentialWithStatusEntity {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "PERSON_SEQ")
@SequenceGenerator(name = "PERSON_SEQ", sequenceName="PERSON_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
......@@ -83,6 +86,7 @@ public class Person implements IReferentialWithStatusEntity {
private String lastName;
@Column(name="email", nullable = false, unique = true)
@ToString.Include
private String email;
@Column(name="email_md5", unique = true)
......@@ -112,10 +116,6 @@ public class Person implements IReferentialWithStatusEntity {
@Cascade(org.hibernate.annotations.CascadeType.DELETE)
private ImageAttachment avatar;
public String toString() {
return new StringBuilder().append(super.toString()).append(",email=").append(this.email).toString();
}
public int hashCode() {
return Objects.hash(id, pubkey, email);
}
......
......@@ -23,11 +23,11 @@
package net.sumaris.core.model.data;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.ITreeNodeEntityBean;
import net.sumaris.core.model.administration.user.Department;
import net.sumaris.core.model.referential.QualityFlag;
import net.sumaris.core.model.referential.location.Location;
import net.sumaris.core.model.referential.taxon.ReferenceTaxon;
import net.sumaris.core.model.referential.taxon.TaxonGroup;
import org.hibernate.annotations.Cascade;
......@@ -38,6 +38,7 @@ import java.util.Date;
import java.util.List;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name = "batch")
......@@ -47,9 +48,11 @@ public class Batch implements IDataEntity<Integer>,
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BATCH_SEQ")
@SequenceGenerator(name = "BATCH_SEQ", sequenceName="BATCH_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@Column(length = 40)
@ToString.Include
private String label;
@Column(name = "rank_order", nullable = false)
......@@ -141,7 +144,4 @@ public class Batch implements IDataEntity<Integer>,
//@JoinColumn(name = "location_fk")
//private Location location;
public String toString() {
return String.format("Batch{id=%s,label=%s}", id, label);
}
}
......@@ -23,6 +23,7 @@
package net.sumaris.core.model.data;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.administration.user.Department;
import net.sumaris.core.model.referential.pmfm.Pmfm;
......@@ -33,6 +34,7 @@ import javax.persistence.*;
import java.util.Date;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name="quantification_measurement_b")
......@@ -41,6 +43,7 @@ public class BatchQuantificationMeasurement implements IQuantifiedMeasurementEnt
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QUANTIF_MEASUREMENT_B_SEQ")
@SequenceGenerator(name = "QUANTIF_MEASUREMENT_B_SEQ", sequenceName="QUANTIF_MEASUREMENT_B_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@Column(name = "update_date")
......@@ -96,17 +99,12 @@ public class BatchQuantificationMeasurement implements IQuantifiedMeasurementEnt
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Pmfm.class)
@JoinColumn(name = "pmfm_fk", nullable = false)
@ToString.Include
private Pmfm pmfm;
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Batch.class)
@JoinColumn(name = "batch_fk")
@ToString.Include
private Batch batch;
public String toString() {
return String.format("BatchQuantificationMeasurement{id:%s, batch:{id:%s}, pmfm:{id:%s, label:%s}}}",
id,
batch != null ? batch.getId() : null,
pmfm != null ? pmfm.getId() : null,
pmfm != null ? pmfm.getLabel() : null);
}
}
......@@ -23,6 +23,7 @@
package net.sumaris.core.model.data;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.administration.user.Department;
import net.sumaris.core.model.referential.pmfm.Pmfm;
......@@ -33,6 +34,7 @@ import javax.persistence.*;
import java.util.Date;
@Data
@ToString(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name="sorting_measurement_b")
......@@ -41,6 +43,7 @@ public class BatchSortingMeasurement implements ISortedMeasurementEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SORTING_MEASUREMENT_B_SEQ")
@SequenceGenerator(name = "SORTING_MEASUREMENT_B_SEQ", sequenceName="SORTING_MEASUREMENT_B_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@ToString.Include
private Integer id;
@Column(name = "update_date")
......@@ -90,17 +93,12 @@ public class BatchSortingMeasurement implements ISortedMeasurementEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "pmfm_fk", nullable = false)
@ToString.Include
private Pmfm pmfm;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "batch_fk")
@ToString.Include
private Batch batch;
public String toString() {
return String.format("BatchSortingMeasurement{id:%s, batch:{id:%s}, pmfm:{id:%s, label:%s}}}",
id,
batch != null ? batch.getId() : null,
pmfm != null ? pmfm.getId() : null,
pmfm != null ? pmfm.getLabel() : null);
}
}
......@@ -28,6 +28,7 @@
package net.sumaris.core.model.data;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.referential.QualityFlag;
......@@ -155,14 +156,17 @@ public class DenormalizedBatch implements IEntity<Integer> {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_batch_fk")
@ToString.Exclude
private DenormalizedBatch parent;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "operation_fk")
@ToString.Exclude
private Operation operation;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sale_fk")
@ToString.Exclude
private Sale sale;
@OneToMany(fetch = FetchType.LAZY, targetEntity = DenormalizedBatchSortingValue.class, mappedBy = DenormalizedBatchSortingValue.Fields.BATCH)
......
......@@ -29,6 +29,7 @@ package net.sumaris.core.model.data;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.referential.pmfm.Parameter;
......@@ -77,6 +78,7 @@ public class DenormalizedBatchSortingValue implements IEntity<Integer>
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "batch_fk", nullable = false)
@ToString.Exclude
private DenormalizedBatch batch;
@ManyToOne(fetch = FetchType.LAZY)
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.data;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.referential.DepthGradient;
......@@ -63,6 +64,7 @@ public class FishingArea implements IEntity<Integer> {
// parent
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Operation.class)
@JoinColumn(name = "operation_fk")
@ToString.Exclude
private Operation operation;
// TODO : add other parent (from SIH-Adagio model)
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.data;
*/
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.administration.user.Department;
import net.sumaris.core.model.referential.pmfm.Pmfm;
......@@ -94,6 +95,7 @@ public class GearUseMeasurement implements IMeasurementEntity {
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Operation.class)
@JoinColumn(name = "operation_fk", nullable = false)
@ToString.Exclude
private Operation operation;
......
......@@ -23,6 +23,7 @@ package net.sumaris.core.model.data;
*/
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;
import net.sumaris.core.model.administration.user.Department;
import net.sumaris.core.model.administration.user.Person;
......@@ -30,9 +31,9 @@ import net.sumaris.core.model.referential.QualityFlag;
import javax.persistence.*;
import java.util.Date;
import java.util.Objects;
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@FieldNameConstants
@Entity
@Table(name="image_attachment")
......@@ -43,6 +44,7 @@ public class ImageAttachment implements IDataEntity<Integer>,
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "IMAGE_ATTACHMENT_SEQ")
@SequenceGenerator(name = "IMAGE_ATTACHMENT_SEQ", sequenceName="IMAGE_ATTACHMENT_SEQ", allocationSize = SEQUENCE_ALLOCATION_SIZE)
@EqualsAndHashCode.Include
private Integer id;
@Column(name = "creation_date", nullable = false)
......@@ -96,18 +98,4 @@ public class ImageAttachment implements IDataEntity<Integer>,
@Column(length=20971520)
private String content;
public int hashCode() {
return Objects.hash(id);
}
public boolean equals(Object other) {
if (this == other) return true;
if ( !(other instanceof ImageAttachment) ) return false;