if (!database.isClosed())
database.close();
}
protected void createBasicTestSchema() {
ODatabaseComplex database = this.database;
if (database instanceof OObjectDatabaseTx)
database = ((OObjectDatabaseTx) database).getUnderlying();
if (database.getMetadata().getSchema().existsClass("Whiz"))
return;
database.addCluster("csv");
database.addCluster("flat");
database.addCluster("binary");
OClass account = database.getMetadata().getSchema()
.createClass("Account", database.addCluster("account"));
account.createProperty("id", OType.INTEGER);
account.createProperty("birthDate", OType.DATE);
account.createProperty("binary", OType.BINARY);
database.getMetadata().getSchema().createClass("Company", account);
OClass profile = database.getMetadata().getSchema()
.createClass("Profile", database.addCluster("profile"));
profile.createProperty("nick", OType.STRING).setMin("3").setMax("30").createIndex(OClass.INDEX_TYPE.UNIQUE);
profile.createProperty("name", OType.STRING).setMin("3").setMax("30").createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
profile.createProperty("surname", OType.STRING).setMin("3").setMax("30");
profile.createProperty("registeredOn", OType.DATETIME).setMin("2010-01-01 00:00:00");
profile.createProperty("lastAccessOn", OType.DATETIME).setMin("2010-01-01 00:00:00");
profile.createProperty("photo", OType.TRANSIENT);
OClass whiz = database.getMetadata().getSchema().createClass("Whiz");
whiz.createProperty("id", OType.INTEGER);
whiz.createProperty("account", OType.LINK, account);
whiz.createProperty("date", OType.DATE).setMin("2010-01-01");
whiz.createProperty("text", OType.STRING).setMandatory(true).setMin("1").setMax("140").createIndex(OClass.INDEX_TYPE.FULLTEXT);
whiz.createProperty("replyTo", OType.LINK, account);
OClass strictTest = database.getMetadata().getSchema().createClass("StrictTest");
strictTest.setStrictMode(true);
strictTest.createProperty("id", OType.INTEGER).isMandatory();
strictTest.createProperty("name", OType.STRING);
OClass animalRace = database.getMetadata().getSchema().createClass("AnimalRace");
animalRace.createProperty("name", OType.STRING);
OClass animal = database.getMetadata().getSchema().createClass("Animal");
animal.createProperty("races", OType.LINKSET, animalRace);
animal.createProperty("name", OType.STRING);
}