Package com.orientechnologies.orient.core.metadata.schema

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


        indexName = value;
      else if (attrib.equals("\"index-type\""))
        indexType = value;
    }

    OPropertyImpl prop = (OPropertyImpl) iClass.getProperty(propName);
    if (prop == null)
      // CREATE IT
      prop = (OPropertyImpl) iClass.createProperty(propName, type);

    prop.setMandatory(mandatory);
    prop.setNotNull(notNull);

    if (min != null)
      prop.setMin(min);
    if (max != null)
      prop.setMax(max);
    if (linkedClass != null)
      linkedClasses.put(prop, linkedClass);
    if (linkedType != null)
      prop.setLinkedType(linkedType);
    if (indexName != null)
      // PUSH INDEX TO CREATE AFTER ALL
      propertyIndexes.put(prop, indexName);
  }
View Full Code Here


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

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

    // CREATE THE PROPERTY
View Full Code Here

      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 {
      idx = database.getMetadata().getIndexManager().createIndex(name, indexType.toUpperCase(), keyType, null, null, null, false);
    }

    if (idx != null)
View Full Code Here

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

    final OPropertyImpl prop = (OPropertyImpl) sourceClass.getProperty(fieldName);
    if (prop == null)
      throw new OCommandExecutionException("Property '" + className + "." + fieldName + "' not exists");

    prop.setInternalAndSave(attribute, value);
    return null;
  }
View Full Code Here

      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) {
View Full Code Here

      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 {
      idx = database.getMetadata().getIndexManager().createIndex(name, indexType.toUpperCase(), null, null, null, false);
    }

//    if (idx != null)
View Full Code Here

      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 + "'");

      prop.dropIndexInternal();
    } else {
      database.getMetadata().getIndexManager().dropIndex(name);
    }

    return null;
View Full Code Here

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

    final OPropertyImpl prop = (OPropertyImpl) sourceClass.getProperty(fieldName);
    if (prop == null)
      throw new OCommandExecutionException("Property '" + className + "." + fieldName + "' not exists");

    prop.setInternal(attribute, value);
    return null;
  }
View Full Code Here

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

    OPropertyImpl prop = (OPropertyImpl) sourceClass.getProperty(fieldName);
    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);

      if (linkedClass == null)
        // NOT FOUND: SEARCH BETWEEN TYPES
        linkedType = OType.valueOf(linked.toUpperCase());
    }

    // CREATE IT LOCALLY
    prop = sourceClass.addPropertyInternal(fieldName, type, linkedType, linkedClass);

    return prop.getId();
  }
View Full Code Here

        indexName = value;
      else if (attrib.equals("\"index-type\""))
        indexType = value;
    }

    OPropertyImpl prop = (OPropertyImpl) iClass.getProperty(propName);
    if (prop == null) {
      // CREATE IT
      prop = (OPropertyImpl) iClass.createProperty(propName, type);
    } else {
      if (prop.getId() != id)
        throw new OSchemaException("Imported property '" + iClass.getName() + "." + propName
            + "' has an id different from the original: " + id);
    }

    prop.setMandatory(mandatory);
    prop.setNotNull(notNull);

    if (min != null)
      prop.setMin(min);
    if (max != null)
      prop.setMax(max);
    if (linkedClass != null)
      linkedClasses.put(prop, linkedClass);
    if (linkedType != null)
      prop.setLinkedType(linkedType);
    if (indexName != null)
      // PUSH INDEX TO CREATE AFTER ALL
      propertyIndexes.put(prop, indexName);
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.metadata.schema.OPropertyImpl

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.