InventoryQualityStatus.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 java.util.Date;
import java.util.List;
import javax.persistence.*;

import org.genesys.blocks.model.Copyable;

import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.model.community.CommunityCodeValues;
import org.gringlobal.model.community.InventoryQualityStatusAttach;

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

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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 = "inventory_quality_status")
@JsonIdentityInfo(scope = InventoryQualityStatus.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class InventoryQualityStatus extends CooperatorOwnedModel implements Copyable<InventoryQualityStatus> {

	private static final long serialVersionUID = 6439022184139987687L;

	/** Inventory Quality Status ID. */
	@Id
	@JsonProperty
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "inventory_quality_status_id", columnDefinition = "int")
	private Long id;

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

	/** Test Type: Type of test performed. Uses PATHOLOGY_TEST_TYPE vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.PATHOLOGY_TEST_TYPE)
	@Column(name = "test_type_code", nullable = false, length = CODE_VALUE_LENGTH)
	private String testTypeCode;

	/** Contaminant: Type of contamination found on the inventory. Uses PATHOLOGY_TEST vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.PATHOLOGY_TEST)
	@Column(name = "contaminant_code", nullable = false, length = CODE_VALUE_LENGTH)
	private String contaminantCode;

	/** Method: Reference to the method used for the test. */
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "method_id")
	private Method method;

	/** Plant Part Tested: Plant part tested. Uses GERMPLASM_FORM vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.GERMPLASM_FORM)
	@Column(name = "plant_part_tested_code", length = CODE_VALUE_LENGTH)
	private String plantPartTestedCode;

	/** Replicate: Replicate number. No decimals; whole numbers only. */
	@Basic
	private Integer replicate;

	/** Required Replication Count: Total number of replications required. No decimals; whole numbers only. */
	@Basic
	@Column(name = "required_replication_count")
	private Integer requiredReplicationCount;

	/** Testing Cooperator: Reference to the cooperator performing the tests. */
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "tester_cooperator_id")
	private Cooperator testerCooperator;

	/** Started Count: Number of units counted at the start of the test. No decimals; whole numbers only. */
	@Basic
	@Column(name = "started_count")
	private Integer startedCount;

	/** Started Date: The test's start date. */
	@Basic
	@Column(name = "started_date")
	private Date startedDate;

	/** Started Date Format: Format of the started date. Uses DATE_FORMAT vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.DATE_FORMAT)
	@Column(name = "started_date_code", length = CODE_VALUE_LENGTH)
	private String startedDateCode;

	/** Completed Count: Number of units counted at test completion. No decimals; whole numbers only. */
	@Basic
	@Column(name = "completed_count")
	private Integer completedCount;

	/** Completed Date: Date when the test was completed. */
	@Basic
	@Column(name = "completed_date")
	private Date completedDate;

	/** Completed Date Format: Format of the completed date. Uses DATE_FORMAT vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.DATE_FORMAT)
	@Column(name = "completed_date_code", length = CODE_VALUE_LENGTH)
	private String completedDateCode;

	/** Plate Or Assay Number: Identifier of the plate or assay used. */
	@Basic
	@Column(name = "plate_or_assay_number", length = 40)
	private String plateOrAssayNumber;

	/** Negative Control Value: Negative control value. Supports decimal values. */
	@Basic
	@Column(name = "negative_control")
	private Double negativeControl;

	/** Positive Control Value: Positive control value. Supports decimal values. */
	@Basic
	@Column(name = "positive_control")
	private Double positiveControl;

	/** Test Result: Test results found on the inventory. Uses PATHOLOGY_TEST_RESULT vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.PATHOLOGY_TEST_RESULT)
	@Column(name = "test_result_code", length = CODE_VALUE_LENGTH)
	private String testResultCode;

	/** Test Results Score: Score for the test results. */
	@Basic
	@Column(name = "test_results_score", length = 40)
	private String testResultsScore;

	/** Test Results Score Type: Type of test results score. Uses PATH_TEST_SCORE_TYPE vocabulary. */
	@Basic
	@CodeValueField(CommunityCodeValues.PATH_TEST_SCORE_TYPE)
	@Column(name = "test_results_score_type_code", length = CODE_VALUE_LENGTH)
	private String testResultsScoreTypeCode;

	/** Note: General remarks about the inventory quality status. */
	@Basic
	@Column
	@Lob
	private String note;

	@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "inventoryQualityStatus")
	@JsonIgnoreProperties({ "inventoryQualityStatus" })
	private List<InventoryQualityStatusAttach> attachments;


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

	@Override
	public void lazyLoad() {
		super.lazyLoad();
		lazyLoad(testerCooperator, false);
		lazyLoad(method, false);
	}

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