本文整理汇总了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;
}
示例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;
}
示例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);
}
};
}
示例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() + "'.");
}
}
示例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;
}
示例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();
}
示例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()
+ "'.");
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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<>()));
}
}
}
}
}