Package com.orientechnologies.orient.core.id

Examples of com.orientechnologies.orient.core.id.ORecordId


      case LINK:
        final int pos = iFieldValueAsString.indexOf('@');
        if (pos > -1)
          // CREATE DOCUMENT
          return new ODocument(iRecord.getDatabase(), iFieldValueAsString.substring(1, pos), new ORecordId(
              iFieldValueAsString.substring(pos + 1)));
        else
          // CREATE SIMPLE RID
          return new ORecordId(iFieldValueAsString.substring(1));

      case EMBEDDED:
        return fromString(iRecord.getDatabase(), iFieldValueAsString);

      case DATE:
View Full Code Here


    return true;
  }

  private void commitEntry(final int iTxId, final OTransactionEntry txEntry) throws IOException {

    final ORecordId rid = (ORecordId) txEntry.getRecord().getIdentity();

    final OCluster cluster = txEntry.clusterName != null ? getClusterByName(txEntry.clusterName) : getClusterById(rid.clusterId);
    rid.clusterId = cluster.getId();

    switch (txEntry.status) {
    case OTransactionEntry.LOADED:
      break;

    case OTransactionEntry.CREATED:
      if (rid.isNew()) {
        // CHECK 2 TIMES TO ASSURE THAT IT'S A CREATE OR AN UPDATE BASED ON RECURSIVE TO-STREAM METHOD
        final byte[] stream = txEntry.getRecord().toStream();

        if (rid.isNew()) {
          createRecord(rid, stream, txEntry.getRecord().getRecordType());
        } else {
          txEntry.getRecord().setVersion(
              updateRecord(rid, stream, txEntry.getRecord().getVersion(), txEntry.getRecord().getRecordType()));
        }
View Full Code Here

        result = new Object[] { l, getDate(iRecord, r) };
      }

      // RIDS
      else if (r instanceof ORID && l instanceof String && !l.equals(OSQLHelper.NOT_NULL)) {
        result = new Object[] { new ORecordId((String) l), r };
      } else if (l instanceof ORID && r instanceof String && !r.equals(OSQLHelper.NOT_NULL)) {
        result = new Object[] { l, new ORecordId((String) r) };
      }

    return result;
  }
View Full Code Here

          fieldValue = fieldValue.substring(0, fieldValue.length() - 1);
        } else
          pos = newPos;

        if (fieldValue.length() > 2 && Character.isDigit(fieldValue.charAt(0)) && fieldValue.contains(":"))
          value = new ORecordId(fieldValue);
        else
          value = fieldValue;

      } else
        value = EMPTY_VALUE;
View Full Code Here

      db = getProfiledDatabaseInstance(iRequest);

      // PARSE PARAMETERS
      final int parametersPos = urlParts[2].indexOf('?');
      final String rid = parametersPos > -1 ? urlParts[2].substring(0, parametersPos) : urlParts[2];
      final ORecordId recorId = new ORecordId(rid);

      if (!recorId.isValid())
        throw new IllegalArgumentException("Invalid Record ID in request: " + urlParts[2]);

      final ODocument doc = new ODocument(db, recorId);
      doc.delete();
View Full Code Here

    if (iPojo == null)
      return this;

    ODocument record = getRecordByUserObject(iPojo, false);
    if (record == null) {
      final ORecordId rid = OObjectSerializerHelper.getObjectID(this, iPojo);
      if (rid == null)
        throw new OObjectNotDetachedException("Can't retrieve the object's ID for '" + iPojo + "' because hasn't been detached");

      record = (ODocument) underlying.load(rid);
    }
View Full Code Here

    final String[] urlParts = checkSyntax(iRequest.url, 2, "Syntax error: document/<database>[/<record-id>]");

    iRequest.data.commandInfo = "Edit Document";

    ODatabaseDocumentTx db = null;
    ORecordId recordId = null;
    final ODocument doc;

    try {
      db = getProfiledDatabaseInstance(iRequest);

      if (urlParts.length > 2) {
        // EXTRACT RID
        final int parametersPos = urlParts[2].indexOf('?');
        final String rid = parametersPos > -1 ? urlParts[2].substring(0, parametersPos) : urlParts[2];
        recordId = new ORecordId(rid);

        if (!recordId.isValid())
          throw new IllegalArgumentException("Invalid Record ID in request: " + recordId);
      } else
        recordId = new ORecordId();

      // UNMARSHALL DOCUMENT WITH REQUEST CONTENT
      doc = new ODocument(db);
      doc.fromJSON(iRequest.content);

      if (!recordId.isValid())
        recordId = (ORecordId) doc.getIdentity();
      else
        doc.setIdentity(recordId);

      if (!recordId.isValid())
        throw new IllegalArgumentException("Invalid Record ID in request: " + recordId);

      doc.save();

    } finally {
View Full Code Here

          // TREATS AS CLUSTER POSITION
          final OClass cls = iDb.getMetadata().getSchema().getClass(iPojo.getClass());
          if (cls == null)
            throw new OConfigurationException("Class " + iPojo.getClass() + " is not managed by current database");

          return new ORecordId(cls.getDefaultClusterId(), ((Number) id).longValue());
        } else if (id instanceof String)
          return new ORecordId((String) id);
      }
    }
    return null;
  }
View Full Code Here

   *
   * @param iFields
   *          Array of field pairs
   */
  public ODocument(final Object[] iFields) {
    _recordId = new ORecordId();
    if (iFields != null && iFields.length > 0)
      for (int i = 0; i < iFields.length; i += 2) {
        field(iFields[i].toString(), iFields[i + 1]);
      }
  }
View Full Code Here

    if (oldValue != null && iType != null) {
      // DETERMINE THE TYPE FROM THE PREVIOUS CONTENT
      if (oldValue instanceof ORecord<?> && iPropertyValue instanceof String)
        // CONVERT TO RECORD-ID
        iPropertyValue = new ORecordId((String) iPropertyValue);
      else if (oldValue instanceof Collection<?> && iPropertyValue instanceof String) {
        // CONVERT TO COLLECTION
        final List<ODocument> newValue = new ArrayList<ODocument>();
        iPropertyValue = newValue;

        final String stringValue = (String) iPropertyValue;

        if (stringValue != null && stringValue.length() > 0) {
          final String[] items = stringValue.split(",");
          for (String s : items) {
            newValue.add(new ODocument(_database, new ORecordId(s)));
          }
        }
      } else if (iPropertyValue instanceof Enum) {
        // ENUM
        if (oldValue instanceof Number)
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.id.ORecordId

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.