Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
7   139   7   2.33
4   34   1   3
3     2.33  
1    
 
 
  PermissionType       Line # 8 7 7 0% 0.0
 
No Tests
 
1    package org.itracker.model;
2   
3    /**
4    * Enumeration for permission types.
5    *
6    * @author johnny
7    */
 
8    public enum PermissionType {
9   
10    /**
11    * User Admin Permission.
12    * Currently this is equivalent to super user, since the permission can't be granted,
13    * and is only available to an admin.
14    */
15    USER_ADMIN(-1),
16   
17    /** Product Admin Permission */
18    PRODUCT_ADMIN(1),
19   
20    /** Issue Create Permission */
21    ISSUE_CREATE(2),
22   
23    /**
24    * Issue Edit Permission.
25    * Users with this permission can edit any issue in the project.
26    */
27    ISSUE_EDIT_ALL(3),
28   
29    /**
30    * Issue Close Permission.
31    * Users with this permission can close issues in the project.
32    */
33    ISSUE_CLOSE(4),
34   
35    /**
36    * Issue Assign to Self Permission.
37    * Users with this permission can assign issues to themselves.
38    */
39    ISSUE_ASSIGN_SELF(5),
40   
41    /**
42    * Issue Assign to Others Permissions.
43    * Users with this permission can assign issues to anyone,
44    * given than those users have the ability to recieve the assignment.
45    */
46    ISSUE_ASSIGN_OTHERS(6),
47   
48    /** View All Issues Permission. Users can view all issues in the project. */
49    ISSUE_VIEW_ALL(7),
50   
51    /**
52    * View Users Issues Permission. Users can view thier own issues.
53    * This includes ones they are the creator or owner of.
54    */
55    ISSUE_VIEW_USERS(8),
56   
57    /**
58    * Edit Users Issues Permission.
59    * Users with this permission can edit any issue they created or own.
60    * They are limited to editing the description, adding history entries,
61    * and adding attachments.
62    */
63    ISSUE_EDIT_USERS(9),
64   
65    /**
66    * Issue Unassign Self Permission.
67    * Users with this permission can unassign issues they own.
68    */
69    ISSUE_UNASSIGN_SELF(10),
70   
71    /**
72    * Issue Assignable.
73    * Users with this permission can be assigned any issue in the system.
74    * To determine if a user can be assigned an issue,
75    * it will be a combination of users with EDIT_ALL,
76    * users with EDIT_USERS if they are the creator,
77    * and users with this permission and EDIT_USERS.
78    */
79    ISSUE_ASSIGNABLE(11),
80   
81    /**
82    * Create for Others.
83    * Users with this permission are allowed to create issues on behalf of other users.
84    * The system will treat the issue as if the other user had created it.
85    * The actual creator will be logged in the audit log.
86    */
87    ISSUE_CREATE_OTHERS(12),
88   
89    /**
90    * Full edit permission.
91    * This defines what levelof editing a user has for an issue.
92    * Without this permission, users will
93    * be limited to editing only the description, attachments, custom fields,
94    * and history of an issue.
95    */
96    ISSUE_EDIT_FULL(13);
97   
98    /* The project value matches the enum order (except for USER_ADMIN which is at position 0) */
99    private static final PermissionType[] PERMISSION_TYPES = values();
100   
101    /** The integer value of this enum member. */
102    private final int code;
103   
104    /**
105    * Creates a new instance of this enum.
106    *
107    * @param value unique value representing this instance
108    */
 
109  0 toggle private PermissionType(int code) {
110  0 this.code = code;
111    }
112   
113    /**
114    * Returns the integer value representing this enum member.
115    *
116    * @return unique value representing this instance
117    */
 
118  0 toggle public int getCode() {
119  0 return code;
120    }
121   
122    /**
123    * Returns the enum instance matching the integer value.
124    *
125    * @param value unique value of the enum instance to return
126    * @return enum instance matching the int value
127    * @throws IllegalArgumentExeption invalid enum value
128    */
 
129  0 toggle public static PermissionType fromCode(int code) {
130  0 if (code == 0 || code < -1 || code > 13) {
131  0 throw new IllegalArgumentException("Unknown PermissionType code " + code);
132    }
133  0 if (code == -1) {
134  0 return PERMISSION_TYPES[0];
135    }
136  0 return PERMISSION_TYPES[code];
137    }
138   
139    }