Coverage Report - org.kuali.student.lum.statement.config.context.util.NLCluSet
 
Classes in this File Line Coverage Branch Coverage Complexity
NLCluSet
92%
39/42
82%
23/28
2.5
 
 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.lum.statement.config.context.util;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import org.kuali.student.lum.lu.dto.CluInfo;
 21  
 
 22  
 /**
 23  
  * <p><b><u>Warning</u></b><br/>
 24  
  * DO NOT change the public method signatures of this class.<br/>
 25  
  * The natural language templates are coded against this class's public methods.
 26  
  * If the method signatures are changed then all the templates referencing 
 27  
  * this class will need to be changed as well.</p>
 28  
  * 
 29  
  * This class is inserted into the template engine to get Clu and CluSet 
 30  
  * information. <code>$cluSet</code> is this class.
 31  
  * <p>
 32  
  * Example:
 33  
  * <code>"Student must have completed $intValue of $cluSet.getCluSetAsShortName()"</code>
 34  
  * </p>
 35  
  * 
 36  
  * {@link MockCluSetInfo} wrapper class.
 37  
  */
 38  
 public class NLCluSet {
 39  
 
 40  
         private String cluSetId;
 41  
         private List<CluInfo> cluList;
 42  
         
 43  53
         public NLCluSet(String cluSetId, List<CluInfo> cluList) {
 44  53
                 this.cluSetId = cluSetId;
 45  53
                 this.cluList = cluList;
 46  53
         }
 47  
 
 48  
         /**
 49  
          * Gets the CLU set id.
 50  
          * 
 51  
          * @return Clu set id
 52  
          */
 53  
         public String getCluSetId() {
 54  4
                 return cluSetId;
 55  
         }
 56  
 
 57  
         /**
 58  
          * Gets a list of CLUs.
 59  
          *  
 60  
          * @return List of CLUs
 61  
          */
 62  
         public List<CluInfo> getCluList() {
 63  23
                 return this.cluList;
 64  
         }
 65  
 
 66  
         /**
 67  
          * Gets a particular CLU's official identifier short name.
 68  
          * 
 69  
          * @param index Index in CLU set
 70  
          * @return CLU official identifier short name
 71  
          */
 72  
         public String getCluAsShortName(int index) {
 73  2
                 return this.cluList.get(index).getOfficialIdentifier().getShortName();
 74  
         }
 75  
 
 76  
         /**
 77  
          * Gets a particular CLU's official identifier code at <code>index</code>
 78  
          * @param index
 79  
          * @return CLU's official identifier code
 80  
          */
 81  
         public String getCluAsCode(int index) {
 82  2
                 return this.cluList.get(index).getOfficialIdentifier().getCode();
 83  
         }
 84  
 
 85  
         /**
 86  
          * Gets all the CLUs' official identifier short name in the CLU set 
 87  
          * as a comma separated list.
 88  
          *   
 89  
          * @return Comma separated list of CLUs' official identifier short name 
 90  
          */
 91  
         public String getCluSetAsShortName() {
 92  1
                 StringBuilder sb = new StringBuilder();
 93  1
                 if (this.cluList.size() > 1) {
 94  1
                     sb.append("(");
 95  
                 }
 96  1
                 for(CluInfo clu : this.cluList) {
 97  2
                         sb.append(clu.getOfficialIdentifier().getShortName());
 98  2
             if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
 99  1
                 sb.append(", ");
 100  
             }
 101  
                 }
 102  1
         if (this.cluList.size() > 1) {
 103  1
             sb.append(")");
 104  
         }                
 105  1
                 return getString(sb);
 106  
         }
 107  
 
 108  
         /**
 109  
          * Gets all the CLUs' official identifier long name in the CLU set 
 110  
          * as a comma separated list.
 111  
          * 
 112  
          * @return Comma separated list of CLUs' official identifier long name 
 113  
          */
 114  
         public String getCluSetAsLongName() {
 115  16
                 StringBuilder sb = new StringBuilder();
 116  16
         if (this.cluList.size() > 1) {
 117  7
             sb.append("(");
 118  
         }                
 119  16
                 for(CluInfo clu : this.cluList) {
 120  23
                         sb.append(clu.getOfficialIdentifier().getLongName());
 121  23
             if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
 122  7
                 sb.append(", ");
 123  
             }
 124  
                 }
 125  16
         if (this.cluList.size() > 1) {
 126  7
             sb.append(")");
 127  
         }                
 128  16
                 return getString(sb);
 129  
         }
 130  
 
 131  
         /**
 132  
          * Gets all the CLUs' official identifier code in the CLU set 
 133  
          * as a comma separated list.
 134  
          * 
 135  
          * @return Comma separated list of CLUs' official identifier code 
 136  
          */
 137  
         public String getCluSetAsCode() {
 138  31
                 StringBuilder sb = new StringBuilder();
 139  31
         if (this.cluList.size() > 1) {
 140  27
             sb.append("(");
 141  
         }                
 142  31
                 for(CluInfo clu : this.cluList) {
 143  61
                         sb.append(clu.getOfficialIdentifier().getCode());
 144  61
                         if (this.cluList.indexOf(clu) < (this.cluList.size() - 1)) {
 145  30
                             sb.append(", ");
 146  
                         }
 147  
                 }
 148  31
         if (this.cluList.size() > 1) {
 149  27
             sb.append(")");
 150  
         }                
 151  31
                 return getString(sb);
 152  
         }
 153  
 
 154  
         private String getString(StringBuilder sb) {
 155  48
                 return (sb.length() == 0 ? "No CLUs available in CluSet" : sb.toString());
 156  
         }
 157  
 
 158  
         public String toString() {
 159  0
                 if(this.cluList == null) {
 160  0
                         return "Null CluSet";
 161  
                 }
 162  0
                 return "id=" + this.cluSetId;
 163  
         }
 164  
 }