Search in sources :

Example 1 with CSVGrid

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);
}
Also used : GetCSVGridResult(edu.stanford.bmir.protege.web.shared.csv.GetCSVGridResult) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) CSVGrid(edu.stanford.bmir.protege.web.shared.csv.CSVGrid) Nonnull(javax.annotation.Nonnull)

Example 2 with CSVGrid

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;
}
Also used : CSVGrid(edu.stanford.bmir.protege.web.shared.csv.CSVGrid)

Example 3 with CSVGrid

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);
    }
}
Also used : CSVGrid(edu.stanford.bmir.protege.web.shared.csv.CSVGrid)

Aggregations

CSVGrid (edu.stanford.bmir.protege.web.shared.csv.CSVGrid)3 DocumentId (edu.stanford.bmir.protege.web.shared.csv.DocumentId)1 GetCSVGridResult (edu.stanford.bmir.protege.web.shared.csv.GetCSVGridResult)1 Nonnull (javax.annotation.Nonnull)1