本文整理汇总了Java中com.orientechnologies.orient.core.metadata.schema.OClass.addSuperClass方法的典型用法代码示例。如果您正苦于以下问题:Java OClass.addSuperClass方法的具体用法?Java OClass.addSuperClass怎么用?Java OClass.addSuperClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.metadata.schema.OClass
的用法示例。
在下文中一共展示了OClass.addSuperClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureClassExists
import com.orientechnologies.orient.core.metadata.schema.OClass; //导入方法依赖的package包/类
private void ensureClassExists(final String className) {
ODatabaseDocumentTx db = getGraph();
final OSchemaProxy schema = db.getMetadata().getSchema();
if (!schema.existsClass(className)) {
final boolean wasInTX = db.getTransaction().isActive();
if (wasInTX) {
LOGGER.warn("Warning: premature commit needed to create class {}", className);
saveDirty();
getGraph().commit();
}
/*
* In order to be treated by OrientDB's query layer as a vertex (e.g. the "Graph" viewer
* in the OrientDB Studio), the vertex classes need to have V as a superclass and refer
* to outgoing edges as out_X and incoming edges as in_X. All edge documents must then
* belong to E or a subclass of and use out and in for the source and target of the edge.
*/
final OClass oClass = schema.createClass(className);
if (className.startsWith(VERTEX_TYPE_PREFIX)) {
OClass baseVertexClass = schema.getClass("V");
if (baseVertexClass == null) {
baseVertexClass = schema.createClass("V");
baseVertexClass.setOverSize(2);
}
oClass.addSuperClass(baseVertexClass);
OrientNode.setupDocumentClass(oClass);
} else if (EDGE_TYPE.equals(className)) {
OrientEdge.setupDocumentClass(oClass);
}
if (wasInTX) {
db.begin();
}
}
}