/*
- * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
+ * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
*
* This file is part of GSS.
*
import java.util.ArrayList;
import java.util.List;
+import com.google.gwt.i18n.client.NumberFormat;
+
/**
* A group of users with common attributes.
*
*/
private List<UserDTO> users = new ArrayList<UserDTO>();
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
+ private SystemStatsDTO statistics;
+
+ @Override
public String toString() {
return name;
}
public void setUsers(final List<UserDTO> newUsers) {
users = newUsers;
}
+
+ /**
+ * Retrieve the statistics.
+ *
+ * @return the statistics
+ */
+ public SystemStatsDTO getStatistics() {
+ return statistics;
+ }
+
+ /**
+ * Modify the statistics.
+ *
+ * @param theStatistics the statistics to set
+ */
+ public void setStatistics(SystemStatsDTO theStatistics) {
+ statistics = theStatistics;
+ }
+
+ public String getQuotaAsString() {
+ if (quota < 1024)
+ return String.valueOf(quota) + " B";
+ else if (quota <= 1024*1024)
+ return getSize(quota, 1024D) + " KB";
+ else if (quota <= 1024*1024*1024)
+ return getSize(quota,(1024D*1024D)) + " MB";
+ return getSize(quota , (1024D*1024D*1024D)) + " GB";
+ }
+
+ private String getSize(Long size, Double divisor){
+ Double res = Double.valueOf(size.toString())/divisor;
+ NumberFormat nf = NumberFormat.getFormat("######.#");
+ return nf.format(res);
+ }
}