SysTableField.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.List;

import javax.persistence.*;

import org.genesys.blocks.model.Copyable;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
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;

/**
 * Auto-generated by:
 * org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
 */
@Entity
@Cacheable
@Table(name = "sys_table_field")
@JsonIdentityInfo(scope = SysTableField.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Getter
@Setter
@NoArgsConstructor
public class SysTableField extends TranslatedCooperatorOwnedModel<SysTableFieldLang, SysTableField> implements Copyable<SysTableField> {

	private static final long serialVersionUID = 7490017363491681472L;

	@Id
	@JsonProperty
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "sys_table_field_id", columnDefinition = "int")
	private Long id;

	@Basic
	@Column(name = "default_value", length = 50)
	private String defaultValue;

	@Basic
	@Column(name = "field_name", nullable = false, length = 50)
	private String fieldName;

	@Basic
	@Column(name = "field_ordinal")
	private Integer fieldOrdinal;

	@Basic
	@Column(name = "field_purpose", nullable = false, length = 50)
	private String fieldPurpose;

	@Basic
	@Column(name = "field_type", nullable = false, length = 50)
	private String fieldType;

	@Basic
	@Column(name = "foreign_key_dataview_name", length = 100)
	private String foreignKeyDataviewName;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "foreign_key_table_field_id")
	private SysTableField foreignKeyTableField;

	@Basic
	@Column(name = "group_name", length = 100)
	private String groupName;

	@Basic
	@Column(name = "gui_hint", nullable = false, length = 50)
	private String guiHint;

	@Basic
	@Column(name = "is_autoincrement", nullable = false, length = 1)
	private String isAutoincrement = "N";

	@Basic
	@Column(name = "is_foreign_key", nullable = false, length = 1)
	private String isForeignKey = "N";

	@Basic
	@Column(name = "is_nullable", nullable = false, length = 1)
	private String isNullable = "N";

	@Basic
	@Column(name = "is_primary_key", nullable = false, length = 1)
	private String isPrimaryKey = "N";

	@Basic
	@Column(name = "is_readonly", nullable = false, length = 1)
	private String isReadonly = "N";

	@Basic
	@Column(name = "max_length")
	private int maxLength;

	@Basic
	@Column(name = "min_length")
	private int minLength;

	@Basic
	@Column(name = "numeric_precision")
	private int numericPrecision;

	@Basic
	@Column(name = "numeric_scale")
	private int numericScale;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "sys_table_id", nullable = false)
	@JsonIdentityReference(alwaysAsId = true)
	@JsonIdentityInfo(scope = SysTable.class, property = "tableName", generator = ObjectIdGenerators.PropertyGenerator.class)
	private SysTable table;

	@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, mappedBy = "entity")
	@JsonIgnore
	private List<SysTableFieldLang> langs;

	@Transient
	private String propertyName; // Populated from object model

	public SysTableField(final Long id) {
		this.id = id;
	}

	@Override
	public boolean canEqual(Object other) {
		return other instanceof SysTableField;
	}
}