/// <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> /// Uses the table model object to obtain the column /// headers. </summary> /// <param name="tm"> StateMod_Data_TableModel Object. </param> /// <returns> List of column headers from the table model. </returns> private string[] getDataTableModelColumnHeader(StateCU_Data_TableModel tm) { if (tm == null) { return(new string[] {}); } string[] header = new string[tm.getColumnCount()]; for (int i = 0; i < tm.getColumnCount(); i++) { header[i] = tm.getColumnName(i); } return(header); }