Revision 623:66f69a7348ed src/gr/ebs/gss/server/domain/dto/UserClassDTO.java
b/src/gr/ebs/gss/server/domain/dto/UserClassDTO.java | ||
---|---|---|
1 | 1 |
/* |
2 |
* Copyright 2007, 2008, 2009 Electronic Business Systems Ltd. |
|
2 |
* Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
|
|
3 | 3 |
* |
4 | 4 |
* This file is part of GSS. |
5 | 5 |
* |
... | ... | |
22 | 22 |
import java.util.ArrayList; |
23 | 23 |
import java.util.List; |
24 | 24 |
|
25 |
import com.google.gwt.i18n.client.NumberFormat; |
|
26 |
|
|
25 | 27 |
/** |
26 | 28 |
* A group of users with common attributes. |
27 | 29 |
* |
... | ... | |
55 | 57 |
*/ |
56 | 58 |
private List<UserDTO> users = new ArrayList<UserDTO>(); |
57 | 59 |
|
60 |
private SystemStatsDTO statistics; |
|
61 |
|
|
58 | 62 |
@Override |
59 | 63 |
public String toString() { |
60 | 64 |
return name; |
... | ... | |
131 | 135 |
public void setUsers(final List<UserDTO> newUsers) { |
132 | 136 |
users = newUsers; |
133 | 137 |
} |
138 |
|
|
139 |
/** |
|
140 |
* Retrieve the statistics. |
|
141 |
* |
|
142 |
* @return the statistics |
|
143 |
*/ |
|
144 |
public SystemStatsDTO getStatistics() { |
|
145 |
return statistics; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Modify the statistics. |
|
150 |
* |
|
151 |
* @param theStatistics the statistics to set |
|
152 |
*/ |
|
153 |
public void setStatistics(SystemStatsDTO theStatistics) { |
|
154 |
statistics = theStatistics; |
|
155 |
} |
|
156 |
|
|
157 |
public String getQuotaAsString() { |
|
158 |
if (quota < 1024) |
|
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"; |
|
165 |
} |
|
166 |
|
|
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); |
|
171 |
} |
|
134 | 172 |
} |
Also available in: Unified diff