protected Session getSession() {
return createSession(null);
}
protected Session createSession(Configuration config) {
Schema schema = new Schema();
Database database = new Database(schema);
Type stringType = new Type("VARCHAR");
stringType.setOperators(new Operator[] {
new Operator("="),
new Operator("IS NULL", Cardinality.ZERO),
new Operator("LIKE"), new Operator("CUSTOM_OP") });
// XXX IN done better as hint or style?
Type refType = new Type("REFS");
refType.setEditor(new Editor.SelectEditor());
refType.setOperators(new Operator[]{
new Operator("IN", Cardinality.MULTI),
new Operator("NOT IN", Cardinality.MULTI)});
Type suggestType = new Type("SUGGEST");
suggestType.setEditor(new SuggestEditor());
suggestType.setOperators(new Operator[]{new Operator("=")});
Type singleRefType = new Type("REF");
singleRefType.setEditor(new Editor.SelectEditor());
singleRefType.setOperators(new Operator[] {
new Operator("="),
new Operator("IS NULL", Cardinality.ZERO),
new Operator("CUSTOM_OP", Cardinality.ONE)});
Type dateType = new Type("DATE");
dateType.setEditor(new Editor.DateEditor());
Type[] types = new Type[]{stringType, dateType, refType, singleRefType};
database.setTypes(types);
Table person = new Table("PERSON"); // XXX want case sensitivity?
Column personId = new Column("id", stringType);
person.add(personId);
person.add(new Column("sex", singleRefType));
person.add(new Column("owner", stringType));
person.add(new Column("category", refType));
person.add(new Column("category2", refType));
person.add(new Column("county", suggestType));
schema.add(person);
{
Table log = new Table("Log");
log.add(new Column("id", stringType));
log.add(new Column("date", dateType));
Column pc = new Column("parent", stringType);
ConstraintReferential fk = new ConstraintReferential("parentfk",
log);
fk.setRefTable(person);
fk.setColumns(new Column[] {pc });
fk.setRefColumns(new Column[] {personId });
log.add(fk);
log.add(pc);
schema.add(log);
}
{
Table order = new Table("Order");
order.add(new Column("date", dateType));
Column pc = new Column("parent", stringType);
ConstraintReferential fk = new ConstraintReferential("orderparentfk",
order);
fk.setRefTable(person);
fk.setColumns(new Column[] {pc });
fk.setRefColumns(new Column[] {personId });
order.add(fk);
order.add(pc);
schema.add(order);
}
if (config == null) {
config = createSimpleConfig();
}