Coverage Report - org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection
 
Classes in this File Line Coverage Branch Coverage Complexity
SummaryTableSection
0%
0/393
0%
0/152
4.16
SummaryTableSection$1
0%
0/7
N/A
4.16
 
 1  
 package org.kuali.student.common.ui.client.widgets.table.summary;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Iterator;
 5  
 import java.util.List;
 6  
 import java.util.Map;
 7  
 
 8  
 import org.kuali.student.common.assembly.data.Data;
 9  
 import org.kuali.student.common.assembly.data.MetadataInterrogator;
 10  
 import org.kuali.student.common.assembly.data.QueryPath;
 11  
 import org.kuali.student.common.assembly.data.Data.Property;
 12  
 import org.kuali.student.common.ui.client.application.Application;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
 14  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly;
 15  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 16  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
 17  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityConfiguration;
 18  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityFieldConfiguration;
 19  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
 20  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 21  
 import org.kuali.student.common.ui.client.mvc.Controller;
 22  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 23  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 24  
 import org.kuali.student.common.validation.dto.ValidationResultInfo;
 25  
 import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel;
 26  
 
 27  
 import com.google.gwt.core.client.GWT;
 28  
 import com.google.gwt.user.client.ui.Widget;
 29  
 
 30  0
 public class SummaryTableSection extends VerticalSection {
 31  0
     SummaryTable summaryTable = new SummaryTable();
 32  0
     SummaryTableModel summaryTableModel = new SummaryTableModel();
 33  
     Controller controller;
 34  0
     DataModel comparisonModel = null;
 35  0
     List<ShowRowConditionCallback> showRowCallbacks = new ArrayList<ShowRowConditionCallback>();
 36  
 
 37  
     public SummaryTableSection(Controller controller) {
 38  0
         super();
 39  0
         this.controller = controller;
 40  0
         this.addWidget(summaryTable);
 41  0
         summaryTable.setModel(summaryTableModel);
 42  0
     }
 43  
 
 44  
     public SummaryTableSection(Controller controller, SectionTitle title) {
 45  0
         super(title);
 46  0
         this.controller = controller;
 47  0
         this.addWidget(summaryTable);
 48  0
         summaryTable.setModel(summaryTableModel);
 49  0
     }
 50  
 
 51  
     public void setContentColumnHeader1(String title) {
 52  0
         summaryTableModel.setContentColumnHeader1(title);
 53  0
     }
 54  
 
 55  
     public void setContentColumnHeader2(String title) {
 56  0
         summaryTableModel.setContentColumnHeader2(title);
 57  0
     }
 58  
 
 59  
     public String getContentColumnHeader1() {
 60  0
         return summaryTableModel.getContentColumnHeader1();
 61  
     }
 62  
 
 63  
     public String getContentColumnHeader2() {
 64  0
         return summaryTableModel.getContentColumnHeader2();
 65  
     }
 66  
 
 67  
     public void setEditable(boolean bool) {
 68  0
         summaryTableModel.setEditable(bool);
 69  0
         summaryTable.doLayout();
 70  0
         summaryTable.markDiffs("rowDiffHighlight");
 71  0
     }
 72  
     
 73  
     public void addShowRowCallback(ShowRowConditionCallback callback){
 74  0
             this.showRowCallbacks.add(callback);
 75  0
     }
 76  
     
 77  
     private void processShowConditions(SummaryTableFieldRow row, DataModel model, DataModel comparisonModel){
 78  0
             for(int i =0; i < showRowCallbacks.size(); i++){
 79  0
                     showRowCallbacks.get(i).processShowConditions(row, model, comparisonModel);
 80  
             }
 81  0
     }
 82  
 
 83  
     public void addSummaryTableFieldBlock(SummaryTableFieldBlock section) {
 84  0
         summaryTableModel.addSection(section);
 85  0
     }
 86  
     
 87  
     @Override
 88  
     public ErrorLevel processValidationResults(
 89  
                     List<ValidationResultInfo> results) {
 90  
             
 91  0
             ErrorLevel status = ErrorLevel.OK;
 92  0
             for(int i = 0; i < results.size(); i++){
 93  0
                     if(summaryTable.containsKey(results.get(i).getElement())){
 94  0
                             System.out.println(results.get(i).getElement() + " *** " + results.get(i).getErrorLevel() + " *** " + results.get(i).getMessage());
 95  0
                             if(results.get(i).getLevel().getLevel() > status.getLevel()){
 96  0
                                     status = results.get(i).getLevel();
 97  
                             }
 98  0
                             if(this.isValidationEnabled){
 99  0
                                 summaryTable.highlightRow(results.get(i).getElement(), "rowHighlight");
 100  
                         }
 101  
                     }
 102  
             }
 103  
             
 104  0
             List<ValidationResultInfo> warnings = Application.getApplicationContext().getValidationWarnings();
 105  0
             ValidationResultInfo tempVr = new ValidationResultInfo();
 106  0
             tempVr.setElement("");
 107  0
             for(int i = 0; i < warnings.size(); i++){
 108  
                     //Reformat the validation element path based on how it can be referenced in sumaryTable rowMap
 109  0
                     String element = warnings.get(i).getElement();                    
 110  0
                     if (element.startsWith("/")){                            
 111  
                             //Remove leading '/' since paths aren't stored this way in rowMap
 112  0
                             element = element.substring(1);
 113  0
                     } else if (element.matches(".*/[0-9]+")){
 114  
                             //Validation warnings returns path to individual items of simple multiplicity, 
 115  
                             //stripping of the item index to highlight the entire field. 
 116  0
                             element = element.substring(0, element.lastIndexOf("/")); 
 117  
                     }
 118  
                     
 119  0
                     if(summaryTable.containsKey(element)){
 120  0
                             if(warnings.get(i).getLevel().getLevel() > status.getLevel()){
 121  0
                                     status = warnings.get(i).getLevel();
 122  
                             }
 123  
                             
 124  0
                                summaryTable.highlightRow(element, "warning");
 125  
                     }
 126  
             }
 127  
             
 128  0
             return status;
 129  
     }
 130  
     
 131  
     @Override
 132  
     public ErrorLevel processValidationResults(List<ValidationResultInfo> results, boolean clearErrors) {
 133  0
             if(clearErrors){
 134  0
                     this.removeValidationHighlighting();
 135  
             }
 136  0
             return this.processValidationResults(results);
 137  
     }
 138  
     
 139  
     public void removeValidationHighlighting(){
 140  0
             summaryTable.clearHighlightedRows("rowHighlight");
 141  0
     }
 142  
     
 143  
     private int buildMultiplicityRows(DataModel model, DataModel compModel, SummaryTableMultiplicityFieldRow parentRow, 
 144  
                     List<SummaryTableRow> rowList, int styleLevel, Integer parentNum){
 145  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-0");
 146  0
             MultiplicityConfiguration config = parentRow.getConfig();
 147  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-1");
 148  0
             int index = rowList.indexOf(parentRow) + 1;
 149  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-2");
 150  0
             int fieldRowsCreated = 0;
 151  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-3");
 152  0
             int number = 0;
 153  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-4");
 154  0
             String path = parentRow.getConfig().getParentFd().getFieldKey();
 155  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-5");
 156  0
             if(parentNum != null){
 157  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-6");
 158  0
                     path = path.replace("*", "" + parentNum);
 159  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-7");
 160  
             }
 161  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-8");
 162  0
             Data data = null;
 163  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-9");
 164  0
             if(model != null && model.isValidPath(path)){
 165  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-10");
 166  0
                     data = model.get(QueryPath.parse(path));
 167  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-11");
 168  
             }
 169  0
             StaticDeletemeLineLogger.log("buildMultiplicityRows-12");
 170  0
                 Data compData = null;
 171  0
                 StaticDeletemeLineLogger.log("buildMultiplicityRows-13");
 172  0
                 if(compModel != null && compModel.isValidPath(path)){
 173  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-14");
 174  0
                         compData = compModel.get(QueryPath.parse(path));
 175  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-15");
 176  
                 }
 177  0
                 StaticDeletemeLineLogger.log("buildMultiplicityRows-16");
 178  0
             if((data != null && data.size() > 0) || (compData != null && compData.size() > 0)){
 179  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-17");
 180  0
                     Iterator<Property> itr = null;
 181  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-18");
 182  0
                     if(data != null && compData != null){
 183  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-19");
 184  0
                             if(data.size() >= compData.size()){
 185  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-20");
 186  0
                                     itr = data.iterator();
 187  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-21");
 188  
                             } else{
 189  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-22");
 190  0
                                     itr = compData.iterator();
 191  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-23");
 192  
                             }
 193  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-24");
 194  0
                     } else if(data != null){
 195  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-25");
 196  0
                             itr = data.iterator();
 197  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-26");
 198  
                     } else{
 199  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-27");
 200  0
                             itr = compData.iterator();
 201  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-28");
 202  
                     }
 203  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-29");
 204  0
                     SummaryTableMultiplicityFieldRow currentMultiplicityRow = parentRow;
 205  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-30");
 206  0
             while (itr.hasNext()) {
 207  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-31");
 208  0
                 Property p = (Property) itr.next();
 209  0
                 StaticDeletemeLineLogger.log("buildMultiplicityRows-32");
 210  0
                 if (p.getKey() instanceof Integer){
 211  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-33");
 212  0
                         number = (Integer)p.getKey();
 213  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-34");
 214  
                 }
 215  0
                 StaticDeletemeLineLogger.log("buildMultiplicityRows-35");
 216  0
                         if(config.getItemLabel() != null && !config.getItemLabel().isEmpty()){
 217  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-36");
 218  0
                                 currentMultiplicityRow.setTitle(config.getItemLabel() + " "+ (number + 1));
 219  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-37");
 220  0
                                 currentMultiplicityRow.setKey(path);
 221  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-38");
 222  0
                             if(MetadataInterrogator.isRequired(config.getMetaData()) || 
 223  
                                         MetadataInterrogator.isRequiredForNextState(config.getMetaData())){
 224  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-39");
 225  0
                                     currentMultiplicityRow.setRequired(true);
 226  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-40");
 227  
                             }
 228  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-41");
 229  0
                             currentMultiplicityRow.addTitleCellStyleName("summary-table-multiplicity-level-" + styleLevel);
 230  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-42");
 231  
                         }
 232  
                         else{
 233  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-43");
 234  0
                                 currentMultiplicityRow.setShown(false);
 235  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-44");
 236  
                         }
 237  
                             //set has-data/requires data style here
 238  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-45");
 239  0
                             Map<Integer, List<MultiplicityFieldConfiguration>> fieldsCopy = config.getFields();
 240  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-46");
 241  0
                                 for(int i = 0; i < config.getFields().size(); i++){
 242  0
                                         StaticDeletemeLineLogger.log("buildMultiplicityRows-47");
 243  0
                                         for(int j = 0; j < config.getFields().get(i).size(); j++){
 244  
                                                 //TODO handle custom widgets (multiplicity field widget initializer)
 245  0
                                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-48");
 246  0
                                                 MultiplicityFieldConfiguration field = fieldsCopy.get(i).get(j);
 247  0
                                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-49");
 248  0
                                             String fieldKey = translatePath(field.getFieldPath(), path, number);
 249  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-50");
 250  0
                                             FieldDescriptorReadOnly fd1 = new FieldDescriptorReadOnly(fieldKey, field.getMessageKeyInfo(), field.getMetadata());
 251  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-51");
 252  0
                                             fd1.setOptional(field.isOptional());
 253  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-52");
 254  0
                                             if(field.getModelWidgetBinding() != null){
 255  0
                                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-53");
 256  0
                                                     fd1.setWidgetBinding(field.getModelWidgetBinding());
 257  0
                                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-54");
 258  
                                             }
 259  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-55");
 260  0
                                             FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(fieldKey, field.getMessageKeyInfo(), field.getMetadata());
 261  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-56");
 262  0
                                             fd2.setOptional(field.isOptional());
 263  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-57");
 264  0
                                             if(field.getModelWidgetBinding() != null){
 265  0
                                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-58");
 266  0
                                                     fd2.setWidgetBinding(field.getModelWidgetBinding());
 267  0
                                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-59");
 268  
                                             }
 269  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-60");
 270  0
                                             SummaryTableFieldRow row = new SummaryTableFieldRow(fd1, fd2);
 271  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-61");
 272  0
                                             row.setTemporaryRowFlag(true);
 273  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-62");
 274  0
                                             rowList.add(index, row);
 275  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-63");
 276  0
                                             index++;
 277  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-64");
 278  0
                                             fieldRowsCreated++;
 279  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-65");
 280  
                                     }
 281  
                                 }
 282  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-66");
 283  0
                             if(config.getNestedConfig() != null){
 284  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-67");
 285  0
                                     MultiplicityConfiguration nestedConfig = config.getNestedConfig();
 286  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-68");
 287  0
                                     nestedConfig.getParentFd().getFieldKey().replace(config.getParentFd().getFieldKey(), path);
 288  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-69");
 289  0
                                     SummaryTableMultiplicityFieldRow mRow = new SummaryTableMultiplicityFieldRow(nestedConfig);
 290  0
                                     mRow.setTemporaryRowFlag(true);
 291  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-70");
 292  0
                                     rowList.add(index, mRow);
 293  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-71");
 294  0
                                     index++;
 295  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-72");
 296  0
                                     fieldRowsCreated++;
 297  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-73");
 298  0
                                     int result = buildMultiplicityRows(model, compModel, mRow, rowList, styleLevel + 1, number);
 299  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-74");
 300  0
                                     index = index + result;
 301  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-75");
 302  
                             }
 303  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-76");
 304  0
                             if(itr.hasNext()){
 305  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-77");
 306  0
                                     SummaryTableMultiplicityFieldRow mRow = new SummaryTableMultiplicityFieldRow(config);
 307  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-78");
 308  0
                                     mRow.setTemporaryRowFlag(true);
 309  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-79");
 310  0
                                     rowList.add(index, mRow);
 311  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-80");
 312  0
                                     index++;
 313  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-81");
 314  0
                                     fieldRowsCreated++;
 315  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-82");
 316  0
                                     currentMultiplicityRow = mRow;
 317  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-83");
 318  
                             }
 319  0
             }
 320  0
             }
 321  
             else{
 322  0
                     StaticDeletemeLineLogger.log("buildMultiplicityRows-84");
 323  0
                 if(MetadataInterrogator.isRequired(config.getMetaData()) || 
 324  
                                 MetadataInterrogator.isRequiredForNextState(config.getMetaData())){
 325  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-85");
 326  0
                         if(config.getItemLabel() != null && !config.getItemLabel().isEmpty()){
 327  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-86");
 328  0
                                 parentRow.setTitle(config.getItemLabel() + " "+ (number + 1));
 329  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-87");
 330  0
                                 parentRow.setKey(path);
 331  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-88");
 332  0
                             parentRow.setRequired(true);
 333  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-89");
 334  0
                             parentRow.addTitleCellStyleName("summary-table-multiplicity-level-" + styleLevel);
 335  0
                             StaticDeletemeLineLogger.log("buildMultiplicityRows-90");
 336  
                         }
 337  
                         else{
 338  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-91");
 339  0
                                 parentRow.setShown(false);
 340  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-92");
 341  
                         }
 342  
                         //set has-data/requires data style here
 343  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-93");
 344  0
                         Map<Integer, List<MultiplicityFieldConfiguration>> fields = config.getFields();
 345  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-94");
 346  0
                                 for(int i = 0; i < fields.size(); i++){
 347  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-95");
 348  0
                                         for(int j = 0; j < fields.get(i).size(); j++){
 349  0
                                         StaticDeletemeLineLogger.log("buildMultiplicityRows-96");
 350  
                                                 //TODO handle custom widgets (multiplicity field widget initializer)
 351  0
                                                 MultiplicityFieldConfiguration field = fields.get(i).get(j);
 352  0
                                         StaticDeletemeLineLogger.log("buildMultiplicityRows-97");
 353  0
                                             String fieldKey = translatePath(field.getFieldPath(), path, number);
 354  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-98");
 355  0
                                             FieldDescriptorReadOnly fd1 = new FieldDescriptorReadOnly(fieldKey, field.getMessageKeyInfo(), field.getMetadata());
 356  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-99");
 357  0
                                             fd1.setOptional(field.isOptional());
 358  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-100");
 359  0
                                             if(field.getModelWidgetBinding() != null){
 360  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-101");
 361  0
                                                     fd1.setWidgetBinding(field.getModelWidgetBinding());
 362  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-102");
 363  
                                             }
 364  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-103");
 365  0
                                             FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(fieldKey, field.getMessageKeyInfo(), field.getMetadata());
 366  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-104");
 367  0
                                             fd2.setOptional(field.isOptional());
 368  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-105");
 369  0
                                             if(field.getModelWidgetBinding() != null){
 370  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-106");
 371  0
                                                     fd2.setWidgetBinding(field.getModelWidgetBinding());
 372  0
                                             StaticDeletemeLineLogger.log("buildMultiplicityRows-107");
 373  
                                             }
 374  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-108");
 375  0
                                             SummaryTableFieldRow row = new SummaryTableFieldRow(fd1, fd2);
 376  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-109");
 377  0
                                             row.setTemporaryRowFlag(true);
 378  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-110");
 379  0
                                             rowList.add(index, row);
 380  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-111");
 381  0
                                             index++;
 382  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-112");
 383  0
                                             fieldRowsCreated++;
 384  0
                                     StaticDeletemeLineLogger.log("buildMultiplicityRows-113");
 385  
                                     }
 386  
                                 }
 387  
                                 
 388  
                             
 389  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-114");
 390  0
                             if(config.getNestedConfig() != null){
 391  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-115");
 392  0
                                     MultiplicityConfiguration nestedConfig = config.getNestedConfig();
 393  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-116");
 394  0
                                     nestedConfig.getParentFd().getFieldKey().replace(config.getParentFd().getFieldKey(), path);
 395  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-117");
 396  0
                                     SummaryTableMultiplicityFieldRow mRow = new SummaryTableMultiplicityFieldRow(nestedConfig);
 397  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-118");
 398  0
                                     mRow.setTemporaryRowFlag(true);
 399  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-119");
 400  0
                                     rowList.add(index, mRow);
 401  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-120");
 402  0
                                     index++;
 403  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-121");
 404  0
                                     fieldRowsCreated++;
 405  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-122");
 406  0
                                     buildMultiplicityRows(null, null, mRow, rowList, styleLevel + 1, number);
 407  0
                                 StaticDeletemeLineLogger.log("buildMultiplicityRows-123");
 408  
                             }
 409  0
                 }
 410  
                 else{
 411  
                         //Alternate label possibly here
 412  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-124");
 413  0
                         parentRow.setTitle(config.getItemLabel());
 414  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-125");
 415  0
                         parentRow.setRequired(false);
 416  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-126");
 417  0
                         parentRow.setKey(config.getParentFd().getFieldKey());
 418  0
                         StaticDeletemeLineLogger.log("buildMultiplicityRows-127");
 419  
                         //set unrequired style here
 420  
                 }
 421  
             }
 422  0
             return fieldRowsCreated;
 423  
     }
 424  
     
 425  
     public String translatePath(String path, String parentPath, int num) {
 426  
         String fieldPath;
 427  0
         if (parentPath != null) {
 428  0
             QueryPath parent = QueryPath.concat(parentPath);
 429  0
             int i = parent.size();
 430  
 
 431  0
             QueryPath subPath = QueryPath.concat(path);
 432  0
             String itemPath =  subPath.subPath(i, subPath.size()).toString();
 433  
 
 434  0
             QueryPath qp = QueryPath.concat(parentPath, itemPath);
 435  0
             fieldPath = qp.toString();
 436  0
         }
 437  
         else {
 438  0
             fieldPath = path;
 439  
         }
 440  
 
 441  0
         fieldPath = fieldPath.replace("*", "" + num);
 442  0
         return fieldPath;
 443  
     }
 444  
     
 445  
     @Override
 446  
     public void updateWidgetData(final DataModel model) {
 447  
             
 448  0
         controller.requestModel("ComparisonModel", new ModelRequestCallback<DataModel>() {
 449  
             @Override
 450  
             public void onModelReady(DataModel otherModel) {
 451  0
                 comparisonModel = otherModel;
 452  0
                 updateTableData(model);
 453  0
             }
 454  
 
 455  
             @Override
 456  
             public void onRequestFail(Throwable cause) {
 457  0
                     comparisonModel = null;
 458  0
                     updateTableData(model);
 459  
                 //GWT.log("ComparisonModel cannot be found. " + cause.getLocalizedMessage(), null);
 460  0
             }
 461  
         });
 462  0
     }
 463  
     
 464  
     private void resetSummaryTableRows(SummaryTableFieldBlock fieldBlock){
 465  0
             List<SummaryTableRow> rowList = fieldBlock.getSectionRowList();
 466  0
             List<SummaryTableRow> removeList = new ArrayList<SummaryTableRow>();
 467  0
         for (int j = 0; j < rowList.size(); j++) {
 468  0
                  SummaryTableFieldRow fieldRow = (SummaryTableFieldRow) rowList.get(j);
 469  0
                  if(fieldRow.isTemporaryRow()){
 470  0
                          removeList.add(fieldRow);
 471  
                  }
 472  0
                  if(!fieldRow.isShown()){
 473  0
                          fieldRow.setShown(true);
 474  
                  }
 475  
         }
 476  0
         rowList.removeAll(removeList);
 477  0
     }
 478  
     
 479  
     private void buildSummaryTableMultiplicity(DataModel model, DataModel compModel, SummaryTableFieldBlock fieldBlock){
 480  0
             List<SummaryTableMultiplicityFieldRow> mRows = fieldBlock.getMultiplicityList();
 481  0
             for(int i = 0; i < mRows.size(); i++){
 482  0
                     SummaryTableMultiplicityFieldRow mRow = mRows.get(i);
 483  
                     
 484  0
                     buildMultiplicityRows(model, compModel, mRow, fieldBlock.getSectionRowList(), 1, null);
 485  
             }
 486  0
     }
 487  
     
 488  
     @SuppressWarnings("unchecked")
 489  
         private void updateTableData(DataModel model){
 490  0
             List<SummaryTableBlock> sectionList = summaryTableModel.getSectionList();
 491  0
         for (int i = 0; i < sectionList.size(); i++) {
 492  0
             SummaryTableFieldBlock fieldBlock = (SummaryTableFieldBlock) sectionList.get(i);
 493  0
             resetSummaryTableRows(fieldBlock);
 494  0
             if(!fieldBlock.getMultiplicityList().isEmpty()){
 495  0
                     buildSummaryTableMultiplicity(model, comparisonModel, fieldBlock);
 496  
             }
 497  0
             List<SummaryTableRow> rowList = fieldBlock.getSectionRowList();
 498  
             
 499  0
             for (int j = 0; j < rowList.size(); j++) {
 500  0
                 SummaryTableFieldRow fieldRow = (SummaryTableFieldRow) rowList.get(j);
 501  0
                 FieldDescriptor field = fieldRow.getFieldDescriptor1();
 502  0
                 final FieldDescriptor field2 = fieldRow.getFieldDescriptor2();
 503  0
                 boolean optional = false;
 504  0
                 boolean firstValueEmpty = true;
 505  0
                 boolean secondValueEmpty = true;
 506  
                 // for the first column
 507  0
                 if(field != null){
 508  
                         
 509  0
                         if(field instanceof FieldDescriptorReadOnly){
 510  0
                                 optional = ((FieldDescriptorReadOnly)field).isOptional();
 511  
                         }
 512  0
                         String fieldPath = QueryPath.getPathSeparator() + field.getFieldKey();
 513  0
                         if(model.isValidPath(fieldPath)){
 514  
                         
 515  0
                                 Object value = model.get(QueryPath.parse(fieldPath));
 516  0
                                 if(value != null){
 517  0
                                     if(value instanceof String && ((String)value).isEmpty()){
 518  0
                                                 firstValueEmpty = true;
 519  
                                         }
 520  0
                                     else if(value instanceof Data && ((Data) value).size() == 0){
 521  0
                                             firstValueEmpty = true;
 522  
                                     }
 523  
                                     else{
 524  0
                                             firstValueEmpty = false;
 525  
                                     }
 526  
                                 }
 527  
                                 
 528  
                                 
 529  0
                                 ModelWidgetBinding binding = field.getModelWidgetBinding();
 530  
                         
 531  0
                                 if (binding != null) {
 532  0
                                     Widget w = field.getFieldWidget();
 533  0
                                     binding.setWidgetValue(w, model, fieldPath);
 534  0
                                 } else {
 535  0
                                     GWT.log(field.getFieldKey() + " has no widget binding.", null);
 536  
                                 }
 537  
                         }
 538  
                         
 539  
                 }
 540  
 
 541  
                 // the second column
 542  0
                 if (comparisonModel == null) {
 543  0
                         if(fieldRow.getContentCellCount() == 2){
 544  0
                                 fieldRow.setContentCellCount(1);
 545  
                         }
 546  
                 }else{
 547  0
                         summaryTableModel.setContentColumnHeader1(model.getModelName());
 548  0
                         summaryTableModel.setContentColumnHeader2(comparisonModel.getModelName());
 549  0
                         if(fieldRow.getContentCellCount() == 1){
 550  0
                                 fieldRow.setContentCellCount(2);
 551  
                         }
 552  0
                         if(field2 != null){
 553  
                             
 554  0
                             String fieldPath2 = QueryPath.getPathSeparator() + field2.getFieldKey();
 555  0
                             if(comparisonModel.isValidPath(fieldPath2)){
 556  
                                     
 557  0
                                     Object value = model.get(QueryPath.parse(fieldPath2));
 558  0
                                     if(value != null){
 559  0
                                             if(value instanceof String && ((String)value).isEmpty()){
 560  0
                                                         secondValueEmpty = true;
 561  
                                                 }
 562  0
                                             else if(value instanceof Data && ((Data) value).size() == 0){
 563  0
                                                     secondValueEmpty = true;
 564  
                                             }
 565  
                                             else{
 566  0
                                                     secondValueEmpty = false;
 567  
                                             }
 568  
                                         }
 569  
                                     
 570  0
                                     ModelWidgetBinding binding2 = field2.getModelWidgetBinding();
 571  
                                     
 572  0
                                     if (binding2 != null) {
 573  0
                                         Widget w = field2.getFieldWidget();
 574  0
                                         binding2.setWidgetValue(w, comparisonModel, fieldPath2);
 575  0
                                     } else {
 576  0
                                         GWT.log(field2.getFieldKey() + " has no widget binding for the ComparisonModel.", null);
 577  
                                     }
 578  
                             }
 579  
                         }
 580  
                 }
 581  
                 
 582  0
                 if(firstValueEmpty && secondValueEmpty && optional){
 583  0
                         fieldRow.setShown(false);
 584  
                 }
 585  0
                 processShowConditions(fieldRow, model, comparisonModel);
 586  
             }
 587  
             
 588  
         }
 589  
 
 590  0
         summaryTable.doLayout();
 591  0
         summaryTable.markDiffs("rowDiffHighlight");
 592  0
     }
 593  
 
 594  
     @Override
 595  
     public String addField(FieldDescriptor fieldDescriptor) {
 596  0
         GWT.log("addField(FieldDescriptor fieldDescriptor) method not supported");
 597  0
         throw new UnsupportedOperationException("SummaryTableSection.addField(FieldDescriptor fieldDescriptor) method not supported");
 598  
     }
 599  
 
 600  
     @Override
 601  
     public String addSection(Section section) {
 602  0
         GWT.log("addSection(Section section) method not supported");
 603  0
         throw new UnsupportedOperationException("SummaryTableSection.addSection(Section section) method not supported");
 604  
     }
 605  
 
 606  
     @Override
 607  
     public String addSection(String key, Section section) {
 608  0
         GWT.log("addSection(String key, Section section) method not supported");
 609  0
         throw new UnsupportedOperationException("SummaryTableSection.addSection(String key, Section section) method not supported");
 610  
     }
 611  
 
 612  
     public SummaryTable getSummaryTable() {
 613  0
         return summaryTable;
 614  
     }
 615  
 
 616  
 }