Package com.orientechnologies.orient.core.record.impl

Examples of com.orientechnologies.orient.core.record.impl.ODocument


@SuppressWarnings("unchecked")
public abstract class OGraphElement extends ODocumentWrapper implements ORecordListener {
  protected ODatabaseGraphTx  database;

  public OGraphElement(final ODatabaseGraphTx iDatabase, final ORID iRID) {
    this(iDatabase, new ODocument((ODatabaseRecord) iDatabase.getUnderlying(), iRID));
    document.setTrackingChanges(false);
  }
View Full Code Here


    this(iDatabase, new ODocument((ODatabaseRecord) iDatabase.getUnderlying(), iRID));
    document.setTrackingChanges(false);
  }

  public OGraphElement(final ODatabaseGraphTx iDatabase, final String iClassName) {
    this(iDatabase, new ODocument((ODatabaseRecord) iDatabase.getUnderlying(), iClassName));
    document.setTrackingChanges(false);
  }
View Full Code Here

    if (e instanceof ODocument) {
      converted = false;
      underlying.put(iKey, e);
    } else {
      if (database.getRecordByUserObject(e, false) == null) {
        underlying.put(iKey, database.pojo2Stream((TYPE) e, new ODocument((ODatabaseRecord) database.getUnderlying())));
      } else {
        underlying.put(iKey, database.getRecordByUserObject(e, false));
      }
    }
    setDirty();
View Full Code Here

   */
  private void deleteHoleRecords() {
    listener.onMessage("\nDelete temporary records...");

    final ORecordId rid = new ORecordId();
    final ODocument doc = new ODocument(database, rid);
    for (String recId : recordToDelete) {
      doc.reset();
      rid.fromString(recId);
      doc.delete();
    }
    listener.onMessage("OK (" + recordToDelete.size() + " records)");
  }
View Full Code Here

    listener.onMessage("\nImporting manual indexes...");

    String key;
    String value;

    final ODocument doc = new ODocument(database);

    // FORCE RELOADING
    database.getMetadata().getIndexManager().load();

    jsonReader.readNext(OJSONReader.BEGIN_OBJECT);

    do {
      final String indexName = jsonReader.readString(OJSONReader.FIELD_ASSIGNMENT);

      if (indexName == null || indexName.length() == 0)
        return;

      listener.onMessage("\n- Index '" + indexName + "'...");

      final OIndex index = database.getMetadata().getIndexManager().getIndex(indexName);

      long tot = 0;

      jsonReader.readNext(OJSONReader.BEGIN_OBJECT);

      String n;
      do {
        jsonReader.readNext(new char[] { ':', '}' });

        if (jsonReader.lastChar() != '}') {
          key = jsonReader.checkContent("\"key\"").readString(OJSONReader.COMMA_SEPARATOR);
          value = jsonReader.readNext(OJSONReader.FIELD_ASSIGNMENT).checkContent("\"value\"")
              .readString(OJSONReader.NEXT_IN_OBJECT);

          if (index != null)
            if (value.length() >= 4) {
              if (value.charAt(0) == '[')
                // REMOVE []
                value = value.substring(1, value.length() - 1);

              final Collection<String> rids = OStringSerializerHelper.split(value, ',', new char[] { '#', '"' });

              for (String rid : rids) {
                doc.setIdentity(new ORecordId(rid));
                index.put(key, doc);
              }
            }

          tot++;
View Full Code Here

      if (record.getIdentity().getClusterPosition() > nextAvailablePos) {
        // CREATE HOLES
        int holes = (int) (record.getIdentity().getClusterPosition() - nextAvailablePos);

        ODocument tempRecord = new ODocument(database);
        for (int i = 0; i < holes; ++i) {
          tempRecord.reset();
          ((ODatabaseRecord) database.getUnderlying()).save(tempRecord, clusterName);
          recordToDelete.add(tempRecord.getIdentity().toString());
        }
      }

      // APPEND THE RECORD
      record.setIdentity(-1, -1);
View Full Code Here

      in = null;
    }
  }

  public static void delete(final ODatabaseGraphTx iDatabase, final ODocument iEdge) {
    final ODocument sourceVertex = (ODocument) iEdge.field(OGraphDatabase.EDGE_FIELD_OUT);
    final ODocument targetVertex = (ODocument) iEdge.field(OGraphDatabase.EDGE_FIELD_IN);

    Set<OGraphEdge> edges;

    if (sourceVertex != null && iDatabase.existsUserObjectByRID(sourceVertex.getIdentity())) {
      // WORK ALSO WITH OGraphDatabase.EDGE_FIELD_IN MEMORY OBJECTS

      final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(sourceVertex, null);
      // REMOVE THE EDGE OBJECT
      edges = vertex.getOutEdges();
      if (edges != null) {
        for (OGraphEdge e : edges)
          if (e.getDocument().equals(iEdge)) {
            edges.remove(e);
            break;
          }
      }
    }

    if (targetVertex != null && iDatabase.existsUserObjectByRID(targetVertex.getIdentity())) {
      // WORK ALSO WITH OGraphDatabase.EDGE_FIELD_IN MEMORY OBJECTS

      final OGraphVertex vertex = (OGraphVertex) iDatabase.getUserObjectByRecord(targetVertex, null);
      // REMOVE THE EDGE OBJECT FROM THE TARGET VERTEX
      edges = vertex.getInEdges();
      if (edges != null) {
        for (OGraphEdge e : edges)
          if (e.getDocument().equals(iEdge)) {
            edges.remove(e);
            break;
          }
      }
    }

    // REMOVE THE EDGE DOCUMENT
    Set<ODocument> docs = sourceVertex.field(OGraphDatabase.VERTEX_FIELD_OUT);
    if (docs != null)
      docs.remove(iEdge);

    sourceVertex.setDirty();
    sourceVertex.save();

    // REMOVE THE EDGE DOCUMENT FROM THE TARGET VERTEX
    docs = targetVertex.field(OGraphDatabase.VERTEX_FIELD_IN);
    if (docs != null)
      docs.remove(iEdge);

    targetVertex.setDirty();
    targetVertex.save();

    if (iDatabase.existsUserObjectByRID(iEdge.getIdentity())) {
      final OGraphEdge edge = (OGraphEdge) iDatabase.getUserObjectByRecord(iEdge, null);
      iDatabase.unregisterPojo(edge, iEdge);
    }
View Full Code Here

  @SuppressWarnings("rawtypes")
  public void attach(final Object iPojo) {
    checkOpeness();

    final ODocument record = objects2Records.get(System.identityHashCode(iPojo));
    if (record != null)
      return;

    if (OObjectSerializerHelper.hasObjectID(iPojo)) {
      for (Field field : iPojo.getClass().getDeclaredFields()) {
View Full Code Here

   */
  public void registerUserObject(final Object iObject, final ORecordInternal<?> iRecord) {
    if (!(iRecord instanceof ODocument))
      return;

    final ODocument doc = (ODocument) iRecord;

    if (retainObjects) {
      if (iObject != null) {
        objects2Records.put(System.identityHashCode(iObject), doc);
        records2Objects.put(doc, (T) iObject);
View Full Code Here

        }

      getStorage().commit(currentTx);

      // COMMIT INDEX CHANGES
      final ODocument indexEntries = currentTx.getIndexChanges();
      if (indexEntries != null) {
        for (Entry<String, Object> indexEntry : indexEntries) {
          final OIndex index = getMetadata().getIndexManager().getIndexInternal(indexEntry.getKey());
          index.commit((ODocument) indexEntry.getValue());
        }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.record.impl.ODocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.