Search in sources :

Example 1 with InternalElement

use of com.thinkaurelius.titan.graphdb.internal.InternalElement in project titan by thinkaurelius.

the class PredicateCondition method evaluate.

@Override
public boolean evaluate(E element) {
    RelationType type;
    if (key instanceof String) {
        type = ((InternalElement) element).tx().getRelationType((String) key);
        if (type == null)
            return satisfiesCondition(null);
    } else {
        type = (RelationType) key;
    }
    Preconditions.checkNotNull(type);
    if (type.isPropertyKey()) {
        Iterator<Object> iter = ElementHelper.getValues(element, (PropertyKey) type).iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                if (satisfiesCondition(iter.next()))
                    return true;
            }
            return false;
        }
        return satisfiesCondition(null);
    } else {
        assert ((InternalRelationType) type).multiplicity().isUnique(Direction.OUT);
        return satisfiesCondition((TitanVertex) element.value(type.name()));
    }
}
Also used : InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) InternalElement(com.thinkaurelius.titan.graphdb.internal.InternalElement)

Example 2 with InternalElement

use of com.thinkaurelius.titan.graphdb.internal.InternalElement in project atlas by apache.

the class PredicateCondition method evaluate.

@Override
public boolean evaluate(E element) {
    RelationType type;
    if (key instanceof String) {
        type = ((InternalElement) element).tx().getRelationType((String) key);
        if (type == null)
            return satisfiesCondition(null);
    } else {
        type = (RelationType) key;
    }
    Preconditions.checkNotNull(type);
    if (type.isPropertyKey()) {
        Iterator<Object> iter = ElementHelper.getValues(element, (PropertyKey) type).iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                if (satisfiesCondition(iter.next()))
                    return true;
            }
            return false;
        }
        return satisfiesCondition(null);
    } else {
        assert ((InternalRelationType) type).getMultiplicity().isUnique(Direction.OUT);
        return satisfiesCondition(((TitanRelation) element).getProperty((EdgeLabel) type));
    }
}
Also used : InternalRelationType(com.thinkaurelius.titan.graphdb.internal.InternalRelationType) InternalElement(com.thinkaurelius.titan.graphdb.internal.InternalElement)

Aggregations

InternalElement (com.thinkaurelius.titan.graphdb.internal.InternalElement)2 InternalRelationType (com.thinkaurelius.titan.graphdb.internal.InternalRelationType)2