use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestMetaDataIsStoredForNextSessions method testSimpleTypesTest.
@Test
public void testSimpleTypesTest() {
Schema schema = database.dropCreateSchema(SCHEMA_NAME + "2");
SimpleTypeTestExample.createSimpleTypeTest(schema.getMetadata());
try {
CompareTools.reloadAndCompare(database, schema);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestMetaDataIsStoredForNextSessions method testProductComponentsPartsModel.
@Test
public void testProductComponentsPartsModel() {
Schema schema = database.dropCreateSchema(SCHEMA_NAME + "1");
ProductComponentPartsExample.create(schema.getMetadata());
try {
CompareTools.reloadAndCompare(database, schema);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestMetaDataIsStoredForNextSessions method testArrayTypesTest.
@Test
public void testArrayTypesTest() {
Schema schema = database.dropCreateSchema(SCHEMA_NAME + "3");
ArrayTypeTestExample.createSimpleTypeTest(schema.getMetadata());
try {
CompareTools.reloadAndCompare(database, schema);
} catch (Exception e) {
fail(e.getMessage());
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestTruncate method testTruncate.
@Test
public void testTruncate() {
Database db = TestDatabaseFactory.getTestDatabase();
Schema schema = db.dropCreateSchema(TestTruncate.class.getSimpleName());
// create simple table, add data, and truncate
Table table1 = schema.create(table("Table1", column("name").setPkey()));
table1.insert(row("name", "a"));
Assert.assertEquals(1, table1.retrieveRows().size());
table1.truncate();
Assert.assertEquals(0, table1.retrieveRows().size());
// create with subclass
Table table2 = schema.create(table("Table2").setInherit("Table1").add(column("col1")));
table1.insert(row("name", "a"));
table2.insert(row("name", "b", "col1", "checkb"));
Assert.assertEquals(2, table1.retrieveRows().size());
Assert.assertEquals(1, table2.retrieveRows().size());
table1.truncate();
Assert.assertEquals(1, table1.retrieveRows().size());
Assert.assertEquals(1, table2.retrieveRows().size());
table2.truncate();
Assert.assertEquals(0, table1.retrieveRows().size());
Assert.assertEquals(0, table2.retrieveRows().size());
// create with subclass of a subclass
Table table3 = schema.create(table("Table3").setInherit("Table2").add(column("col2")));
table1.insert(row("name", "a"));
table2.insert(row("name", "b", "col1", "checkb"));
table3.insert(row("name", "c", "col1", "checkc", "col2", "checkc"));
Assert.assertEquals(3, table1.retrieveRows().size());
Assert.assertEquals(2, table2.retrieveRows().size());
Assert.assertEquals(1, table3.retrieveRows().size());
// leaves subclass?!!! is this expected behavior?
table2.truncate();
Assert.assertEquals(2, table1.retrieveRows().size());
// !!!
Assert.assertEquals(1, table2.retrieveRows().size());
Assert.assertEquals(1, table3.retrieveRows().size());
table3.truncate();
Assert.assertEquals(1, table1.retrieveRows().size());
Assert.assertEquals(0, table2.retrieveRows().size());
Assert.assertEquals(0, table3.retrieveRows().size());
table1.truncate();
Assert.assertEquals(0, table1.retrieveRows().size());
Assert.assertEquals(0, table2.retrieveRows().size());
Assert.assertEquals(0, table3.retrieveRows().size());
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project DataflowTemplates by GoogleCloudPlatform.
the class SchemaUtils method fromBeamField.
private static ColumnSchema fromBeamField(org.apache.beam.sdk.schemas.Schema.Field beamField) {
ColumnSchema.Builder columnBuilder = ColumnSchema.newBuilder();
if (beamField.getType().getNullable()) {
columnBuilder.setMode("NULLABLE");
} else {
columnBuilder.setMode("REQUIRED");
}
if (beamField.getType().getTypeName() == TypeName.ROW) {
String columnType = "STRUCT";
Schema subSchema = fromBeamSchema(beamField.getType().getRowSchema());
return columnBuilder.setColumn(beamField.getName()).setType(columnType).addAllSubcolumns(subSchema.getColumnsList()).build();
} else if (LOGICAL_FIELD_TYPES.inverse().containsKey(beamField.getType())) {
String columnType = LOGICAL_FIELD_TYPES.inverse().get(beamField.getType());
return columnBuilder.setColumn(beamField.getName()).setType(columnType).build();
} else {
String columnType = FIELD_TYPE_NAMES.inverse().get(beamField.getType().getTypeName());
// TODO(pabloem): Include other characteristics of the field (e.g. required/nullable/etc).
return columnBuilder.setColumn(beamField.getName()).setType(columnType).build();
}
}
Aggregations