use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.
the class ViewJdbcResourceTypeTest method path.
@Test
public void path() {
final ResourceType view = new ViewJdbcResourceType(dataSource);
assertEquals(2, view.path().size());
assertEquals("schema", view.path().get(0));
assertEquals("view", view.path().get(1));
}
use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.
the class ViewJdbcResourceTypeTest method read.
@Test
public void read() {
final ResourceType view = new ViewJdbcResourceType(dataSource);
final Stream<DbResource> views = view.read(new SqlPlaceholdersWrapper(new DbUri("view", asList("*"))));
assertEquals(2, views.count());
}
use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.
the class ApiController method getListResponseEntity.
private ResponseEntity<List<DbResource>> getListResponseEntity(final HttpServletRequest request, final String connectionName, final String type) {
final Uri uri = new SqlPlaceholdersWrapper(new DbUri(parseUri(type, request)));
final ResourceType fsResourceTypes = new FsResourceTypes(dbConnectionList.getConnectionByName(connectionName));
final List<DbResource> collect = fsResourceTypes.read(uri).collect(toList());
if (collect.isEmpty()) {
return new ResponseEntity<>(collect, HttpStatus.NO_CONTENT);
} else {
return new ResponseEntity<>(collect, HttpStatus.OK);
}
}
use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.
the class ApiController method getListResponseEntityHeaders.
private ResponseEntity<List<Map<String, Object>>> getListResponseEntityHeaders(final HttpServletRequest request, final String connectionName, final String path) {
final Uri uri = new SqlPlaceholdersWrapper(new DbUri(parseUri(path, request)));
ResourceType fsResourceTypes = new FsResourceTypes(dbConnectionList.getConnectionByName(connectionName));
final List<Map<String, Object>> headers = fsResourceTypes.read(uri).map(DbResource::headers).collect(toList());
if (headers.isEmpty()) {
return new ResponseEntity<>(headers, HttpStatus.NO_CONTENT);
} else {
return new ResponseEntity<>(headers, HttpStatus.OK);
}
}
use of com.github.mgramin.sqlboot.model.resource_type.ResourceType in project sql-boot by sql-boot.
the class SchemaJdbcResourceTypeTest method read.
@Test
public void read() {
final ResourceType schema = new SchemaJdbcResourceType(dataSource);
final Stream<DbResource> schemas = schema.read(new SqlPlaceholdersWrapper(new DbUri("schema", asList("*"))));
assertEquals(3, schemas.count());
}
Aggregations