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.ArrayList;
022import java.util.LinkedList;
023import java.util.List;
024import java.util.Objects;
025import java.util.StringJoiner;
026
027import javax.annotation.Nullable;
028
029/**
030 * A dataset can be part of a project. A project can have a unique identifier, used to link datasets associated with
031 * the same project.
032 */
033@SuppressWarnings({"unused", "LombokSetterMayBeUsed", "LombokGetterMayBeUsed"})
034public class Project implements Serializable {
035
036  private static final long serialVersionUID = -2625204169061362016L;
037
038  private String title;
039  // TODO: enable searching datasets by their project identifier: http://dev.gbif.org/issues/browse/POR-3129
040  private String identifier;
041  private String description;
042
043  private List<Contact> contacts;
044  private String abstract_;
045  private String funding;
046  private List<ProjectAward> awards = new ArrayList<>();
047  private String studyAreaDescription;
048  private String designDescription;
049  private List<RelatedProject> relatedProjects = new ArrayList<>();
050
051  public Project() {
052  }
053
054  public Project(
055    String title, String identifier, List<Contact> contacts, String abstract_, String funding,
056    String studyAreaDescription, String designDescription) {
057    this.title = title;
058    this.identifier = identifier;
059    this.contacts = contacts;
060    this.abstract_ = abstract_;
061    this.funding = funding;
062    this.studyAreaDescription = studyAreaDescription;
063    this.designDescription = designDescription;
064  }
065
066  public String getAbstract() {
067    return abstract_;
068  }
069
070  public void setAbstract(String abstract_) {
071    this.abstract_ = abstract_;
072  }
073
074  public List<Contact> getContacts() {
075    return contacts;
076  }
077
078  public void setContacts(List<Contact> contacts) {
079    this.contacts = contacts;
080  }
081
082  public String getDesignDescription() {
083    return designDescription;
084  }
085
086  public void setDesignDescription(String designDescription) {
087    this.designDescription = designDescription;
088  }
089
090  public String getFunding() {
091    return funding;
092  }
093
094  public void setFunding(String funding) {
095    this.funding = funding;
096  }
097
098  public List<ProjectAward> getAwards() {
099    return awards;
100  }
101
102  public void setAwards(List<ProjectAward> awards) {
103    this.awards = awards;
104  }
105
106  public void addAward(ProjectAward award) {
107    this.awards.add(award);
108  }
109
110  public String getStudyAreaDescription() {
111    return studyAreaDescription;
112  }
113
114  public void setStudyAreaDescription(String studyAreaDescription) {
115    this.studyAreaDescription = studyAreaDescription;
116  }
117
118  public String getTitle() {
119    return title;
120  }
121
122  public void setTitle(String title) {
123    this.title = title;
124  }
125
126  /**
127   * A unique identifier for the project. Used to link multiple datasets associated with the same project.
128   *
129   * @return the unique identifier for the project
130   */
131  @Nullable
132  public String getIdentifier() {
133    return identifier;
134  }
135
136  public void setIdentifier(String identifier) {
137    this.identifier = identifier;
138  }
139
140  public String getDescription() {
141    return description;
142  }
143
144  public void setDescription(String description) {
145    this.description = description;
146  }
147
148  public List<RelatedProject> getRelatedProjects() {
149    return relatedProjects;
150  }
151
152  public void setRelatedProjects(List<RelatedProject> relatedProjects) {
153    this.relatedProjects = relatedProjects;
154  }
155
156  public void addRelatedProject(RelatedProject relatedProject) {
157    this.relatedProjects.add(relatedProject);
158  }
159
160  /**
161   * Add contact to Contact List.
162   */
163  public void addContact(Contact contact) {
164    if (contacts == null) {
165      contacts = new LinkedList<>();
166    }
167    contacts.add(contact);
168  }
169
170  @Override
171  public boolean equals(Object o) {
172    if (this == o) {
173      return true;
174    }
175    if (o == null || getClass() != o.getClass()) {
176      return false;
177    }
178    Project project = (Project) o;
179    return Objects.equals(title, project.title) &&
180      Objects.equals(identifier, project.identifier) &&
181      Objects.equals(description, project.description) &&
182      Objects.equals(contacts, project.contacts) &&
183      Objects.equals(abstract_, project.abstract_) &&
184      Objects.equals(funding, project.funding) &&
185      Objects.equals(awards, project.awards) &&
186      Objects.equals(studyAreaDescription, project.studyAreaDescription) &&
187      Objects.equals(designDescription, project.designDescription) &&
188      Objects.equals(relatedProjects, project.relatedProjects);
189  }
190
191  @Override
192  public int hashCode() {
193    return Objects
194      .hash(title, identifier, description, contacts, abstract_, funding, awards, studyAreaDescription,
195        designDescription, relatedProjects);
196  }
197
198  @Override
199  public String toString() {
200    return new StringJoiner(", ", Project.class.getSimpleName() + "[", "]")
201        .add("title='" + title + "'")
202        .add("identifier='" + identifier + "'")
203        .add("description='" + description + "'")
204        .add("contacts=" + contacts)
205        .add("abstract_='" + abstract_ + "'")
206        .add("funding='" + funding + "'")
207        .add("awards=" + awards)
208        .add("studyAreaDescription='" + studyAreaDescription + "'")
209        .add("designDescription='" + designDescription + "'")
210        .add("relatedProjects=" + relatedProjects)
211        .toString();
212  }
213}