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

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


    return buffer.toString();
  }

  protected OCollate getCollateForField(final ODocument doc, final String iFieldName) {
    if (doc.getSchemaClass() != null) {
      final OProperty p = doc.getSchemaClass().getProperty(iFieldName);
      if (p != null)
        return p.getCollate();
    }
    return null;
  }
View Full Code Here


      if (clazz.getSize() != clazz2.getSize()) {
        listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same defined size in DB2.");
        ok = false;
      }
      for (OProperty prop : clazz.declaredProperties()) {
        OProperty prop2 = clazz2.getProperty(prop.getName());
        if (prop2 == null) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as missed property " + prop.getName()
              + "in DB2.");
          ok = false;
        }
        if (prop.getType() != prop2.getType()) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same type for property "
              + prop.getName() + "in DB2. ");
          ok = false;
        }

        if (prop.getLinkedType() != prop2.getLinkedType()) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same linkedtype for property "
              + prop.getName() + "in DB2.");
          ok = false;
        }

        if (prop.getMin() != null) {
          if (!prop.getMin().equals(prop2.getMin())) {
            listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same min for property "
                + prop.getName() + "in DB2.");
            ok = false;
          }
        }
        if (prop.getMax() != null) {
          if (!prop.getMax().equals(prop2.getMax())) {
            listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same max for property "
                + prop.getName() + "in DB2.");
            ok = false;
          }
        }

        if (prop.getMax() != null) {
          if (!prop.getMax().equals(prop2.getMax())) {
            listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same regexp for property "
                + prop.getName() + "in DB2.");
            ok = false;
          }
        }

        if (prop.getLinkedClass() != null) {
          if (!prop.getLinkedClass().equals(prop2.getLinkedClass())) {
            listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same linked class for property "
                + prop.getName() + "in DB2.");
            ok = false;
          }
        }

        if (prop.getLinkedClass() != null) {
          if (!prop.getCustomKeys().equals(prop2.getCustomKeys())) {
            listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same custom keys for property "
                + prop.getName() + "in DB2.");
            ok = false;
          }
        }
        if (prop.isMandatory() != prop2.isMandatory()) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same mandatory flag for property "
              + prop.getName() + "in DB2.");
          ok = false;
        }
        if (prop.isNotNull() != prop2.isNotNull()) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName() + " as not same nut null flag for property "
              + prop.getName() + "in DB2.");
          ok = false;
        }
        if (prop.isReadonly() != prop2.isReadonly()) {
          listener.onMessage("\n- ERR: Class definition for " + clazz.getName()
              + " as not same readonly flag setting for property " + prop.getName() + "in DB2.");
          ok = false;
        }
View Full Code Here

       else
         database = serverInstance.openDatabase("document", iDatabaseName, replicatorUser.name, replicatorUser.password);

       if (database.getMetadata() != null) {
         OClass cls = database.getMetadata().getSchema().getClass(DISTRIBUTED_CONFLICT_CLASS);
         final OProperty p;
         if (cls == null) {
           cls = database.getMetadata().getSchema().createClass(DISTRIBUTED_CONFLICT_CLASS);
           index = cls.createProperty(FIELD_RECORD, OType.LINK).createIndex(INDEX_TYPE.UNIQUE);
         } else {
           p = cls.getProperty(FIELD_RECORD);
           if (p == null)
             index = cls.createProperty(FIELD_RECORD, OType.LINK).createIndex(INDEX_TYPE.UNIQUE);
           else {
             index = p.getIndex();
           }
         }
       }
     }
   }
View Full Code Here

         throw new IllegalArgumentException(
             "linked type declared as "
                 + urlParts[5]
                 + " can be either a Type or a Class, use the JSON document usage instead. See 'http://code.google.com/p/orient/w/edit/OrientDB_REST'");
       } else if (linkType != null) {
         final OProperty prop = cls.createProperty(propertyName, propertyType, linkType);
       } else if (linkClass != null) {
         final OProperty prop = cls.createProperty(propertyName, propertyType, linkClass);
       } else {
         throw new IllegalArgumentException("property named " + propertyName + " is declared as " + propertyType
             + " but linked type is not declared");
       }
     }
       break;
     case LINK: {
       if (urlParts.length < 6) {
         throw new OHttpRequestException("Syntax error: property named " + propertyName + " is declared as " + propertyType
             + " but linked type is not declared: property/<database>/<class-name>/<property-name>/<property-type>/<link-type>");
       }
       final String linkClass = urlParts[5];
       if (linkClass != null) {
         final OProperty prop = cls.createProperty(propertyName, propertyType, db.getMetadata().getSchema().getClass(linkClass));
       } else {
         throw new IllegalArgumentException("property named " + propertyName + " is declared as " + propertyType
             + " but linked Class is not declared");
       }

     }
       break;

     default:
       final OProperty prop = cls.createProperty(propertyName, propertyType);
       break;
     }

     iResponse.send(OHttpUtils.STATUS_CREATED_CODE, OHttpUtils.STATUS_CREATED_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, cls
         .properties().size(), null);
