/// <summary> /// Performs data validation based on the validators found in /// the table model for the current component. </summary> /// <param name="tm"> Interface implemented by each data table model. </param> /// <returns> List of data that has gone through data validation. /// If any element fails any one of its validators the content /// of that element is formatted to tag it as an error. </returns> private IList <string []> performDataValidation(StateCU_Data_TableModel tm, string title) { IList <string []> data = new List <string []>(); if (tm == null) { return(data); } Status status = Status.OKAY; bool row_had_problem = false; __gen_problems = 0; // Validate every row and column of data found in the table model for (int i = 0; i < tm.getRowCount(); i++) { string[] row = new string[tm.getColumnCount()]; row_had_problem = false; for (int j = 0; j < tm.getColumnCount(); j++) { Validator[] vals = (tm.getValidators(j)); // If there are no validators for this column then // just add the data value. If the value is blank // then add a space so the check file is able to show // the column. if (vals.Length == 0) { string value = tm.getValueAt(i, j).ToString(); if (value.Length == 0) { value = " "; } row[j] = value; } for (int k = 0; k < vals.Length; k++) { status = vals[k].validate(tm.getValueAt(i, j)); row[j] = checkStatus(status, tm.getValueAt(i, j)); // if the current validator fails then don't // check finer grained validators since there is no need. // Log the error as a runtime message in the check file if (status.getLevel() != Status.OK) { row_had_problem = true; break; } } } data.Add(row); if (row_had_problem) { __gen_problems++; } } return(data); }
/// <summary> /// Returns a formatted header from the table model /// with HTML tooltips. </summary> /// <param name="tm"> Table model for the component under validation. </param> /// <returns> List of column headers with tooltips. </returns> private string[] getColumnHeader(StateCU_Data_TableModel tm) { string[] header = getDataTableModelColumnHeader(tm); string[] return_header = new string[header.Length]; // format the header to include HTML tooltips based on // the validation being performed on a column of data for (int i = 0; i < header.Length; i++) { Validator[] vals = (tm.getValidators(i)); string val_desc = "Data validators for this column:\n"; for (int j = 0; j < vals.Length; j++) { int num = j + 1; val_desc = val_desc + num + ". " + vals[j].ToString(); } // write the final header string with tooltip return_header[i] = "%tooltip_start" + val_desc + "%tooltip_end" + header[i]; } return(return_header); }