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

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


              throw new IllegalArgumentException("unsupported type of record");
          } else if (iRecord instanceof ODocument) {
            final ODocument doc = ((ODocument) iRecord);

            // DETERMINE THE TYPE FROM THE SCHEMA
            OType type = determineType(doc, fieldName);

            final Object v = getValue(doc, fieldName, fieldValue, fieldValueAsString, type, null, fieldTypes, noMap, iOptions);

            if (v != null)
              if (v instanceof Collection<?> && !((Collection<?>) v).isEmpty()) {
                if (v instanceof ORecordLazyMultiValue)
                  ((ORecordLazyMultiValue) v).setAutoConvertToRecord(false);

                // CHECK IF THE COLLECTION IS EMBEDDED
                if (type == null) {
                  // TRY TO UNDERSTAND BY FIRST ITEM
                  Object first = ((Collection<?>) v).iterator().next();
                  if (first != null && first instanceof ORecord && !((ORecord) first).getIdentity().isValid())
                    type = v instanceof Set<?> ? OType.EMBEDDEDSET : OType.EMBEDDEDLIST;
                }

                if (type != null) {
                  // TREAT IT AS EMBEDDED
                  doc.field(fieldName, v, type);
                  continue;
                }
              } else if (v instanceof Map<?, ?> && !((Map<?, ?>) v).isEmpty()) {
                // CHECK IF THE MAP IS EMBEDDED
                Object first = ((Map<?, ?>) v).values().iterator().next();
                if (first != null && first instanceof ORecord && !((ORecord) first).getIdentity().isValid()) {
                  doc.field(fieldName, v, OType.EMBEDDEDMAP);
                  continue;
                }
              } else if (v instanceof ODocument && type != null && type.isLink()) {
                String className = ((ODocument) v).getClassName();
                if (className != null && className.length() > 0)
                  ((ODocument) v).save();
              }
View Full Code Here


  public String toString() {
    return NAME;
  }

  private OType determineType(ODocument doc, String fieldName) {
    OType type = null;
    final OClass cls = doc.getSchemaClass();
    if (cls != null) {
      final OProperty prop = cls.getProperty(fieldName);
      if (prop != null)
        type = prop.getType();
View Full Code Here

        if (!entries.isEmpty()) {
          final Object mapValueObject;
          if (entries.size() > 1) {
            String mapValue = entries.get(1);

            final OType linkedType;

            if (iLinkedType == null)
              if (!mapValue.isEmpty()) {
                linkedType = getType(mapValue);
                if ((iName == null || iSourceDocument.fieldType(iName) == null || iSourceDocument.fieldType(iName) != OType.EMBEDDEDMAP)
View Full Code Here

      coll = iType == OType.EMBEDDEDLIST ? new OTrackedList<Object>(iDocument) : new OTrackedSet<Object>(iDocument);

    if (value.length() == 0)
      return coll;

    OType linkedType;

    if (coll instanceof ORecordElement)
      ((ORecordElement) coll).setInternalStatus(STATUS.UNMARSHALLING);

    final List<String> items = OStringSerializerHelper.smartSplit(value, OStringSerializerHelper.RECORD_SEPARATOR, true, false);
View Full Code Here

      final Set<ODocument> iMarshalledRecords, final boolean iSaveOnlyDirty, final boolean iSet) {
    iOutput.append(iSet ? OStringSerializerHelper.SET_BEGIN : OStringSerializerHelper.LIST_BEGIN);

    final Iterator<Object> iterator = OMultiValue.getMultiValueIterator(iValue);

    OType linkedType = iLinkedType;

    for (int i = 0; iterator.hasNext(); ++i) {
      final Object o = iterator.next();

      if (i > 0)
View Full Code Here

    final OBinarySerializerFactory factory = OBinarySerializerFactory.getInstance();
    for (int i = 0; i < keys.size(); i++) {
      final Object key = keys.get(i);

      if (key != null) {
        final OType type;
        if (types.length > i)
          type = types[i];
        else
          type = OType.getTypeByClass(key.getClass());
View Full Code Here

    for (int i = 0; i < keys.size(); i++) {
      final Object key = keys.get(i);

      OBinarySerializer<Object> binarySerializer;
      if (key != null) {
        final OType type;
        if (types.length > i)
          type = types[i];
        else
          type = OType.getTypeByClass(key.getClass());
View Full Code Here

    final int keysSize = inputStream.getAsInteger();
    for (int i = 0; i < keysSize; i++) {
      final byte[] keyBytes = inputStream.getAsByteArray();
      final String keyString = OBinaryProtocol.bytes2string(keyBytes);
      final int typeSeparatorPos = keyString.indexOf(',');
      final OType type = OType.valueOf(keyString.substring(0, typeSeparatorPos));
      compositeKey.addKey(ORecordSerializerStringAbstract.simpleValueFromStream(keyString.substring(typeSeparatorPos + 1), type));
    }
    return compositeKey;
  }
View Full Code Here

    for (int i = 0; i < keys.size(); i++) {
      final Object key = keys.get(i);
      OBinarySerializer<Object> binarySerializer;
      if (key != null) {
        final OType type;
        if (types.length > i)
          type = types[i];
        else
          type = OType.getTypeByClass(key.getClass());
View Full Code Here

    for (int i = 0; i < keys.size(); i++) {
      final Object key = keys.get(i);

      OBinarySerializer<Object> binarySerializer;
      if (key != null) {
        final OType type;
        if (types.length > i)
          type = types[i];
        else
          type = OType.getTypeByClass(key.getClass());
View Full Code Here

TOP

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

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.