GeneticObservation.java

/*
 * Copyright 2026 Global Crop Diversity Trust
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
 */

package org.gringlobal.model;

import static org.gringlobal.model.community.CommunityCodeValues.CODE_VALUE_LENGTH;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.genesys.blocks.model.Copyable;

import org.gringlobal.custom.validation.javax.CodeValueField;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

/**
 * Auto-generated by:
 * org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
 */
@Entity
@Table(name = "genetic_observation")
@JsonIdentityInfo(scope = GeneticObservation.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class GeneticObservation extends CooperatorOwnedModel implements Copyable<GeneticObservation> {

	private static final long serialVersionUID = -6740760232177787925L;

	/** Genetic Observation ID. */
	@Id
	@JsonProperty
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "genetic_observation_id", columnDefinition = "int")
	private Long id;

	/** Inventory: Reference to the inventory described by this observation. */
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "inventory_id", nullable = false)
	private Inventory inventory;

	/** Is Archived?: Y/N flag indicating the data for this observation has been archived. */
	@Basic
	@Column(name = "is_archived", nullable = false, length = 1)
	private String isArchived;

	/** Data Quality: A code indicating the quality of the data recorded. Uses OBSERVATION_DATA_QUALITY vocabulary. */
	@Basic
	@Column(name = "data_quality_code", length = CODE_VALUE_LENGTH)
	@CodeValueField("OBSERVATION_DATA_QUALITY")
	private String dataQualityCode;

	/** Frequency: The frequency of this observation expressed as a percent. Supports decimal values. */
	@Basic
	@Min(0) @Max(100) private Double frequency;

	/** Genetic Annotation: Reference to the genetic annotation described by this observation. */
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "genetic_annotation_id")
	private GeneticAnnotation geneticAnnotation;

	/** Maximum Value: The maximum value for this genetic observation. Supports decimal values. */
	@Basic
	@Column(name = "maximum_value")
	private Double maximumValue;

	/** Mean Value: The mean value for this genetic observation. Supports decimal values. */
	@Basic
	@Column(name = "mean_value")
	private Double meanValue;

	/** Minimum Value: The minimum value for this genetic observation. Supports decimal values. */
	@Basic
	@Column(name = "minimum_value")
	private Double minimumValue;

	/** Rank: The rank of this genetic observation. No decimals; whole numbers only. */
	@Basic
	private Integer rank;

	/** Sample Size: The sample size used to obtain the genetic observation. No decimals; whole numbers only. */
	@Basic
	@Column(name = "sample_size")
	@Min(0) private Integer sampleSize;

	/** Standard Deviation: The standard deviation for this genetic observation. Supports decimal values. */
	@Basic
	@Column(name = "standard_deviation")
	private Double standardDeviation;

	/** Value: The observed value for this genetic observation. */
	@Basic
	@Column(length = 1000)
	private String value;

	/** Note: General remarks about the genetic observation. */
	@Basic
	@Column
	@Lob
	private String note;

	public GeneticObservation(final Long id) {
		this.id = id;
	}

	@Override
	public void lazyLoad() {
		super.lazyLoad();
		lazyLoad(this.inventory);
		lazyLoad(this.geneticAnnotation);
	}

	@Override
	public boolean canEqual(Object other) {
		return other instanceof GeneticObservation;
	}
}