Coverage Report - org.kuali.student.common.ui.client.application.ViewContext
 
Classes in this File Line Coverage Branch Coverage Complexity
ViewContext
0%
0/26
0%
0/6
1.308
 
 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.ui.shared.IdAttributes.IdType;
 22  
 import org.kuali.student.core.rice.authorization.PermissionType;
 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  0
 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  0
         private Map<String, String> attributes = new HashMap<String, String>();
 38  0
         private String id = "";
 39  0
         private IdType idType = null;
 40  
         // FIXME: change state to proper default or null
 41  0
         private String state = "draft";
 42  
         private PermissionType permissionType;
 43  
 
 44  
         public String getId() {
 45  0
                 return id;
 46  
         }
 47  
 
 48  
         public void setId(String id) {
 49  0
                 this.id = id;
 50  0
         }
 51  
 
 52  
         public IdType getIdType() {
 53  0
                 return idType;
 54  
         }
 55  
 
 56  
         public void setIdType(IdType idType) {
 57  0
                 this.idType = idType;
 58  0
         }
 59  
         
 60  
         public void setIdType(String idTypeString){
 61  0
                 this.idType = IdType.fromString(idTypeString);
 62  0
         }
 63  
 
 64  
         public String getState() {
 65  0
                 return state;
 66  
         }
 67  
 
 68  
         public void setState(String state) {
 69  0
                 this.state = state;
 70  0
         }
 71  
 
 72  
         public PermissionType getPermissionType() {
 73  0
             return permissionType;
 74  
     }
 75  
 
 76  
         public void setPermissionType(PermissionType permissionType) {
 77  0
             this.permissionType = permissionType;
 78  0
     }
 79  
 
 80  
         @Override
 81  
         public int compareTo(ViewContext o) {
 82  0
                 if(o.getId().equals(id) && o.getIdType() == idType && o.getAttributes().equals(attributes)){
 83  0
                         return 0;
 84  
                 }
 85  
                 else{
 86  0
                         return -1;
 87  
                 }
 88  
         }
 89  
 
 90  
     public void setAttribute(String key, String value) {
 91  0
                 attributes.put(key, value);
 92  0
         }
 93  
         
 94  
         public String getAttribute(String key){
 95  0
                 return attributes.get(key);
 96  
         }
 97  
         
 98  
         public Map<String, String> getAttributes(){
 99  0
                 return attributes;
 100  
         }
 101  
 
 102  
 }