Coverage Report - org.kuali.rice.krms.impl.ui.AgendaEditor
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaEditor
0%
0/45
0%
0/18
2.125
 
 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 java.util.List;
 19  
 
 20  
 import org.kuali.rice.core.util.Node;
 21  
 import org.kuali.rice.core.util.Tree;
 22  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
 23  
 import org.kuali.rice.krms.impl.repository.AgendaBo;
 24  
 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
 25  
 import org.kuali.rice.krms.impl.repository.ContextBo;
 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  0
 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 agendaItemAddLine;
 41  
         
 42  
         private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
 43  0
             Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
 44  0
             child.setNodeLabel(agendaItem.getRuleText());
 45  0
             child.setNodeType("agendaNode ruleNode");
 46  0
             child.setData(new AgendaTreeRuleNode(agendaItem));
 47  0
             parent.getChildren().add(child);
 48  
             
 49  
             // deal with peer nodes:
 50  0
             if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
 51  
             
 52  
             // deal with child nodes:
 53  0
             if (agendaItem.getWhenTrue() != null) {
 54  0
                 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
 55  0
                 whenTrue.setNodeLabel("When TRUE");
 56  0
                 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
 57  0
                 whenTrue.setData(new AgendaTreeLogicNode());
 58  0
                 child.getChildren().add(whenTrue);
 59  
                 
 60  0
                 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
 61  
             }
 62  0
         if (agendaItem.getWhenFalse() != null) {
 63  0
             Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
 64  0
             whenFalse.setNodeLabel("When FALSE");
 65  0
             whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
 66  0
             whenFalse.setData(new AgendaTreeLogicNode());
 67  0
             child.getChildren().add(whenFalse);
 68  
             
 69  0
             addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
 70  
         }
 71  0
         }
 72  
         
 73  
     public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
 74  0
         Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
 75  
 
 76  0
         Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
 77  0
         agendaTree.setRootElement(rootNode);
 78  
         
 79  0
         if (agenda != null) {
 80  0
             String firstItemId = agenda.getFirstItemId();
 81  0
             List<AgendaItemBo> items = agenda.getItems();
 82  0
             AgendaItemBo firstItem = null;
 83  
 
 84  0
             if (items != null && firstItemId != null) {
 85  0
                 for (AgendaItemBo item : items) {
 86  0
                     if (firstItemId.equals(item.getId())) {
 87  0
                         firstItem = item;
 88  0
                         break;
 89  
                     }
 90  
                 }
 91  
             }
 92  
 
 93  0
             if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
 94  
         } 
 95  
         
 96  0
         return agendaTree;
 97  
     }        
 98  
         
 99  
         /**
 100  
      * @return the agendaItemAddLine
 101  
      */
 102  
     public AgendaItemBo getAgendaItemAddLine() {
 103  0
         return this.agendaItemAddLine;
 104  
     }
 105  
     /**
 106  
      * @param agendaItemAddLine the agendaItemAddLine to set
 107  
      */
 108  
     public void setAgendaItemAddLine(AgendaItemBo agendaItemAddLine) {
 109  0
         this.agendaItemAddLine = agendaItemAddLine;
 110  0
     }
 111  
     /**
 112  
          * @return the context
 113  
          */
 114  
         public ContextBo getContext() {
 115  0
                 return this.context;
 116  
         }
 117  
         /**
 118  
          * @param context the context to set
 119  
          */
 120  
         public void setContext(ContextBo context) {
 121  0
                 this.context = context;
 122  0
         }
 123  
         /**
 124  
          * @return the agenda
 125  
          */
 126  
         public AgendaBo getAgenda() {
 127  0
                 return this.agenda;
 128  
         }
 129  
         /**
 130  
          * @param agenda the agenda to set
 131  
          */
 132  
         public void setAgenda(AgendaBo agenda) {
 133  0
                 this.agenda = agenda;
 134  0
         }
 135  
         
 136  
         
 137  
 }