Examples of OProperty


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

    if (OSerializationThreadLocal.INSTANCE.get().contains(identityRecord))
      return iRecord;

    OSerializationThreadLocal.INSTANCE.get().add(identityRecord);

    OProperty schemaProperty;

    final Class<?> pojoClass = iPojo.getClass();

    final List<Field> properties = getClassFields(pojoClass);

    // CHECK FOR ID BINDING
    final String idFieldName = fieldIds.get(pojoClass);
    if (idFieldName != null) {
      Object id = getFieldValue(iPojo, idFieldName);
      if (id != null) {
        // FOUND
        if (id instanceof ORecordId) {
          iRecord.setIdentity((ORecordId) id);
        } else if (id instanceof Number) {
          // TREATS AS CLUSTER POSITION
          ((ORecordId) iRecord.getIdentity()).clusterId = schemaClass.getDefaultClusterId();
          ((ORecordId) iRecord.getIdentity()).clusterPosition = ((Number) id).longValue();
        } else if (id instanceof String)
          ((ORecordId) iRecord.getIdentity()).fromString((String) id);
        else if (id.getClass().equals(Object.class))
          iRecord.setIdentity((ORecordId) id);
        else
          OLogManager.instance().warn(OObjectSerializerHelper.class,
              "@Id field has been declared as %s while the supported are: ORID, Number, String, Object", id.getClass());
      }
    }

    // CHECK FOR VERSION BINDING
    final String vFieldName = fieldVersions.get(pojoClass);
    boolean versionConfigured = false;
    if (vFieldName != null) {
      versionConfigured = true;
      Object ver = getFieldValue(iPojo, vFieldName);
      if (ver != null) {
        // FOUND
        if (ver instanceof Number) {
          // TREATS AS CLUSTER POSITION
          iRecord.setVersion(((Number) ver).intValue());
        } else if (ver instanceof String)
          iRecord.setVersion(Integer.parseInt((String) ver));
        else if (ver.getClass().equals(Object.class))
          iRecord.setVersion((Integer) ver);
        else
          OLogManager.instance().warn(OObjectSerializerHelper.class,
              "@Version field has been declared as %s while the supported are: Number, String, Object", ver.getClass());
      }
    }

    if (!versionConfigured && iRecord.getDatabase().getTransaction() instanceof OTransactionOptimistic)
      throw new OTransactionException("Can't involve an object of class '" + pojoClass
          + "' in an Optimistic Transaction commit because it doesn't define @Version or @OVersion and therefore can't handle MVCC");

    // SET OBJECT CLASS
    iRecord.setClassName(schemaClass != null ? schemaClass.getName() : null);

    String fieldName;
    Object fieldValue;

    // CALL BEFORE MARSHALLING
    invokeCallback(iPojo, iRecord, OBeforeSerialization.class);

    for (Field p : properties) {
      fieldName = p.getName();

      if (fieldName.equals(idFieldName) || fieldName.equals(vFieldName))
        continue;

      fieldValue = serializeFieldValue(iPojo, fieldName, getFieldValue(iPojo, fieldName));

      schemaProperty = schemaClass != null ? schemaClass.getProperty(fieldName) : null;

      fieldValue = typeToStream(fieldValue, schemaProperty != null ? schemaProperty.getType() : null, iEntityManager,
          iObj2RecHandler, db, iSaveOnlyDirty);

      iRecord.field(fieldName, fieldValue);
    }
