Examples of ODatabaseRecord


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

  /**
   * Execute the ALTER CLASS.
   */
  public Object execute(final Map<Object, Object> iArgs) {
    final ODatabaseRecord database = getDatabase();

    if (attribute == null)
      throw new OCommandExecutionException("Cannot execute the command because it has not been parsed yet");

    final OClassImpl cls = (OClassImpl) database.getMetadata().getSchema().getClass(className);
    if (cls == null)
      throw new OCommandExecutionException("Source class '" + className + "' not found");

    cls.set(attribute, value);

View Full Code Here

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

  }
 
  //loaded when open database
  public void load() {
    schedulers.clear();
    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
    if (db.getMetadata().getSchema().existsClass(OScheduler.CLASSNAME)) {
      List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from " + OScheduler.CLASSNAME + " order by name"));
      for (ODocument d : result) {
        d.reload();
          this.addScheduler(new OScheduler(d));
      }
    }
View Full Code Here

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

  public void close() {
    schedulers.clear();
  }
 
  public void create(){
    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();
      if (db.getMetadata().getSchema().existsClass(OScheduler.CLASSNAME))
          return;
    final OClass f = db.getMetadata().getSchema().createClass(OScheduler.CLASSNAME);
    f.createProperty(OScheduler.PROP_NAME, OType.STRING).setMandatory(true).setNotNull(true);
    f.createProperty(OScheduler.PROP_RULE, OType.STRING).setMandatory(true).setNotNull(true);
    f.createProperty(OScheduler.PROP_ARGUMENTS, OType.EMBEDDEDMAP);
    f.createProperty(OScheduler.PROP_STATUS, OType.STRING);
    f.createProperty(OScheduler.PROP_FUNC, OType.LINK, db.getMetadata().getSchema().getClass(OFunction.CLASS_NAME)).setMandatory(true).setNotNull(true);
    f.createProperty(OScheduler.PROP_STARTTIME, OType.DATETIME);
    f.createProperty(OScheduler.PROP_STARTED, OType.BOOLEAN);
  }
View Full Code Here

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

  public static Calendar getDatabaseCalendar() {
    return Calendar.getInstance(getDatabaseTimeZone());
  }

  public static TimeZone getDatabaseTimeZone() {
    final ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
    if (db != null && !db.isClosed())
      return ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration().getTimeZone();
    return TimeZone.getDefault();
  }
View Full Code Here

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

      throw new IllegalArgumentException("Unsupported record type: " + iRecordType);
    return cls;
  }

  public ORecord newInstance() {
    final ODatabaseRecord database = ODatabaseRecordThreadLocal.INSTANCE.get();
    try {
      return (ORecord) getFactory(database.getRecordType()).newRecord();
    } catch (Exception e) {
      throw new IllegalArgumentException("Unsupported record type: " + database.getRecordType(), e);
    }
  }
View Full Code Here

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

    super(cacheLocator.threadLocalCache());
  }

  @Override
  public void startup() {
    ODatabaseRecord db = ODatabaseRecordThreadLocal.INSTANCE.get();

    profilerPrefix = "db." + db.getName() + ".cache.level1.";
    profilerMetadataPrefix = "db.*.cache.level1.";

    CACHE_HIT = profilerPrefix + "cache.found";
    CACHE_MISS = profilerPrefix + "cache.notFound";

    excludedCluster = db.getClusterIdByName(CLUSTER_INDEX_NAME);

    super.startup();
    setEnable(OGlobalConfiguration.CACHE_LOCAL_ENABLED.getValueAsBoolean());
  }
View Full Code Here

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

    checkForClusterRebalance(iDatabaseName);

    final OHazelcastDistributedRequest req = new OHazelcastDistributedRequest(getLocalNodeName(), iDatabaseName, iTask,
        iExecutionMode);

    final ODatabaseRecord currentDatabase = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
    if (currentDatabase != null && currentDatabase.getUser() != null)
      // SET CURRENT DATABASE NAME
      req.setUserName(currentDatabase.getUser().getName());

    final OHazelcastDistributedDatabase db = messageService.getDatabase(iDatabaseName);

    if (iTargetNodes == null || iTargetNodes.isEmpty()) {
      ODistributedServerLog.error(this, getLocalNodeName(), null, DIRECTION.OUT,
View Full Code Here

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

      final String[] fields = fieldNames.split(",");
      String identityType = ((OClassImpl) cls).getCustom(OSecurityShared.ONCREATE_IDENTITY_TYPE);
      if (identityType == null)
        identityType = "user";

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

      ODocument identity = null;
      if (identityType.equals("user")) {
        final OUser user = db.getUser();
        if (user != null)
          identity = user.getDocument();
      } else if (identityType.equals("role")) {
        final Set<ORole> roles = db.getUser().getRoles();
        if (!roles.isEmpty())
          identity = roles.iterator().next().getDocument();
      } else
        throw new OConfigurationException("Wrong custom field '" + OSecurityShared.ONCREATE_IDENTITY_TYPE + "' in class '"
            + cls.getName() + "' with value '" + identityType + "'. Supported ones are: 'user', 'role'");

      if (identity != null) {
        for (String f : fields)
          db.getMetadata().getSecurity().allowIdentity(iDocument, f, identity);
        return RESULT.RECORD_CHANGED;
      }
    }
    return RESULT.RECORD_NOT_CHANGED;
  }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  protected boolean isAllowed(final ODocument iDocument, final String iAllowOperation, final boolean iReadOriginal) {
    final OClass cls = iDocument.getSchemaClass();
    if (cls != null && cls.isSubClassOf(OSecurityShared.RESTRICTED_CLASSNAME)) {

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

      if (db.getUser() == null)
        return true;

      if (db.getUser().isRuleDefined(ODatabaseSecurityResources.BYPASS_RESTRICTED))
        if (db.getUser().checkIfAllowed(ODatabaseSecurityResources.BYPASS_RESTRICTED, ORole.PERMISSION_READ) != null)
          // BYPASS RECORD LEVEL SECURITY: ONLY "ADMIN" ROLE CAN BY DEFAULT
          return true;

      final ODocument doc;
      if (iReadOriginal)
        // RELOAD TO AVOID HACKING OF "_ALLOW" FIELDS
        doc = (ODocument) db.load(iDocument.getIdentity());
      else
        doc = iDocument;

      return db
          .getMetadata()
          .getSecurity()
          .isAllowed((Set<OIdentifiable>) doc.field(OSecurityShared.ALLOW_ALL_FIELD),
              (Set<OIdentifiable>) doc.field(iAllowOperation));
    }
View Full Code Here

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

      rwSpinLock.releaseWriteLock();
    }
  }

  private void saveInternal() {
    final ODatabaseRecord db = getDatabase();

    if (db.getTransaction().isActive()) {
      reload(null, true);
      throw new OSchemaException("Cannot change the schema while a transaction is active. Schema changes are not transactional");
    }

    setDirty();
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.