2 * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.server.domain.dto;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
25 import com.google.gwt.i18n.client.NumberFormat;
28 * A group of users with common attributes.
32 public class UserClassDTO implements Serializable {
35 * The serial version UID of the class.
37 private static final long serialVersionUID = 1L;
40 * The persistence ID of the object.
45 * A name for this class.
50 * The disk quota of this user class.
55 * The users belonging to this class
58 private List<UserDTO> users = new ArrayList<UserDTO>();
60 private SystemStatsDTO statistics;
63 public String toString() {
79 * @param newId the id to set
81 public void setId(final Long newId) {
90 public String getName() {
97 * @param newName the name to set
99 public void setName(final String newName) {
104 * Retrieve the quota.
108 public long getQuota() {
115 * @param newQuota the quota to set
117 public void setQuota(final long newQuota) {
122 * Retrieve the users.
126 public List<UserDTO> getUsers() {
133 * @param newUsers the users to set
135 public void setUsers(final List<UserDTO> newUsers) {
140 * Retrieve the statistics.
142 * @return the statistics
144 public SystemStatsDTO getStatistics() {
149 * Modify the statistics.
151 * @param theStatistics the statistics to set
153 public void setStatistics(SystemStatsDTO theStatistics) {
154 statistics = theStatistics;
157 public String getQuotaAsString() {
159 return String.valueOf(quota) + " B";
160 else if (quota <= 1024*1024)
161 return getSize(quota, 1024D) + " KB";
162 else if (quota <= 1024*1024*1024)
163 return getSize(quota,(1024D*1024D)) + " MB";
164 return getSize(quota , (1024D*1024D*1024D)) + " GB";
167 private String getSize(Long size, Double divisor){
168 Double res = Double.valueOf(size.toString())/divisor;
169 NumberFormat nf = NumberFormat.getFormat("######.#");
170 return nf.format(res);