當前位置: 首頁>>代碼示例>>Java>>正文


Java RelationTypeMetadata.Direction方法代碼示例

本文整理匯總了Java中com.buschmais.xo.spi.metadata.type.RelationTypeMetadata.Direction方法的典型用法代碼示例。如果您正苦於以下問題:Java RelationTypeMetadata.Direction方法的具體用法?Java RelationTypeMetadata.Direction怎麽用?Java RelationTypeMetadata.Direction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.buschmais.xo.spi.metadata.type.RelationTypeMetadata的用法示例。


在下文中一共展示了RelationTypeMetadata.Direction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasSingleRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public boolean hasSingleRelation(DuctileVertex source, RelationTypeMetadata<DuctileEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
String label = metadata.getDatastoreMetadata().getDiscriminator();
long count;
switch (direction) {
case FROM:
    count = graph.traversal().V(source.id()).outE(label).count().next();
    break;
case TO:
    count = graph.traversal().V(source.id()).inE(label).count().next();
    break;
default:
    throw new XOException("Unkown direction '" + direction.name() + "'.");
}
if (count > 1) {
    throw new XOException("Multiple results are available.");
}
return count == 1;
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:21,代碼來源:DucileStoreEdgeManager.java

示例2: getSingleRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public DuctileEdge getSingleRelation(DuctileVertex source, RelationTypeMetadata<DuctileEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
String descriminator = metadata.getDatastoreMetadata().getDiscriminator();
Iterator<Edge> edges;
switch (direction) {
case FROM:
    edges = source.edges(Direction.OUT, descriminator);
    break;
case TO:
    edges = source.edges(Direction.IN, descriminator);
    break;
default:
    throw new XOException("Unkown direction '" + direction.name() + "'.");
}
if (!edges.hasNext()) {
    throw new XOException("No result is available.");
}
DuctileEdge result = (DuctileEdge) edges.next();
if (edges.hasNext()) {
    throw new XOException("Multiple results are available.");
}
return result;
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:25,代碼來源:DucileStoreEdgeManager.java

示例3: getRelations

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public Iterable<DuctileEdge> getRelations(DuctileVertex source, RelationTypeMetadata<DuctileEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
String discriminator = metadata.getDatastoreMetadata().getDiscriminator();
final Iterator<Edge> edges;
switch (direction) {
case TO:
    edges = source.edges(Direction.IN, discriminator);
    break;
case FROM:
    edges = source.edges(Direction.OUT, discriminator);
    break;
default:
    throw new XOException("Unknown direction '" + direction.name() + "'.");
}
return new Iterable<DuctileEdge>() {
    @Override
    public Iterator<DuctileEdge> iterator() {
	return new CastIterator<Edge, DuctileEdge>(edges);
    }
};
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:23,代碼來源:DucileStoreEdgeManager.java

示例4: createRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public DuctileEdge createRelation(DuctileVertex source, RelationTypeMetadata<DuctileEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction, DuctileVertex target,
    Map<PrimitivePropertyMethodMetadata<DuctilePropertyMetadata>, Object> exampleEntity) {
String name = metadata.getDatastoreMetadata().getDiscriminator();
Object[] keyValues = new Object[exampleEntity.size() * 2];
@SuppressWarnings("unchecked")
PrimitivePropertyMethodMetadata<DuctilePropertyMetadata> keys[] = exampleEntity.keySet()
	.toArray(new PrimitivePropertyMethodMetadata[exampleEntity.size()]);
for (int i = 0; i < exampleEntity.size(); ++i) {
    PrimitivePropertyMethodMetadata<DuctilePropertyMetadata> key = keys[i];
    String propertyName = key.getDatastoreMetadata().getName();
    keyValues[2 * i] = propertyName;
    keyValues[2 * i + 1] = exampleEntity.get(key);
}
switch (direction) {
case FROM:
    return source.addEdge(name, target);
case TO:
    return target.addEdge(name, source);
default:
    throw new XOException("Unknown direction '" + direction.name() + "'.");
}
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:25,代碼來源:DucileStoreEdgeManager.java

示例5: hasSingleRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public boolean hasSingleRelation(Vertex source,
    RelationTypeMetadata<TitanEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
String label = metadata.getDatastoreMetadata().getDiscriminator();
long count;
switch (direction) {
case FROM:
    count = source.query().direction(Direction.OUT).labels(label)
	    .count();
    break;
case TO:
    count = source.query().direction(Direction.IN).labels(label)
	    .count();
    break;
default:
    throw new XOException("Unkown direction '" + direction.name()
	    + "'.");
}
if (count > 1) {
    throw new XOException("Multiple results are available.");
}
return count == 1;
   }
 
開發者ID:PureSolTechnologies,項目名稱:extended-objects-titan,代碼行數:25,代碼來源:TitanStoreEdgeManager.java

示例6: getRelations

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public Iterable<Edge> getRelations(Vertex source,
    RelationTypeMetadata<TitanEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
VertexQuery query = source.query();
String discriminator = metadata.getDatastoreMetadata()
	.getDiscriminator();
switch (direction) {
case TO:
    query = query.direction(Direction.IN).labels(discriminator);
    break;
case FROM:
    query = query.direction(Direction.OUT).labels(discriminator);
    break;
default:
    throw new XOException("Unknown direction '" + direction.name()
	    + "'.");
}
return query.edges();
   }
 
開發者ID:PureSolTechnologies,項目名稱:extended-objects-titan,代碼行數:21,代碼來源:TitanStoreEdgeManager.java

示例7: createRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public Edge createRelation(
    Vertex source,
    RelationTypeMetadata<TitanEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction,
    Vertex target,
    Map<PrimitivePropertyMethodMetadata<TitanPropertyMetadata>, Object> exampleEntity) {
String name = metadata.getDatastoreMetadata().getDiscriminator();
switch (direction) {
case FROM:
    return source.addEdge(name, target);
case TO:
    return target.addEdge(name, source);
default:
    throw new XOException("Unknown direction '" + direction.name()
	    + "'.");
}
   }
 
開發者ID:PureSolTechnologies,項目名稱:extended-objects-titan,代碼行數:19,代碼來源:TitanStoreEdgeManager.java

示例8: getSingleRelation

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
@Override
   public Edge getSingleRelation(Vertex source,
    RelationTypeMetadata<TitanEdgeMetadata> metadata,
    RelationTypeMetadata.Direction direction) {
String descriminator = metadata.getDatastoreMetadata()
	.getDiscriminator();
Iterable<Edge> edges;
switch (direction) {
case FROM:
    edges = source.getEdges(Direction.OUT, descriminator);
    break;
case TO:
    edges = source.getEdges(Direction.IN, descriminator);
    break;
default:
    throw new XOException("Unkown direction '" + direction.name()
	    + "'.");
}
Iterator<Edge> iterator = edges.iterator();
if (!iterator.hasNext()) {
    throw new XOException("No result is available.");
}
Edge result = iterator.next();
if (iterator.hasNext()) {
    throw new XOException("Multiple results are available.");
}
return result;
   }
 
開發者ID:PureSolTechnologies,項目名稱:extended-objects-titan,代碼行數:29,代碼來源:TitanStoreEdgeManager.java

示例9: getReferencedEntity

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private Entity getReferencedEntity(Relation relation, RelationTypeMetadata.Direction direction) {
    DatastoreRelationManager<Entity, ?, Relation, ? extends DatastoreRelationMetadata<?>, ?, ?> relationManager = sessionContext.getDatastoreSession()
            .getDatastoreRelationManager();
    switch (direction) {
    case FROM:
        return relationManager.getTo(relation);
    case TO:
        return relationManager.getFrom(relation);
    default:
        throw new XOException("Unsupported direction: " + direction);
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:13,代碼來源:EntityPropertyManager.java

示例10: createReference

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private Relation createReference(Entity sourceEntity, RelationTypeMetadata metadata, RelationTypeMetadata.Direction direction, Entity targetEntity,
        Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> example) {
    DatastoreRelationManager<Entity, ?, Relation, ?, ?, PropertyMetadata> datastoreRelationManager = sessionContext.getDatastoreSession()
            .getDatastoreRelationManager();
    Relation relation = (Relation) datastoreRelationManager.createRelation(sourceEntity, metadata, direction, targetEntity, example);
    AbstractInstanceManager<?, Entity> entityInstanceManager = sessionContext.getEntityInstanceManager();
    entityInstanceManager.updateInstance(sourceEntity);
    entityInstanceManager.updateInstance(targetEntity);
    return relation;
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:EntityPropertyManager.java

示例11: getDirection

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private EmbeddedDirection getDirection(RelationTypeMetadata.Direction direction) {
    switch (direction) {
    case FROM:
        return EmbeddedDirection.OUTGOING;
    case TO:
        return EmbeddedDirection.INCOMING;
    default:
        throw new XOException("Unsupported direction " + direction);
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:Neo4jRelationManager.java

示例12: getReferencedEntity

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private Entity getReferencedEntity(Relation relation, RelationTypeMetadata.Direction direction) {
    DatastoreRelationManager<Entity, ?, Relation, ? extends DatastoreRelationMetadata<?>, ?, ?> relationManager = sessionContext.getDatastoreSession().getDatastoreRelationManager();
    switch (direction) {
        case TO:
            return relationManager.getTo(relation);
        case FROM:
            return relationManager.getFrom(relation);
        default:
            throw direction.createNotSupportedException();
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:12,代碼來源:RelationPropertyManager.java

示例13: getSingleRelationship

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private Set<RemoteRelationship> getSingleRelationship(RemoteNode source, RelationTypeMetadata<RelationshipMetadata<RemoteRelationshipType>> metadata,
        RelationTypeMetadata.Direction direction) {
    Set<RemoteRelationship> relationships = getRelationships(source, metadata.getDatastoreMetadata().getDiscriminator(), getRemoteDirection(direction))
            .getElements();
    if (relationships.size() > 1) {
        throw new XOException("Found more than one relationship for node=" + source + ", type=" + metadata.getDatastoreMetadata().getDiscriminator()
                + ", direction=" + direction + ", relationships=" + relationships);
    }
    return relationships;
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:RemoteDatastoreRelationManager.java

示例14: getRemoteDirection

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
private RemoteDirection getRemoteDirection(RelationTypeMetadata.Direction direction) {
    switch (direction) {
    case FROM:
        return RemoteDirection.OUTGOING;
    case TO:
        return RemoteDirection.INCOMING;
    default:
        throw new XOException("Direction not supported " + direction);
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:RemoteDatastoreRelationManager.java

示例15: initializeEntity

import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //導入方法依賴的package包/類
/**
 * Initializes all relation properties of the given node state with empty
 * collections.
 *
 * @param types
 *            The types.
 * @param nodeState
 *            The state of the entity.
 */
private void initializeEntity(Collection<? extends TypeMetadata> types, NodeState nodeState) {
    for (TypeMetadata type : types) {
        Collection<TypeMetadata> superTypes = type.getSuperTypes();
        initializeEntity(superTypes, nodeState);
        for (MethodMetadata<?, ?> methodMetadata : type.getProperties()) {
            if (methodMetadata instanceof AbstractRelationPropertyMethodMetadata) {
                AbstractRelationPropertyMethodMetadata<?> relationPropertyMethodMetadata = (AbstractRelationPropertyMethodMetadata) methodMetadata;
                RelationTypeMetadata<RelationshipMetadata<RemoteRelationshipType>> relationshipMetadata = relationPropertyMethodMetadata
                        .getRelationshipMetadata();
                RemoteRelationshipType relationshipType = relationshipMetadata.getDatastoreMetadata().getDiscriminator();
                RelationTypeMetadata.Direction direction = relationPropertyMethodMetadata.getDirection();
                RemoteDirection remoteDirection;
                switch (direction) {
                case FROM:
                    remoteDirection = RemoteDirection.OUTGOING;
                    break;
                case TO:
                    remoteDirection = RemoteDirection.INCOMING;
                    break;
                default:
                    throw new XOException("Unsupported direction: " + direction);
                }
                if (nodeState.getRelationships(remoteDirection, relationshipType) == null) {
                    nodeState.setRelationships(remoteDirection, relationshipType, new StateTracker<>(new LinkedHashSet<>()));
                }
            }
        }
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:39,代碼來源:RemoteDatastoreEntityManager.java


注:本文中的com.buschmais.xo.spi.metadata.type.RelationTypeMetadata.Direction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。