TaxonomyFamily.java
/*
* Copyright 2024 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.genesys.server.model.grin;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
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.springframework.data.elasticsearch.annotations.Document;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
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;
@Entity
@Cacheable
@Table(name = "grin_family")
@Document(indexName = "grinfamily")
@JsonIdentityInfo(scope = TaxonomyFamily.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class TaxonomyFamily extends CooperatorOwnedModel implements Copyable<TaxonomyFamily> {
private static final long serialVersionUID = 3373830137037007643L;
@Id
@JsonProperty
@Column(name = "taxonomy_family_id", columnDefinition = "int")
private Long id;
@Column(name = "grin_family_id")
private Long grinId;
@Basic
@Column(name = "alternate_name", length = 25)
private String alternateName;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "current_taxonomy_family_id")
@JsonIdentityReference(alwaysAsId = true)
@JsonIdentityInfo(scope = TaxonomyFamily.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
private TaxonomyFamily currentTaxonomyFamily;
@Basic
@Column(name = "family_authority", length = 100)
private String familyAuthority;
@Basic
@Column(name = "family_name", nullable = false, length = 25)
private String familyName;
@Basic
@Column
@Lob
private String note;
@Basic
@Column(name = "subfamily_name", length = 25)
private String subfamilyName;
@Basic
@Column(name = "subtribe_name", length = 25)
private String subtribeName;
@Basic
@Column(name = "suprafamily_rank_code", length = 30)
private String suprafamilyRankCode;
@Basic
@Column(name = "suprafamily_rank_name", length = 100)
private String suprafamilyRankName;
@Basic
@Column(name = "tribe_name", length = 25)
private String tribeName;
@Basic
@Column(name = "family_type_code", length = 30)
private String familyTypeCode;
public TaxonomyFamily(final Long id) {
this.id = id;
}
@JsonProperty
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public static TaxonomyFamily withId(Long taxonomyFamilyId) {
return taxonomyFamilyId == null ? null : new TaxonomyFamily(taxonomyFamilyId);
}
@Override
public boolean canEqual(Object other) {
return other instanceof TaxonomyFamily;
}
}