View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.adopter.registration.dto;
23  
24  import com.google.gson.Gson;
25  import com.google.gson.annotations.SerializedName;
26  
27  /**
28   * DTO for the general data of an adopter.
29   */
30  public class GeneralData {
31  
32    /** JSON parser */
33    private static final Gson gson = new Gson();
34  
35    //================================================================================
36    // Properties
37    //================================================================================
38  
39    /** The unique identification key for an adopter. */
40    @SerializedName("adopter_key")
41    private String adopterKey;
42  
43    /** The organisation of the adopter. */
44    @SerializedName("organisation_name")
45    private final String organisationName;
46  
47    /** Department name of the adopter. */
48    @SerializedName("department_name")
49    private final String departmentName;
50  
51    /** The first name of the adopter. */
52    @SerializedName("first_name")
53    private final String firstName;
54  
55    /** The last name of the adopter. */
56    @SerializedName("last_name")
57    private final String lastName;
58  
59    /** Organization country. */
60    private final String country;
61  
62    /** Organization city. */
63    private final String city;
64  
65    /** Organization postal code. */
66    @SerializedName("postal_code")
67    private final String postalCode;
68  
69    /** Organization street name. */
70    private final String street;
71  
72    /** Organization street number. */
73    @SerializedName("street_no")
74    private final String streetNo;
75  
76    /** The E-Mail address of the adopter. */
77    private final String email;
78  
79    /** Whether we can contact the adopter */
80    @SerializedName("contact_me")
81    private final boolean allowContact;
82  
83    /** Which type of system is this */
84    @SerializedName("system_type")
85    private final String systemType;
86  
87    /** Whether we can send error reports */
88    @SerializedName("send_errors")
89    private final boolean allowErrorReports;
90  
91    /** Whether we can contact statistics */
92    @SerializedName("send_usage")
93    private final boolean allowStatistics;
94  
95  
96    //================================================================================
97    // Constructor and Methods
98    //================================================================================
99  
100   public GeneralData(Adopter adopter) {
101     this.adopterKey = adopter.getAdopterKey();
102     this.organisationName = adopter.getOrganisationName();
103     this.departmentName = adopter.getDepartmentName();
104     this.firstName = adopter.getFirstName();
105     this.lastName = adopter.getLastName();
106     this.country = adopter.getCountry();
107     this.city = adopter.getCity();
108     this.postalCode = adopter.getPostalCode();
109     this.street = adopter.getStreet();
110     this.streetNo = adopter.getStreetNo();
111     this.email = adopter.getEmail();
112     this.allowContact = adopter.allowsContacting();
113     this.systemType = adopter.systemType();
114     this.allowErrorReports = adopter.allowsErrorReports();
115     this.allowStatistics = adopter.allowsStatistics();
116   }
117 
118   /**
119    * Creates a JSON string from an instance of this class.
120    * @return This class as a JSON string.
121    */
122   public String jsonify() {
123     return gson.toJson(this);
124   }
125 
126 
127   //================================================================================
128   // Getter and Setter
129   //================================================================================
130 
131   public String getAdopterKey() {
132     return adopterKey;
133   }
134 
135   public void setAdopterKey(String key) {
136     this.adopterKey = key;
137   }
138 
139   public String getOrganisationName() {
140     return organisationName;
141   }
142 
143   public String getDepartmentName() {
144     return departmentName;
145   }
146 
147   public String getFirstName() {
148     return firstName;
149   }
150 
151   public String getLastName() {
152     return lastName;
153   }
154 
155   public String getCountry() {
156     return country;
157   }
158 
159   public String getCity() {
160     return city;
161   }
162 
163   public String getPostalCode() {
164     return postalCode;
165   }
166 
167   public String getStreet() {
168     return street;
169   }
170 
171   public String getStreetNo() {
172     return streetNo;
173   }
174 
175   public String getEmail() {
176     return email;
177   }
178 
179   public String getContactMe() {
180     return Boolean.toString(allowContact);
181   }
182 
183   public String getSystemType() {
184     return systemType;
185   }
186 
187   public String getErrorReports() {
188     return Boolean.toString(allowErrorReports);
189   }
190 
191   public String getStatisticss() {
192     return Boolean.toString(allowStatistics);
193   }
194 }