InventoryMaintPolicySeason.java

/*
 * Copyright 2023 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.gringlobal.model;

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

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.model.community.CommunityCodeValues;

import java.time.Instant;

@Entity
@Table(name = "inventory_maint_policy_season")
@Getter
@Setter
@NoArgsConstructor
public class InventoryMaintPolicySeason extends CooperatorOwnedModel {

	private static final long serialVersionUID = 5303947493006851263L;

	@Id
	@Column(name = "inventory_maint_policy_season_id", columnDefinition = "int")
	private Long id;

	@Basic
	@Column(name = "distribution_form_type_code", columnDefinition = "nvarchar", nullable = false, length = CODE_VALUE_LENGTH)
	@CodeValueField(CommunityCodeValues.GERMPLASM_FORM)
	private String distributionFormTypeCode;

	@Basic
	@Column(name = "distribution_quantity")
	private double distributionQuantity;

	@Basic
	@Column(name = "distribution_unit_code", columnDefinition = "nvarchar", length = CODE_VALUE_LENGTH)
	@CodeValueField(CommunityCodeValues.UNIT_OF_QUANTITY)
	private String distributionUnitCode;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "inventory_maint_policy_id", nullable = false)
	private InventoryMaintenancePolicy inventoryMaintPolicy;

	@Basic
	@Column(name = "seasonal_end_date", nullable = false)
	private Instant seasonalEndDate;

	@Basic
	@Column(name = "seasonal_start_date", nullable = false)
	private Instant seasonalStartDate;

	@Basic
	@Column
	@Lob
	private String note;

	public InventoryMaintPolicySeason(Long id) {
		this.id = id;
	}
	
	@Override
	public boolean canEqual(Object other) {
		return other instanceof InventoryMaintPolicySeason;
	}
}