AccessionQuarantine.java

/*
 * Copyright 2019 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 java.util.Date;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

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;

/**
 * Auto-generated by:
 * org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
 */
@Entity
@Table(name = "accession_quarantine")
@JsonIdentityInfo(scope = AccessionQuarantine.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class AccessionQuarantine extends CooperatorOwnedModel implements Copyable<AccessionQuarantine> {
	private static final long serialVersionUID = 376842662962874778L;

	@NotNull
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "accession_id", nullable = false)
	private Accession accession;

	@NotNull
	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "custodial_cooperator_id", nullable = false)
	private Cooperator custodialCooperator;

	@Basic
	@Column(name = "entered_date")
	private Date enteredDate;

	@Basic
	@Column(name = "established_date")
	private Date establishedDate;

	@Basic
	@Column(name = "expected_release_date")
	private Date expectedReleaseDate;

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

	@Basic
	@Column
	@Lob
	private String note;

	@Basic
	@CodeValueField(CommunityCodeValues.ACCESSION_QUARANTINE_STATUS)
	@Column(name = "progress_status_code", length = CODE_VALUE_LENGTH)
	private String progressStatusCode;

	@Basic
	@NotNull
	@CodeValueField(CommunityCodeValues.ACCESSION_QUARANTINE_TYPE)
	@Column(name = "quarantine_type_code", nullable = false, length = CODE_VALUE_LENGTH)
	private String quarantineTypeCode;

	@Basic
	@Column(name = "released_date")
	private Date releasedDate;

	public AccessionQuarantine(final Long id) {
		this.id = id;
	}
	
	@Override
	public void lazyLoad() {
		super.lazyLoad();
		lazyLoad(this.custodialCooperator);
		lazyLoad(this.accession, true);
	}

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