| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.common.ui.client.configurable.mvc.multiplicity; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.HashMap; |
| 20 |
|
import java.util.List; |
| 21 |
|
import java.util.Map; |
| 22 |
|
|
| 23 |
|
import org.kuali.student.common.assembly.data.Metadata; |
| 24 |
|
import org.kuali.student.common.assembly.data.QueryPath; |
| 25 |
|
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 26 |
|
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
| 27 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 117 (117) |
Complexity: 41 |
Complexity Density: 0.56 |
|
| 46 |
|
public class MultiplicityConfiguration { |
| 47 |
|
|
| 48 |
|
private MultiplicityType multiplicityType; |
| 49 |
|
|
| 50 |
|
private StyleType styleType; |
| 51 |
|
private boolean updateable = false; |
| 52 |
|
|
| 53 |
|
private String itemLabel; |
| 54 |
|
private String addItemLabel; |
| 55 |
|
|
| 56 |
|
private Metadata metaData; |
| 57 |
|
|
| 58 |
|
private SectionTitle title; |
| 59 |
|
private int defaultItemsCreated = 0; |
| 60 |
|
|
| 61 |
|
int row = 0; |
| 62 |
|
|
| 63 |
|
private FieldDescriptor parentFd; |
| 64 |
|
private Map<Integer, List<MultiplicityFieldConfiguration>> fields = new HashMap<Integer, List<MultiplicityFieldConfiguration>>(); |
| 65 |
|
private Map<String, FieldDescriptor> fieldMap = new HashMap<String, FieldDescriptor>(); |
| 66 |
|
protected Map<String, String> concatenatedFields = new HashMap<String, String>(); |
| 67 |
|
|
| 68 |
|
private MultiplicityConfiguration nestedConfig ; |
| 69 |
|
private MultiplicityGroup customMultiplicityGroup; |
| 70 |
|
private boolean showHeaders; |
| 71 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 72 |
|
public static enum MultiplicityType {GROUP, TABLE } |
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
| 73 |
|
public static enum StyleType { |
| 74 |
|
TOP_LEVEL_GROUP, SUB_LEVEL_GROUP, BORDERLESS_TABLE, BORDERED_TABLE |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@param |
| 84 |
|
@param |
| 85 |
|
@param |
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 87 |
0
|
public MultiplicityConfiguration(MultiplicityType multiplicityType, StyleType styleType, Metadata metaData) {... |
| 88 |
0
|
this.multiplicityType = multiplicityType; |
| 89 |
0
|
this.styleType = styleType; |
| 90 |
0
|
this.metaData = metaData; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 97 |
0
|
public void nextLine() {... |
| 98 |
0
|
row++; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
@param |
| 106 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 107 |
0
|
public void addFieldConfiguration(MultiplicityFieldConfiguration fieldDescriptor) {... |
| 108 |
|
|
| 109 |
0
|
List<MultiplicityFieldConfiguration> fds; |
| 110 |
0
|
if (fields.containsKey(row)) { |
| 111 |
0
|
fds = fields.get(row); |
| 112 |
|
} |
| 113 |
|
else { |
| 114 |
0
|
fds = new ArrayList<MultiplicityFieldConfiguration>(); |
| 115 |
|
} |
| 116 |
0
|
fds.add(fieldDescriptor); |
| 117 |
0
|
fields.put(row, fds); |
| 118 |
|
} |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 120 |
0
|
public void setFields(Map<Integer, List<MultiplicityFieldConfiguration>> fields) {... |
| 121 |
0
|
if (fields == null || fields.isEmpty()) { |
| 122 |
0
|
row = 0; |
| 123 |
|
} else { |
| 124 |
0
|
row = fields.size() - 1; |
| 125 |
|
} |
| 126 |
0
|
this.fields = fields; |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
@param |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 144 |
0
|
public void addConcatenatedField(MultiplicityFieldConfiguration parentField, String fieldKey){... |
| 145 |
0
|
addFieldConfiguration(parentField); |
| 146 |
0
|
concatenatedFields.put(parentField.getFieldPath(), fieldKey); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@return |
| 153 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 3 |
Complexity Density: 0.14 |
|
| 154 |
0
|
public MultiplicityConfiguration copy() {... |
| 155 |
0
|
MultiplicityConfiguration copy = new MultiplicityConfiguration(getMultiplicityType(), getStyleType(), getMetaData()); |
| 156 |
0
|
copy.setAddItemLabel(getAddItemLabel()); |
| 157 |
0
|
copy.setItemLabel(getItemLabel()); |
| 158 |
0
|
copy.setMetaData(getMetaData()); |
| 159 |
0
|
copy.setUpdateable(isUpdateable()); |
| 160 |
0
|
copy.setDefaultItemsCreated(getDefaultItemsCreated()); |
| 161 |
0
|
if (getNestedConfig() != null) { |
| 162 |
0
|
copy.setNestedConfig(getNestedConfig().copy()); |
| 163 |
|
} |
| 164 |
0
|
FieldDescriptor parent = new FieldDescriptor(getParentFd().getFieldKey(), getParentFd().getMessageKey(), getParentFd().getMetadata()); |
| 165 |
0
|
if(!getParentFd().isLabelShown()){ |
| 166 |
0
|
parent.hideLabel(); |
| 167 |
|
} |
| 168 |
0
|
copy.setParent(parent); |
| 169 |
0
|
for (Integer row : getFields().keySet()) { |
| 170 |
0
|
List<MultiplicityFieldConfiguration> fields = getFields().get(row); |
| 171 |
0
|
for (MultiplicityFieldConfiguration fieldConfig : fields) { |
| 172 |
0
|
MultiplicityFieldConfiguration newfieldConfig = new MultiplicityFieldConfiguration(fieldConfig.getFieldPath(), fieldConfig.getMessageKeyInfo(), fieldConfig.getMetadata(), fieldConfig.getFieldWidgetInitializer()); |
| 173 |
0
|
newfieldConfig.setOptional(fieldConfig.isOptional()); |
| 174 |
0
|
newfieldConfig.setModelWidgetBinding(fieldConfig.getModelWidgetBinding()); |
| 175 |
0
|
copy.addFieldConfiguration(newfieldConfig); |
| 176 |
|
} |
| 177 |
0
|
copy.nextLine(); |
| 178 |
|
} |
| 179 |
0
|
return copy; |
| 180 |
|
} |
| 181 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 182 |
0
|
public MultiplicityType getMultiplicityType() {... |
| 183 |
0
|
return multiplicityType; |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
@link |
| 190 |
|
@param |
| 191 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 192 |
0
|
public void setMultiplicityType(MultiplicityType multiplicityType) {... |
| 193 |
0
|
this.multiplicityType = multiplicityType; |
| 194 |
|
} |
| 195 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 196 |
0
|
public FieldDescriptor getParentFd() {... |
| 197 |
0
|
return parentFd; |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
@param |
| 204 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 205 |
0
|
public void setParent(FieldDescriptor parentFd) {... |
| 206 |
0
|
this.parentFd = parentFd; |
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 211 |
0
|
public Map<Integer, List<MultiplicityFieldConfiguration>> getFields() {... |
| 212 |
0
|
return fields; |
| 213 |
|
} |
| 214 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 215 |
0
|
public String getItemLabel() {... |
| 216 |
0
|
return itemLabel; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
@param |
| 222 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 223 |
0
|
public void setItemLabel(String itemLabel) {... |
| 224 |
0
|
this.itemLabel = itemLabel; |
| 225 |
|
} |
| 226 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 227 |
0
|
public String getAddItemLabel() {... |
| 228 |
0
|
return addItemLabel; |
| 229 |
|
} |
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
@param |
| 234 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 235 |
0
|
public void setAddItemLabel(String addItemLabel) {... |
| 236 |
0
|
this.addItemLabel = addItemLabel; |
| 237 |
|
} |
| 238 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 239 |
0
|
public StyleType getStyleType() {... |
| 240 |
0
|
return styleType; |
| 241 |
|
} |
| 242 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 243 |
0
|
public void setStyleType(StyleType styleType) {... |
| 244 |
0
|
this.styleType = styleType; |
| 245 |
|
} |
| 246 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 247 |
0
|
public MultiplicityConfiguration getNestedConfig() {... |
| 248 |
0
|
return nestedConfig; |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
@param |
| 256 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 257 |
0
|
public void setNestedConfig(MultiplicityConfiguration config) {... |
| 258 |
0
|
this.nestedConfig = config; |
| 259 |
|
} |
| 260 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 261 |
0
|
public boolean isShowHeaders() {... |
| 262 |
0
|
return showHeaders; |
| 263 |
|
} |
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
@param |
| 268 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 269 |
0
|
public void setShowHeaders(boolean showHeaders) {... |
| 270 |
0
|
this.showHeaders = showHeaders; |
| 271 |
|
} |
| 272 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 273 |
0
|
public Map<String, String> getConcatenatedFields() {... |
| 274 |
0
|
return concatenatedFields; |
| 275 |
|
} |
| 276 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 277 |
0
|
public boolean isUpdateable() {... |
| 278 |
0
|
return updateable; |
| 279 |
|
} |
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
@param |
| 286 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 287 |
0
|
public void setUpdateable(boolean updateable) {... |
| 288 |
0
|
this.updateable = updateable; |
| 289 |
|
} |
| 290 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 291 |
0
|
public MultiplicityType getLayoutType() {... |
| 292 |
0
|
return multiplicityType; |
| 293 |
|
} |
| 294 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 295 |
0
|
public void setLayoutType(MultiplicityType multiplicityType) {... |
| 296 |
0
|
this.multiplicityType = multiplicityType; |
| 297 |
|
} |
| 298 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 299 |
0
|
public Metadata getMetaData() {... |
| 300 |
0
|
return metaData; |
| 301 |
|
} |
| 302 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 303 |
0
|
public void setMetaData(Metadata metaData) {... |
| 304 |
0
|
this.metaData = metaData; |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 308 |
0
|
public SectionTitle getTitle() {... |
| 309 |
0
|
return title; |
| 310 |
|
} |
| 311 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 312 |
0
|
public void setTitle(SectionTitle title) {... |
| 313 |
0
|
this.title = title; |
| 314 |
|
} |
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
@param |
| 323 |
|
@param |
| 324 |
|
@param |
| 325 |
|
@param |
| 326 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 327 |
0
|
public void setParent(String fieldKey, String messageKey, String parentPath, Metadata meta) {... |
| 328 |
|
|
| 329 |
0
|
QueryPath path = QueryPath.concat(parentPath, fieldKey); |
| 330 |
0
|
FieldDescriptor fd = new FieldDescriptor(path.toString(), new MessageKeyInfo(messageKey), meta); |
| 331 |
0
|
fd.getFieldElement().setRequired(false); |
| 332 |
|
|
| 333 |
0
|
setParent(fd); |
| 334 |
|
|
| 335 |
|
} |
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
@param |
| 344 |
|
@param |
| 345 |
|
@param |
| 346 |
|
@param |
| 347 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 348 |
0
|
public void addField(String fieldKey, String messageKey, String parentPath, Metadata meta) {... |
| 349 |
|
|
| 350 |
0
|
QueryPath path = QueryPath.concat(parentPath, QueryPath.getWildCard(), fieldKey); |
| 351 |
|
|
| 352 |
0
|
MultiplicityFieldConfiguration fieldConfig = new MultiplicityFieldConfiguration(path.toString(), new MessageKeyInfo(messageKey), meta, null); |
| 353 |
0
|
fieldConfig.setRequired(false); |
| 354 |
0
|
addFieldConfiguration(fieldConfig); |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
|
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
| 370 |
|
|
| 371 |
|
|
| 372 |
|
|
| 373 |
|
|
| 374 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 375 |
0
|
public MultiplicityGroup getCustomMultiplicityGroup() {... |
| 376 |
0
|
return customMultiplicityGroup; |
| 377 |
|
} |
| 378 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 379 |
0
|
public void setCustomMultiplicityGroup(MultiplicityGroup customMultiplicityGroup) {... |
| 380 |
0
|
this.customMultiplicityGroup = customMultiplicityGroup; |
| 381 |
|
} |
| 382 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 383 |
0
|
public void setDefaultItemsCreated(int defaultItemsCreated) {... |
| 384 |
0
|
this.defaultItemsCreated = defaultItemsCreated; |
| 385 |
|
} |
| 386 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 387 |
0
|
public int getDefaultItemsCreated() {... |
| 388 |
0
|
return defaultItemsCreated; |
| 389 |
|
} |
| 390 |
|
|
| 391 |
|
|
| 392 |
|
} |
| 393 |
|
|