Site.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.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.genesys.blocks.model.Copyable;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.blocks.util.ClassAclOid;
import org.gringlobal.compatibility.LookupDisplay;
import org.gringlobal.custom.validation.javax.CodeValueField;
import org.springframework.data.elasticsearch.annotations.Document;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import static org.gringlobal.model.community.CommunityCodeValues.ABBR_LENGTH;
import static org.gringlobal.model.community.CommunityCodeValues.CODE_VALUE_LENGTH;
/**
* Auto-generated by:
* org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
*/
@Entity
@Cacheable
@Document(indexName = "site")
@Table(name = "site")
@JsonIdentityInfo(scope = Site.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class Site extends CooperatorOwnedModel implements Copyable<Site>, AclAwareModel {
private static final long serialVersionUID = 1691183510177595819L;
// ACL Parent
@Transient
public static final ClassAclOid<Site> ACL_CLASS_IDENTITY = ClassAclOid.forClass(Site.class);
@Basic
@Pattern(regexp = "[A-Z]{3}\\d{3,4}")
@Column(name = "fao_institute_number", length = 20)
private String faoInstituteNumber;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "site_id", columnDefinition = "int")
private Long id;
@Basic
@Column(name = "is_distribution_site", nullable = false, length = 1)
private String isDistributionSite = "N";
@Basic
@Column(name = "is_internal", nullable = false, length = 1)
private String isInternal = "Y";
@Basic
@Column
@Lob
private String note;
@Basic
@Size(max = ABBR_LENGTH)
@Column(name = "organization_abbrev", length = ABBR_LENGTH)
private String organizationAbbrev;
@Basic
@Column(name = "provider_identifier", length = 6)
private String providerIdentifier;
@Basic
@NotBlank
@Column(name = "site_long_name", nullable = false, length = 200)
private String siteLongName;
@Basic
@NotBlank
@Column(name = "site_short_name", nullable = false, length = 20)
@LookupDisplay
private String siteShortName;
@Basic
@Column(name = "type_code", length = CODE_VALUE_LENGTH)
@CodeValueField("SITE_TYPE")
private String typeCode;
public Site(final Long id) {
this.id = id;
}
@Override
public void lazyLoad() {
super.lazyLoad();
}
/**
* Each Site inherits permissions from the Site type.
*/
@Override
public AclAwareModel aclParentObject() {
return ACL_CLASS_IDENTITY;
}
@Override
public boolean canEqual(Object other) {
return other instanceof Site;
}
}