@Test public void testUpdate() { String id = UUID.randomUUID().toString(); final DataSetMetadata metadata = metadataBuilder.metadata().id(id).build(); dataSetMetadataRepository.save(metadata); contentStore.storeAsRaw(metadata, DataSetServiceTest.class.getResourceAsStream("../avengers.csv")); formatAnalysis.analyze(id); final DataSetMetadata original = dataSetMetadataRepository.get(id); final DataSetMetadata modified = dataSetMetadataRepository.get(id); modified.setEncoding("windows-1252"); modified.getContent().getParameters().put("SEPARATOR", ","); formatAnalysis.update(original, modified); final DataSetMetadata updated = dataSetMetadataRepository.get(id); assertNotNull(updated); assertThat(updated.getContent().getFormatFamilyId(), is(CSVFormatFamily.BEAN_ID)); assertThat(updated.getContent().getMediaType(), is("text/csv")); assertThat(updated.getEncoding(), is("windows-1252")); }
public void update(DataSetMetadata original, DataSetMetadata updated) { final Marker marker = Markers.dataset(updated.getId()); FormatFamily formatFamily = formatFamilyFactory.getFormatFamily(original.getContent().getFormatFamilyId()); if (!formatFamily.getSchemaGuesser().accept(updated)) { LOG.debug(marker, "the schema cannot be updated"); return; } Format format = new Format(formatFamily, updated.getEncoding()); internalUpdateMetadata(updated, format); LOG.debug(marker, "format updated for dataset"); }
FormatAnalysis implements SynchronousDataSetAnalyzer { public void update(DataSetMetadata original, DataSetMetadata updated) { final Marker marker = Markers.dataset(updated.getId()); FormatFamily formatFamily = formatFamilyFactory.getFormatFamily(original.getContent().getFormatFamilyId()); if (!formatFamily.getSchemaGuesser().accept(updated)) { LOG.debug(marker, "the schema cannot be updated"); return; } Format format = new Format(formatFamily, updated.getEncoding()); internalUpdateMetadata(updated, format); LOG.debug(marker, "format updated for dataset"); } }
FormatAnalysis implements SynchronousDataSetAnalyzer { public void update(DataSetMetadata original, DataSetMetadata updated) { final Marker marker = Markers.dataset(updated.getId()); FormatFamily formatFamily = formatFamilyFactory.getFormatFamily(original.getContent().getFormatFamilyId()); if (!formatFamily.getSchemaGuesser().accept(updated)) { LOG.debug(marker, "the schema cannot be updated"); return; } Format format = new Format(formatFamily, updated.getEncoding()); internalUpdateMetadata(updated, format); LOG.debug(marker, "format updated for dataset"); }  }
FormatAnalysis implements SynchronousDataSetAnalyzer { public void update(DataSetMetadata original, DataSetMetadata updated) { final Marker marker = Markers.dataset(updated.getId()); FormatFamily formatFamily = formatFamilyFactory.getFormatFamily(original.getContent().getFormatFamilyId()); if (!formatFamily.getSchemaGuesser().accept(updated)) { LOG.debug(marker, "the schema cannot be updated"); return; } Format format = new Format(formatFamily, updated.getEncoding()); internalUpdateMetadata(updated, format); LOG.debug(marker, "format updated for dataset"); }  @Override void analyze(String dataSetId); void update(DataSetMetadata original, DataSetMetadata updated); @Override int order(); }
FormatAnalysis implements SynchronousDataSetAnalyzer { public void update(DataSetMetadata original, DataSetMetadata updated) { final Marker marker = Markers.dataset(updated.getId()); FormatFamily formatFamily = formatFamilyFactory.getFormatFamily(original.getContent().getFormatFamilyId()); if (!formatFamily.getSchemaGuesser().accept(updated)) { LOG.debug(marker, "the schema cannot be updated"); return; } Format format = new Format(formatFamily, updated.getEncoding()); internalUpdateMetadata(updated, format); LOG.debug(marker, "format updated for dataset"); }  @Override void analyze(String dataSetId); void update(DataSetMetadata original, DataSetMetadata updated); @Override int order();  }