001/*
002 * Copyright 2014 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;
023
024import javax.annotation.Nullable;
025
026import com.google.common.base.Objects;
027
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 */
033public class Project implements Serializable {
034
035  private static final long serialVersionUID = -2625204169061362016L;
036
037  private String title;
038  // TODO: enable searching datasets by their project identifier: http://dev.gbif.org/issues/browse/POR-3129
039  private String identifier;
040  private String description;
041
042  private List<Contact> contacts;
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 funding, String studyAreaDescription,
052    String designDescription) {
053    this.title = title;
054    this.identifier = identifier;
055    this.contacts = contacts;
056    this.funding = funding;
057    this.studyAreaDescription = studyAreaDescription;
058    this.designDescription = designDescription;
059  }
060
061  public List<Contact> getContacts() {
062    return contacts;
063  }
064
065  public void setContacts(List<Contact> contacts) {
066    this.contacts = contacts;
067  }
068
069  public String getDesignDescription() {
070    return designDescription;
071  }
072
073  public void setDesignDescription(String designDescription) {
074    this.designDescription = designDescription;
075  }
076
077  public String getFunding() {
078    return funding;
079  }
080
081  public void setFunding(String funding) {
082    this.funding = funding;
083  }
084
085  public String getStudyAreaDescription() {
086    return studyAreaDescription;
087  }
088
089  public void setStudyAreaDescription(String studyAreaDescription) {
090    this.studyAreaDescription = studyAreaDescription;
091  }
092
093  public String getTitle() {
094    return title;
095  }
096
097  public void setTitle(String title) {
098    this.title = title;
099  }
100
101  /**
102   * A unique identifier for the project. Used to link multiple datasets associated with the same project.
103   *
104   * @return the unique identifier for the project
105   */
106  @Nullable
107  public String getIdentifier() {
108    return identifier;
109  }
110
111  public void setIdentifier(String identifier) {
112    this.identifier = identifier;
113  }
114
115  public String getDescription() {
116    return description;
117  }
118
119  public void setDescription(String description) {
120    this.description = description;
121  }
122
123  /**
124   * Add contact to Contact List.
125   */
126  public void addContact(Contact contact) {
127    if (contacts == null) {
128      contacts = new LinkedList<Contact>();
129    }
130    contacts.add(contact);
131  }
132
133  @Override
134  public boolean equals(Object obj) {
135    if (this == obj) {
136      return true;
137    }
138    if (!(obj instanceof Project)) {
139      return false;
140    }
141
142    Project that = (Project) obj;
143    return Objects.equal(this.title, that.title)
144           && Objects.equal(this.identifier, that.identifier)
145           && Objects.equal(this.description, that.description)
146           && Objects.equal(this.contacts, that.contacts)
147           && Objects.equal(this.funding, that.funding)
148           && Objects.equal(this.studyAreaDescription, that.studyAreaDescription)
149           && Objects.equal(this.designDescription, that.designDescription);
150  }
151
152  @Override
153  public int hashCode() {
154    return Objects.hashCode(title, identifier, contacts, funding, studyAreaDescription, designDescription);
155  }
156
157  @Override
158  public String toString() {
159    return Objects.toStringHelper(this)
160      .add("title", title)
161      .add("identifier", identifier)
162      .add("description", description)
163      .add("contacts", contacts)
164      .add("funding", funding)
165      .add("studyAreaDescription", studyAreaDescription)
166      .add("designDescription", designDescription)
167      .toString();
168  }
169
170}