Examples of ODatabaseRecord


Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

      final String iName, final String iValue) {

    if (iValue == null)
      return null;

    final ODatabaseRecord database = iSourceRecord.getDatabase();

    switch (iType) {
    case EMBEDDEDLIST:
    case EMBEDDEDSET:
      return embeddedCollectionFromStream(database, (ODocument) iSourceRecord, iType, iLinkedClass, iLinkedType, iValue);

    case LINKLIST:
    case LINKSET: {
      if (iValue.length() == 0)
        return null;

      // REMOVE BEGIN & END COLLECTIONS CHARACTERS IF IT'S A COLLECTION
      final String value = iValue.startsWith("[") ? iValue.substring(1, iValue.length() - 1) : iValue;

      return iType == OType.LINKLIST ? new ORecordLazyList(iSourceRecord).setStreamedContent(new StringBuilder(value))
          : new ORecordLazySet(iSourceRecord).setStreamedContent(new StringBuilder(value));
    }

    case LINKMAP: {
      if (iValue.length() == 0)
        return null;

      // REMOVE BEGIN & END MAP CHARACTERS
      String value = iValue.substring(1, iValue.length() - 1);

      @SuppressWarnings("rawtypes")
      final Map map = new ORecordLazyMap(iSourceRecord, ODocument.RECORD_TYPE);

      if (value.length() == 0)
        return map;

      final List<String> items = OStringSerializerHelper.smartSplit(value, OStringSerializerHelper.RECORD_SEPARATOR);

      // EMBEDDED LITERALS
      for (String item : items) {
        if (item != null && item.length() > 0) {
          final List<String> entry = OStringSerializerHelper.smartSplit(item, OStringSerializerHelper.ENTRY_SEPARATOR);
          if (entry.size() > 0) {
            String mapValue = entry.get(1);
            if (mapValue != null && mapValue.length() > 0)
              mapValue = mapValue.substring(1);
            map.put(fieldTypeFromStream((ODocument) iSourceRecord, OType.STRING, entry.get(0)), new ORecordId(mapValue));
          }

        }
      }
      return map;
    }

    case EMBEDDEDMAP:
      return embeddedMapFromStream((ODocument) iSourceRecord, iLinkedType, iValue);

    case LINK:
      if (iValue.length() > 1) {
        int pos = iValue.indexOf(OStringSerializerHelper.CLASS_SEPARATOR);
        if (pos > -1)
          iLinkedClass = database.getMetadata().getSchema().getClass(iValue.substring(1, pos));
        else
          pos = 0;

        return new ORecordId(iValue.substring(pos + 1));
      } else
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

        resultRid = iLinkedRecord;
      }

      if (iParentRecord != null && iParentRecord.getDatabase() instanceof ODatabaseRecord) {
        final ODatabaseRecord db = iParentRecord.getDatabase();
        if (!db.isRetainRecords())
          // REPLACE CURRENT RECORD WITH ITS ID: THIS SAVES A LOT OF MEMORY
          resultRid = iLinkedRecord.getIdentity();
      }
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

    // WRITE ENTITY SCHEMA IF ANY
    if (iRecords != null && iRecords.size() > 0) {
      ORecord<?> first = iRecords.get(0);
      if (first != null && first instanceof ODocument) {
        ODatabaseRecord db = ((ODocument) first).getDatabase();

        final String className = ((ODocument) first).getClassName();
        exportClassSchema(db, json, db.getMetadata().getSchema().getClass(className));
      }
    }

    final String format = iFetchPlan != null ? JSON_FORMAT + ",fetchPlan:" + iFetchPlan : JSON_FORMAT;
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

      lock.releaseExclusiveLock();
    }
  }

  public void create() {
    final ODatabaseRecord db = getDatabase();
    super.save(OStorage.CLUSTER_INTERNAL_NAME);
    db.getStorage().getConfiguration().schemaRecordId = document.getIdentity().toString();
    db.getStorage().getConfiguration().update();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

  protected void readConfiguration() {
    if (cls.isAbstract())
      throw new IllegalArgumentException("Cannot create a new instance of abstract class");

    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();

    final int[] clusterIds = cls.getClusterIds();
    final List<String> clusterNames = new ArrayList<String>(clusterIds.length);
    for (int c : clusterIds)
      clusterNames.add(db.getClusterNameById(c));

    ODistributedConfiguration cfg = manager.getDatabaseConfiguration(databaseName);

    final String bestCluster = cfg.getLocalCluster(clusterNames, nodeName);
    if (bestCluster == null)
      throw new OException("Cannot find best cluster for class '" + cls.getName() + "'. ClusterStrategy=" + getName());

    bestClusterId = db.getClusterIdByName(bestCluster);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

  @SuppressWarnings("unchecked")
  public <T extends ORecord> T getRecord() {
    if (!isValid())
      return null;

    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
    if (db == null)
      throw new ODatabaseException(
          "No database found in current thread local space. If you manually control databases over threads assure to set the current database before to use it by calling: ODatabaseRecordThreadLocal.INSTANCE.set(db);");

    return (T) db.load(this);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

  private Object                         returnExpression = null;
  private List<ODocument>                queryResult      = null;

  @SuppressWarnings("unchecked")
  public OCommandExecutorSQLInsert parse(final OCommandRequest iRequest) {
    final ODatabaseRecord database = getDatabase();

    init((OCommandRequestText) iRequest);

    className = null;
    newRecords = null;
    content = null;

    parserRequiredKeyword("INSERT");
    parserRequiredKeyword("INTO");

    String subjectName = parserRequiredWord(true, "Invalid subject name. Expected cluster, class or index");
    if (subjectName.startsWith(OCommandExecutorSQLAbstract.CLUSTER_PREFIX))
      // CLUSTER
      clusterName = subjectName.substring(OCommandExecutorSQLAbstract.CLUSTER_PREFIX.length());

    else if (subjectName.startsWith(OCommandExecutorSQLAbstract.INDEX_PREFIX))
      // INDEX
      indexName = subjectName.substring(OCommandExecutorSQLAbstract.INDEX_PREFIX.length());

    else {
      // CLASS
      if (subjectName.startsWith(OCommandExecutorSQLAbstract.CLASS_PREFIX))
        subjectName = subjectName.substring(OCommandExecutorSQLAbstract.CLASS_PREFIX.length());

      final OClass cls = database.getMetadata().getSchema().getClass(subjectName);
      if (cls == null)
        throwParsingException("Class " + subjectName + " not found in database");

      className = cls.getName();
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

    if (name.isEmpty())
      throw new OCommandExecutionException("Syntax Error. You must specify a function name: " + getSyntax());
    if (code == null || code.isEmpty())
      throw new OCommandExecutionException("Syntax Error. You must specify the function code: " + getSyntax());

    ODatabaseRecord database = getDatabase();
    final OFunction f = database.getMetadata().getFunctionLibrary().createFunction(name);
    f.setCode(code);
    f.setIdempotent(idempotent);
    if (parameters != null)
      f.setParameters(parameters);
    if (language != null)
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

    if (pos == -1)
      throw new OCommandSQLParsingException("Expected cluster name. Use " + getSyntax(), parserText, oldPos);

    clusterName = word.toString();

    final ODatabaseRecord database = getDatabase();
    if (database.getClusterIdByName(clusterName) == -1)
      throw new OCommandSQLParsingException("Cluster '" + clusterName + "' not found", parserText, oldPos);
    return this;
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.db.record.ODatabaseRecord

  private String             className;
  private ATTRIBUTES         attribute;
  private String             value;

  public OCommandExecutorSQLAlterClass parse(final OCommandRequest iRequest) {
    final ODatabaseRecord database = getDatabase();

    init((OCommandRequestText) iRequest);

    StringBuilder word = new StringBuilder();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.