Exploration.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 java.util.List;
import javax.persistence.*;
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.annotations.NotCopyable;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.compatibility.LookupDisplay;
import org.gringlobal.custom.elasticsearch.IgnoreField;
import org.hibernate.annotations.Formula;
/**
* Auto-generated by:
* org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
*/
@Entity
@Table(name = "exploration")
@JsonIdentityInfo(scope = Exploration.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class Exploration extends CooperatorOwnedModel implements Copyable<Exploration> {
private static final long serialVersionUID = -6311529525374946263L;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "exploration_id", columnDefinition = "int")
private Long id;
@Basic
@Column(name = "began_date")
private Date beganDate;
@Basic
@Column(name = "exploration_number", nullable = false, length = 40, unique = true) // ndx_uniq_ex
@LookupDisplay
private String explorationNumber;
@Basic
@Column(name = "finished_date")
private Date finishedDate;
@Basic
@Column(name = "fiscal_year")
private Integer fiscalYear;
@Basic
@Column(name = "funding_amount")
private Double fundingAmount;
@Basic
@Column(name = "funding_source", length = 100)
private String fundingSource;
@ManyToOne(fetch = FetchType.LAZY, cascade = {})
@JoinColumn(name = "host_cooperator_id")
private Cooperator hostCooperator;
@Basic
@Column
@Lob
private String note;
@Basic
@Column(length = 240)
private String permits;
@Basic
@Column(length = 60)
private String restrictions;
@Basic
@Column(name = "target_species", length = 200)
private String targetSpecies;
@Basic
@Column(length = 240)
private String title;
@NotCopyable
@OneToMany(fetch = FetchType.LAZY, cascade = {}, mappedBy = "exploration")
@IgnoreField
private List<Accession> accessions;
/**
* The number of items in the group
*/
@Formula("(SELECT COUNT(*) FROM accession a WHERE a.exploration_id = exploration_id)")
private int numberOfItems;
public Exploration(final Long id) {
this.id = id;
}
@Override
public boolean canEqual(Object other) {
return other instanceof Exploration;
}
}