DiversityTreeCreator.java

/*
 * Copyright 2020 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.impl;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.genesys.blocks.model.UuidModel;

/**
 * The Class DiversityTreeCreator.
 *
 * @author Maxym Borodenko
 */
@Entity
@Table(name="diversitytree_creator")
@Getter
@Setter
public class DiversityTreeCreator extends UuidModel {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -2810380670804909368L;

	/**
	 * The Enum DiversityTreeCreatorRole.
	 */
	public enum DiversityTreeCreatorRole {

		/** Data manager: Responsible of the planning and execution of the germplasm characterization and evaluation activity which resulted in the subset. Oversees the collection and management of characterization and evaluation data, and has final sign-off on publication. */
		MANAGER,

		/** Data collector: Records germplasm characterization or evaluation data in the field. */
		COLLECTOR,

		/** Data digitizer: Digitizes data. */
		DIGITIZER,

		/** Data curator: Organizes and validates data and metadata in correct format, ensures quality of both. */
		CURATOR,

		/** Data contributor */
		CONTRIBUTOR
	}

	/** The full name. */
	@NotNull
	@Size(max = 200)
	@Column(length = 200, nullable = false)
	private String fullName;

	/** The email. */
	private String email;

	/** The phone number. */
	private String phoneNumber;

	/** The fax. */
	private String fax;

	/** The institutional affiliation. */
	private String institutionalAffiliation;

	/** The institute address. */
	private String instituteAddress;

	/** The role. */
	@Enumerated(EnumType.STRING)
	private DiversityTreeCreatorRole role;

	/** The DiversityTree. */
	@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.DETACH }, optional = false, fetch = FetchType.EAGER)
	@JoinColumn(name = "diversitytreeId")
	@JsonIgnore
	private DiversityTree diversityTree;
	
	@Override
	public boolean canEqual(Object other) {
		return other instanceof DiversityTreeCreator;
	}
}