| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  | package org.kuali.student.common.assembly.dictionary; | 
            
  
    | 16 |  |  | 
            
  
    | 17 |  | import java.util.ArrayList; | 
            
  
    | 18 |  | import java.util.Collections; | 
            
  
    | 19 |  | import java.util.List; | 
            
  
    | 20 |  | import java.util.Set; | 
            
  
    | 21 |  |  | 
            
  
    | 22 |  | import org.kuali.student.common.assembly.data.ConstraintMetadata; | 
            
  
    | 23 |  | import org.kuali.student.common.assembly.data.Data; | 
            
  
    | 24 |  | import org.kuali.student.common.assembly.data.LookupMetadata; | 
            
  
    | 25 |  | import org.kuali.student.common.assembly.data.LookupParamMetadata; | 
            
  
    | 26 |  | import org.kuali.student.common.assembly.data.Metadata; | 
            
  
    | 27 |  | import org.kuali.student.common.assembly.data.MetadataInterrogator; | 
            
  
    | 28 |  |  | 
               
        |  |  | 
           
           |  | 58.1% | Uncovered Elements: 220 (525) | Complexity: 108 | Complexity Density: 0.31 |  | 
  
  
    | 29 |  | public class MetadataFormatter { | 
            
  
    | 30 |  |  | 
            
  
    | 31 |  | private StringBuilder builder = new StringBuilder(5000); | 
            
  
    | 32 |  | private Metadata structureMetadata; | 
            
  
    | 33 |  | private String type; | 
            
  
    | 34 |  | private String rowSeperator = "\n"; | 
            
  
    | 35 |  | private String colSeperator = "|"; | 
            
  
    | 36 |  | private String structureName; | 
            
  
    | 37 |  | private int level; | 
            
  
    | 38 |  |  | 
            
  
    | 39 |  | private Set<Metadata> structuresAlreadyProcessed; | 
            
  
    | 40 |  | private MetadataFormatter parent; | 
            
  
    | 41 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (6) | Complexity: 1 | Complexity Density: 0.17 |  | 
  
  
    | 42 | 4 |  public MetadataFormatter(String structureName, Metadata structureMetadata,... | 
            
  
    | 43 |  | String type, MetadataFormatter parent, | 
            
  
    | 44 |  | Set<Metadata> structuresAlreadyProcessed, int level) { | 
            
  
    | 45 | 4 | this.structureName = structureName; | 
            
  
    | 46 | 4 | this.structureMetadata = structureMetadata; | 
            
  
    | 47 | 4 | this.type = type; | 
            
  
    | 48 | 4 | this.parent = parent; | 
            
  
    | 49 | 4 | this.structuresAlreadyProcessed = structuresAlreadyProcessed; | 
            
  
    | 50 | 4 | this.level = level; | 
            
  
    | 51 |  | } | 
            
  
    | 52 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 53 | 0 |  public String getStructureName() {... | 
            
  
    | 54 | 0 | return structureName; | 
            
  
    | 55 |  | } | 
            
  
    | 56 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 57 | 0 |  public MetadataFormatter getParent() {... | 
            
  
    | 58 | 0 | return parent; | 
            
  
    | 59 |  | } | 
            
  
    | 60 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 61 | 0 |  public String getRowSeperator() {... | 
            
  
    | 62 | 0 | return rowSeperator; | 
            
  
    | 63 |  | } | 
            
  
    | 64 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 65 | 0 |  public void setRowSeperator(String rowSeperator) {... | 
            
  
    | 66 | 0 | this.rowSeperator = rowSeperator; | 
            
  
    | 67 |  | } | 
            
  
    | 68 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 69 | 0 |  public String getColSeparator() {... | 
            
  
    | 70 | 0 | return colSeperator; | 
            
  
    | 71 |  | } | 
            
  
    | 72 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 73 | 0 |  public void setColSeparator(String separator) {... | 
            
  
    | 74 | 0 | this.colSeperator = separator; | 
            
  
    | 75 |  | } | 
            
  
    | 76 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (7) | Complexity: 2 | Complexity Density: 0.4 |  | 
  
  
    | 77 | 150 |  private String pad(String str, int size) {... | 
            
  
    | 78 | 150 | StringBuilder padStr = new StringBuilder(size); | 
            
  
    | 79 | 150 | padStr.append(str); | 
            
  
    | 80 | 2058 | while (padStr.length() < size) { | 
            
  
    | 81 | 1908 | padStr.append(' '); | 
            
  
    | 82 |  | } | 
            
  
    | 83 | 150 | return padStr.toString(); | 
            
  
    | 84 |  | } | 
            
  
    | 85 |  |  | 
               
        |  |  | 
           
           |  | 87.4% | Uncovered Elements: 12 (95) | Complexity: 8 | Complexity Density: 0.1 |  | 
  
  
    | 86 | 4 |  public String formatForWiki() {... | 
            
  
    | 87 | 4 | if (!this.structuresAlreadyProcessed.add(structureMetadata)) { | 
            
  
    | 88 | 0 | return ""; | 
            
  
    | 89 |  | } | 
            
  
    | 90 | 4 | if (level == 1) { | 
            
  
    | 91 | 4 | builder.append(rowSeperator); | 
            
  
    | 92 |  |  | 
            
  
    | 93 |  |  | 
            
  
    | 94 | 4 | builder.append(rowSeperator); | 
            
  
    | 95 | 4 | String header = "h1. " + this.calcSimpleName(structureName); | 
            
  
    | 96 | 4 | if (type != null) { | 
            
  
    | 97 | 2 | header = "h2. " + type; | 
            
  
    | 98 |  | } | 
            
  
    | 99 | 4 | builder.append(header); | 
            
  
    | 100 | 4 | builder.append("{anchor:" + structureName + "}"); | 
            
  
    | 101 | 4 | builder.append(rowSeperator); | 
            
  
    | 102 | 4 | builder.append("The object key is " + structureName); | 
            
  
    | 103 | 4 | builder.append(rowSeperator); | 
            
  
    | 104 | 4 | builder.append("The type is " + type); | 
            
  
    | 105 | 4 | builder.append(rowSeperator); | 
            
  
    | 106 | 4 | builder.append(colSeperator); | 
            
  
    | 107 | 4 | builder.append(colSeperator); | 
            
  
    | 108 | 4 | builder.append("Field"); | 
            
  
    | 109 | 4 | builder.append(colSeperator); | 
            
  
    | 110 | 4 | builder.append(colSeperator); | 
            
  
    | 111 | 4 | builder.append("Required?"); | 
            
  
    | 112 | 4 | builder.append(colSeperator); | 
            
  
    | 113 | 4 | builder.append(colSeperator); | 
            
  
    | 114 | 4 | builder.append("DataType"); | 
            
  
    | 115 | 4 | builder.append(colSeperator); | 
            
  
    | 116 | 4 | builder.append(colSeperator); | 
            
  
    | 117 | 4 | builder.append("Length"); | 
            
  
    | 118 | 4 | builder.append(colSeperator); | 
            
  
    | 119 | 4 | builder.append(colSeperator); | 
            
  
    | 120 | 4 | builder.append("Dynamic"); | 
            
  
    | 121 | 4 | builder.append(colSeperator); | 
            
  
    | 122 | 4 | builder.append(colSeperator); | 
            
  
    | 123 | 4 | builder.append("Default"); | 
            
  
    | 124 | 4 | builder.append(colSeperator); | 
            
  
    | 125 | 4 | builder.append(colSeperator); | 
            
  
    | 126 | 4 | builder.append("Repeats?"); | 
            
  
    | 127 | 4 | builder.append(colSeperator); | 
            
  
    | 128 | 4 | builder.append(colSeperator); | 
            
  
    | 129 | 4 | builder.append("Valid Characters"); | 
            
  
    | 130 | 4 | builder.append(colSeperator); | 
            
  
    | 131 | 4 | builder.append(colSeperator); | 
            
  
    | 132 | 4 | builder.append("Lookup Widget"); | 
            
  
    | 133 | 4 | builder.append(colSeperator); | 
            
  
    | 134 | 4 | builder.append(colSeperator); | 
            
  
    | 135 | 4 | builder.append("Lookup"); | 
            
  
    | 136 | 4 | builder.append(colSeperator); | 
            
  
    | 137 | 4 | builder.append(colSeperator); | 
            
  
    | 138 | 4 | builder.append(rowSeperator); | 
            
  
    | 139 |  | } | 
            
  
    | 140 |  |  | 
            
  
    | 141 | 4 | List<String> keys = new ArrayList<String>(); | 
            
  
    | 142 | 4 | keys.addAll(structureMetadata.getProperties().keySet()); | 
            
  
    | 143 | 4 | Collections.sort(keys); | 
            
  
    | 144 | 4 | for (String key : keys) { | 
            
  
    | 145 | 25 | if (key.equalsIgnoreCase ("_runtimeData")) | 
            
  
    | 146 |  | { | 
            
  
    | 147 | 0 | continue; | 
            
  
    | 148 |  | } | 
            
  
    | 149 | 25 | Metadata fieldMeta = structureMetadata.getProperties().get(key); | 
            
  
    | 150 | 25 | builder.append(colSeperator); | 
            
  
    | 151 | 25 | builder.append(calcFieldInfo (key, fieldMeta)); | 
            
  
    | 152 | 25 | builder.append(colSeperator); | 
            
  
    | 153 | 25 | builder.append(pad(calcRequired(fieldMeta), 10)); | 
            
  
    | 154 | 25 | builder.append(colSeperator); | 
            
  
    | 155 | 25 | builder.append(pad(calcDataType(fieldMeta), 25)); | 
            
  
    | 156 | 25 | builder.append(colSeperator); | 
            
  
    | 157 | 25 | builder.append(pad(calcLength(fieldMeta), 15)); | 
            
  
    | 158 | 25 | builder.append(colSeperator); | 
            
  
    | 159 | 25 | builder.append(pad(calcDynamic(fieldMeta), 7)); | 
            
  
    | 160 | 25 | builder.append(colSeperator); | 
            
  
    | 161 | 25 | builder.append(pad(calcDefaultValue(fieldMeta), 15)); | 
            
  
    | 162 | 25 | builder.append(colSeperator); | 
            
  
    | 163 | 25 | builder.append(calcRepeating(fieldMeta)); | 
            
  
    | 164 | 25 | builder.append(colSeperator); | 
            
  
    | 165 | 25 | builder.append(calcValidChars(fieldMeta)); | 
            
  
    | 166 | 25 | builder.append(colSeperator); | 
            
  
    | 167 | 25 | builder.append(calcWidget(fieldMeta)); | 
            
  
    | 168 | 25 | builder.append(colSeperator); | 
            
  
    | 169 | 25 | builder.append(calcLookup(fieldMeta)); | 
            
  
    | 170 | 25 | builder.append(colSeperator); | 
            
  
    | 171 | 25 | builder.append(rowSeperator); | 
            
  
    | 172 | 25 | if (fieldMeta.getDataType().equals(Data.DataType.DATA) | 
            
  
    | 173 |  | || fieldMeta.getDataType().equals(Data.DataType.LIST)) { | 
            
  
    | 174 | 0 | if (fieldMeta.getProperties() == null) { | 
            
  
    | 175 | 0 | throw new IllegalArgumentException( | 
            
  
    | 176 |  | fieldMeta.getName() | 
            
  
    | 177 |  | + " is DATA but does not have a sub-structure defined"); | 
            
  
    | 178 |  | } | 
            
  
    | 179 | 0 | MetadataFormatter formatter = new MetadataFormatter(key, | 
            
  
    | 180 |  | fieldMeta, null, this, structuresAlreadyProcessed, | 
            
  
    | 181 |  | level + 1); | 
            
  
    | 182 | 0 | builder.append(formatter.formatForWiki()); | 
            
  
    | 183 |  | } | 
            
  
    | 184 |  | } | 
            
  
    | 185 |  |  | 
            
  
    | 186 | 4 | return builder.toString(); | 
            
  
    | 187 |  | } | 
            
  
    | 188 |  |  | 
               
        |  |  | 
           
           |  | 25% | Uncovered Elements: 9 (12) | Complexity: 2 | Complexity Density: 0.2 |  | 
  
  
    | 189 | 25 |  private String calcDataType(Metadata fieldMeta) {... | 
            
  
    | 190 | 25 | if (fieldMeta.getDataType().equals(Data.DataType.LIST)) { | 
            
  
    | 191 | 0 | StringBuilder type = new StringBuilder(); | 
            
  
    | 192 | 0 | type.append("LIST of "); | 
            
  
    | 193 | 0 | String comma = ""; | 
            
  
    | 194 | 0 | for (String key : fieldMeta.getProperties().keySet()) { | 
            
  
    | 195 | 0 | type.append(comma); | 
            
  
    | 196 | 0 | type.append(fieldMeta.getProperties().get(key).getDataType() | 
            
  
    | 197 |  | .toString()); | 
            
  
    | 198 | 0 | comma = ", "; | 
            
  
    | 199 |  | } | 
            
  
    | 200 | 0 | return type.toString(); | 
            
  
    | 201 |  | } | 
            
  
    | 202 | 25 | return fieldMeta.getDataType().toString(); | 
            
  
    | 203 |  | } | 
            
  
    | 204 |  |  | 
               
        |  |  | 
           
           |  | 60% | Uncovered Elements: 2 (5) | Complexity: 2 | Complexity Density: 0.67 |  | 
  
  
    | 205 | 25 |  private String calcDefaultValue(Metadata fieldMeta) {... | 
            
  
    | 206 | 25 | if (fieldMeta.getDefaultValue() != null) { | 
            
  
    | 207 | 0 | return fieldMeta.getDefaultValue().toString(); | 
            
  
    | 208 |  | } | 
            
  
    | 209 | 25 | return " "; | 
            
  
    | 210 |  | } | 
            
  
    | 211 |  |  | 
               
        |  |  | 
           
           |  | 60% | Uncovered Elements: 2 (5) | Complexity: 2 | Complexity Density: 0.67 |  | 
  
  
    | 212 | 25 |  private String calcDynamic(Metadata meta) {... | 
            
  
    | 213 | 25 | if (meta.isDynamic()) { | 
            
  
    | 214 | 0 | return "dynamic"; | 
            
  
    | 215 |  | } | 
            
  
    | 216 | 25 | return " "; | 
            
  
    | 217 |  | } | 
            
  
    | 218 |  |  | 
               
        |  |  | 
           
           |  | 55.6% | Uncovered Elements: 4 (9) | Complexity: 2 | Complexity Density: 0.29 |  | 
  
  
    | 219 | 25 |  private String calcFieldInfo (String key, Metadata fieldMeta)... | 
            
  
    | 220 |  | { | 
            
  
    | 221 | 25 | StringBuilder bldr = new StringBuilder (40); | 
            
  
    | 222 | 25 | bldr.append (pad(calcFullyQualifiedFieldName(key), 30)); | 
            
  
    | 223 | 25 | if (fieldMeta.getLabelKey () != null) | 
            
  
    | 224 |  | { | 
            
  
    | 225 | 0 | bldr.append ("\\\\\n"); | 
            
  
    | 226 | 0 | bldr.append ("Label: "); | 
            
  
    | 227 | 0 | bldr.append (fieldMeta.getLabelKey ()); | 
            
  
    | 228 |  | } | 
            
  
    | 229 | 25 | return bldr.toString (); | 
            
  
    | 230 |  | } | 
            
  
    | 231 |  |  | 
               
        |  |  | 
           
           |  | 60% | Uncovered Elements: 2 (5) | Complexity: 2 | Complexity Density: 0.67 |  | 
  
  
    | 232 | 25 |  public String calcFullyQualifiedFieldName(String fieldName) {... | 
            
  
    | 233 | 25 | if (parent == null) { | 
            
  
    | 234 | 25 | return escapeWiki(fieldName); | 
            
  
    | 235 |  | } | 
            
  
    | 236 | 0 | return parent.calcFullyQualifiedFieldName(structureName) + "." | 
            
  
    | 237 |  | + escapeWiki(fieldName); | 
            
  
    | 238 |  | } | 
            
  
    | 239 |  |  | 
               
        |  |  | 
           
           |  | 60% | Uncovered Elements: 2 (5) | Complexity: 2 | Complexity Density: 0.67 |  | 
  
  
    | 240 | 4 |  private String calcSimpleName(String name) {... | 
            
  
    | 241 | 4 | if (name.lastIndexOf(".") != -1) { | 
            
  
    | 242 | 0 | name = name.substring(name.lastIndexOf(".") + 1); | 
            
  
    | 243 |  | } | 
            
  
    | 244 | 4 | return name; | 
            
  
    | 245 |  | } | 
            
  
    | 246 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 7 (7) | Complexity: 2 | Complexity Density: 0.4 |  | 
  
  
    | 247 | 0 |  private String calcNotSoSimpleName(String name) {... | 
            
  
    | 248 | 0 | if (name.lastIndexOf(".") == -1) { | 
            
  
    | 249 | 0 | return name; | 
            
  
    | 250 |  | } | 
            
  
    | 251 | 0 | String simpleName = calcSimpleName(name); | 
            
  
    | 252 | 0 | String fieldName = calcSimpleName(name.substring(0, name.length() | 
            
  
    | 253 |  | - simpleName.length() - 1)); | 
            
  
    | 254 | 0 | return fieldName + "." + simpleName; | 
            
  
    | 255 |  | } | 
            
  
    | 256 |  |  | 
               
        |  |  | 
           
           |  | 87.5% | Uncovered Elements: 2 (16) | Complexity: 5 | Complexity Density: 0.62 |  | 
  
  
    | 257 | 25 |  private String calcRequired(Metadata fieldMeta) {... | 
            
  
    | 258 | 25 | for (ConstraintMetadata cons : fieldMeta.getConstraints()) { | 
            
  
    | 259 | 25 | if (cons.getMaxOccurs() != null) { | 
            
  
    | 260 | 12 | if (cons.getMaxOccurs() == 0) { | 
            
  
    | 261 | 0 | return "NOT USED"; | 
            
  
    | 262 |  | } | 
            
  
    | 263 |  | } | 
            
  
    | 264 |  |  | 
            
  
    | 265 | 25 | if (cons.getMinOccurs() != null) { | 
            
  
    | 266 | 24 | if (cons.getMinOccurs() >= 1) { | 
            
  
    | 267 | 11 | return "required"; | 
            
  
    | 268 |  | } | 
            
  
    | 269 |  | } | 
            
  
    | 270 |  | } | 
            
  
    | 271 | 14 | return " "; | 
            
  
    | 272 |  |  | 
            
  
    | 273 |  | } | 
            
  
    | 274 |  |  | 
            
  
    | 275 |  | private static final String LINK_TO_DEFINITIONS = "KULSTG:Formatted View of Base Dictionary#Valid Character Definitions"; | 
            
  
    | 276 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (9) | Complexity: 2 | Complexity Density: 0.29 |  | 
  
  
    | 277 | 25 |  private String calcValidChars(Metadata fieldMeta) {... | 
            
  
    | 278 | 25 | for (ConstraintMetadata cons : fieldMeta.getConstraints()) { | 
            
  
    | 279 | 25 | if (cons.getValidChars() == null) { | 
            
  
    | 280 | 18 | continue; | 
            
  
    | 281 |  | } | 
            
  
    | 282 | 7 | String validChars = escapeWiki(cons.getValidChars()); | 
            
  
    | 283 | 7 | String descr = "[" + "See" + "|" + LINK_TO_DEFINITIONS + "]" | 
            
  
    | 284 |  | + "\\\\\n" + validChars; | 
            
  
    | 285 | 7 | return descr; | 
            
  
    | 286 |  | } | 
            
  
    | 287 | 18 | return " "; | 
            
  
    | 288 |  | } | 
            
  
    | 289 |  |  | 
               
        |  |  | 
           
           |  | 80.8% | Uncovered Elements: 5 (26) | Complexity: 9 | Complexity Density: 0.45 |  | 
  
  
    | 290 | 32 |  private String escapeWiki(String str) {... | 
            
  
    | 291 | 32 | StringBuilder bldr = new StringBuilder(str.length()); | 
            
  
    | 292 | 32 | boolean precededByBackSlash = false; | 
            
  
    | 293 | 266 | for (int i = 0; i < str.length(); i++) { | 
            
  
    | 294 | 234 | char c = str.charAt(i); | 
            
  
    | 295 | 234 | switch (c) { | 
            
  
    | 296 | 0 | case '\\': | 
            
  
    | 297 | 7 | case '[': | 
            
  
    | 298 | 7 | case '*': | 
            
  
    | 299 | 7 | case ']': | 
            
  
    | 300 | 0 | case '|': | 
            
  
    | 301 | 21 | if (!precededByBackSlash) { | 
            
  
    | 302 | 21 | bldr.append('\\'); | 
            
  
    | 303 |  | } | 
            
  
    | 304 | 21 | break; | 
            
  
    | 305 | 213 | default: | 
            
  
    | 306 | 213 | break; | 
            
  
    | 307 |  | } | 
            
  
    | 308 | 234 | bldr.append(c); | 
            
  
    | 309 | 234 | if (c == '\\') { | 
            
  
    | 310 | 0 | precededByBackSlash = true; | 
            
  
    | 311 |  | } else { | 
            
  
    | 312 | 234 | precededByBackSlash = false; | 
            
  
    | 313 |  | } | 
            
  
    | 314 |  | } | 
            
  
    | 315 | 32 | return bldr.toString(); | 
            
  
    | 316 |  | } | 
            
  
    | 317 |  |  | 
               
        |  |  | 
           
           |  | 87.1% | Uncovered Elements: 4 (31) | Complexity: 6 | Complexity Density: 0.29 |  | 
  
  
    | 318 | 25 |  private String calcWidget(Metadata fieldMeta) {... | 
            
  
    | 319 | 25 | StringBuilder bldr = new StringBuilder(); | 
            
  
    | 320 | 25 | String comma = ""; | 
            
  
    | 321 | 25 | if (!fieldMeta.isCanEdit()) { | 
            
  
    | 322 | 2 | bldr.append(comma); | 
            
  
    | 323 | 2 | bldr.append("not editable"); | 
            
  
    | 324 | 2 | comma = ", "; | 
            
  
    | 325 |  | } | 
            
  
    | 326 | 25 | if (!fieldMeta.isCanView()) { | 
            
  
    | 327 | 0 | bldr.append(comma); | 
            
  
    | 328 | 0 | bldr.append("not viewable"); | 
            
  
    | 329 | 0 | comma = ", "; | 
            
  
    | 330 |  | } | 
            
  
    | 331 | 25 | if (!fieldMeta.isCanUnmask()) { | 
            
  
    | 332 | 1 | bldr.append(comma); | 
            
  
    | 333 | 1 | bldr.append("Not unmaskable"); | 
            
  
    | 334 | 1 | comma = ", "; | 
            
  
    | 335 |  | } | 
            
  
    | 336 | 25 | if (fieldMeta.getInitialLookup() != null) { | 
            
  
    | 337 | 2 | bldr.append(comma); | 
            
  
    | 338 | 2 | bldr.append(fieldMeta.getInitialLookup().getWidget()); | 
            
  
    | 339 | 2 | comma = ", "; | 
            
  
    | 340 |  | } | 
            
  
    | 341 | 25 | if (bldr.length() == 0) { | 
            
  
    | 342 | 21 | bldr.append(" "); | 
            
  
    | 343 |  | } | 
            
  
    | 344 | 25 | return bldr.toString(); | 
            
  
    | 345 |  | } | 
            
  
    | 346 |  |  | 
               
        |  |  | 
           
           |  | 45.5% | Uncovered Elements: 18 (33) | Complexity: 6 | Complexity Density: 0.26 |  | 
  
  
    | 347 | 25 |  private String calcLookup(Metadata fieldMeta) {... | 
            
  
    | 348 | 25 | StringBuilder bldr = new StringBuilder (); | 
            
  
    | 349 | 25 | if (fieldMeta.getInitialLookup() != null) { | 
            
  
    | 350 | 2 | bldr.append (calcLookup (fieldMeta.getInitialLookup ())); | 
            
  
    | 351 |  | } | 
            
  
    | 352 |  |  | 
            
  
    | 353 | 25 | if (fieldMeta.getAdditionalLookups () != null) { | 
            
  
    | 354 | 25 | if (fieldMeta.getAdditionalLookups ().size () > 0) { | 
            
  
    | 355 | 0 | if (fieldMeta.getInitialLookup() == null) { | 
            
  
    | 356 | 0 | bldr.append ("No initial lookup but..."); | 
            
  
    | 357 |  | } | 
            
  
    | 358 | 0 | bldr.append("\\\\"); | 
            
  
    | 359 | 0 | bldr.append("\n"); | 
            
  
    | 360 | 0 | bldr.append("\\\\"); | 
            
  
    | 361 | 0 | bldr.append("\n"); | 
            
  
    | 362 | 0 | bldr.append ("Additional Lookups:"); | 
            
  
    | 363 | 0 | bldr.append("\\\\"); | 
            
  
    | 364 | 0 | bldr.append("\n"); | 
            
  
    | 365 |  | } | 
            
  
    | 366 | 25 | for (LookupMetadata lm : fieldMeta.getAdditionalLookups ())  { | 
            
  
    | 367 | 0 | bldr.append("\\\\"); | 
            
  
    | 368 | 0 | bldr.append("\n"); | 
            
  
    | 369 | 0 | bldr.append (calcLookup (lm)); | 
            
  
    | 370 | 0 | bldr.append("\\\\"); | 
            
  
    | 371 | 0 | bldr.append("\n"); | 
            
  
    | 372 |  | } | 
            
  
    | 373 |  | } | 
            
  
    | 374 | 25 | if (bldr.length () == 0) | 
            
  
    | 375 |  | { | 
            
  
    | 376 | 23 | bldr.append (" "); | 
            
  
    | 377 |  | } | 
            
  
    | 378 | 25 | return bldr.toString (); | 
            
  
    | 379 |  | } | 
            
  
    | 380 |  |  | 
               
        |  |  | 
           
           |  | 42.2% | Uncovered Elements: 48 (83) | Complexity: 10 | Complexity Density: 0.15 |  | 
  
  
    | 381 | 2 |  private String calcLookup(LookupMetadata lm) {... | 
            
  
    | 382 | 2 | StringBuilder bldr = new StringBuilder(); | 
            
  
    | 383 | 2 | bldr.append(lm.getId()); | 
            
  
    | 384 |  |  | 
            
  
    | 385 |  |  | 
            
  
    | 386 |  |  | 
            
  
    | 387 |  |  | 
            
  
    | 388 | 2 | bldr.append (" - "); | 
            
  
    | 389 | 2 | bldr.append (lm.getName()); | 
            
  
    | 390 | 2 | bldr.append (" " + lm.getWidget ()); | 
            
  
    | 391 | 2 | String and = " with option "; | 
            
  
    | 392 | 2 | if (lm.getWidgetOptions () != null) { | 
            
  
    | 393 | 0 | for (LookupMetadata.WidgetOption wo: lm.getWidgetOptions ().keySet ()) | 
            
  
    | 394 |  | { | 
            
  
    | 395 | 0 | bldr.append (" and "); | 
            
  
    | 396 | 0 | bldr.append (wo); | 
            
  
    | 397 | 0 | bldr.append ("="); | 
            
  
    | 398 | 0 | bldr.append (lm.getWidgetOptions ().get (wo)); | 
            
  
    | 399 |  | } | 
            
  
    | 400 |  | } | 
            
  
    | 401 | 2 | and = ""; | 
            
  
    | 402 | 2 | bldr.append("\\\\\n"); | 
            
  
    | 403 | 2 | bldr.append("Implemented using search: "); | 
            
  
    | 404 | 2 | String searchPage = calcWikiSearchPage(lm.getSearchTypeId()); | 
            
  
    | 405 | 2 | bldr.append("[" + lm.getSearchTypeId() + "|" + searchPage + "#" | 
            
  
    | 406 |  | + lm.getSearchTypeId() + "]"); | 
            
  
    | 407 | 2 | List<LookupParamMetadata> configuredParameters = filterConfiguredParams(lm | 
            
  
    | 408 |  | .getParams()); | 
            
  
    | 409 | 2 | if (configuredParameters.size() > 0) { | 
            
  
    | 410 | 2 | bldr.append("\\\\"); | 
            
  
    | 411 | 2 | bldr.append("\n"); | 
            
  
    | 412 | 2 | bldr.append(" where "); | 
            
  
    | 413 | 2 | and = ""; | 
            
  
    | 414 | 2 | for (LookupParamMetadata param : configuredParameters) { | 
            
  
    | 415 | 2 | bldr.append(and); | 
            
  
    | 416 | 2 | and = " and "; | 
            
  
    | 417 | 2 | bldr.append(param.getName()); | 
            
  
    | 418 | 2 | bldr.append (" (" + param.getDataType () + ") "); | 
            
  
    | 419 | 2 | bldr.append("="); | 
            
  
    | 420 | 2 | if (param.getDefaultValueString() != null) { | 
            
  
    | 421 | 2 | bldr.append(param.getDefaultValueString()); | 
            
  
    | 422 |  | } | 
            
  
    | 423 | 2 | if (param.getDefaultValueList() != null) { | 
            
  
    | 424 | 0 | String comma = ""; | 
            
  
    | 425 | 0 | for (String defValue : param.getDefaultValueList()) { | 
            
  
    | 426 | 0 | bldr.append(comma); | 
            
  
    | 427 | 0 | comma = ", "; | 
            
  
    | 428 | 0 | bldr.append(defValue); | 
            
  
    | 429 |  | } | 
            
  
    | 430 |  | } | 
            
  
    | 431 |  | } | 
            
  
    | 432 |  | } | 
            
  
    | 433 | 2 | List<LookupParamMetadata> userEnterableParameters = this.filterUserEnterableParams (lm | 
            
  
    | 434 |  | .getParams()); | 
            
  
    | 435 | 2 | if (userEnterableParameters.size() > 0) { | 
            
  
    | 436 | 0 | bldr.append("\\\\"); | 
            
  
    | 437 | 0 | bldr.append("\n"); | 
            
  
    | 438 | 0 | bldr.append(" and the user can enter: "); | 
            
  
    | 439 | 0 | for (LookupParamMetadata param : userEnterableParameters) { | 
            
  
    | 440 | 0 | bldr.append ("\\\\\n"); | 
            
  
    | 441 | 0 | bldr.append(param.getName()); | 
            
  
    | 442 | 0 | bldr.append (" (" + param.getDataType () + ")"); | 
            
  
    | 443 | 0 | if (param.getWidget () != null) { | 
            
  
    | 444 | 0 | bldr.append(" using widget "); | 
            
  
    | 445 | 0 | bldr.append (param.getWidget ()); | 
            
  
    | 446 |  | } | 
            
  
    | 447 | 0 | if (param.getDefaultValueString() != null) { | 
            
  
    | 448 | 0 | bldr.append("defaulted to " + param.getDefaultValueString()); | 
            
  
    | 449 |  | } | 
            
  
    | 450 | 0 | if (param.getDefaultValueList() != null) { | 
            
  
    | 451 | 0 | String comma = "defaulted to "; | 
            
  
    | 452 | 0 | for (String defValue : param.getDefaultValueList()) { | 
            
  
    | 453 | 0 | bldr.append(comma); | 
            
  
    | 454 | 0 | comma = ", "; | 
            
  
    | 455 | 0 | bldr.append(defValue); | 
            
  
    | 456 |  | } | 
            
  
    | 457 |  | } | 
            
  
    | 458 | 0 | if (param.getChildLookup () != null) | 
            
  
    | 459 |  | { | 
            
  
    | 460 | 0 | bldr.append("\\\\"); | 
            
  
    | 461 | 0 | bldr.append("\n"); | 
            
  
    | 462 | 0 | bldr.append ("using a child lookup: "); | 
            
  
    | 463 | 0 | bldr.append("\\\\"); | 
            
  
    | 464 | 0 | bldr.append("\n"); | 
            
  
    | 465 | 0 | bldr.append (calcLookup (param.getChildLookup ())); | 
            
  
    | 466 |  | } | 
            
  
    | 467 |  | } | 
            
  
    | 468 |  | } | 
            
  
    | 469 | 2 | return bldr.toString(); | 
            
  
    | 470 |  | } | 
            
  
    | 471 |  |  | 
            
  
    | 472 |  | private static final String PAGE_PREFIX = "Formatted View of "; | 
            
  
    | 473 |  | private static final String PAGE_SUFFIX = " Searches"; | 
            
  
    | 474 |  |  | 
               
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 475 | 2 |  private String calcWikiSearchPage(String searchType) {... | 
            
  
    | 476 | 2 | return PAGE_PREFIX + calcWikigPageAbbrev(searchType) + PAGE_SUFFIX; | 
            
  
    | 477 |  | } | 
            
  
    | 478 |  |  | 
               
        |  |  | 
           
           |  | 10.2% | Uncovered Elements: 44 (49) | Complexity: 13 | Complexity Density: 0.52 |  | 
  
  
    | 479 | 2 |  private String calcWikigPageAbbrev(String searchType) {... | 
            
  
    | 480 | 2 | if (searchType == null) { | 
            
  
    | 481 | 0 | return null; | 
            
  
    | 482 |  | } | 
            
  
    | 483 | 2 | if (searchType.equals("enumeration.management.search")) { | 
            
  
    | 484 | 2 | return "EM"; | 
            
  
    | 485 |  | } | 
            
  
    | 486 | 0 | if (searchType.startsWith("lu.")) { | 
            
  
    | 487 | 0 | return "LU"; | 
            
  
    | 488 |  | } | 
            
  
    | 489 | 0 | if (searchType.startsWith("cluset.")) { | 
            
  
    | 490 | 0 | return "LU"; | 
            
  
    | 491 |  | } | 
            
  
    | 492 | 0 | if (searchType.startsWith("lo.")) { | 
            
  
    | 493 | 0 | return "LO"; | 
            
  
    | 494 |  | } | 
            
  
    | 495 | 0 | if (searchType.startsWith("lrc.")) { | 
            
  
    | 496 | 0 | return "LRC"; | 
            
  
    | 497 |  | } | 
            
  
    | 498 | 0 | if (searchType.startsWith("comment.")) { | 
            
  
    | 499 | 0 | return "Comment"; | 
            
  
    | 500 |  | } | 
            
  
    | 501 | 0 | if (searchType.startsWith("org.")) { | 
            
  
    | 502 | 0 | return "Organization"; | 
            
  
    | 503 |  | } | 
            
  
    | 504 | 0 | if (searchType.startsWith("atp.")) { | 
            
  
    | 505 | 0 | return "ATP"; | 
            
  
    | 506 |  | } | 
            
  
    | 507 | 0 | if (searchType.startsWith("person.")) { | 
            
  
    | 508 | 0 | return "Person"; | 
            
  
    | 509 |  | } | 
            
  
    | 510 | 0 | if (searchType.startsWith("proposal.")) { | 
            
  
    | 511 | 0 | return "Proposal"; | 
            
  
    | 512 |  | } | 
            
  
    | 513 | 0 | if (searchType.startsWith("subjectCode.")) { | 
            
  
    | 514 | 0 | return "SC"; | 
            
  
    | 515 |  | } | 
            
  
    | 516 | 0 | throw new IllegalArgumentException("Unknown type of search: " | 
            
  
    | 517 |  | + searchType); | 
            
  
    | 518 |  | } | 
            
  
    | 519 |  |  | 
               
        |  |  | 
           
           |  | 66.7% | Uncovered Elements: 7 (21) | Complexity: 5 | Complexity Density: 0.38 |  | 
  
  
    | 520 | 2 |  private List<LookupParamMetadata> filterConfiguredParams(... | 
            
  
    | 521 |  | List<LookupParamMetadata> params) { | 
            
  
    | 522 | 2 | List<LookupParamMetadata> list = new ArrayList<LookupParamMetadata>(); | 
            
  
    | 523 | 2 | if (params == null) { | 
            
  
    | 524 | 0 | return list; | 
            
  
    | 525 |  | } | 
            
  
    | 526 | 2 | if (params.size() == 0) { | 
            
  
    | 527 | 0 | return list; | 
            
  
    | 528 |  | } | 
            
  
    | 529 | 2 | for (LookupParamMetadata param : params) { | 
            
  
    | 530 | 10 | if (param.getDefaultValueString() != null) { | 
            
  
    | 531 | 2 | list.add(param); | 
            
  
    | 532 | 2 | continue; | 
            
  
    | 533 |  | } | 
            
  
    | 534 | 8 | if (param.getDefaultValueList() != null) { | 
            
  
    | 535 | 0 | list.add(param); | 
            
  
    | 536 | 0 | continue; | 
            
  
    | 537 |  | } | 
            
  
    | 538 |  | } | 
            
  
    | 539 | 2 | return list; | 
            
  
    | 540 |  | } | 
            
  
    | 541 |  |  | 
               
        |  |  | 
           
           |  | 63.2% | Uncovered Elements: 7 (19) | Complexity: 5 | Complexity Density: 0.45 |  | 
  
  
    | 542 | 2 |  private List<LookupParamMetadata> filterUserEnterableParams (... | 
            
  
    | 543 |  | List<LookupParamMetadata> params) { | 
            
  
    | 544 | 2 | List<LookupParamMetadata> list = new ArrayList<LookupParamMetadata>(); | 
            
  
    | 545 | 2 | if (params == null) { | 
            
  
    | 546 | 0 | return list; | 
            
  
    | 547 |  | } | 
            
  
    | 548 | 2 | if (params.size() == 0) { | 
            
  
    | 549 | 0 | return list; | 
            
  
    | 550 |  | } | 
            
  
    | 551 | 2 | for (LookupParamMetadata param : params) { | 
            
  
    | 552 | 10 | if (param.getWriteAccess () != null) { | 
            
  
    | 553 | 8 | if ( ! param.getWriteAccess ().equals (Metadata.WriteAccess.NEVER)) { | 
            
  
    | 554 | 0 | list.add(param); | 
            
  
    | 555 | 0 | continue; | 
            
  
    | 556 |  | } | 
            
  
    | 557 |  | } | 
            
  
    | 558 |  | } | 
            
  
    | 559 | 2 | return list; | 
            
  
    | 560 |  | } | 
            
  
    | 561 |  |  | 
               
        |  |  | 
           
           |  | 10.3% | Uncovered Elements: 26 (29) | Complexity: 9 | Complexity Density: 0.6 |  | 
  
  
    | 562 | 25 |  private String calcRepeating(Metadata fieldMeta) {... | 
            
  
    | 563 | 25 | if (!fieldMeta.getDataType().equals(Data.DataType.LIST)) { | 
            
  
    | 564 | 25 | return " "; | 
            
  
    | 565 |  | } | 
            
  
    | 566 |  |  | 
            
  
    | 567 | 0 | MetadataInterrogator mi = new MetadataInterrogator(fieldMeta); | 
            
  
    | 568 | 0 | if (mi.getSmallestMaxOccurs() == null) { | 
            
  
    | 569 | 0 | if (mi.getLargestMinOccurs() != null | 
            
  
    | 570 |  | && mi.getLargestMinOccurs() > 1) { | 
            
  
    | 571 | 0 | return "repeating: minimum " + mi.getLargestMinOccurs() | 
            
  
    | 572 |  | + " times"; | 
            
  
    | 573 |  | } | 
            
  
    | 574 | 0 | return "repeating: unlimited"; | 
            
  
    | 575 |  | } | 
            
  
    | 576 | 0 | if (mi.getSmallestMaxOccurs() == 0) { | 
            
  
    | 577 | 0 | return "NOT USED"; | 
            
  
    | 578 |  | } | 
            
  
    | 579 | 0 | if (mi.getSmallestMaxOccurs() == 1) { | 
            
  
    | 580 | 0 | return " "; | 
            
  
    | 581 |  |  | 
            
  
    | 582 |  | } | 
            
  
    | 583 |  |  | 
            
  
    | 584 | 0 | if (mi.getLargestMinOccurs() != null) { | 
            
  
    | 585 | 0 | if (mi.getLargestMinOccurs() > 1) { | 
            
  
    | 586 | 0 | return "repeating: " + mi.getLargestMinOccurs() + " to " | 
            
  
    | 587 |  | + mi.getSmallestMaxOccurs() + " times"; | 
            
  
    | 588 |  | } | 
            
  
    | 589 |  | } | 
            
  
    | 590 | 0 | return "repeating: maximum " + mi.getSmallestMaxOccurs() + " times"; | 
            
  
    | 591 |  | } | 
            
  
    | 592 |  |  | 
               
        |  |  | 
           
           |  | 66.7% | Uncovered Elements: 6 (18) | Complexity: 6 | Complexity Density: 0.6 |  | 
  
  
    | 593 | 25 |  private String calcLength(Metadata fieldMeta) {... | 
            
  
    | 594 | 25 | MetadataInterrogator mi = new MetadataInterrogator(fieldMeta); | 
            
  
    | 595 | 25 | if (mi.getSmallestMaxLength() != null) { | 
            
  
    | 596 | 22 | if (mi.getLargestMinLength() != null | 
            
  
    | 597 |  | && mi.getLargestMinLength() != 0) { | 
            
  
    | 598 | 22 | if (mi.getSmallestMaxLength() == mi.getLargestMinLength()) { | 
            
  
    | 599 | 0 | return ("(must be " + mi.getSmallestMaxLength() + ")"); | 
            
  
    | 600 |  | } | 
            
  
    | 601 | 22 | return "(" + mi.getLargestMinLength() + " to " | 
            
  
    | 602 |  | + mi.getSmallestMaxLength() + ")"; | 
            
  
    | 603 |  | } | 
            
  
    | 604 | 0 | return "(up to " + mi.getSmallestMaxLength() + ")"; | 
            
  
    | 605 |  | } | 
            
  
    | 606 | 3 | if (mi.getLargestMinLength() != null) { | 
            
  
    | 607 | 0 | return "(over " + mi.getLargestMinLength() + ")"; | 
            
  
    | 608 |  | } | 
            
  
    | 609 | 3 | return " "; | 
            
  
    | 610 |  | } | 
            
  
    | 611 |  | } |