InventoryViabilityEnvironment.java

/*
 * Copyright 2021 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 javax.persistence.*;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.model.community.CommunityCodeValues;

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

@Entity
@Table(name = "inventory_viability_environment",
		// Unique constraints
		uniqueConstraints = @UniqueConstraint(columnNames = { "light_hours", "nm_wave_lenght", "light_potency", "light_grades", "light_potency_unit_code", "grades_unit_code", "dark_grades", "equipment_code"}))
@JsonIdentityInfo(scope = InventoryViabilityEnvironment.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class InventoryViabilityEnvironment extends CooperatorOwnedModel implements Copyable<InventoryViabilityEnvironment> {

	private static final long serialVersionUID = 5087750409300945335L;

	@Id
	@JsonProperty
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "inventory_viability_environment_id", columnDefinition = "int")
	private Long id;

	@Column(name = "light_hours")
	private Integer lightHours;

	@Column(name = "nm_wave_lenght")
	private Integer nmWaveLenght;

	@Column(name = "light_potency")
	private Integer lightPotency;

	@Column(name = "light_grades")
	private Integer lightGrades;

	@Size(max = CODE_VALUE_LENGTH)
	@Column(name = "light_potency_unit_code", length = CODE_VALUE_LENGTH)
	@CodeValueField(CommunityCodeValues.UNIT_OF_LIGHTPOTENCY)
	private String lightPotencyUnitCode;

	@Size(max = CODE_VALUE_LENGTH)
	@Column(name = "grades_unit_code", length = CODE_VALUE_LENGTH)
	@CodeValueField(CommunityCodeValues.UNIT_OF_TEMPERATURE)
	private String gradesUnitCode;

	@Column(name = "dark_grades")
	private Integer darkGrades;

	@Size(max = CODE_VALUE_LENGTH)
	@Column(name = "equipment_code", length = CODE_VALUE_LENGTH)
	@CodeValueField(CommunityCodeValues.VIABILITY_EQUIPMENT)
	private String equipmentCode;

	@Lob
	@Column(name = "note")
	private String note;

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

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