Author.java

/*
 * Copyright 2024 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.bib;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import org.genesys.custom.elasticsearch.SearchField;
import org.genesys.spring.validation.javax.SimpleString;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Embeddable // This is not a standalone entity
@Getter
@Setter
@NoArgsConstructor
public class Author {

	public Author(String lastName, String otherNames) {
		this.lastName = lastName;
		this.otherNames = otherNames;
	}

	@Basic
	@Size(min = 1, max = 200)
	@Column(length = 200, nullable = false)
	@SimpleString
	@NotBlank
	@SearchField
	private String lastName;

	@Basic
	@Size(max = 200)
	@Column(length = 200)
	@SimpleString
	@SearchField
	private String otherNames;

	// /**
	//  * ORCID
	//  * @see https://support.orcid.org/hc/en-us/articles/360006897674-Structure-of-the-ORCID-Identifier
	//  */
	// @Basic
	// @Column(length = 16+3, unique = true)
	// @Pattern(message = "Invalid ORCID", regexp = "^\\d{4}\\-\\d{4}\\-\\d{4}\\-\\d{4}$")
	// private String orcid;


	// /**
	//  * The ORCID iD is expressed as an https URI, i.e. the 16-digit identifier is preceded by "https://orcid.org/". A hyphen is inserted every 4 digits of the identifier to aid readability.
	//  */
	// public String getORCIDid() {
	// 	return this.orcid == null ? null : "https://orcid.org/" + this.orcid;
	// }
}