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  import java.util.ArrayList;
28  import java.util.List;
29  
30  /**
31   * DTO that contains anonymous statistic data of an adopter.
32   */
33  public class StatisticData {
34  
35    /** JSON parser */
36    private static final Gson gson = new Gson();
37  
38    //================================================================================
39    // Properties
40    //================================================================================
41  
42    /**
43     * A key that's unique for every adopter.
44     *
45     * Every adopter has his own statistic key, so when the data of different adopters will be
46     * collected, we can use this as an ID and identify every statistic data entry
47     * later on to update existing entries in the database.
48     * We don't use the adopter key from {@link GeneralData} at this point,
49     * because we are not allowed to associate the statistic data with the adopter.
50     */
51    @SerializedName("statistic_key")
52    private String statisticKey;
53  
54    @SerializedName("adopter_key")
55    private String adopterKey;
56  
57    /** The total number of jobs. */
58    @SerializedName("job_count")
59    private long jobCount;
60  
61    /** The total number of events. */
62    @SerializedName("event_count")
63    private long eventCount;
64  
65    /** The total number of series. */
66    @SerializedName("series_count")
67    private int seriesCount;
68  
69    /** The total number of users. */
70    @SerializedName("user_count")
71    private long userCount;
72  
73    @SerializedName("ca_count")
74    private long caCount;
75  
76    @SerializedName("total_minutes")
77    private long totalMinutes;
78  
79    @SerializedName("tenant_count")
80    private int tenantCount;
81  
82    /** The hosts of an adopter.*/
83    private List<Host> hosts;
84  
85    /** The Opencast version */
86    private String version;
87  
88    //================================================================================
89    // Methods
90    //================================================================================
91  
92    /**
93     * A StatisticData instance should always have a unique key.
94     * @param statisticKey The unique key that identifies a statistic entry.
95     */
96    public StatisticData(String statisticKey) {
97      this.statisticKey = statisticKey;
98    }
99  
100   /**
101    * Parses an instance of this class to a JSON string.
102    * @return The instance as JSON string.
103    */
104   public String jsonify() {
105     return gson.toJson(this);
106   }
107 
108 
109   //================================================================================
110   // Getter and Setter
111   //================================================================================
112 
113   public String getStatisticKey() {
114     return statisticKey;
115   }
116 
117   public void setStatisticKey(String statisticKey) {
118     this.statisticKey = statisticKey;
119   }
120 
121   public String getAdopterKey() {
122     return adopterKey;
123   }
124 
125   public void setAdopterKey(String adopterKey) {
126     this.adopterKey = adopterKey;
127   }
128 
129   public long getJobCount() {
130     return jobCount;
131   }
132 
133   public void setJobCount(long jobCount) {
134     this.jobCount = jobCount;
135   }
136 
137   public long getEventCount() {
138     return eventCount;
139   }
140 
141   public void setEventCount(long eventCount) {
142     this.eventCount = eventCount;
143   }
144 
145   public int getSeriesCount() {
146     return seriesCount;
147   }
148 
149   public void setSeriesCount(int seriesCount) {
150     this.seriesCount = seriesCount;
151   }
152 
153   public long getUserCount() {
154     return userCount;
155   }
156 
157   public void setUserCount(long userCount) {
158     this.userCount = userCount;
159   }
160 
161   public long getCACount() {
162     return caCount;
163   }
164 
165   public void setCACount(long caCount) {
166     this.caCount = caCount;
167   }
168 
169   public long getTotalMinutes() {
170     return totalMinutes;
171   }
172 
173   public void setTotalMinutes(long totalMinutes) {
174     this.totalMinutes = totalMinutes;
175   }
176 
177   public List<Host> getHosts() {
178     return hosts;
179   }
180 
181   public void setHosts(List<Host> hosts) {
182     this.hosts = hosts;
183   }
184 
185   public int getTenantCount() {
186     return tenantCount;
187   }
188 
189   public void setTenantCount(int tenantCount) {
190     this.tenantCount = tenantCount;
191   }
192 
193   public void addHost(Host host) {
194     if (this.hosts == null) {
195       this.hosts = new ArrayList<>();
196     }
197     this.hosts.add(host);
198   }
199 
200   public void setVersion(String version) {
201     this.version = version;
202   }
203 
204   public String getVersion() {
205     return version;
206   }
207 }