Search in sources :

Example 6 with SqlPlaceholdersWrapper

use of com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper 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);
    }
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) ResponseEntity(org.springframework.http.ResponseEntity) FsResourceTypes(com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) Uri(com.github.mgramin.sqlboot.model.uri.Uri)

Example 7 with SqlPlaceholdersWrapper

use of com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper 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);
    }
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) ResponseEntity(org.springframework.http.ResponseEntity) FsResourceTypes(com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) Uri(com.github.mgramin.sqlboot.model.uri.Uri) Map(java.util.Map)

Example 8 with SqlPlaceholdersWrapper

use of com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper 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());
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Example 9 with SqlPlaceholdersWrapper

use of com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper in project sql-boot by sql-boot.

the class FunctionJdbcResourceTypeTest method read.

@Test
@Ignore
public void read() {
    final ResourceType function = new FunctionJdbcResourceType(dataSource);
    final Stream<DbResource> functions = function.read(new SqlPlaceholdersWrapper(new DbUri("function", asList("*"))));
    assertEquals(1, functions.count());
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) ProcedureJdbcResourceType(com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.procedure.ProcedureJdbcResourceType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with SqlPlaceholdersWrapper

use of com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper in project sql-boot by sql-boot.

the class ProcedureJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType procedure = new ProcedureJdbcResourceType(dataSource);
    final Stream<DbResource> procedures = procedure.read(new SqlPlaceholdersWrapper(new DbUri("procedure", asList("*"))));
    assertEquals(1, procedures.count());
}
Also used : SqlPlaceholdersWrapper(com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper) DbUri(com.github.mgramin.sqlboot.model.uri.impl.DbUri) DbResource(com.github.mgramin.sqlboot.model.resource.DbResource) ResourceType(com.github.mgramin.sqlboot.model.resource_type.ResourceType) Test(org.junit.Test)

Aggregations

ResourceType (com.github.mgramin.sqlboot.model.resource_type.ResourceType)13 DbUri (com.github.mgramin.sqlboot.model.uri.impl.DbUri)13 SqlPlaceholdersWrapper (com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper)13 DbResource (com.github.mgramin.sqlboot.model.resource.DbResource)12 Test (org.junit.Test)11 FsResourceTypes (com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes)2 Uri (com.github.mgramin.sqlboot.model.uri.Uri)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ProcedureJdbcResourceType (com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.procedure.ProcedureJdbcResourceType)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1