Coverage Report - org.kuali.rice.krms.impl.ui.AgendaEditor
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaEditor
0%
0/50
0%
0/18
1.818
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.AgendaBo;
 22  
 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
 23  
 import org.kuali.rice.krms.impl.repository.ContextBo;
 24  
 
 25  
 import java.util.List;
 26  
 
 27  
 /**
 28  
  * BO for the KRMS agenda editor
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  
 // TODO: this is not a document, rename?
 34  
 public class AgendaEditor extends PersistableBusinessObjectBase {
 35  
         
 36  
         private static final long serialVersionUID = 1L;
 37  
         
 38  
         private ContextBo context;
 39  
         private AgendaBo agenda;
 40  
         private AgendaItemBo agendaItemLine;
 41  
     private String selectedAgendaItemId;
 42  
 
 43  0
     public AgendaEditor() {
 44  0
         agendaItemLine = new AgendaItemBo();
 45  0
     }
 46  
 
 47  
         private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
 48  0
             Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
 49  0
             child.setNodeLabel(agendaItem.getRuleText());
 50  0
             child.setNodeType("agendaNode ruleNode");
 51  0
             child.setData(new AgendaTreeRuleNode(agendaItem));
 52  0
             parent.getChildren().add(child);
 53  
             
 54  
             // deal with peer nodes:
 55  0
             if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
 56  
             
 57  
             // deal with child nodes:
 58  0
             if (agendaItem.getWhenTrue() != null) {
 59  0
                 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
 60  0
                 whenTrue.setNodeLabel("When TRUE");
 61  0
                 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
 62  0
                 whenTrue.setData(new AgendaTreeLogicNode());
 63  0
                 child.getChildren().add(whenTrue);
 64  
                 
 65  0
                 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
 66  
             }
 67  0
         if (agendaItem.getWhenFalse() != null) {
 68  0
             Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
 69  0
             whenFalse.setNodeLabel("When FALSE");
 70  0
             whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
 71  0
             whenFalse.setData(new AgendaTreeLogicNode());
 72  0
             child.getChildren().add(whenFalse);
 73  
             
 74  0
             addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
 75  
         }
 76  0
         }
 77  
         
 78  
     public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
 79  0
         Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
 80  
 
 81  0
         Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
 82  0
         agendaTree.setRootElement(rootNode);
 83  
         
 84  0
         if (agenda != null) {
 85  0
             String firstItemId = agenda.getFirstItemId();
 86  0
             List<AgendaItemBo> items = agenda.getItems();
 87  0
             AgendaItemBo firstItem = null;
 88  
 
 89  0
             if (items != null && firstItemId != null) {
 90  0
                 for (AgendaItemBo item : items) {
 91  0
                     if (firstItemId.equals(item.getId())) {
 92  0
                         firstItem = item;
 93  0
                         break;
 94  
                     }
 95  
                 }
 96  
             }
 97  
 
 98  0
             if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
 99  
         } 
 100  
         
 101  0
         return agendaTree;
 102  
     }        
 103  
         
 104  
         /**
 105  
      * @return the agendaItemLine
 106  
      */
 107  
     public AgendaItemBo getAgendaItemLine() {
 108  0
         return this.agendaItemLine;
 109  
     }
 110  
     /**
 111  
      * @param agendaItemLine the agendaItemLine to set
 112  
      */
 113  
     public void setAgendaItemLine(AgendaItemBo agendaItemLine) {
 114  0
         this.agendaItemLine = agendaItemLine;
 115  0
     }
 116  
     /**
 117  
      * @return the selectedAgendaItemId
 118  
      */
 119  
     public String getSelectedAgendaItemId() {
 120  0
         return this.selectedAgendaItemId;
 121  
     }
 122  
     /**
 123  
      * @param selectedAgendaItemId the selectedAgendaItemId to set
 124  
      */
 125  
     public void setSelectedAgendaItemId(String selectedAgendaItemId) {
 126  0
         this.selectedAgendaItemId = selectedAgendaItemId;
 127  0
     }
 128  
     /**
 129  
          * @return the context
 130  
          */
 131  
         public ContextBo getContext() {
 132  0
                 return this.context;
 133  
         }
 134  
         /**
 135  
          * @param context the context to set
 136  
          */
 137  
         public void setContext(ContextBo context) {
 138  0
                 this.context = context;
 139  0
         }
 140  
         /**
 141  
          * @return the agenda
 142  
          */
 143  
         public AgendaBo getAgenda() {
 144  0
                 return this.agenda;
 145  
         }
 146  
         /**
 147  
          * @param agenda the agenda to set
 148  
          */
 149  
         public void setAgenda(AgendaBo agenda) {
 150  0
                 this.agenda = agenda;
 151  0
         }
 152  
         
 153  
         
 154  
 }