コード例 #1
0
  @Override
  public ArrayList<ArrayList<String>> convertToRowWise(DataSet dataSet) {

    ArrayList<ArrayList<String>> columnDataArrayList = new ArrayList<ArrayList<String>>();
    ArrayList<ArrayList<String>> rowArrayList = new ArrayList<ArrayList<String>>();

    for (int index = 0; index < dataSet.getColumns().size(); index++) {

      columnDataArrayList.add(
          dataSet.getData().get(dataSet.getColumns().get(index).getId()).getValues());
    }

    for (int i = 0; i < columnDataArrayList.size(); i++) {
      ArrayList<String> colwisewRow = columnDataArrayList.get(i);

      for (int j = 0; j < colwisewRow.size(); j++) {

        if (i == 0) {
          ArrayList<String> temp = new ArrayList<String>();
          rowArrayList.add(temp);
        }

        rowArrayList.get(j).add(colwisewRow.get(j));
      }
    }

    return rowArrayList;
  }
コード例 #2
0
 private List<ArrayList<String>> getCSVFormat(String datasetId) {
   List<ArrayList<String>> csvLines = new ArrayList<ArrayList<String>>();
   DataSet dataSet = DataSets.dataSets.get(datasetId);
   ArrayList<DataSetColumn> columns = dataSet.getColumns();
   DataSetServiceImpl dataSetServiceImpl = new DataSetServiceImpl();
   ArrayList<String> datasetCols = new ArrayList<String>();
   for (int i = 0; i < columns.size(); i++) {
     datasetCols.add(columns.get(i).getName());
   }
   csvLines.add(datasetCols);
   csvLines.addAll(dataSetServiceImpl.convertToRowWise(dataSet));
   return csvLines;
 }