View Full Code Here

       case LINKMAP:
       case LINKSET: {
         final String linkType = doc.get(LINKED_TYPE_JSON_FIELD);
         final String linkClass = doc.get(LINKED_CLASS_JSON_FIELD);
         if (linkType != null) {
           final OProperty prop = cls.createProperty(propertyName, propertyType, OType.valueOf(linkType));
         } else if (linkClass != null) {
           final OProperty prop = cls.createProperty(propertyName, propertyType, db.getMetadata().getSchema().getClass(linkClass));
         } else {
           throw new IllegalArgumentException("property named " + propertyName + " is declared as " + propertyType
               + " but linked type is not declared");
         }
       }
         break;
       case LINK: {
         final String linkClass = doc.get(LINKED_CLASS_JSON_FIELD);
         if (linkClass != null) {
           final OProperty prop = cls.createProperty(propertyName, propertyType, db.getMetadata().getSchema().getClass(linkClass));
         } else {
           throw new IllegalArgumentException("property named " + propertyName + " is declared as " + propertyType
               + " but linked Class is not declared");
         }

       }
         break;

       default:
         final OProperty prop = cls.createProperty(propertyName, propertyType);
         break;
       }
     }

     iResponse.send(OHttpUtils.STATUS_CREATED_CODE, OHttpUtils.STATUS_CREATED_DESCRIPTION, OHttpUtils.CONTENT_TEXT_PLAIN, cls
View Full Code Here

        final ODatabaseDocumentTx db = getRawGraph();
        final OSchema schema = db.getMetadata().getSchema();

        final OClass cls = schema.getOrCreateClass(className, schema.getClass(ancestorClassName));
        final OProperty property = cls.getProperty(key);
        if (property != null)
          keyType = property.getType();

        db.getMetadata()
            .getIndexManager()
            .createIndex(className + "." + key, indexType, new OPropertyIndexDefinition(className, key, keyType),
                cls.getPolymorphicClusterIds(), null, metadata);
View Full Code Here

    final OClass linkClass = iFromVertex.getSchemaClass();
    if (linkClass == null)
      throw new IllegalArgumentException("Class ot found in source vertex: " + iFromVertex);

    final OProperty prop = linkClass.getProperty(iFieldName);
    final OType propType = prop != null && prop.getType() != OType.ANY ? prop.getType() : null;

    if (found == null) {
      if (iGraph.isAutoScaleEdgeType()
          && (prop == null || propType == OType.LINK || "true".equalsIgnoreCase(prop.getCustom("ordered")))) {
        // CREATE ONLY ONE LINK
        out = iTo;
      } else if (propType == OType.LINKLIST || (prop != null && "true".equalsIgnoreCase(prop.getCustom("ordered")))) {
        final Collection coll = new ORecordLazyList(iFromVertex);
        coll.add(iTo);
        out = coll;
      } else if (propType == null || propType == OType.LINKBAG) {
        final ORidBag bag = new ORidBag();
        bag.add(iTo);
        out = bag;
      } else
        throw new IllegalStateException("Type of field provided in schema '" + prop.getType()
            + " can not be used for link creation.");

    } else if (found instanceof OIdentifiable) {
      if (prop != null && propType == OType.LINK)
        throw new IllegalStateException("Type of field provided in schema '" + prop.getType()
            + " can not be used for creation to hold several links.");

      if (prop != null && "true".equalsIgnoreCase(prop.getCustom("ordered"))) {
        final Collection coll = new ORecordLazyList(iFromVertex);
        coll.add(found);
        coll.add(iTo);
        out = coll;
      } else {
View Full Code Here

  @Test
  public void testCreateUniqueIndex() {
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.getClass("PropertyIndexTestClass");
    final OProperty propOne = oClass.getProperty("prop1");

    propOne.createIndex(OClass.INDEX_TYPE.UNIQUE);

    final Collection<OIndex<?>> indexes = propOne.getIndexes();
    OIndexDefinition indexDefinition = null;

    for (final OIndex<?> index : indexes) {
      if (index.getName().equals("PropertyIndexTestClass.prop1")) {
        indexDefinition = index.getDefinition();
View Full Code Here

  @Test(dependsOnMethods = "createAdditionalSchemas")
  public void testGetIndexes() {
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.getClass("PropertyIndexTestClass");
    final OProperty propOne = oClass.getProperty("prop1");

    final Collection<OIndex<?>> indexes = propOne.getIndexes();
    Assert.assertEquals(indexes.size(), 3);
    Assert.assertNotNull(containsIndex(indexes, "PropertyIndexTestClass.prop1"));
    Assert.assertNotNull(containsIndex(indexes, "propOne1"));
    Assert.assertNotNull(containsIndex(indexes, "propOne2"));
  }
View Full Code Here

  @Test(dependsOnMethods = "createAdditionalSchemas")
  public void testGetAllIndexes() {
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.getClass("PropertyIndexTestClass");
    final OProperty propOne = oClass.getProperty("prop1");

    final Collection<OIndex<?>> indexes = propOne.getAllIndexes();
    Assert.assertEquals(indexes.size(), 5);
    Assert.assertNotNull(containsIndex(indexes, "PropertyIndexTestClass.prop1"));
    Assert.assertNotNull(containsIndex(indexes, "propOne0"));
    Assert.assertNotNull(containsIndex(indexes, "propOne1"));
    Assert.assertNotNull(containsIndex(indexes, "propOne2"));
View Full Code Here

TOP

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

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.