View Full Code Here

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

    if (iFieldType != null)
      setFieldType(iFieldName, iFieldType);
    else if (_clazz != null) {
      // SCHEMAFULL?
      final OProperty prop = _clazz.getProperty(iFieldName);
      if (prop != null)
        iFieldType = prop.getType();
    }

    if (iPropertyValue == null) {
      _fieldValues.put(iFieldName, iPropertyValue);
    } else {
View Full Code Here

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

    if (iFieldValue.equals("null"))
      return null;

    if (iFieldName != null)
      if (iRecord.getSchemaClass() != null) {
        final OProperty p = iRecord.getSchemaClass().getProperty(iFieldName);
        if (p != null) {
          iType = p.getType();
          iLinkedType = p.getLinkedType();
        }
      }

    if (iFieldValue.startsWith("{") && iFieldValue.endsWith("}")) {
      // OBJECT OR MAP. CHECK THE TYPE ATTRIBUTE TO KNOW IT
View Full Code Here

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

      // MARSHALL THE CLASSNAME
      iOutput.append(record.getSchemaClass().getStreamableName());
      iOutput.append(OStringSerializerHelper.CLASS_SEPARATOR);
    }

    OProperty prop;
    OType type;
    OClass linkedClass;
    OType linkedType;
    String fieldClassName;
    int i = 0;

    final String[] fieldNames = iOnlyDelta && record.isTrackingChanges() ? record.getDirtyFields() : record.fieldNames();

    // MARSHALL ALL THE FIELDS OR DELTA IF TRACKING IS ENABLED
    for (String fieldName : fieldNames) {
      Object fieldValue = record.rawField(fieldName);
      if (i > 0)
        iOutput.append(OStringSerializerHelper.RECORD_SEPARATOR);

      // SEARCH FOR A CONFIGURED PROPERTY
      prop = record.getSchemaClass() != null ? record.getSchemaClass().getProperty(fieldName) : null;
      fieldClassName = getClassName(fieldValue);

      type = record.fieldType(fieldName);
      linkedClass = null;
      linkedType = null;

      if (prop != null) {
        // RECOGNIZED PROPERTY
        type = prop.getType();
        linkedClass = prop.getLinkedClass();
        linkedType = prop.getLinkedType();

      } else if (fieldValue != null) {
        // NOT FOUND: TRY TO DETERMINE THE TYPE FROM ITS CONTENT
        if (type == null) {
          if (fieldValue.getClass() == byte[].class)
View Full Code Here

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

    String fieldName = null;
    String fieldValue;
    OType type = null;
    OClass linkedClass;
    OType linkedType;
    OProperty prop;

    // UNMARSHALL ALL THE FIELDS
    for (int i = 0; i < fields.size(); ++i) {
      field = fields.get(i).trim();

      boolean uncertainType = false;

      try {
        pos = field.indexOf(FIELD_VALUE_SEPARATOR);
        if (pos > -1) {
          // GET THE FIELD NAME
          fieldName = field.substring(0, pos);

          // GET THE FIELD VALUE
          fieldValue = field.length() > pos + 1 ? field.substring(pos + 1) : null;

          // SEARCH FOR A CONFIGURED PROPERTY
          prop = record.getSchemaClass() != null ? record.getSchemaClass().getProperty(fieldName) : null;
          if (prop != null) {
            // RECOGNIZED PROPERTY
            type = prop.getType();
            linkedClass = prop.getLinkedClass();
            linkedType = prop.getLinkedType();

          } else {
            // SCHEMA PROPERTY NOT FOUND FOR THIS FIELD: TRY TO AUTODETERMINE THE BEST TYPE
            type = record.fieldType(fieldName);
            linkedClass = null;
View Full Code Here

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

      }

      if (total > 0) {
        if (inverse) {
          // REMOVE THE OLD PROPERTY IF ANY
          OProperty prop = destClass.getProperty(linkName);
          if (prop != null)
            destClass.dropProperty(linkName);

          // CREATE THE PROPERTY
          destClass.createProperty(linkName, multipleRelationship ? OType.LINKLIST : OType.LINK, sourceClass);

        } else {

          // REMOVE THE OLD PROPERTY IF ANY
          OProperty prop = sourceClass.getProperty(linkName);
          if (prop != null)
            sourceClass.dropProperty(linkName);

          // CREATE THE PROPERTY
          sourceClass.createProperty(linkName, OType.LINK, destClass);
View Full Code Here

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

    for (Map.Entry<String, Object> entry : addEntries.entrySet()) {
      coll = null;
      if (!record.containsField(entry.getKey())) {
        // GET THE TYPE IF ANY
        if (record.getSchemaClass() != null) {
          OProperty prop = record.getSchemaClass().getProperty(entry.getKey());
          if (prop != null && prop.getType() == OType.LINKSET)
            // SET TYPE
            coll = new HashSet<Object>();
        }

        if (coll == null)
          // IN ALL OTHER CASES USE A LIST
          coll = new ArrayList<Object>();

        record.field(entry.getKey(), coll);
      } else {
        fieldValue = record.field(entry.getKey());

        if (fieldValue instanceof Collection<?>)
          coll = (Collection<Object>) fieldValue;
        else
          continue;
      }

      v = entry.getValue();

      if (v instanceof OSQLFilterItem)
        v = ((OSQLFilterItem) v).getValue(record);
      else if (v instanceof OSQLFunctionRuntime)
        v = ((OSQLFunctionRuntime) v).execute(record);

      coll.add(v);
      recordUpdated = true;
    }

    // BIND VALUES TO PUT (AS MAP)
    Map<String, Object> map;
    OPair<String, Object> pair;
    for (Entry<String, OPair<String, Object>> entry : putEntries.entrySet()) {
      fieldValue = record.field(entry.getKey());

      if (fieldValue == null) {
        if (record.getSchemaClass() != null) {
          final OProperty property = record.getSchemaClass().getProperty(entry.getKey());
          if (property != null
              && (property.getType() != null && (!property.getType().equals(OType.EMBEDDEDMAP) && !property.getType().equals(
                  OType.LINKMAP)))) {
            throw new OCommandExecutionException("field " + entry.getKey() + " is not defined as a map");
          }
        }
        fieldValue = new HashMap();
View Full Code Here

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

    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.OProperty

    else
      fieldValue = iCondition.getLeft().toString();

    final String className = iTargetClasses.get(0);

    final OProperty prop = iDatabase.getMetadata().getSchema().getClass(className).getProperty(fieldName);
    if (prop == null)
      // NO PROPERTY DEFINED
      return null;

    final OPropertyIndex index = prop.getIndex();
    if (index == null || !(index.getUnderlying() instanceof OIndexFullText))
      // NO FULL TEXT INDEX
      return null;

    return index.getUnderlying().get(fieldValue);
View Full Code Here

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

    if (iCondition.getLeft() instanceof OSQLFilterItemField && iCondition.getRight() instanceof OSQLFilterItemField)
      return false;

    final OSQLFilterItemField item = (OSQLFilterItemField) iItem;

    OProperty prop = iSchemaClass.getProperty(item.getRoot());

    while ((prop == null || !prop.isIndexed()) && iSchemaClass.getSuperClass() != null) {
      iSchemaClass = iSchemaClass.getSuperClass();
      prop = iSchemaClass.getProperty(item.getRoot());
    }

    if (prop != null && prop.isIndexed()) {
      final Object origValue = iCondition.getLeft() == iItem ? iCondition.getRight() : iCondition.getLeft();
      final OIndex underlyingIndex = prop.getIndex().getUnderlying();

      if (iCondition.getOperator() instanceof OQueryOperatorBetween) {
        iSearchInIndexTriples.add(new OSearchInIndexTriple(iCondition.getOperator(), origValue, underlyingIndex));
        return true;
      }
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.