use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSet in project kylo by Teradata.
the class DataSetController method getDataSet.
@GET
@Path("{id}")
@ApiOperation("Retrieves the specified data set")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the data set", response = DataSet.class), @ApiResponse(code = 404, message = "Data set not found", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "Internal server error", response = RestResponseStatus.class) })
public Response getDataSet(@PathParam("id") @UUID final String dataSetId) {
log.entry(dataSetId);
final boolean encryptCredentials = true;
final DataSet dataSet = findDataSet(dataSetId, encryptCredentials);
return Response.ok(log.exit(dataSet)).build();
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSet in project kylo by Teradata.
the class DataSetController method updateDataSet.
@PUT
@ApiOperation("Updates an existing data set")
@ApiResponses({ @ApiResponse(code = 200, message = "Data set updated", response = DataSet.class), @ApiResponse(code = 400, message = "Invalid data source", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "Internal server error", response = RestResponseStatus.class) })
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateDataSet(@Nonnull final DataSet source) {
log.entry(source);
final boolean encryptCredentials = true;
final DataSet dataSet;
try {
dataSet = dataSetService.updateDataSet(source, encryptCredentials);
} catch (final CatalogException e) {
throw new BadRequestException(getMessage(e));
}
return Response.ok(log.exit(dataSet)).build();
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSet in project kylo by Teradata.
the class DataSetUtilTest method getPaths.
/**
* Verify merging paths for a data set.
*/
@Test
public void getPaths() {
// Create mock connector
final DefaultDataSetTemplate connectorTemplate = new DefaultDataSetTemplate();
connectorTemplate.setOptions(Collections.singletonMap("path", "connector1.txt"));
connectorTemplate.setPaths(Collections.singletonList("connector2.txt"));
final Connector connector = new Connector();
connector.setTemplate(connectorTemplate);
// Create mock data source
final DefaultDataSetTemplate dataSourceTemplate = new DefaultDataSetTemplate();
dataSourceTemplate.setOptions(Collections.singletonMap("path", "datasource1.txt"));
dataSourceTemplate.setPaths(Collections.singletonList("datasource2.txt"));
final DataSource dataSource = new DataSource();
dataSource.setConnector(connector);
dataSource.setTemplate(dataSourceTemplate);
// Create mock data set
final DataSet dataSet = new DataSet();
dataSet.setDataSource(dataSource);
dataSet.setOptions(Collections.singletonMap("path", "dataset1.txt"));
dataSet.setPaths(Collections.singletonList("dataset2.txt"));
// Test retrieving data set paths
Assert.assertEquals(Arrays.asList("dataset1.txt", "dataset2.txt"), DataSetUtil.getPaths(dataSet).orElse(null));
// Test retrieving data source paths
dataSet.setOptions(null);
Assert.assertEquals(Arrays.asList("datasource1.txt", "dataset2.txt"), DataSetUtil.getPaths(dataSet).orElse(null));
dataSet.setPaths(null);
Assert.assertEquals(Arrays.asList("datasource1.txt", "datasource2.txt"), DataSetUtil.getPaths(dataSet).orElse(null));
// Test retrieving connector paths
dataSourceTemplate.setOptions(null);
Assert.assertEquals(Arrays.asList("connector1.txt", "datasource2.txt"), DataSetUtil.getPaths(dataSet).orElse(null));
dataSourceTemplate.setPaths(null);
Assert.assertEquals(Arrays.asList("connector1.txt", "connector2.txt"), DataSetUtil.getPaths(dataSet).orElse(null));
// Test retrieving empty paths
connectorTemplate.setOptions(null);
connectorTemplate.setPaths(null);
Assert.assertEquals(Optional.empty(), DataSetUtil.getPaths(dataSet));
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSet in project kylo by Teradata.
the class CatalogFileManagerTest method createUpload.
/**
* Verify uploading a file.
*/
@Test
public void createUpload() throws IOException {
final DataSet dataSet = createDataSet();
final String src = "Hello world!";
// Test uploading a file
final CatalogFileManager fileManager = new MockCatalogFileManager();
final DataSetFile upload = fileManager.createUpload(dataSet, "file-upload.txt", new ByteArrayInputStream(src.getBytes(StandardCharsets.UTF_8)));
final File file = datasetsFolder.getRoot().toPath().resolve(dataSet.getId()).resolve("file-upload.txt").toFile();
Assert.assertFalse("Expected uploaded file to not be a directory", upload.isDirectory());
Assert.assertEquals(src.length(), upload.getLength().longValue());
Assert.assertEquals("file-upload.txt", upload.getName());
Assert.assertEquals(file.toURI(), URI.create(upload.getPath()));
Assert.assertEquals(src, Files.toString(file, StandardCharsets.UTF_8));
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSet in project kylo by Teradata.
the class CatalogFileManagerTest method deleteUpload.
/**
* Verify deleting an uploaded file.
*/
@Test
@SuppressWarnings("ResultOfMethodCallIgnored")
public void deleteUpload() throws IOException {
// Create data set including files
final DataSet dataSet = createDataSet();
final File file = new File(datasetsFolder.newFolder(dataSet.getId()), "test-file.txt");
file.createNewFile();
Assert.assertTrue("Expected file to exist", file.exists());
// Test deleting a file
final CatalogFileManager fileManager = new MockCatalogFileManager();
fileManager.deleteUpload(dataSet, "test-file.txt");
Assert.assertFalse("Expected file to be deleted", file.exists());
}
Aggregations