Package com.orientechnologies.orient.core.db.record

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


  public void load() {
    functions.clear();

    // LOAD ALL THE FUNCTIONS IN MEMORY
    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
    if (db.getMetadata().getSchema().existsClass("OFunction")) {
      List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from OFunction order by name"));
      for (ODocument d : result) {
        d.reload();
        functions.put(d.field("name").toString().toUpperCase(), new OFunction(d));
      }
    }
View Full Code Here


  public void close() {
    functions.clear();
  }

  protected void init() {
    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
    if (db.getMetadata().getSchema().existsClass("OFunction"))
      return;

    final OClass f = db.getMetadata().getSchema().createClass("OFunction");
    f.createProperty("name", OType.STRING);
    f.createProperty("code", OType.STRING);
    f.createProperty("language", OType.STRING);
    f.createProperty("idempotent", OType.BOOLEAN);
    f.createProperty("parameters", OType.EMBEDDEDLIST, OType.STRING);
View Full Code Here

  protected int              clusterId       = -1;
  protected ATTRIBUTES       attribute;
  protected String           value;

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

    init((OCommandRequestText) iRequest);

    StringBuilder word = new StringBuilder();
View Full Code Here

   */
  public Object execute(final Map<Object, Object> iArgs) {
    if (clusterName == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final ODatabaseRecord database = getDatabase();

    if (requestedId == -1) {
      return database.addCluster(clusterName);
    } else {
      return database.addCluster(clusterName, requestedId, null);
    }
  }
View Full Code Here

    return Math.min(sqlLimit, requestLimit);
  }

  @SuppressWarnings("rawtypes")
  private boolean searchForIndexes(final OClass iSchemaClass) {
    final ODatabaseRecord database = getDatabase();
    database.checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_READ, iSchemaClass.getName().toLowerCase());

    // fetch all possible variants of subqueries that can be used in indexes.
    if (compiledFilter == null)
      if (orderedFields.size() == 0)
        return false;
View Full Code Here

  private String                        clusterName;
  private LinkedHashMap<String, Object> fields;

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

    init((OCommandRequestText) iRequest);

    String className = null;

    parserRequiredKeyword("CREATE");
    parserRequiredKeyword("VERTEX");

    String temp = parseOptionalWord(true);

    while (temp != null) {
      if (temp.equals("CLUSTER")) {
        clusterName = parserRequiredWord(false);

      } else if (temp.equals(KEYWORD_SET)) {
        fields = new LinkedHashMap<String, Object>();
        parseSetFields(fields);

      } else if (temp.equals(KEYWORD_CONTENT)) {
        parseContent();

      } else if (className == null && temp.length() > 0)
        className = temp;

      temp = parserOptionalWord(true);
      if (parserIsEnded())
        break;
    }

    if (className == null)
      // ASSIGN DEFAULT CLASS
      className = "V";

    // GET/CHECK CLASS NAME
    clazz = database.getMetadata().getSchema().getClass(className);
    if (clazz == null)
      throw new OCommandSQLParsingException("Class " + className + " was not found");

    return this;
  }
View Full Code Here

    final int[] clusters = iClass.getClusterIds();
    if (clusters.length == 1)
      // ONLY ONE: RETURN THE FIRST ONE
      return clusters[0];

    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
    if (db == null)
      return clusters[0];

    if (lastCount < 0 || System.currentTimeMillis() - lastCount > REFRESH_TIMEOUT) {
      // REFRESH COUNTERS
      long min = Long.MAX_VALUE;

      for (int cluster : clusters) {
        final long count = db.countClusterElements(cluster);
        if (count < min) {
          min = count;
          smallerClusterId = cluster;
        }
      }
View Full Code Here

  private LinkedHashMap<String, Object> fields;
  private ODocument                     merge;

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

    init((OCommandRequestText) iRequest);

    parserRequiredKeyword("MOVE");
    parserRequiredKeyword("VERTEX");

    source = parserRequiredWord(false, "Syntax error", " =><,\r\n");
    if (source == null)
      throw new OCommandSQLParsingException("Cannot find source");

    parserRequiredKeyword("TO");

    String temp = parseOptionalWord(true);

    while (temp != null) {
      if (temp.startsWith("CLUSTER:")) {
        if (className != null)
          throw new OCommandSQLParsingException("Cannot define multiple sources. Found both cluster and class.");

        clusterName = temp.substring("CLUSTER:".length());
        if (database.getClusterIdByName(clusterName) == -1)
          throw new OCommandSQLParsingException("Cluster '" + clusterName + "' was not found");

      } else if (temp.startsWith("CLASS:")) {
        if (clusterName != null)
          throw new OCommandSQLParsingException("Cannot define multiple sources. Found both cluster and class.");

        className = temp.substring("CLASS:".length());

        if (!database.getMetadata().getSchema().existsClass(className))
          throw new OCommandSQLParsingException("Class " + className + " was not found");

      } else if (temp.equals(KEYWORD_SET)) {
        fields = new LinkedHashMap<String, Object>();
        parseSetFields(fields);
View Full Code Here

  }

  @BeforeClass
  public void init() {
    try {
      ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
      db.close();
      ODatabaseRecordThreadLocal.INSTANCE.set(null);
    } catch (ODatabaseException ode) {
    }
  }
View Full Code Here

      @Override
      public ODatabaseRecordInternal getThreadDatabase() {
        return ODatabaseDocumentPool.global().acquire(url, "admin", "admin");
      }
    });
    ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
    Assert.assertNotNull(db);
    db.close();
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.record.ODatabaseRecord

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.