Search in sources :

Example 1 with DbResource

use of com.github.mgramin.sqlboot.model.resource.DbResource in project sql-boot by sql-boot.

the class ColumnJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType table = new ColumnJdbcResourceType(dataSource);
    final Stream<DbResource> tables = table.read(new SqlPlaceholdersWrapper(new DbUri("table", asList("MAIN_SCHEMA", "CITY"))));
    tables.forEach(v -> System.out.println(v.name()));
}
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 2 with DbResource

use of com.github.mgramin.sqlboot.model.resource.DbResource in project sql-boot by sql-boot.

the class IndexJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType index = new IndexJdbcResourceType(dataSource);
    final Stream<DbResource> indexes = index.read(new SqlPlaceholdersWrapper(new DbUri("index", asList("*"))));
    assertEquals(5, indexes.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 3 with DbResource

use of com.github.mgramin.sqlboot.model.resource.DbResource in project sql-boot by sql-boot.

the class PkJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType pk = new PkJdbcResourceType(dataSource);
    final Stream<DbResource> primaryKeys = pk.read(new SqlPlaceholdersWrapper(new DbUri("pk", asList("*"))));
    assertEquals(2, primaryKeys.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 4 with DbResource

use of com.github.mgramin.sqlboot.model.resource.DbResource in project sql-boot by sql-boot.

the class ParentTableJdbcResourceTypeTest method read.

@Test
public void read() {
    final ResourceType pk = new ParentTableJdbcResourceType(dataSource);
    final Stream<DbResource> primaryKeys = pk.read(new SqlPlaceholdersWrapper(new DbUri("parent_table", asList("*"))));
    assertEquals(1, primaryKeys.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 5 with DbResource

use of com.github.mgramin.sqlboot.model.resource.DbResource 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());
}
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

DbResource (com.github.mgramin.sqlboot.model.resource.DbResource)26 DbUri (com.github.mgramin.sqlboot.model.uri.impl.DbUri)25 DbResourceImpl (com.github.mgramin.sqlboot.model.resource.impl.DbResourceImpl)13 ResourceType (com.github.mgramin.sqlboot.model.resource_type.ResourceType)13 BootException (com.github.mgramin.sqlboot.exceptions.BootException)12 SqlPlaceholdersWrapper (com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper)12 LinkedHashMap (java.util.LinkedHashMap)12 Test (org.junit.Test)12 ResultSet (java.sql.ResultSet)11 ResultSetMetaData (java.sql.ResultSetMetaData)11 SQLException (java.sql.SQLException)11 ArrayList (java.util.ArrayList)11 TableJdbcResourceType (com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.table.TableJdbcResourceType)5 Uri (com.github.mgramin.sqlboot.model.uri.Uri)2 Connection (java.sql.Connection)2 Entry (java.util.Map.Entry)2 DbResourceBodyWrapper (com.github.mgramin.sqlboot.model.resource.wrappers.DbResourceBodyWrapper)1 FsResourceTypes (com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes)1 ProcedureJdbcResourceType (com.github.mgramin.sqlboot.model.resource_type.impl.jdbc.schema.procedure.ProcedureJdbcResourceType)1 SqlQuery (com.github.mgramin.sqlboot.sql.SqlQuery)1