• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package autotest.tko;
2 
3 import autotest.common.spreadsheet.Spreadsheet.CellInfo;
4 import autotest.common.spreadsheet.Spreadsheet.Header;
5 
6 import com.google.gwt.json.client.JSONObject;
7 
8 import java.util.List;
9 
10 public class TkoSpreadsheetUtils {
11     public static enum DrilldownType {DRILLDOWN_ROW, DRILLDOWN_COLUMN, DRILLDOWN_BOTH}
12 
getTestSet(CellInfo cellInfo, JSONObject condition, List<HeaderField> rowFields, List<HeaderField> columnFields)13     public static TestSet getTestSet(CellInfo cellInfo, JSONObject condition,
14             List<HeaderField> rowFields, List<HeaderField> columnFields) {
15         boolean isSingleTest = cellInfo.testCount == 1;
16         if (isSingleTest) {
17             return new SingleTestSet(cellInfo.testIndex, condition);
18         }
19 
20         ConditionTestSet testSet = new ConditionTestSet(condition);
21         if (cellInfo.row != null) {
22             setSomeFields(testSet, rowFields, cellInfo.row);
23         }
24         if (cellInfo.column != null) {
25             setSomeFields(testSet, columnFields, cellInfo.column);
26         }
27         return testSet;
28     }
29 
setSomeFields(ConditionTestSet testSet, List<HeaderField> allFields, Header values)30     private static void setSomeFields(ConditionTestSet testSet, List<HeaderField> allFields,
31             Header values) {
32         for (int i = 0; i < values.size(); i++) {
33             HeaderField field = allFields.get(i);
34             String value = values.get(i);
35             testSet.addCondition(field.getSqlCondition(value));
36         }
37     }
38 
getDrilldownType(CellInfo cellInfo)39     public static DrilldownType getDrilldownType(CellInfo cellInfo) {
40         if (cellInfo.row == null) {
41             // column header
42             return DrilldownType.DRILLDOWN_COLUMN;
43         }
44         if (cellInfo.column == null) {
45             // row header
46             return DrilldownType.DRILLDOWN_ROW;
47         }
48         return DrilldownType.DRILLDOWN_BOTH;
49     }
50 }
51