Search in sources :

Example 1 with DbUri

use of com.github.mgramin.sqlboot.model.uri.impl.DbUri 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 DbUri

use of com.github.mgramin.sqlboot.model.uri.impl.DbUri 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 DbUri

use of com.github.mgramin.sqlboot.model.uri.impl.DbUri 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 DbUri

use of com.github.mgramin.sqlboot.model.uri.impl.DbUri 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 DbUri

use of com.github.mgramin.sqlboot.model.uri.impl.DbUri 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

DbUri (com.github.mgramin.sqlboot.model.uri.impl.DbUri)33 DbResource (com.github.mgramin.sqlboot.model.resource.DbResource)25 Test (org.junit.Test)18 ResourceType (com.github.mgramin.sqlboot.model.resource_type.ResourceType)16 SqlPlaceholdersWrapper (com.github.mgramin.sqlboot.model.uri.wrappers.SqlPlaceholdersWrapper)13 BootException (com.github.mgramin.sqlboot.exceptions.BootException)12 DbResourceImpl (com.github.mgramin.sqlboot.model.resource.impl.DbResourceImpl)12 LinkedHashMap (java.util.LinkedHashMap)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)4 FsResourceTypes (com.github.mgramin.sqlboot.model.resource_type.impl.composite.FsResourceTypes)2 WhereWrapper (com.github.mgramin.sqlboot.model.resource_type.wrappers.list.WhereWrapper)2 JdbcSqlQuery (com.github.mgramin.sqlboot.sql.impl.JdbcSqlQuery)2 GroovyTemplateGenerator (com.github.mgramin.sqlboot.template.generator.impl.GroovyTemplateGenerator)2 Connection (java.sql.Connection)2 Map (java.util.Map)2