use of org.molgenis.emx2.Column in project molgenis-emx2 by molgenis.
the class JsonLdExample method create.
public static void create(Schema schema) {
Table personTable = schema.create(table("Person").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#Person").add(column("name").setPkey().setSemantics("https://schema.org/docs/jsonldcontext.jsonld#name"), column("jobTitle").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#jobTitle").setRequired(true), column("telephone").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#telephone"), column("url").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#url")));
personTable.insert(row("name", "Jane Doe", "jobTitle", "Professor", "telephone", "(425) 123-4567", "url", "http://www.janedoe.com"), row("id", "2", "name", "Mary Stone", "jobTitle", "Cook"));
Table recipeTable = schema.create(table("Recipe").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#Recipe").add(column("name").setPkey().setSemantics("https://schema.org/docs/jsonldcontext.jsonld#name"), column("author").setType(REF).setRefTable("Person").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#author").setRequired(true), column("datePublished").setType(DATE).setSemantics("https://schema.org/docs/jsonldcontext.jsonld#datePublished").setRequired(true), column("prepTime").setSemantics("https://schema.org/docs/jsonldcontext.jsonld#prepTime").setRequired(true)));
recipeTable.insert(row("name", "Mary's Cookies", "author", "Mary Stone", "datePublished", "2018-03-10", "prepTime", "PT20M"));
}
use of org.molgenis.emx2.Column in project SpinalTap by airbnb.
the class Table method toThriftTable.
public static com.airbnb.jitney.event.spinaltap.v1.Table toThriftTable(Table table) {
Set<String> primaryKey = ImmutableSet.of();
if (table.getPrimaryKey().isPresent()) {
primaryKey = ImmutableSet.copyOf(table.getPrimaryKey().get().getColumns().values().stream().map(ColumnMetadata::getName).sorted().collect(Collectors.toList()));
}
Map<String, Column> columns = table.getColumns().values().stream().map(c -> {
com.airbnb.jitney.event.spinaltap.v1.Column column = new com.airbnb.jitney.event.spinaltap.v1.Column(c.getColType().getCode(), c.isPrimaryKey(), c.getName());
column.setPosition(c.getPosition());
return column;
}).collect(Collectors.toMap(c -> c.getName(), c -> c));
com.airbnb.jitney.event.spinaltap.v1.Table thriftTable = new com.airbnb.jitney.event.spinaltap.v1.Table(table.getId(), table.getName(), table.getDatabase(), primaryKey, columns);
if (!Strings.isNullOrEmpty(table.getOverridingDatabase())) {
thriftTable.setOverridingDatabase(table.getOverridingDatabase());
}
return thriftTable;
}
Aggregations