AccessionPedigree.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 javax.validation.constraints.Size;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.genesys.blocks.model.Copyable;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.gringlobal.compatibility.LookupDisplay;
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_pedigree")
@JsonIdentityInfo(scope = AccessionPedigree.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
@LookupDisplay(template = "trim(concat(coalesce(accession.accessionNumber, ''), ' ', coalesce(cast(releasedDate as string), '')))")
public class AccessionPedigree extends CooperatorOwnedModel implements Copyable<AccessionPedigree> {
private static final long serialVersionUID = 1774726820847799218L;
@NotNull
@OneToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "accession_id", nullable = false)
private Accession accession;
@Basic
@Column(name = "cross_code", length = CODE_VALUE_LENGTH)
@CodeValueField(value = CommunityCodeValues.PEDIGREE_CROSS)
private String crossCode;
@Basic
@Column
@Lob
private String description;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "female_accession_id")
private Accession femaleAccession;
@Basic
@Size(max = 50)
@Column(name = "female_external_accession", length = 50)
private String femaleExternalAccession;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "accession_pedigree_id", columnDefinition = "int")
private Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "male_accession_id")
private Accession maleAccession;
@Basic
@Size(max = 50)
@Column(name = "male_external_accession", length = 50)
private String maleExternalAccession;
@Basic
@Column(name = "released_date")
private Date releasedDate;
@Basic
@Column(name = "released_date_code", length = CODE_VALUE_LENGTH)
@CodeValueField(CommunityCodeValues.DATE_FORMAT)
private String releasedDateCode;
public AccessionPedigree(final Long id) {
this.id = id;
}
@Override
public void lazyLoad() {
lazyLoad(this.accession, true);
lazyLoad(this.femaleAccession);
lazyLoad(this.maleAccession);
}
@Override
public boolean canEqual(Object other) {
return other instanceof AccessionPedigree;
}
}