use of edu.stanford.bmir.protege.web.shared.csv.CSVGrid in project webprotege by protegeproject.
the class GetCSVGridActionHandler method execute.
@Nonnull
@Override
public GetCSVGridResult execute(@Nonnull GetCSVGridAction action, @Nonnull ExecutionContext executionContext) {
DocumentId documentId = action.getCSVDocumentId();
File file = new File(uploadsDirectory, documentId.getDocumentId());
if (!file.exists()) {
throw new RuntimeException("CSV file does not exist");
}
CSVGrid grid = getCSVGrid(file, action.getRowLimit());
return new GetCSVGridResult(grid);
}
use of edu.stanford.bmir.protege.web.shared.csv.CSVGrid in project webprotege by protegeproject.
the class GetCSVGridActionHandler method getCSVGrid.
private CSVGrid getCSVGrid(File file, int rowLimit) {
CSVGrid grid;
try {
Reader fileReader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8"));
CSVGridParser gridParser = new CSVGridParser();
grid = gridParser.readToLimit(fileReader, rowLimit);
fileReader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return grid;
}
use of edu.stanford.bmir.protege.web.shared.csv.CSVGrid in project webprotege by protegeproject.
the class ImportCSVFileActionHandler method parseCSVGrid.
private CSVGrid parseCSVGrid(ImportCSVFileAction action) {
try {
CSVGridParser parser = new CSVGridParser();
final File file = new File(uploadsDirectory, action.getDocumentId().getDocumentId());
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8"));
CSVGrid grid = parser.readAll(reader);
reader.close();
return grid;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations