Use an exponential backoff strategy for retrying rolled back transactions.
[pithos] / src / gr / ebs / gss / server / domain / UserClass.java
1 /*
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
3  *
4  * This file is part of GSS.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19 package gr.ebs.gss.server.domain;
20
21 import gr.ebs.gss.server.domain.dto.UserClassDTO;
22
23 import java.io.Serializable;
24 import java.util.List;
25
26 import javax.persistence.CascadeType;
27 import javax.persistence.Embedded;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.Id;
31 import javax.persistence.OneToMany;
32 import javax.persistence.Version;
33
34 /**
35  * A group of users with common attributes.
36  *
37  * @author droutsis
38  */
39 @Entity
40 public class UserClass  implements Serializable{
41
42         /**
43          * The persistence ID of the object.
44          */
45         @Id
46         @GeneratedValue
47         private Long id;
48
49         /**
50          * Version field for optimistic locking.
51          */
52         @SuppressWarnings("unused")
53         @Version
54         private int version;
55
56         /**
57          * The audit information.
58          */
59         @SuppressWarnings("unused")
60         @Embedded
61         private AuditInfo auditInfo;
62
63         /**
64          * A name for this class.
65          */
66         private String name;
67
68         /**
69          * The disk quota of this user class.
70          */
71         private long quota;
72
73         /**
74          * The users belonging to this class
75          */
76         @OneToMany(cascade = CascadeType.ALL, mappedBy = "userClass")
77         private List<User> users;
78
79         /*
80          * (non-Javadoc)
81          *
82          * @see java.lang.Object#toString()
83          */
84         @Override
85         public String toString() {
86                 return name;
87         }
88
89         /**
90          * Return a new Data Transfer Object for this user class.
91          *
92          * @return a new DTO with the same contents as this object
93          */
94         public UserClassDTO getDTO() {
95                 final UserClassDTO u = new UserClassDTO();
96                 u.setId(id);
97                 u.setName(name);
98                 u.setQuota(quota);
99                 for (final User user : users)
100                         u.getUsers().add(user.getDTO());
101                 return u;
102         }
103 }