Examples of OClass


Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      throw new IllegalArgumentException("The document received is not an edge. Found class '" + iEdge.getSchemaClass() + "'");
  }

  public void checkEdgeClass(final String iEdgeTypeName) {
    if (iEdgeTypeName != null) {
      final OClass cls = getMetadata().getSchema().getClass(iEdgeTypeName);
      if (cls == null)
        throw new IllegalArgumentException("The class '" + iEdgeTypeName + "' was not found");

      if (!cls.isSubClassOf(edgeBaseClass))
        throw new IllegalArgumentException("The class '" + iEdgeTypeName + "' doesn't extend the edge type");
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    if (prop != null)
      throw new OCommandExecutionException("Property '" + className + "." + fieldName
          + "' already exists. Remove it before to retry.");

    // CREATE THE PROPERTY
    OClass linkedClass = null;
    OType linkedType = null;
    if (linked != null) {
      // FIRST SEARCH BETWEEN CLASSES
      linkedClass = database.getMetadata().getSchema().getClass(linked);
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    }
  }

  public boolean evaluate(final ODatabaseRecord iDatabase, final ORecordSchemaAware<?> iRecord) {
    if (targetClasses != null) {
      final OClass cls = targetClasses.keySet().iterator().next();
      // CHECK IF IT'S PART OF THE REQUESTED CLASS
      if (iRecord.getSchemaClass() == null || !iRecord.getSchemaClass().isSubClassOf(cls))
        // EXCLUDE IT
        return false;
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

          // REGISTER AS CLASS
          if (targetClasses == null)
            targetClasses = new HashMap<OClass, String>();

          OClass cls = database.getMetadata().getSchema().getClass(subjectName);
          if (cls == null)
            throw new OCommandExecutionException("Class '" + subjectName + "' was not found in current database");

          targetClasses.put(cls, alias);
        }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    pos = OSQLHelper.nextWord(text, textUpperCase, oldPos, word, true);
    if (pos == -1 || word.toString().equalsIgnoreCase("NULL")) {
      if (name.indexOf('.') > 0) {
        final String[] parts = name.split("\\.");

        final OClass cls = database.getMetadata().getSchema().getClass(parts[0]);
        final OProperty prop = cls.getProperty(parts[1]);
        keyType = prop.getType();
      }
    } else
      // GET THE LINK TYPE
      keyType = OType.valueOf(word.toString());
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      final String className = parts[0];
      if (className == null)
        throw new OCommandExecutionException("Class " + className + " not found");
      String fieldName = parts[1];

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

      final OPropertyImpl prop = (OPropertyImpl) cls.getProperty(fieldName);
      if (prop == null)
        throw new IllegalArgumentException("Property '" + fieldName + "' was not found in class '" + cls + "'");

      idx = prop.createIndexInternal(indexType.toUpperCase(), progressListener).getUnderlying();
    } else {
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      request.getResultListener().result(iRecord);
  }

  private void searchInClasses() {
    final int[] clusterIds;
    final OClass cls = compiledFilter.getTargetClasses().keySet().iterator().next();

    database.checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_READ, cls.getName());

    clusterIds = cls.getPolymorphicClusterIds();

    // CHECK PERMISSION TO ACCESS TO ALL THE CONFIGURED CLUSTERS
    for (int clusterId : clusterIds)
      database.checkSecurity(ODatabaseSecurityResources.CLUSTER, ORole.PERMISSION_READ, database.getClusterNameById(clusterId));
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

  }

  @Test
  public void saveLotOfMixedData() {
    database.open(DEFAULT_DB_USER, DEFAULT_DB_PASSWORD);
    OClass chunk = database.getMetadata().getSchema().createClass("Chunk");
    index = chunk.createProperty("hash", OType.STRING).createIndex(INDEX_TYPE.UNIQUE);
    chunk.createProperty("binary", OType.LINK);

    try {
      byte[] data = new byte[size];

      for (int i = 0; i < size; i++) {
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

  }

  private void executeClassProperties(final OHttpRequest iRequest, final ODatabaseDocumentTx db, final String operation,
      final String rid, final String className, final Map<String, String> fields) throws IOException {
    // GET THE TARGET CLASS
    final OClass cls = db.getMetadata().getSchema().getClass(rid);
    if (cls == null) {
      sendTextContent(iRequest, OHttpUtils.STATUS_INTERNALERROR, "Error", null, OHttpUtils.CONTENT_TEXT_PLAIN, "Error: Class '"
          + rid + "' not found.");
      return;
    }

    if ("add".equals(operation)) {
      iRequest.data.commandInfo = "Studio add property";

      try {
        OType type = OType.valueOf(fields.get("type"));

        OPropertyImpl prop;
        if (type == OType.LINK || type == OType.LINKLIST || type == OType.LINKSET || type == OType.LINKMAP)
          prop = (OPropertyImpl) cls.createProperty(fields.get("name"), type,
              db.getMetadata().getSchema().getClass(fields.get("linkedClass")));
        else
          prop = (OPropertyImpl) cls.createProperty(fields.get("name"), type);

        if (fields.get("linkedType") != null)
          prop.setLinkedType(OType.valueOf(fields.get("linkedType")));
        if (fields.get("mandatory") != null)
          prop.setMandatory("on".equals(fields.get("mandatory")));
        if (fields.get("notNull") != null)
          prop.setNotNull("on".equals(fields.get("notNull")));
        if (fields.get("min") != null)
          prop.setMin(fields.get("min"));
        if (fields.get("max") != null)
          prop.setMax(fields.get("max"));
        if (fields.get("indexed") != null)
          prop.createIndex(fields.get("indexed").equals("Unique") ? OProperty.INDEX_TYPE.UNIQUE : OProperty.INDEX_TYPE.NOTUNIQUE);

        sendTextContent(iRequest, OHttpUtils.STATUS_OK_CODE, "OK", null, OHttpUtils.CONTENT_TEXT_PLAIN,
            "Property " + fields.get("name") + " created successfully");

      } catch (Exception e) {
        sendTextContent(iRequest, OHttpUtils.STATUS_INTERNALERROR, "Error on creating a new property in class " + rid + ": " + e,
            null, OHttpUtils.CONTENT_TEXT_PLAIN, "Error on creating a new property in class " + rid + ": " + e);
      }
    } else if ("del".equals(operation)) {
      iRequest.data.commandInfo = "Studio delete property";

      cls.dropProperty(className);

      sendTextContent(iRequest, OHttpUtils.STATUS_OK_CODE, "OK", null, OHttpUtils.CONTENT_TEXT_PLAIN,
          "Property " + fields.get("name") + " deleted successfully.");
    }
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      // int defCluster = fields.get("defaultCluster") != null ? Integer.parseInt(fields.get("defaultCluster")) : db
      // .getDefaultClusterId();

      try {
        final String superClassName = fields.get("superClass");
        final OClass superClass;
        if (superClassName != null)
          superClass = db.getMetadata().getSchema().getClass(superClassName);
        else
          superClass = null;

        final OClass cls = db.getMetadata().getSchema().createClass(fields.get("name"), superClass);

        final String alias = fields.get("alias");
        if (alias != null)
          cls.setShortName(alias);

        sendTextContent(iRequest, OHttpUtils.STATUS_OK_CODE, "OK", null, OHttpUtils.CONTENT_TEXT_PLAIN, "Class '" + rid
            + "' created successfully with id=" + db.getMetadata().getSchema().getClasses().size());

      } catch (Exception e) {
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.