DatasetCreator.java

/*
 * Copyright 2017 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.dataset;

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 lombok.Getter;
import lombok.Setter;
import org.genesys.blocks.model.UuidModel;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * The Class DatasetCreator.
 *
 * @author Andrey Lugovskoy.
 */
@Entity
@Table(name="dataset_creator")
@Getter
@Setter
public class DatasetCreator extends UuidModel {

	/**
	 *
	 */
	private static final long serialVersionUID = -4720879830778959498L;

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

		/** Data manager: Responsible of the planning and execution of the germplasm characterization and evaluation activity which resulted in the dataset. 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
	}

	/** 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 DatasetCreatorRole role;

	/** The dataset. */
	@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.DETACH }, optional = false, fetch = FetchType.LAZY)
	@JoinColumn(name = "datasetId")
	@JsonIgnore
	private Dataset dataset;

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