2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.server.domain;
\r
21 import java.io.Serializable;
\r
22 import java.util.Date;
\r
24 import javax.persistence.Column;
\r
25 import javax.persistence.Entity;
\r
26 import javax.persistence.GeneratedValue;
\r
27 import javax.persistence.Id;
\r
28 import javax.persistence.JoinColumn;
\r
29 import javax.persistence.ManyToOne;
\r
30 import javax.persistence.Temporal;
\r
31 import javax.persistence.TemporalType;
\r
34 * This class holds information about bandwidth usage by users.
\r
35 * This information is broken down in time periods.
\r
38 public class AccountingInfo implements Serializable{
\r
41 * The persistence ID of the object.
\r
43 @SuppressWarnings("unused")
\r
49 * The user whose usage we are noting. We can never change it after
\r
53 @JoinColumn(updatable = false, nullable = false)
\r
57 * The start of the time period. We can never change it after
\r
60 @Temporal(TemporalType.TIMESTAMP)
\r
61 @Column(updatable = false, nullable = false)
\r
62 private Date dateFrom;
\r
66 * The end of the time period. We can never change it after
\r
69 @Temporal(TemporalType.TIMESTAMP)
\r
70 @Column(updatable = false, nullable = false)
\r
71 private Date dateTo;
\r
75 * The usage itself, in bytes.
\r
77 @Column(nullable = false)
\r
78 private long bandwidthUsed = 0;
\r
82 * Default constructor. Required by Hibernate,
\r
83 * but shouldn't be called.
\r
85 @SuppressWarnings("unused")
\r
86 private AccountingInfo() {
\r
93 public AccountingInfo(User _user, Date _dateFrom, Date _dateTo) {
\r
95 dateFrom = _dateFrom;
\r
101 * Retrieve the user
\r
104 public User getUser() {
\r
110 * Retrieve the start of the time period.
\r
111 * @return the start of the time period
\r
113 public Date getDateFrom() {
\r
119 * Retrieve the end of the time period.
\r
120 * @return the end of the time period
\r
122 public Date getDateTo() {
\r
128 * Retrieve the bandwidth used.
\r
129 * @return the bandwidth used
\r
131 public long getBandwidthUsed() {
\r
132 return bandwidthUsed;
\r
137 * Update bandwidth used upwards or downwards with new amount.
\r
138 * @param bandwidthDiff The amount by which to update;
\r
139 * positive for increase, negative for decrease.
\r
141 public void updateBandwidth(long bandwidthDiff) {
\r
142 bandwidthUsed += bandwidthDiff;
\r