CropTrait.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 javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
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.component.elastic.ElasticLoader;
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 = "crop_trait")
@JsonIdentityInfo(scope = CropTrait.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class CropTrait extends TranslatedCooperatorOwnedModel<CropTraitLang, CropTrait> implements Copyable<CropTrait>, ElasticLoader {
private static final long serialVersionUID = 5665579459926376559L;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "crop_trait_id", columnDefinition = "int")
private Long id;
@NotNull
@Size(min = 1, max = 1)
@Basic
@Column(name = "is_archived", nullable = false, length = 1)
private String isArchived;
@NotNull
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "crop_id", nullable = false)
private Crop crop;
@Basic
@CodeValueField("DESCRIPTOR_CATEGORY")
@Column(name = "category_code", nullable = false, length = CODE_VALUE_LENGTH)
private String categoryCode;
@NotNull
@Size(min = 1, max = 30)
@Basic
@Column(name = "coded_name", nullable = false, length = 30)
private String codedName;
@NotNull
@Basic
@CodeValueField(CommunityCodeValues.CROP_TRAIT_DATA_TYPE)
@Column(name = "data_type_code", nullable = false, length = CODE_VALUE_LENGTH)
private String dataTypeCode;
@NotNull
@Size(min = 1, max = 1)
@Basic
@Column(name = "is_coded", nullable = false, length = 1)
private String isCoded;
@NotNull
@Size(min = 1, max = 1)
@Basic
@Column(name = "is_peer_reviewed", nullable = false, length = 1)
private String isPeerReviewed;
@Basic
@Column(name = "max_length")
private Integer maxLength;
@Size(max = 15)
@Basic
@Column(name = "numeric_format", length = 15)
private String numericFormat;
@Basic
@Column(name = "numeric_minimum")
private Double numericMinimum;
@Basic
@Column(name = "numeric_maximum")
private Double numericMaximum;
@Size(max = 300)
@Basic
@Column(name = "ontology_url", length = 300)
private String ontologyUrl;
@Size(max = 50)
@Basic
@Column(name = "original_value_format", length = 50)
private String originalValueFormat;
@Basic
@CodeValueField("CROP_TRAIT_DATA_TYPE")
@Column(name = "original_value_type_code", length = CODE_VALUE_LENGTH)
private String originalValueTypeCode;
@Basic
@Column
@Lob
private String note;
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, mappedBy = "cropTrait")
@JsonIgnore
private List<CropTraitCode> codes;
@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "cropTrait")
@JsonIgnore
private List<CropTraitAttach> attachments;
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "cropTrait")
@JsonIgnore
private List<CropTraitObservation> cropTraitObservations;
public CropTrait(final Long id) {
this.id = id;
}
@Override
public void lazyLoad() {
super.lazyLoad();
lazyLoad(this.crop);
}
@Override
public void prepareForIndexing() {
this.lazyLoad();
if (this.langs != null) {
this.langs.size();
}
}
@Override
public boolean canEqual(Object other) {
return other instanceof CropTrait;
}
}