Examples of ODatabaseRecordInternal


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

  public static ODatabaseRecordThreadLocal INSTANCE = new ODatabaseRecordThreadLocal();

  @Override
  public ODatabaseRecordInternal get() {
    ODatabaseRecordInternal db = super.get();
    if (db == null) {
      if (Orient.instance().getDatabaseThreadFactory() == null) {
        throw new ODatabaseException(
            "Database instance is not set in current thread. Assure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db);");
      } else {
View Full Code Here

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

  public int getSchemaClusterId() {
    return schemaClusterId;
  }

  private void init(final boolean iLoad) {
    final ODatabaseRecordInternal database = getDatabase();
    schemaClusterId = database.getClusterIdByName(CLUSTER_INTERNAL_NAME);

    schema = new OSchemaProxy(database.getStorage().getResource(OSchema.class.getSimpleName(), new Callable<OSchemaShared>() {
      public OSchemaShared call() {
        ODatabaseRecordInternal database = getDatabase();
        final OSchemaShared instance = new OSchemaShared(database.getStorageVersions().classesAreDetectedByClusterId());
        if (iLoad)
          instance.load();
        return instance;
      }
    }), database);

    indexManager = new OIndexManagerProxy(database.getStorage().getResource(OIndexManager.class.getSimpleName(),
        new Callable<OIndexManager>() {
          public OIndexManager call() {
            OIndexManager instance;
            if (database.getStorage() instanceof OStorageProxy)
              instance = new OIndexManagerRemote(database);
            else
              instance = new OIndexManagerShared(database);

            if (iLoad)
              try {
                instance.load();
              } catch (Exception e) {
                OLogManager.instance().error(this, "[OMetadata] Error on loading index manager, reset index configuration", e);
                instance.create();
              }

            return instance;
          }
        }), database);

    final Boolean enableSecurity = (Boolean) database.getProperty(ODatabase.OPTIONS.SECURITY.toString());
    if (enableSecurity != null && !enableSecurity)
      // INSTALL NO SECURITY IMPL
      security = new OSecurityNull();
    else
      security = new OSecurityProxy(database.getStorage().getResource(OSecurity.class.getSimpleName(),
          new Callable<OSecurityShared>() {
            public OSecurityShared call() {
              final OSecurityShared instance = new OSecurityShared();
              if (iLoad) {
                security = instance;
                instance.load();
              }
              return instance;
            }
          }), database);

    functionLibrary = new OFunctionLibraryProxy(database.getStorage().getResource(OFunctionLibrary.class.getSimpleName(),
        new Callable<OFunctionLibrary>() {
          public OFunctionLibrary call() {
            final OFunctionLibraryImpl instance = new OFunctionLibraryImpl();
            if (iLoad)
              instance.load();
            return instance;
          }
        }), database);
    scheduler = new OSchedulerListenerProxy(database.getStorage().getResource(OSchedulerListener.class.getSimpleName(),
        new Callable<OSchedulerListener>() {
          public OSchedulerListener call() {
            final OSchedulerListenerImpl instance = new OSchedulerListenerImpl();
            if (iLoad)
              instance.load();
View Full Code Here

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

      cache.clear();

      recordsToCommit.clear();
      root = null;

      final ODatabaseRecordInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
      if (db != null && !db.isClosed() && db.getStorage().getUnderlying() instanceof OStorageEmbedded) {
        // RELOAD IT
        try {
          load();
        } catch (Exception e) {
          // IGNORE IT
View Full Code Here

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

  private String             clusterName;
  private int                requestedId         = -1;

  public OCommandExecutorSQLCreateCluster parse(final OCommandRequest iRequest) {
    final ODatabaseRecordInternal database = getDatabase();

    init((OCommandRequestText) iRequest);

    parserRequiredKeyword(KEYWORD_CREATE);
    parserRequiredKeyword(KEYWORD_CLUSTER);

    clusterName = parserRequiredWord(false);
    if (!clusterName.isEmpty() && Character.isDigit(clusterName.charAt(0)))
      throw new IllegalArgumentException("Cluster name cannot begin with a digit");

    String temp = parseOptionalWord(true);

    while (temp != null) {
      if (temp.equals(KEYWORD_ID)) {
        requestedId = Integer.parseInt(parserRequiredWord(false));
      }

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

    final int clusterId = database.getStorage().getClusterIdByName(clusterName);
    if (clusterId > -1)
      throw new OCommandSQLParsingException("Cluster '" + clusterName + "' already exists");

    return this;
  }
View Full Code Here

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

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

    final ODatabaseRecordInternal database = getDatabase();
    for (String rec : records) {
      try {
        final ORecordId rid = new ORecordId(rec);
        database.getStorage().deleteRecord(rid, OVersionFactory.instance().createUntrackedVersion(), 0, null);
        database.getLocalCache().deleteRecord(rid);
      } catch (Throwable e) {
        throw new OCommandExecutionException("Error on executing command", e);
      }
    }

View Full Code Here

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

  private String             className;
  private OClass             superClass;
  private int[]              clusterIds;

  public OCommandExecutorSQLCreateClass parse(final OCommandRequest iRequest) {
    final ODatabaseRecordInternal database = getDatabase();
    init((OCommandRequestText) iRequest);

    StringBuilder word = new StringBuilder();

    int oldPos = 0;
    int pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
    if (pos == -1 || !word.toString().equals(KEYWORD_CREATE))
      throw new OCommandSQLParsingException("Keyword " + KEYWORD_CREATE + " not found. Use " + getSyntax(), parserText, oldPos);

    oldPos = pos;
    pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true);
    if (pos == -1 || !word.toString().equals(KEYWORD_CLASS))
      throw new OCommandSQLParsingException("Keyword " + KEYWORD_CLASS + " not found. Use " + getSyntax(), parserText, oldPos);

    oldPos = pos;
    pos = nextWord(parserText, parserTextUpperCase, oldPos, word, false);
    if (pos == -1)
      throw new OCommandSQLParsingException("Expected <class>", parserText, oldPos);

    className = word.toString();
    if (className == null)
      throw new OCommandSQLParsingException("Expected <class>", parserText, oldPos);

    oldPos = pos;

    while ((pos = nextWord(parserText, parserTextUpperCase, oldPos, word, true)) > -1) {
      final String k = word.toString();
      if (k.equals(KEYWORD_EXTENDS)) {
        oldPos = pos;
        pos = nextWord(parserText, parserTextUpperCase, oldPos, word, false);
        if (pos == -1)
          throw new OCommandSQLParsingException("Syntax error after EXTENDS for class " + className
              + ". Expected the super-class name. Use " + getSyntax(), parserText, oldPos);

        if (!database.getMetadata().getSchema().existsClass(word.toString()))
          throw new OCommandSQLParsingException("Super-class " + word + " not exists", parserText, oldPos);

        superClass = database.getMetadata().getSchema().getClass(word.toString());
      } else if (k.equals(KEYWORD_CLUSTER)) {
        oldPos = pos;
        pos = nextWord(parserText, parserTextUpperCase, oldPos, word, false, " =><()");
        if (pos == -1)
          throw new OCommandSQLParsingException("Syntax error after CLUSTER for class " + className
              + ". Expected the cluster id or name. Use " + getSyntax(), parserText, oldPos);

        final String[] clusterIdsAsStrings = word.toString().split(",");
        if (clusterIdsAsStrings.length > 0) {
          clusterIds = new int[clusterIdsAsStrings.length];
          for (int i = 0; i < clusterIdsAsStrings.length; ++i) {
            if (Character.isDigit(clusterIdsAsStrings[i].charAt(0)))
              // GET CLUSTER ID FROM NAME
              clusterIds[i] = Integer.parseInt(clusterIdsAsStrings[i]);
            else
              // GET CLUSTER ID
              clusterIds[i] = database.getStorage().getClusterIdByName(clusterIdsAsStrings[i]);

            if (clusterIds[i] == -1)
              throw new OCommandSQLParsingException("Cluster with id " + clusterIds[i] + " does not exists", parserText, oldPos);

            try {
              database.getStorage().getClusterById(clusterIds[i]);
            } catch (Exception e) {
              throw new OCommandSQLParsingException("Cluster with id " + clusterIds[i] + " does not exists", parserText, oldPos);
            }
          }
        }
      } else if (k.equals(KEYWORD_ABSTRACT))
        clusterIds = new int[] { -1 };
      else
        throw new OCommandSQLParsingException("Invalid keyword: " + k);

      oldPos = pos;
    }

    if (clusterIds == null) {
      final int clusterId = database.getStorage().getClusterIdByName(className);
      if (clusterId > -1) {
        clusterIds = new int[] { clusterId };
      }
    }
View Full Code Here

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

       if (index != null)
         return;

       final OServerUserConfiguration replicatorUser = serverInstance.getUser(ODistributedAbstractPlugin.REPLICATOR_USER);

       final ODatabaseRecordInternal threadDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
       if (threadDb != null && !threadDb.isClosed() && threadDb.getStorage().getName().equals(iDatabaseName))
         database = threadDb;
       else
         database = serverInstance.openDatabase("document", iDatabaseName, replicatorUser.name, replicatorUser.password);

       if (database.getMetadata() != null) {
View Full Code Here

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

    return lockStrategy;
  }

  protected Set<String> getInvolvedClustersOfClasses(final Collection<String> iClassNames) {
    final ODatabaseRecordInternal db = getDatabase();

    final Set<String> clusters = new HashSet<String>();

    for (String clazz : iClassNames) {
      final OClass cls = db.getMetadata().getSchema().getClass(clazz);
      if (cls != null)
        for (int clId : cls.getClusterIds()) {
          // FILTER THE CLUSTER WHERE THE USER HAS THE RIGHT ACCESS
          if (clId > -1 && checkClusterAccess(db, db.getClusterNameById(clId)))
            clusters.add(db.getClusterNameById(clId).toLowerCase());
        }
    }

    return clusters;
  }
View Full Code Here

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

    return clusters;
  }

  protected Set<String> getInvolvedClustersOfClusters(final Collection<String> iClusterNames) {
    final ODatabaseRecordInternal db = getDatabase();

    final Set<String> clusters = new HashSet<String>();

    for (String cluster : iClusterNames) {
      final String c = cluster.toLowerCase();
View Full Code Here

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

    return clusters;
  }

  protected Set<String> getInvolvedClustersOfIndex(final String iIndexName) {
    final ODatabaseRecordInternal db = getDatabase();

    final Set<String> clusters = new HashSet<String>();

    final OIndex<?> idx = db.getMetadata().getIndexManager().getIndex(iIndexName);
    if (idx != null) {
      final String clazz = idx.getDefinition().getClassName();

      if (clazz != null) {
        final OClass cls = db.getMetadata().getSchema().getClass(clazz);
        if (cls != null)
          for (int clId : cls.getClusterIds()) {
            clusters.add(db.getClusterNameById(clId).toLowerCase());
          }
      }
    }

    return clusters;
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.