Refine search
private static void checkRecord(final Set<ORID> iSourceRIDs, final Map<ORID, Set<ORID>> map, final OIdentifiable value, final ORecord iRootObject) { if (iSourceRIDs.contains(value.getIdentity())) { map.get(value.getIdentity()).add(iRootObject.getIdentity()); }else if(!value.getIdentity().isValid() && value.getRecord() instanceof ODocument){ //embedded document ODocument doc = value.getRecord(); for (String fieldName : doc.fieldNames()) { Object fieldValue = doc.field(fieldName); checkObject(iSourceRIDs, map, fieldValue, iRootObject); } } } }
public int compare(final OIdentifiable iObj1, final OIdentifiable iObj2) { if (iObj1 == iObj2) return 0; if (iObj1 != null) return iObj1.compareTo(iObj2); return -1; }
if (iFieldValue == null) { OLogManager.instance() .debug(this, "Edge not found in vertex's property %s.%s while removing the edge %s", iVertex.getIdentity(), iFieldName, iEdge.getIdentity()); return false; iVertex.removeField(iFieldName); else { OLogManager.instance() .warn(this, "Edge not found in vertex's property %s.%s link while removing the edge %s", iVertex.getIdentity(), iFieldName, iEdge.getIdentity()); return false; OLogManager.instance() .warn(this, "Edge not found in vertex's property %s.%s set while removing the edge %s", iVertex.getIdentity(), iFieldName, iEdge.getIdentity()); return false;
final ODocument vOutRecord = vOut.getRecord(); final ODocument vInRecord = vIn.getRecord(); doc.field(OrientBaseGraph.CONNECTION_OUT, graph .isKeepInMemoryReferences() ? vOutRecord.getIdentity() : vOutRecord); doc.field(OrientBaseGraph.CONNECTION_IN, graph .isKeepInMemoryReferences() ? vInRecord.getIdentity() : vInRecord); .isUseVertexFieldsForEdgeLabels(); final String outFieldName = OrientVertex.getConnectionFieldName( Direction.OUT, label, useVertexFieldsForEdgeLabels); OrientVertex.removeEdges(vOutRecord, outFieldName, vInRecord, false, useVertexFieldsForEdgeLabels); final String inFieldName = OrientVertex.getConnectionFieldName( Direction.IN, label, useVertexFieldsForEdgeLabels); OrientVertex.removeEdges(vInRecord, inFieldName, vOutRecord, false,
final OrientBaseGraph graph = getGraph(); if (checkDeletedInTx()) graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted"); final ORID oldIdentity = getIdentity().copy(); final ORecord oldRecord = oldIdentity.getRecord(); if (oldRecord == null) graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted"); final ODocument doc = ((ODocument) rawElement.getRecord()).copy(); final Iterable<Edge> outEdges = getEdges(Direction.OUT); copyRidBags(oldRecord, doc); oldRecord.delete(); doc.setClassName(iClassName); doc.setDirty();
outVertexRecord = outVertex.getRecord(); if (outVertexRecord != null) { final String outFieldName = OrientVertex .getConnectionFieldName(Direction.OUT, edgeClassName, useVertexFieldsForEdgeLabels); outVertexChanged = edge .dropEdgeFromVertex(inVertexEdge, outVertexRecord, outFieldName, outVertexRecord.field(outFieldName)); } else OLogManager.instance().debug(graph, "Found broken link to outgoing vertex " + outVertex.getIdentity() + " while removing edge " + edge.getId()); inVertexRecord = inVertex.getRecord(); if (inVertexRecord != null) { final String inFieldName = OrientVertex .getConnectionFieldName(Direction.IN, edgeClassName, useVertexFieldsForEdgeLabels); inVertexChanged = edge .dropEdgeFromVertex(outVertexEdge, inVertexRecord, inFieldName, inVertexRecord.field(inFieldName)); } else OLogManager.instance().debug(graph, "Found broken link to incoming vertex " + inVertex.getIdentity() + " while removing edge " + edge.getId()); outVertexRecord.save(); if (inVertexChanged) inVertexRecord.save();
outVertexRecord = outVertex.getRecord(); if (outVertexRecord != null) { final String outFieldName = OrientVertex.getConnectionFieldName(Direction.OUT, edgeClassName, useVertexFieldsForEdgeLabels); outVertexChanged = edge.dropEdgeFromVertex(inVertexEdge, outVertexRecord, outFieldName, outVertexRecord.field(outFieldName)); inVertexRecord = inVertex.getRecord(); if (inVertexRecord != null) { final String inFieldName = OrientVertex.getConnectionFieldName(Direction.IN, edgeClassName, useVertexFieldsForEdgeLabels); inVertexChanged = edge.dropEdgeFromVertex(outVertexEdge, inVertexRecord, inFieldName, inVertexRecord.field(inFieldName)); outVertexRecord.save(); if (inVertexChanged) inVertexRecord.save();
.field(iFieldName) : iVertex.removeField(iFieldName); if (fieldValue == null) return; iVertex.removeField(iFieldName); removeInverseEdge(iVertex, iFieldName, iVertexToRemove, fieldValue, useVertexFieldsForEdgeLabels); deleteEdgeIfAny((OIdentifiable) fieldValue); for (OLazyIterator<OIdentifiable> it = ((OMVRBTreeRIDSet) fieldValue) .iterator(false); it.hasNext();) { final ODocument curr = it.next().getRecord(); removeInverseEdge(iVertex, iFieldName, iVertexToRemove, curr, useVertexFieldsForEdgeLabels); break; } else if (curr.getSchemaClass().isSubClassOf( OrientEdge.CLASS_NAME)) { if (curr.getSchemaClass().isSubClassOf( OrientEdge.CLASS_NAME)) { final Direction direction = getConnectionDirection(
@SuppressWarnings("unchecked") public OIdentifiable process() { while (target.hasNext()) { record = target.next(); index++; final ORecord rec = record.getRecord(); if (rec instanceof ODocument) { ODocument doc = (ODocument) rec; if (!doc.getIdentity().isPersistent() && doc.fields() == 1) { // EXTRACT THE FIELD CONTEXT Object fieldvalue = doc.field(doc.fieldNames()[0]); if (fieldvalue instanceof Collection<?>) { command.getContext().push( new OTraverseRecordSetProcess(command, ((Collection<OIdentifiable>) fieldvalue).iterator(), getPath())); } else if (fieldvalue instanceof ODocument) { command.getContext().push(new OTraverseRecordProcess(command, (ODocument) rec, getPath())); } } else { command.getContext().push(new OTraverseRecordProcess(command, (ODocument) rec, getPath())); } return null; } } return pop(); }
public <T> T getProperty(final String key) { if (key == null) return null; if (key.equals("_class")) return (T) getRecord().getSchemaClass().getName(); else if (key.equals("_version")) return (T) new Integer(getRecord().getVersion()); else if (key.equals("_rid")) return (T) rawElement.getIdentity().toString(); return getRecord().field(key); }
final ODocument document = entries.next().getRecord(); map.put(field, new StringByteIterator((String) document.field(field))); for (String field : document.fieldNames()) { map.put(field, new StringByteIterator((String) document.field(field)));
protected ODocument serializeIndexChangeEntry(OTransactionIndexChangesPerKey entry, final ODocument indexDoc) { ODocument keyContainer = new ODocument(); keyContainer.setTrackingChanges(false); final List<Object> keys = ((OCompositeKey) entry.key).getKeys(); keyContainer.field("key", keys, OType.EMBEDDEDLIST); keyContainer.field("binary", false); } else { changeDoc.field("o", e.operation.ordinal()); if (e.value instanceof ORecord && e.value.getIdentity().isNew()) { final ORecord saved = getRecord(e.value.getIdentity()); if (saved != null) e.value = saved; else ((ORecord) e.value).save(); changeDoc.field("v", e.value != null ? e.value.getIdentity() : null);
private boolean matchesClass(OIdentifiable identifiable, OClass oClass) { if (identifiable == null) { return false; } ORecord record = identifiable.getRecord(); if (record == null) { return false; } if (record instanceof ODocument) { return ((ODocument) record).getSchemaClass().isSubClassOf(oClass); } return false; }
@Override public boolean result(final Object iRecord) { OClass oldClass = null; ORecord oldRecord = ((OIdentifiable) iRecord).getRecord(); if (oldRecord instanceof ODocument) { oldClass = ((ODocument) oldRecord).getSchemaClass(); final ORecord rec = oldRecord.copy(); rec.getIdentity().reset(); doc.setClassName(className); doc.setTrackingChanges(true); OElement doc = (OElement) rec; Object edges = doc.getProperty(field); if (edges instanceof OIdentifiable) { ODocument edgeRec = ((OIdentifiable) edges).getRecord(); if (edgeRec.getSchemaClass() != null && edgeRec.getSchemaClass().isSubClassOf("E")) { doc.removeProperty(field); for (Object edge : (Iterable) edges) { if (edge instanceof OIdentifiable) { OElement edgeRec = ((OIdentifiable) edge).getRecord(); if (edgeRec.getSchemaType().isPresent() && edgeRec.getSchemaType().get().isSubClassOf("E")) { doc.removeProperty(field); break;
@Override public String apply(ODocument vertex) { Object fieldIn = getModelObject().field("in"); String direction; if (fieldIn != null) { direction = ((OIdentifiable)fieldIn).getIdentity().equals(vertex.getIdentity()) ? "in":"out"; } else direction = "empty"; return getLocalizer().getString("widget.document.vertices.title." + direction, GraphVerticesWidget.this); }
+ " but the value is not a record or a record-id"); final OClass schemaClass = p.getLinkedClass(); if (schemaClass != null && !schemaClass.isSubClassOf(OIdentity.CLASS_NAME)) { final ORID rid = ((OIdentifiable) fieldValue).getIdentity(); if (!schemaClass.hasPolymorphicClusterId(rid.getClusterId())) { linkedRecord = ((OIdentifiable) fieldValue).getRecord(); if (linkedRecord != null) { if (!(linkedRecord instanceof ODocument)) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " of type '" + schemaClass + "' but the value is the record " + linkedRecord.getIdentity() + " that is not a document"); if (doc.getImmutableSchemaClass() != null && !schemaClass.isSuperClassOf(doc.getImmutableSchemaClass())) throw new OValidationException( "The field '" + p.getFullName() + "' has been declared as " + p.getType() + " of type '" + schemaClass.getName() + "' but the value is the document " + linkedRecord.getIdentity() + " of class '" + doc .getImmutableSchemaClass() + "'");
@Override public Map<String, Object> getProperties() { if (this.rawElement == null) return null; final ODocument raw = this.rawElement.getRecord(); if (raw == null) return null; final OrientBaseGraph graph = setCurrentGraphInThreadLocal(); final Map<String, Object> result = new HashMap<String, Object>(); for (String field : raw.fieldNames()) if (graph != null && settings.isUseVertexFieldsForEdgeLabels()) { if (!field.startsWith(CONNECTION_OUT_PREFIX) && !field.startsWith(CONNECTION_IN_PREFIX)) result.put(field, raw.field(field)); } else if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN)) result.put(field, raw.field(field)); return result; }
return iCurrent.getRecord(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_RID)) return iCurrent.getIdentity(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_RID_ID)) return iCurrent.getIdentity().getClusterId(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_RID_POS)) return iCurrent.getIdentity().getClusterPosition(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_VERSION)) return iCurrent.getRecord().getVersion(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_CLASS)) return ((ODocument) iCurrent.getRecord()).getClassName(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_TYPE)) return Orient.instance().getRecordFactoryManager().getRecordTypeName(ORecordInternal.getRecordType(iCurrent.getRecord())); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_SIZE)) { final byte[] stream = iCurrent.getRecord().toStream(); return stream != null ? stream.length : 0; } else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_FIELDS)) return ((ODocument) iCurrent.getRecord()).fieldNames(); else if (iFieldName.equalsIgnoreCase(ATTRIBUTE_RAW)) return new String(iCurrent.getRecord().toStream()); return null; final ODocument doc = ((ODocument) iCurrent.getRecord()); if (doc == null) {// broken link return null;
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }