* @param schemaNode
* @param version
* @throws org.dbwiki.exception.WikiException
*/
public void insertSchemaNode(SchemaNode schemaNode, Version version) throws org.dbwiki.exception.WikiException {
User user = version.provenance().user();
TimeSequence timestamp = new TimeSequence(version);
try {
PreparedStatement insert = _con.prepareStatement(
"INSERT INTO " + _database.name() + RelationSchema + " (" +
RelSchemaColID + ", " +
RelSchemaColType + ", " +
RelSchemaColLabel + ", " +
RelSchemaColParent + ", " +
RelSchemaColUser + ")" +
" VALUES(?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
insert.setInt(1, schemaNode.id());
if (schemaNode.isAttribute()) {
insert.setInt(2, RelSchemaColTypeValAttribute);
} else {
insert.setInt(2, RelSchemaColTypeValGroup);
}
insert.setString(3, schemaNode.label());
if (schemaNode.parent() != null) {
insert.setInt(4, schemaNode.parent().id());
} else {
insert.setInt(4, RelSchemaColParentValUnknown);
}
if (user != null) {
insert.setInt(5, user.id());
} else {
insert.setInt(5, User.UnknownUserID);
}
insert.execute();