use of com.orientechnologies.orient.core.metadata.schema.OImmutableClass in project orientdb by orientechnologies.
the class OrientVertexIterator method getGraphElementRecord.
@Override
public OIdentifiable getGraphElementRecord(final Object iObject) {
final ORecord rec = ((OIdentifiable) iObject).getRecord();
if (rec == null || !(rec instanceof ODocument))
return null;
final ODocument value = (ODocument) rec;
final OIdentifiable v;
OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(value);
if (immutableClass.isVertexType()) {
// DIRECT VERTEX
v = value;
} else if (immutableClass.isEdgeType()) {
// EDGE
if (vertex.settings.isUseVertexFieldsForEdgeLabels() || OrientEdge.isLabeled(OrientEdge.getRecordLabel(value), iLabels))
v = OrientEdge.getConnection(value, connection.getKey().opposite());
else
v = null;
} else
throw new IllegalStateException("Invalid content found between connections: " + value);
return v;
}
use of com.orientechnologies.orient.core.metadata.schema.OImmutableClass in project orientdb by orientechnologies.
the class OrientVertexIterator method isVertex.
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;
OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(value);
if (immutableClass.isVertexType()) {
// DIRECT VERTEX
return true;
} else if (immutableClass.isEdgeType()) {
return false;
}
throw new IllegalStateException("Invalid content found between connections: " + value);
}
use of com.orientechnologies.orient.core.metadata.schema.OImmutableClass in project orientdb by orientechnologies.
the class OSQLFunctionMove method v2e.
protected Object v2e(final OrientBaseGraph graph, final OIdentifiable iRecord, final Direction iDirection, final String[] iLabels) {
final ODocument rec = iRecord.getRecord();
OImmutableClass immutableClass = ODocumentInternal.getImmutableSchemaClass(rec);
if (immutableClass != null && immutableClass.isVertexType()) {
// VERTEX
final OrientVertex vertex = graph.getVertex(rec);
if (vertex != null)
return vertex.getEdges(iDirection, iLabels);
}
return null;
}
use of com.orientechnologies.orient.core.metadata.schema.OImmutableClass in project orientdb by orientechnologies.
the class OClassTrigger method onTrigger.
public RESULT onTrigger(final TYPE iType, final ORecord iRecord) {
if (database.getStatus() != STATUS.OPEN)
return RESULT.RECORD_NOT_CHANGED;
if (!(iRecord instanceof ODocument))
return RESULT.RECORD_NOT_CHANGED;
final ODocument document = (ODocument) iRecord;
OImmutableClass immutableSchemaClass = ODocumentInternal.getImmutableSchemaClass(document);
if (immutableSchemaClass != null && immutableSchemaClass.isTriggered())
return super.onTrigger(iType, iRecord);
return RESULT.RECORD_NOT_CHANGED;
}
use of com.orientechnologies.orient.core.metadata.schema.OImmutableClass in project orientdb by orientechnologies.
the class OClassTrigger method checkClzAttribute.
private Object checkClzAttribute(final ODocument iDocument, String attr) {
final OImmutableClass clz = ODocumentInternal.getImmutableSchemaClass(iDocument);
if (clz != null && clz.isTriggered()) {
OFunction func = null;
String fieldName = clz.getCustom(attr);
OClass superClz = clz.getSuperClass();
while (fieldName == null || fieldName.length() == 0) {
if (superClz == null || superClz.getName().equals(CLASSNAME))
break;
fieldName = superClz.getCustom(attr);
superClz = superClz.getSuperClass();
}
if (fieldName != null && fieldName.length() > 0) {
// check if it is reflection or not
final Object[] clzMethod = this.checkMethod(fieldName);
if (clzMethod != null)
return clzMethod;
func = database.getMetadata().getFunctionLibrary().getFunction(fieldName);
if (func == null) {
// check if it is rid
if (OStringSerializerHelper.contains(fieldName, ORID.SEPARATOR)) {
try {
ODocument funcDoc = database.load(new ORecordId(fieldName));
if (funcDoc != null) {
func = database.getMetadata().getFunctionLibrary().getFunction((String) funcDoc.field("name"));
}
} catch (Exception ex) {
OLogManager.instance().error(this, "illegal record id : ", ex.getMessage());
}
}
}
} else {
final Object funcProp = iDocument.field(attr);
if (funcProp != null) {
final String funcName = funcProp instanceof ODocument ? (String) ((ODocument) funcProp).field("name") : funcProp.toString();
func = database.getMetadata().getFunctionLibrary().getFunction(funcName);
}
}
return func;
}
return null;
}
Aggregations