| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AgendaItemBoFoo |
|
| 0.0;0 |
| 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.repository | |
| 17 | ||
| 18 | import org.kuali.rice.krad.bo.PersistableBusinessObjectBase | |
| 19 | import org.kuali.rice.krms.api.repository.agenda.AgendaItem | |
| 20 | ||
| 21 | // NOTE: this class is temporarily renamed to get it out of the way. See AgendaItemBo.java | |
| 22 | public class AgendaItemBoFoo extends PersistableBusinessObjectBase { | |
| 23 | ||
| 24 | // public MetaClass getMetaClass() { | |
| 25 | // return super.getMetaClass(); | |
| 26 | // } | |
| 27 | ||
| 28 | def String id | |
| 29 | def String agendaId | |
| 30 | def String ruleId | |
| 31 | def String subAgendaId | |
| 32 | def String whenTrueId | |
| 33 | def String whenFalseId | |
| 34 | def String alwaysId | |
| 35 | ||
| 36 | def AgendaItemBo whenTrue; | |
| 37 | def AgendaItemBo whenFalse; | |
| 38 | def AgendaItemBo always; | |
| 39 | ||
| 40 | public String getUl(AgendaItemBo firstItem) { | |
| 41 | 0 | return ("<ul>" + getUlHelper(firstItem) + "</ul>"); |
| 42 | } | |
| 43 | ||
| 44 | public String getUlHelper(AgendaItemBo item) { | |
| 45 | 0 | StringBuilder sb = new StringBuilder(); |
| 46 | 0 | sb.append("<li>" + ruleId + "</li>"); |
| 47 | 0 | if (whenTrue != null) { |
| 48 | 0 | sb.append("<ul><li>when true</li><ul>"); |
| 49 | 0 | sb.append(getUlHelper(whenTrue)); |
| 50 | 0 | sb.append("</ul></ul>"); |
| 51 | } | |
| 52 | 0 | if (whenFalse != null) { |
| 53 | 0 | sb.append("<ul><li>when false</li><ul>"); |
| 54 | 0 | sb.append(getUlHelper(whenFalse)); |
| 55 | 0 | sb.append("</ul></ul>"); |
| 56 | } | |
| 57 | 0 | if (always != null) { |
| 58 | 0 | sb.append(getUlHelper(always)); |
| 59 | } | |
| 60 | 0 | return sb.toString(); |
| 61 | } | |
| 62 | ||
| 63 | // def List<AgendaItemBo> alwaysList | |
| 64 | // def List<AgendaItemBo> whenTrueList | |
| 65 | // def List<AgendaItemBo> whenFalseList | |
| 66 | ||
| 67 | public List<AgendaItemBo> getAlwaysList() { | |
| 68 | 0 | List<AgendaItemBo> results = new ArrayList<AgendaItemBo>(); |
| 69 | ||
| 70 | 0 | AgendaItemBo currentNode = this; |
| 71 | 0 | while (currentNode.always != null) { |
| 72 | 0 | results.add(currentNode.always); |
| 73 | 0 | currentNode = currentNode.always; |
| 74 | } | |
| 75 | ||
| 76 | 0 | return results; |
| 77 | } | |
| 78 | ||
| 79 | // public List<AgendaItemBo> getWhenTrueList() { | |
| 80 | // List<AgendaItemBo> results = new ArrayList<AgendaItemBo>(); | |
| 81 | // | |
| 82 | // AgendaItemBo currentNode = this; | |
| 83 | // if (currentNode.whenTrue != null) { | |
| 84 | // results.add(currentNode.whenTrue); | |
| 85 | // currentNode = currentNode.whenTrue; | |
| 86 | // } | |
| 87 | // while (currentNode.always != null) { | |
| 88 | // results.add(currentNode.always); | |
| 89 | // currentNode = currentNode.always; | |
| 90 | // } | |
| 91 | // | |
| 92 | // return results; | |
| 93 | // } | |
| 94 | // | |
| 95 | // public List<AgendaItemBo> getWhenFalseList() { | |
| 96 | // List<AgendaItemBo> results = new ArrayList<AgendaItemBo>(); | |
| 97 | // | |
| 98 | // AgendaItemBo currentNode = this; | |
| 99 | // if (currentNode.whenFalse != null) { | |
| 100 | // results.add(currentNode.whenFalse); | |
| 101 | // currentNode = currentNode.whenFalse; | |
| 102 | // } | |
| 103 | // while (currentNode.always != null) { | |
| 104 | // results.add(currentNode.always); | |
| 105 | // currentNode = currentNode.always; | |
| 106 | // } | |
| 107 | // | |
| 108 | // return results; | |
| 109 | // } | |
| 110 | ||
| 111 | // Would make life in KNS easier to map to related AgendaItemBos, and RuleBos | |
| 112 | ||
| 113 | ||
| 114 | /** | |
| 115 | * Converts a mutable bo to it's immutable counterpart | |
| 116 | * @param bo the mutable business object | |
| 117 | * @return the immutable object | |
| 118 | */ | |
| 119 | static AgendaItem to(AgendaItemBo bo) { | |
| 120 | 0 | if (bo == null) { return null } |
| 121 | 0 | AgendaItem.Builder builder = AgendaItem.Builder.create(bo.getId(), bo.getAgendaId()) |
| 122 | 0 | builder.setRuleId( bo.getRuleId() ) |
| 123 | 0 | builder.setSubAgendaId( bo.getSubAgendaId() ) |
| 124 | 0 | builder.setWhenTrueId( bo.getWhenTrueId() ) |
| 125 | 0 | builder.setWhenFalseId( bo.getWhenFalseId() ) |
| 126 | 0 | builder.setAlwaysId( bo.getAlwaysId() ) |
| 127 | 0 | builder.setVersionNumber( bo.getVersionNumber() ); |
| 128 | 0 | return builder.build() |
| 129 | // NOTE: should we create tree nodes (whenTrue, whenFalse, always) ?? | |
| 130 | // If so, we would end up creating the entire sub-tree. | |
| 131 | // If we do want to create the entire tree, having AgendaItem implement AgendaItemContract would be easier | |
| 132 | // so we could recursively build it out. | |
| 133 | ||
| 134 | // return org.kuali.rice.krms.api.repository.agenda.AgendaItem.Builder.create(bo).build() | |
| 135 | } | |
| 136 | ||
| 137 | /** | |
| 138 | * Converts a immutable object to it's mutable bo counterpart | |
| 139 | * @param im immutable object | |
| 140 | * @return the mutable bo | |
| 141 | */ | |
| 142 | static AgendaItemBo from(AgendaItem im) { | |
| 143 | 0 | if (im == null) { return null } |
| 144 | ||
| 145 | 0 | AgendaItemBo bo = new AgendaItemBo() |
| 146 | 0 | bo.id = im.id |
| 147 | 0 | bo.agendaId = im.agendaId |
| 148 | 0 | bo.ruleId = im.ruleId |
| 149 | 0 | bo.subAgendaId = im.subAgendaId |
| 150 | 0 | bo.whenTrueId = im.whenTrueId |
| 151 | 0 | bo.whenFalseId = im.whenFalseId |
| 152 | 0 | bo.alwaysId = im.alwaysId |
| 153 | 0 | bo.versionNumber = im.versionNumber |
| 154 | ||
| 155 | 0 | return bo |
| 156 | } | |
| 157 | ||
| 158 | } |