@Override public boolean isVertex() { if (this instanceof OVertex) return true; OClass type = this.getSchemaClass(); if (type == null) { return false; } return type.isVertexType(); }
@Override public Optional<OVertex> asVertex() { if (this instanceof OVertex) return Optional.of((OVertex) this); OClass type = this.getSchemaClass(); if (type == null) { return Optional.empty(); } if (type.isVertexType()) { return Optional.of(new OVertexDelegate(this)); } return Optional.empty(); }
public OVertexDocument(String klass) { super(klass); if (!getSchemaClass().isVertexType()) { throw new IllegalArgumentException("" + getClassName() + " is not a vertex class"); } }
public OVertex newVertex(final String iClassName) { OClass cl = getClass(iClassName); if (cl == null || !cl.isVertexType()) { throw new IllegalArgumentException("" + iClassName + " is not a vertex class"); } OVertex doc = new OVertexDocument(cl); return doc; }
@Override public boolean isClusterVertex(int cluster) { OClass clazz = getMetadata().getImmutableSchemaSnapshot().getClassByClusterId(cluster); if (clazz != null && clazz.isVertexType()) return true; return false; } }
if (cls.isVertexType()) throw new IllegalArgumentException("Cannot retrieve an edge with the RID " + id + " because it is a vertex");
private boolean isVertex(final OIdentifiable iObject) { final ORecord rec = iObject.getRecord(); if (rec == null || !(rec instanceof ODocument)) return false; final ODocument value = (ODocument) rec; final OIdentifiable v; OClass klass = ODocumentInternal.getImmutableSchemaClass(value); if (klass == null && ODatabaseRecordThreadLocal.instance().getIfDefined() != null) { ODatabaseRecordThreadLocal.instance().getIfDefined().getMetadata().reload(); klass = value.getSchemaClass(); } if (klass.isVertexType()) { // DIRECT VERTEX return true; } else if (klass.isEdgeType()) { return false; } throw new IllegalStateException("Invalid content found between connections: " + value); } }
if (schemaClass != null && schemaClass.isVertexType()) vertices.add(graph.getVertex(entry)); else if (schemaClass != null && schemaClass.isEdgeType()) {
if (fieldRecord != null) { final OClass schemaClass = fieldRecord.getSchemaClass(); if (schemaClass != null && (schemaClass.isVertexType() || schemaClass.isEdgeType())) {
if (klass.isVertexType()) { if (iTargetVertex != null && !iTargetVertex.equals(fieldValue)) return null;
private Object getLabel(final OrientBaseGraph graph, final OIdentifiable iCurrentRecord) { final ODocument rec = iCurrentRecord.getRecord(); OClass klass = ODocumentInternal.getImmutableSchemaClass(rec); if (klass == null && ODatabaseRecordThreadLocal.instance().getIfDefined() != null) { ODatabaseRecordThreadLocal.instance().getIfDefined().getMetadata().reload(); klass = rec.getSchemaClass(); } if (klass.isVertexType()) { // VERTEX final OrientVertex vertex = graph.getVertex(iCurrentRecord); return vertex.getLabel(); } else if (klass.isEdgeType()) { // EDGE final OrientEdge edge = graph.getEdge(iCurrentRecord); return edge.getLabel(); } else throw new OCommandExecutionException("Invalid record: is neither a vertex nor an edge. Found class: " + klass); }
if (klass.isVertexType()) {
klass = fieldRecord.getSchemaClass(); if (klass.isVertexType()) {
@Override public OResultSet executeDDL(OCommandContext ctx) { OSchema schema = ctx.getDatabase().getMetadata().getSchema(); OClass clazz = schema.getClass(name.getStringValue()); if (clazz == null) { if (ifExists) { return new OInternalResultSet(); } throw new OCommandExecutionException("Class " + name.getStringValue() + " does not exist"); } if (!unsafe && clazz.count() > 0) { //check vertex or edge if (clazz.isVertexType()) { throw new OCommandExecutionException("'DROP CLASS' command cannot drop class '" + name.getStringValue() + "' because it contains Vertices. Use 'DELETE VERTEX' command first to avoid broken edges in a database, or apply the 'UNSAFE' keyword to force it"); } else if (clazz.isEdgeType()) { // FOUND EDGE CLASS throw new OCommandExecutionException("'DROP CLASS' command cannot drop class '" + name.getStringValue() + "' because it contains Edges. Use 'DELETE EDGE' command first to avoid broken vertices in a database, or apply the 'UNSAFE' keyword to force it"); } } schema.dropClass(name.getStringValue()); OInternalResultSet rs = new OInternalResultSet(); OResultInternal result = new OResultInternal(); result.setProperty("operation", "drop class"); result.setProperty("className", name.getStringValue()); rs.add(result); return rs; }