001/* 002 * Copyright 2020 Global Biodiversity Information Facility (GBIF) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.gbif.api.model.registry.eml; 017 018import org.gbif.api.model.registry.Contact; 019 020import java.io.Serializable; 021import java.util.LinkedList; 022import java.util.List; 023import java.util.Objects; 024import java.util.StringJoiner; 025 026import javax.annotation.Nullable; 027 028/** 029 * A dataset can be part of a project. A project can have a unique identifier, used to link datasets associated with 030 * the same project. 031 */ 032public class Project implements Serializable { 033 034 private static final long serialVersionUID = -2625204169061362016L; 035 036 private String title; 037 // TODO: enable searching datasets by their project identifier: http://dev.gbif.org/issues/browse/POR-3129 038 private String identifier; 039 private String description; 040 041 private List<Contact> contacts; 042 private String abstract_; 043 private String funding; 044 private String studyAreaDescription; 045 private String designDescription; 046 047 public Project() { 048 } 049 050 public Project( 051 String title, String identifier, List<Contact> contacts, String abstract_, String funding, 052 String studyAreaDescription, String designDescription) { 053 this.title = title; 054 this.identifier = identifier; 055 this.contacts = contacts; 056 this.abstract_ = abstract_; 057 this.funding = funding; 058 this.studyAreaDescription = studyAreaDescription; 059 this.designDescription = designDescription; 060 } 061 062 public String getAbstract() { 063 return abstract_; 064 } 065 066 public void setAbstract(String abstract_) { 067 this.abstract_ = abstract_; 068 } 069 070 public List<Contact> getContacts() { 071 return contacts; 072 } 073 074 public void setContacts(List<Contact> contacts) { 075 this.contacts = contacts; 076 } 077 078 public String getDesignDescription() { 079 return designDescription; 080 } 081 082 public void setDesignDescription(String designDescription) { 083 this.designDescription = designDescription; 084 } 085 086 public String getFunding() { 087 return funding; 088 } 089 090 public void setFunding(String funding) { 091 this.funding = funding; 092 } 093 094 public String getStudyAreaDescription() { 095 return studyAreaDescription; 096 } 097 098 public void setStudyAreaDescription(String studyAreaDescription) { 099 this.studyAreaDescription = studyAreaDescription; 100 } 101 102 public String getTitle() { 103 return title; 104 } 105 106 public void setTitle(String title) { 107 this.title = title; 108 } 109 110 /** 111 * A unique identifier for the project. Used to link multiple datasets associated with the same project. 112 * 113 * @return the unique identifier for the project 114 */ 115 @Nullable 116 public String getIdentifier() { 117 return identifier; 118 } 119 120 public void setIdentifier(String identifier) { 121 this.identifier = identifier; 122 } 123 124 public String getDescription() { 125 return description; 126 } 127 128 public void setDescription(String description) { 129 this.description = description; 130 } 131 132 /** 133 * Add contact to Contact List. 134 */ 135 public void addContact(Contact contact) { 136 if (contacts == null) { 137 contacts = new LinkedList<Contact>(); 138 } 139 contacts.add(contact); 140 } 141 142 @Override 143 public boolean equals(Object o) { 144 if (this == o) { 145 return true; 146 } 147 if (o == null || getClass() != o.getClass()) { 148 return false; 149 } 150 Project project = (Project) o; 151 return Objects.equals(title, project.title) && 152 Objects.equals(identifier, project.identifier) && 153 Objects.equals(description, project.description) && 154 Objects.equals(contacts, project.contacts) && 155 Objects.equals(abstract_, project.abstract_) && 156 Objects.equals(funding, project.funding) && 157 Objects.equals(studyAreaDescription, project.studyAreaDescription) && 158 Objects.equals(designDescription, project.designDescription); 159 } 160 161 @Override 162 public int hashCode() { 163 return Objects 164 .hash(title, identifier, description, contacts, abstract_, funding, studyAreaDescription, 165 designDescription); 166 } 167 168 @Override 169 public String toString() { 170 return new StringJoiner(", ", Project.class.getSimpleName() + "[", "]") 171 .add("title='" + title + "'") 172 .add("identifier='" + identifier + "'") 173 .add("description='" + description + "'") 174 .add("contacts=" + contacts) 175 .add("abstract_='" + abstract_ + "'") 176 .add("funding='" + funding + "'") 177 .add("studyAreaDescription='" + studyAreaDescription + "'") 178 .add("designDescription='" + designDescription + "'") 179 .toString(); 180 } 181}