View Javadoc
1   /*
2    * The coLAB project
3    * Copyright (C) 2021-2023 AlbaSim, MEI, HEIG-VD, HES-SO
4    *
5    * Licensed under the MIT License
6    */
7   package ch.colabproject.colab.api.rest.project.bean;
8   
9   import ch.colabproject.colab.api.model.DuplicationParam;
10  import ch.colabproject.colab.api.model.common.Illustration;
11  import ch.colabproject.colab.api.model.project.ProjectType;
12  import ch.colabproject.colab.generator.model.annotations.ExtractJavaDoc;
13  import java.io.Serializable;
14  import java.util.ArrayList;
15  import java.util.List;
16  import org.apache.commons.lang3.builder.EqualsBuilder;
17  import org.apache.commons.lang3.builder.HashCodeBuilder;
18  
19  /**
20   * Bean with everything needed to create a project
21   *
22   * @author sandra
23   */
24  @ExtractJavaDoc
25  public class ProjectCreationData implements Serializable {
26  
27      private static final long serialVersionUID = 1L;
28  
29      // ---------------------------------------------------------------------------------------------
30      // fields
31      // ---------------------------------------------------------------------------------------------
32  
33      /**
34       * The kind : project or model
35       */
36      private ProjectType type;
37  
38      /**
39       * The name of the project
40       */
41      private String name;
42  
43      /**
44       * The description of the project
45       */
46      private String description;
47      
48      // no globalProject boolean since projects can't be initialised as global
49  
50      /**
51       * The icon to illustrate the project
52       */
53      private Illustration illustration;
54  
55      /**
56       * The project used as a base to create a new project
57       */
58      private Long baseProjectId;
59  
60      /**
61       * Duplication parameters to fine tune what is taken from baseProjectId
62       */
63      private DuplicationParam duplicationParam;
64  
65      /**
66       * The email address of the people we want to invite
67       */
68      private List<String> guestsEmail = new ArrayList<>();
69  
70      // ---------------------------------------------------------------------------------------------
71      // getters and setters
72      // ---------------------------------------------------------------------------------------------
73  
74      /**
75       * @return the kind : project or model
76       */
77      public ProjectType getType() {
78          return type;
79      }
80  
81      /**
82       * @param type the kind : project or model
83       */
84      public void setType(ProjectType type) {
85          this.type = type;
86      }
87  
88      /**
89       * @return the name of the project
90       */
91      public String getName() {
92          return name;
93      }
94  
95      /**
96       * @param name the name of the project
97       */
98      public void setName(String name) {
99          this.name = name;
100     }
101 
102     /**
103      * @return the description of the project
104      */
105     public String getDescription() {
106         return description;
107     }
108 
109     /**
110      * @param description the description of the project
111      */
112     public void setDescription(String description) {
113         this.description = description;
114     }
115 
116     /**
117      * @return the icon to illustrate the project
118      */
119     public Illustration getIllustration() {
120         return illustration;
121     }
122 
123     /**
124      * @param illustration the icon to illustrate the project
125      */
126     public void setIllustration(Illustration illustration) {
127         this.illustration = illustration;
128     }
129 
130     /**
131      * @return the project used as a base to create a new project
132      */
133     public Long getBaseProjectId() {
134         return baseProjectId;
135     }
136 
137     /**
138      * @param baseProjectId The project used as a base to create a new project
139      */
140     public void setBaseProjectId(Long baseProjectId) {
141         this.baseProjectId = baseProjectId;
142     }
143 
144     /**
145      * @return the duplication parameters to fine tune what is taken from baseProjectId
146      */
147     public DuplicationParam getDuplicationParam() {
148         return duplicationParam;
149     }
150 
151     /**
152      * @param duplicationParam the duplication parameters to fine tune what is taken from
153      *                         baseProjectId
154      */
155     public void setDuplicationParam(DuplicationParam duplicationParam) {
156         this.duplicationParam = duplicationParam;
157     }
158 
159     /**
160      * @return the email address of the people we want to invite
161      */
162     public List<String> getGuestsEmail() {
163         return guestsEmail;
164     }
165 
166     /**
167      * @param guestsEmail the email address of the people we want to invite
168      */
169     public void setGuestsEmail(List<String> guestsEmail) {
170         this.guestsEmail = guestsEmail;
171     }
172 
173     // ---------------------------------------------------------------------------------------------
174     // concerning the whole class
175     // ---------------------------------------------------------------------------------------------
176 
177     @Override
178     public int hashCode() {
179         return new HashCodeBuilder()
180             .append(this.type)
181             .append(this.name)
182             .append(this.description)
183             .append(this.illustration)
184             .append(this.baseProjectId)
185             .append(this.duplicationParam)
186             .toHashCode();
187     }
188 
189     @Override
190     public boolean equals(Object obj) {
191         if (this == obj) {
192             return true;
193         }
194         if (obj == null) {
195             return false;
196         }
197         if (getClass() != obj.getClass()) {
198             return false;
199         }
200         final ProjectCreationData other = (ProjectCreationData) obj;
201         return new EqualsBuilder()
202             .append(this.type, other.type)
203             .append(this.name, other.name)
204             .append(this.description, other.description)
205             .append(this.illustration, other.illustration)
206             .append(this.baseProjectId, other.baseProjectId)
207             .append(this.duplicationParam, other.duplicationParam)
208             .isEquals();
209     }
210 
211     @Override
212     public String toString() {
213         return "ProjectCreationData{" + " type=" + type.name() + ", name=" + name + ", description="
214             + description
215             + ", illustration=" + illustration
216             + ", baseProjectId=" + baseProjectId + ", duplicationParam=" + duplicationParam
217             + ", guestsEmail=" + guestsEmail + "}";
218     }
219 
220 }