Coverage Report - org.kuali.rice.krms.impl.ui.AgendaEditor
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaEditor
0%
0/91
0%
0/18
1.265
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krms.impl.ui;
 17  
 
 18  
 import org.kuali.rice.core.api.util.tree.Node;
 19  
 import org.kuali.rice.core.api.util.tree.Tree;
 20  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
 21  
 import org.kuali.rice.krms.impl.repository.ActionBo;
 22  
 import org.kuali.rice.krms.impl.repository.AgendaBo;
 23  
 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
 24  
 import org.kuali.rice.krms.impl.repository.ContextBo;
 25  
 
 26  
 import java.util.HashMap;
 27  
 import java.util.List;
 28  
 import java.util.Map;
 29  
 
 30  
 /**
 31  
  * synthetic (not directly persisted) BO for the KRMS agenda editor
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  *
 35  
  */
 36  
 public class AgendaEditor extends PersistableBusinessObjectBase {
 37  
         
 38  
         private static final long serialVersionUID = 1L;
 39  
         
 40  
         private ContextBo context;
 41  
     private String namespace;
 42  
         private AgendaBo agenda;
 43  
     private String contextName;
 44  
         private AgendaItemBo agendaItemLine;
 45  
     private ActionBo agendaItemLineRuleAction;
 46  
     private String selectedAgendaItemId;
 47  
     private String cutAgendaItemId;
 48  
     private String selectedPropositionId;
 49  
     private String cutPropositionId;
 50  
     private String copyRuleName;
 51  
     private String oldContextId;
 52  0
     private Map<String, String> customAttributesMap = new HashMap<String, String>();
 53  0
     private Map<String, String> customRuleAttributesMap = new HashMap<String, String>();
 54  0
     private Map<String, String> customRuleActionAttributesMap = new HashMap<String, String>();
 55  
 
 56  0
     public AgendaEditor() {
 57  0
         agenda = new AgendaBo();
 58  
         // ToDo: Determine proper default values of agenda's typeId
 59  0
         agenda.setTypeId("");
 60  0
         agendaItemLine = new AgendaItemBo();
 61  0
         agendaItemLineRuleAction = new ActionBo();
 62  0
     }
 63  
 
 64  
         private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
 65  0
             Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
 66  0
             child.setNodeLabel(agendaItem.getRuleText());
 67  0
             child.setNodeType("agendaNode ruleNode");
 68  0
             child.setData(new AgendaTreeRuleNode(agendaItem));
 69  0
             parent.getChildren().add(child);
 70  
             
 71  
             // deal with peer nodes:
 72  0
             if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
 73  
             
 74  
             // deal with child nodes:
 75  0
             if (agendaItem.getWhenTrue() != null) {
 76  0
                 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
 77  0
                 whenTrue.setNodeLabel("When TRUE");
 78  0
                 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
 79  0
                 whenTrue.setData(new AgendaTreeLogicNode());
 80  0
                 child.getChildren().add(whenTrue);
 81  
                 
 82  0
                 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
 83  
             }
 84  0
         if (agendaItem.getWhenFalse() != null) {
 85  0
             Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
 86  0
             whenFalse.setNodeLabel("When FALSE");
 87  0
             whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
 88  0
             whenFalse.setData(new AgendaTreeLogicNode());
 89  0
             child.getChildren().add(whenFalse);
 90  
             
 91  0
             addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
 92  
         }
 93  0
         }
 94  
         
 95  
     public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
 96  0
         Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
 97  
 
 98  0
         Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
 99  0
         agendaTree.setRootElement(rootNode);
 100  
         
 101  0
         if (agenda != null) {
 102  0
             String firstItemId = agenda.getFirstItemId();
 103  0
             List<AgendaItemBo> items = agenda.getItems();
 104  0
             AgendaItemBo firstItem = null;
 105  
 
 106  0
             if (items != null && firstItemId != null) {
 107  0
                 for (AgendaItemBo item : items) {
 108  0
                     if (firstItemId.equals(item.getId())) {
 109  0
                         firstItem = item;
 110  0
                         break;
 111  
                     }
 112  
                 }
 113  
             }
 114  
 
 115  0
             if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
 116  
         } 
 117  
         
 118  0
         return agendaTree;
 119  
     }        
 120  
         
 121  
         /**
 122  
      * @return the agendaItemLine
 123  
      */
 124  
     public AgendaItemBo getAgendaItemLine() {
 125  0
         return this.agendaItemLine;
 126  
     }
 127  
 
 128  
     /**
 129  
      * @param agendaItemLine the agendaItemLine to set
 130  
      */
 131  
     public void setAgendaItemLine(AgendaItemBo agendaItemLine) {
 132  0
         this.agendaItemLine = agendaItemLine;
 133  0
     }
 134  
 
 135  
     public ActionBo getAgendaItemLineRuleAction() {
 136  0
         return agendaItemLineRuleAction;
 137  
     }
 138  
 
 139  
     public void setAgendaItemLineRuleAction(ActionBo actionBo) {
 140  0
         this.agendaItemLineRuleAction = actionBo;
 141  0
     }
 142  
 
 143  
     /**
 144  
      * @return the selectedAgendaItemId
 145  
      */
 146  
     public String getSelectedAgendaItemId() {
 147  0
         return this.selectedAgendaItemId;
 148  
     }
 149  
 
 150  
     /**
 151  
      * @param selectedAgendaItemId the selectedAgendaItemId to set
 152  
      */
 153  
     public void setSelectedAgendaItemId(String selectedAgendaItemId) {
 154  0
         this.selectedAgendaItemId = selectedAgendaItemId;
 155  0
     }
 156  
 
 157  
     /**
 158  
      * @return the cutAgendaItemId
 159  
      */
 160  
     public String getCutAgendaItemId() {
 161  0
         return this.cutAgendaItemId;
 162  
     }
 163  
 
 164  
     /**
 165  
      * @param cutAgendaItemId the cutAgendaItemId to set
 166  
      */
 167  
     public void setCutAgendaItemId(String cutAgendaItemId) {
 168  0
         this.cutAgendaItemId = cutAgendaItemId;
 169  0
     }
 170  
 
 171  
     /**
 172  
          * @return the context
 173  
          */
 174  
         public ContextBo getContext() {
 175  0
                 return this.context;
 176  
         }
 177  
 
 178  
         /**
 179  
          * @param context the context to set
 180  
          */
 181  
         public void setContext(ContextBo context) {
 182  0
                 this.context = context;
 183  0
         }
 184  
 
 185  
         /**
 186  
          * @return the agenda
 187  
          */
 188  
         public AgendaBo getAgenda() {
 189  0
                 return this.agenda;
 190  
         }
 191  
 
 192  
         /**
 193  
          * @param agenda the agenda to set
 194  
          */
 195  
         public void setAgenda(AgendaBo agenda) {
 196  0
                 this.agenda = agenda;
 197  0
         }
 198  
 
 199  
     public Map<String, String> getCustomAttributesMap() {
 200  0
         return customAttributesMap;
 201  
     }
 202  
 
 203  
     public void setCustomAttributesMap(Map<String, String> customAttributesMap) {
 204  0
         this.customAttributesMap = customAttributesMap;
 205  0
     }
 206  
 
 207  
     public Map<String, String> getCustomRuleAttributesMap() {
 208  0
         return customRuleAttributesMap;
 209  
     }
 210  
 
 211  
     public void setCustomRuleAttributesMap(Map<String, String> customRuleAttributesMap) {
 212  0
         this.customRuleAttributesMap = customRuleAttributesMap;
 213  0
     }
 214  
 
 215  
     public Map<String, String> getCustomRuleActionAttributesMap() {
 216  0
         return customRuleActionAttributesMap;
 217  
     }
 218  
 
 219  
     public void setCustomRuleActionAttributesMap(Map<String, String> customRuleActionAttributesMap) {
 220  0
         this.customRuleActionAttributesMap = customRuleActionAttributesMap;
 221  0
     }
 222  
 
 223  
     /**
 224  
      * @param copyRuleName the rule name from which to copy
 225  
      */
 226  
     public void setCopyRuleName(String copyRuleName) {
 227  0
         this.copyRuleName = copyRuleName;
 228  0
     }
 229  
 
 230  
     /**
 231  
      * @return the rule name from which to copy
 232  
      */
 233  
     public String getCopyRuleName() {
 234  0
         return copyRuleName;
 235  
     }
 236  
 
 237  
     /**
 238  
      * @param oldContextId the contextId that the agenda currently has (i.e. before the next context change)
 239  
      */
 240  
     public void setOldContextId(String oldContextId) {
 241  0
         this.oldContextId = oldContextId;
 242  0
     }
 243  
 
 244  
     /**
 245  
      * @return the contextId that the agenda had before the context change
 246  
      */
 247  
     public String getOldContextId() {
 248  0
         return oldContextId;
 249  
     }
 250  
 
 251  
     /**
 252  
      * @return the selectedPropositionId
 253  
      */
 254  
     public String getSelectedPropositionId() {
 255  0
         return this.selectedPropositionId;
 256  
     }
 257  
 
 258  
     /**
 259  
      * @param selectedPropositionId the selectedPropositionId to set
 260  
      */
 261  
     public void setSelectedPropositionId(String selectedPropositionId) {
 262  0
         this.selectedPropositionId = selectedPropositionId;
 263  0
     }
 264  
 
 265  
 
 266  
     /**
 267  
      * @return the cutPropositionId
 268  
      */
 269  
     public String getCutPropositionId() {
 270  0
         return cutPropositionId;
 271  
     }
 272  
 
 273  
     public String getContextName() {
 274  0
         return contextName;
 275  
     }
 276  
 
 277  
     public void setContextName(String contextName) {
 278  0
         this.contextName = contextName;
 279  0
     }
 280  
 
 281  
     public String getNamespace() {
 282  0
         return namespace;
 283  
     }
 284  
 
 285  
     public void setNamespace(String namespace) {
 286  0
         this.namespace = namespace;
 287  0
     }
 288  
 
 289  
     /**
 290  
      * @param cutPropositionId the cutPropositionId to set
 291  
      */
 292  
     public void setCutPropositionId(String cutPropositionId) {
 293  0
         this.cutPropositionId = cutPropositionId;
 294  0
     }
 295  
 
 296  
     // Need to override this method since the actual persistable BO is wrapped inside dataObject.
 297  
     @Override
 298  
     public void refreshNonUpdateableReferences() {
 299  0
         getPersistenceService().refreshAllNonUpdatingReferences(this.getAgenda());
 300  0
     }
 301  
 
 302  
 }