示例#1
0
 @Override
 public Object execute(
     Object iThis,
     OIdentifiable iCurrentRecord,
     Object iCurrentResult,
     Object[] iParams,
     OCommandContext iContext) {
   if (iParams[0] instanceof Number) {
     addValue((Number) iParams[0]);
   } else if (OMultiValue.isMultiValue(iParams[0])) {
     for (Object n : OMultiValue.getMultiValueIterable(iParams[0])) {
       addValue((Number) n);
     }
   }
   return null;
 }
示例#2
0
  /**
   * Returns a Property value.
   *
   * @param key Property name
   * @return Property value if any, otherwise NULL.
   */
  @Override
  public <T> T getProperty(final String key) {
    if (key == null) return null;

    final OrientBaseGraph graph = getGraph();
    if (key.equals("_class"))
      return (T) ODocumentInternal.getImmutableSchemaClass(getRecord()).getName();
    else if (key.equals("_version")) return (T) new Integer(getRecord().getVersion());
    else if (key.equals("_rid")) return (T) rawElement.getIdentity().toString();

    final Object fieldValue = getRecord().field(key);
    if (graph != null
        && fieldValue instanceof OIdentifiable
        && !(((OIdentifiable) fieldValue).getRecord() instanceof ORecordBytes))
      // CONVERT IT TO VERTEX/EDGE
      return (T) graph.getElement(fieldValue);
    else if (OMultiValue.isMultiValue(fieldValue)
        && OMultiValue.getFirstValue(fieldValue) instanceof OIdentifiable) {
      final OIdentifiable firstValue = (OIdentifiable) OMultiValue.getFirstValue(fieldValue);

      if (firstValue instanceof ODocument) {
        final ODocument document = (ODocument) firstValue;

        if (document.isEmbedded() || ODocumentInternal.getImmutableSchemaClass(document) == null)
          return (T) fieldValue;
      }

      if (graph != null)
        // CONVERT IT TO ITERABLE<VERTEX/EDGE>
        return (T)
            new OrientElementIterable<OrientElement>(
                graph, OMultiValue.getMultiValueIterable(fieldValue));
    }

    return (T) fieldValue;
  }
示例#3
0
  protected static boolean comparesValues(
      final Object iValue, final ORecord<?> iRecord, final boolean iConsiderIn) {
    // ORID && RECORD
    final ORID other = ((ORecord<?>) iRecord).getIdentity();

    if (!other.isPersistent() && iRecord instanceof ODocument) {
      // ODOCUMENT AS RESULT OF SUB-QUERY: GET THE FIRST FIELD IF ANY
      final String[] firstFieldName = ((ODocument) iRecord).fieldNames();
      if (firstFieldName.length > 0) {
        Object fieldValue = ((ODocument) iRecord).field(firstFieldName[0]);
        if (fieldValue != null) {
          if (iConsiderIn && OMultiValue.isMultiValue(fieldValue)) {
            for (Object o : OMultiValue.getMultiValueIterable(fieldValue)) {
              if (o != null && o.equals(iValue)) return true;
            }
          }

          return fieldValue.equals(iValue);
        }
      }
      return false;
    }
    return other.equals(iValue);
  }