Clover Coverage Report - KS Common UI 1.2-M4-SNAPSHOT
Coverage timestamp: Wed Jul 20 2011 12:41:05 EDT
../../../../../../../img/srcFileCovDistChart0.png 4% of files have more coverage
15   119   16   1.15
2   59   1.07   13
13     1.23  
1    
 
  ViewContext       Line # 31 15 0% 16 30 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.ui.client.application;
17   
18    import java.util.HashMap;
19    import java.util.Map;
20   
21    import org.kuali.student.common.rice.authorization.PermissionType;
22    import org.kuali.student.common.ui.shared.IdAttributes.IdType;
23   
24    /**
25    * ViewContext can be used to pass along context information when switching or initializing a view.
26    *
27    * For example a display view requires the id of the object to display, the view context can be used
28    * to pass along that information from a different controller or view.
29    *
30    */
 
31    public class ViewContext implements Comparable<ViewContext>{
32   
33    public static final String ID_ATR = "docId";
34    public static final String ID_TYPE_ATR = "idType";
35   
36   
37    private Map<String, String> attributes = new HashMap<String, String>();
38    private String id = "";
39    private IdType idType = null;
40    // FIXME: change state to proper default or null
41    private String state = "draft";
42    private PermissionType permissionType;
43   
 
44  0 toggle public String getId() {
45  0 return id;
46    }
47   
48    /**
49    * Set the id for this view context, this will appear as part of the address bar when used in
50    * a controller, the controller can use this id to determine what to show (determine the context)
51    */
 
52  0 toggle public void setId(String id) {
53  0 this.id = id;
54    }
55   
 
56  0 toggle public IdType getIdType() {
57  0 return idType;
58    }
59   
60    /**
61    * Set the type of id for this view context, this will appear as part of the address bar when used in
62    * a controller
63    */
 
64  0 toggle public void setIdType(IdType idType) {
65  0 this.idType = idType;
66    }
67   
 
68  0 toggle public void setIdType(String idTypeString){
69  0 this.idType = IdType.fromString(idTypeString);
70    }
71   
 
72  0 toggle public String getState() {
73  0 return state;
74    }
75   
 
76  0 toggle public void setState(String state) {
77  0 this.state = state;
78    }
79   
 
80  0 toggle public PermissionType getPermissionType() {
81  0 return permissionType;
82    }
83   
84    /**
85    * Sets the type of permission needed to be at the the current view, this is interpreted by the controller
86    * if set which checks with the server to see if the user has this kind of permission. Doesn't appear in
87    * the address bar
88    */
 
89  0 toggle public void setPermissionType(PermissionType permissionType) {
90  0 this.permissionType = permissionType;
91    }
92   
 
93  0 toggle @Override
94    public int compareTo(ViewContext o) {
95  0 if(o.getId().equals(id) && o.getIdType() == idType && o.getAttributes().equals(attributes)){
96  0 return 0;
97    }
98    else{
99  0 return -1;
100    }
101    }
102   
103    /**
104    * Add an additional attribute to the view context, this will appear in the address bar like id
105    * and type does
106    */
 
107  0 toggle public void setAttribute(String key, String value) {
108  0 attributes.put(key, value);
109    }
110   
 
111  0 toggle public String getAttribute(String key){
112  0 return attributes.get(key);
113    }
114   
 
115  0 toggle public Map<String, String> getAttributes(){
116  0 return attributes;
117    }
118   
119    }