@Test public void testBuild() throws URISyntaxException, IOException, DatasetException { Dataset dataset = builder.build(new ZipBinaryInput(Paths.get(inputUri).toFile())); log.debug(String.format("dataset: %s", dataset)); assertThat(dataset.name(), is(FilenameUtils.getBaseName(inputUri.toURL().getFile()))); assertThat(dataset.analyses().list().size(), is(11)); Dimension column = dataset.dimension(Dimension.Type.COLUMN); assertThat(column.keys().size(), is(6)); Dimension row = dataset.dimension(Dimension.Type.ROW); assertThat(row.keys().size(), is(39)); Analysis pca = dataset.analyses().get("PCA"); log.debug(String.format("analysis PCA analysis: %s", pca)); String pcaJson = mapper.writeValueAsString(pca); log.debug(String.format("analysis PCA json: %s", pcaJson)); assertThat(pcaJson, containsString("\"sdev\"")); assertTrue(dataset.dimension(Dimension.Type.COLUMN).annotation() instanceof OpenRefineAnnotation ); assertTrue(dataset.dimension(Dimension.Type.ROW).annotation() instanceof OpenRefineAnnotation ); }
@Override public Dataset build (RawInput zip) throws DatasetBuilderException { try{ DatasetZipHelper dszip = new DatasetZipHelper(); File dir = dszip.extract(zip.input(), zip.name()); File datasetFile = Paths.get(dir.getPath(), "dataset.json").toFile(); JsonNode datasetNode = mapper.readTree(datasetFile); JsonNode columnNode = datasetNode.get("column"); List<String> columns = getKeys(columnNode); Selection[] columnSelections = mapper.treeToValue(columnNode.get("selections"), Selection[].class); JsonNode rowNode = datasetNode.get("row"); List<String> rows = getKeys(rowNode); Selection[] rowSelections = mapper.treeToValue(rowNode.get("selections"), Selection[].class); File valuesFile = Paths.get(dir.getPath(), "values.bin").toFile(); RawInput values = new FileBinaryInput(valuesFile); DatasetBuilderFlatFile builder = new DatasetBuilderFlatFile(); Dataset dataset = builder.build(values, formatDatasetName(zip.name()), columns, rows, Arrays.asList(columnSelections), Arrays.asList(rowSelections)); for(File analysisFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("analysis_"); } })){ JsonNode analysisNode = mapper.readTree(analysisFile); dataset.analyses().put( new AnalysisJson(analysisFile) ); } for(File annotationFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("annotations_"); } })){ if(annotationFile.getName().endsWith("column.tar.gz")) dataset.dimension(Dimension.Type.COLUMN).annotation( new OpenRefineAnnotation(annotationFile) ); else if(annotationFile.getName().endsWith("row.tar.gz")) dataset.dimension(Dimension.Type.ROW).annotation( new OpenRefineAnnotation(annotationFile) ); } return dataset; }catch(IOException | DatasetException e){ throw new DatasetBuilderException (String.format("Error while building dataset name from zip: %s", zip)); } }
DatasetBuilderZip extends AbstractDatasetBuilder { @Override public Dataset build (RawInput zip) throws DatasetBuilderException { try{ DatasetZipHelper dszip = new DatasetZipHelper(); File dir = dszip.extract(zip.input(), zip.name()); File datasetFile = Paths.get(dir.getPath(), "dataset.json").toFile(); JsonNode datasetNode = mapper.readTree(datasetFile); JsonNode columnNode = datasetNode.get("column"); List<String> columns = getKeys(columnNode); Selection[] columnSelections = mapper.treeToValue(columnNode.get("selections"), Selection[].class); JsonNode rowNode = datasetNode.get("row"); List<String> rows = getKeys(rowNode); Selection[] rowSelections = mapper.treeToValue(rowNode.get("selections"), Selection[].class); File valuesFile = Paths.get(dir.getPath(), "values.bin").toFile(); RawInput values = new FileBinaryInput(valuesFile); DatasetBuilderFlatFile builder = new DatasetBuilderFlatFile(); Dataset dataset = builder.build(values, formatDatasetName(zip.name()), columns, rows, Arrays.asList(columnSelections), Arrays.asList(rowSelections)); for(File analysisFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("analysis_"); } })){ JsonNode analysisNode = mapper.readTree(analysisFile); dataset.analyses().put( new AnalysisJson(analysisFile) ); } for(File annotationFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("annotations_"); } })){ if(annotationFile.getName().endsWith("column.tar.gz")) dataset.dimension(Dimension.Type.COLUMN).annotation( new OpenRefineAnnotation(annotationFile) ); else if(annotationFile.getName().endsWith("row.tar.gz")) dataset.dimension(Dimension.Type.ROW).annotation( new OpenRefineAnnotation(annotationFile) ); } return dataset; }catch(IOException | DatasetException e){ throw new DatasetBuilderException (String.format("Error while building dataset name from zip: %s", zip)); } } }
DatasetBuilderZip extends AbstractDatasetBuilder { @Override public Dataset build (RawInput zip) throws DatasetBuilderException { try{ DatasetZipHelper dszip = new DatasetZipHelper(); File dir = dszip.extract(zip.input(), zip.name()); File datasetFile = Paths.get(dir.getPath(), "dataset.json").toFile(); JsonNode datasetNode = mapper.readTree(datasetFile); JsonNode columnNode = datasetNode.get("column"); List<String> columns = getKeys(columnNode); Selection[] columnSelections = mapper.treeToValue(columnNode.get("selections"), Selection[].class); JsonNode rowNode = datasetNode.get("row"); List<String> rows = getKeys(rowNode); Selection[] rowSelections = mapper.treeToValue(rowNode.get("selections"), Selection[].class); File valuesFile = Paths.get(dir.getPath(), "values.bin").toFile(); RawInput values = new FileBinaryInput(valuesFile); DatasetBuilderFlatFile builder = new DatasetBuilderFlatFile(); Dataset dataset = builder.build(values, formatDatasetName(zip.name()), columns, rows, Arrays.asList(columnSelections), Arrays.asList(rowSelections)); for(File analysisFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("analysis_"); } })){ JsonNode analysisNode = mapper.readTree(analysisFile); dataset.analyses().put( new AnalysisJson(analysisFile) ); } for(File annotationFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("annotations_"); } })){ if(annotationFile.getName().endsWith("column.tar.gz")) dataset.dimension(Dimension.Type.COLUMN).annotation( new OpenRefineAnnotation(annotationFile) ); else if(annotationFile.getName().endsWith("row.tar.gz")) dataset.dimension(Dimension.Type.ROW).annotation( new OpenRefineAnnotation(annotationFile) ); } return dataset; }catch(IOException | DatasetException e){ throw new DatasetBuilderException (String.format("Error while building dataset name from zip: %s", zip)); } }  }
DatasetBuilderZip extends AbstractDatasetBuilder { @Override public Dataset build (RawInput zip) throws DatasetBuilderException { try{ DatasetZipHelper dszip = new DatasetZipHelper(); File dir = dszip.extract(zip.input(), zip.name()); File datasetFile = Paths.get(dir.getPath(), "dataset.json").toFile(); JsonNode datasetNode = mapper.readTree(datasetFile); JsonNode columnNode = datasetNode.get("column"); List<String> columns = getKeys(columnNode); Selection[] columnSelections = mapper.treeToValue(columnNode.get("selections"), Selection[].class); JsonNode rowNode = datasetNode.get("row"); List<String> rows = getKeys(rowNode); Selection[] rowSelections = mapper.treeToValue(rowNode.get("selections"), Selection[].class); File valuesFile = Paths.get(dir.getPath(), "values.bin").toFile(); RawInput values = new FileBinaryInput(valuesFile); DatasetBuilderFlatFile builder = new DatasetBuilderFlatFile(); Dataset dataset = builder.build(values, formatDatasetName(zip.name()), columns, rows, Arrays.asList(columnSelections), Arrays.asList(rowSelections)); for(File analysisFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("analysis_"); } })){ JsonNode analysisNode = mapper.readTree(analysisFile); dataset.analyses().put( new AnalysisJson(analysisFile) ); } for(File annotationFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("annotations_"); } })){ if(annotationFile.getName().endsWith("column.tar.gz")) dataset.dimension(Dimension.Type.COLUMN).annotation( new OpenRefineAnnotation(annotationFile) ); else if(annotationFile.getName().endsWith("row.tar.gz")) dataset.dimension(Dimension.Type.ROW).annotation( new OpenRefineAnnotation(annotationFile) ); } return dataset; }catch(IOException | DatasetException e){ throw new DatasetBuilderException (String.format("Error while building dataset name from zip: %s", zip)); } }  @Override Dataset build(RawInput zip); }
DatasetBuilderZip extends AbstractDatasetBuilder { @Override public Dataset build (RawInput zip) throws DatasetBuilderException { try{ DatasetZipHelper dszip = new DatasetZipHelper(); File dir = dszip.extract(zip.input(), zip.name()); File datasetFile = Paths.get(dir.getPath(), "dataset.json").toFile(); JsonNode datasetNode = mapper.readTree(datasetFile); JsonNode columnNode = datasetNode.get("column"); List<String> columns = getKeys(columnNode); Selection[] columnSelections = mapper.treeToValue(columnNode.get("selections"), Selection[].class); JsonNode rowNode = datasetNode.get("row"); List<String> rows = getKeys(rowNode); Selection[] rowSelections = mapper.treeToValue(rowNode.get("selections"), Selection[].class); File valuesFile = Paths.get(dir.getPath(), "values.bin").toFile(); RawInput values = new FileBinaryInput(valuesFile); DatasetBuilderFlatFile builder = new DatasetBuilderFlatFile(); Dataset dataset = builder.build(values, formatDatasetName(zip.name()), columns, rows, Arrays.asList(columnSelections), Arrays.asList(rowSelections)); for(File analysisFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("analysis_"); } })){ JsonNode analysisNode = mapper.readTree(analysisFile); dataset.analyses().put( new AnalysisJson(analysisFile) ); } for(File annotationFile : dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("annotations_"); } })){ if(annotationFile.getName().endsWith("column.tar.gz")) dataset.dimension(Dimension.Type.COLUMN).annotation( new OpenRefineAnnotation(annotationFile) ); else if(annotationFile.getName().endsWith("row.tar.gz")) dataset.dimension(Dimension.Type.ROW).annotation( new OpenRefineAnnotation(annotationFile) ); } return dataset; }catch(IOException | DatasetException e){ throw new DatasetBuilderException (String.format("Error while building dataset name from zip: %s", zip)); } }  @Override Dataset build(RawInput zip);  }