本文整理汇总了Java中com.buschmais.xo.spi.metadata.type.RelationTypeMetadata类的典型用法代码示例。如果您正苦于以下问题:Java RelationTypeMetadata类的具体用法?Java RelationTypeMetadata怎么用?Java RelationTypeMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelationTypeMetadata类属于com.buschmais.xo.spi.metadata.type包,在下文中一共展示了RelationTypeMetadata类的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: createRelation
import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //导入依赖的package包/类
@Override
public EmbeddedRelationship createRelation(EmbeddedNode source, RelationTypeMetadata<RelationshipMetadata<EmbeddedRelationshipType>> metadata,
RelationTypeMetadata.Direction direction, EmbeddedNode target, Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> example) {
EmbeddedRelationship relationship;
EmbeddedRelationshipType relationshipType = metadata.getDatastoreMetadata().getDiscriminator();
switch (direction) {
case FROM:
relationship = source.createRelationshipTo(target, relationshipType);
break;
case TO:
relationship = target.createRelationshipTo(source, relationshipType);
break;
default:
throw new XOException("Unsupported direction " + direction);
}
setProperties(relationship, example);
return relationship;
}
示例9: getRelationTypes
import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //导入依赖的package包/类
/**
* Determine the relation type for the given source discriminators, relation
* descriminator and target discriminators.
*
* @param sourceDiscriminators
* The source discriminators.
* @param discriminator
* The relation discriminator.
* @param targetDiscriminators
* The target discriminators.
* @return A set of matching relation types.
*/
public TypeMetadataSet<RelationTypeMetadata<RelationMetadata>> getRelationTypes(Set<EntityDiscriminator> sourceDiscriminators,
RelationDiscriminator discriminator, Set<EntityDiscriminator> targetDiscriminators) {
TypeMetadataSet<RelationTypeMetadata<RelationMetadata>> types = new TypeMetadataSet<>();
Set<RelationMapping<EntityDiscriminator, RelationMetadata, RelationDiscriminator>> relations = relationMappings.get(discriminator);
if (relations != null) {
for (RelationMapping<EntityDiscriminator, RelationMetadata, RelationDiscriminator> relation : relations) {
Set<EntityDiscriminator> source = relation.getSource();
Set<EntityDiscriminator> target = relation.getTarget();
if (sourceDiscriminators.containsAll(source) && targetDiscriminators.containsAll(target)) {
types.add(relation.getRelationType());
}
}
}
return types;
}
示例10: findRelationById
import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //导入依赖的package包/类
@Override
public DuctileEdge findRelationById(RelationTypeMetadata<DuctileEdgeMetadata> metadata, Long id) {
Iterator<Edge> edges = graph.edges(id);
if (!edges.hasNext()) {
return null;
}
return (DuctileEdge) edges.next();
}
示例11: 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;
}
示例12: 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);
}
}
示例13: findRelationById
import com.buschmais.xo.spi.metadata.type.RelationTypeMetadata; //导入依赖的package包/类
@Override
public RemoteRelationship findRelationById(RelationTypeMetadata<RelationshipMetadata<RemoteRelationshipType>> metadata, Long id) {
String statement = String.format("MATCH (start)-[r:%s]->(end) WHERE id(r)={id} RETURN start,r,end",
metadata.getDatastoreMetadata().getDiscriminator().getName());
Record record = statementExecutor.getSingleResult(statement, parameters("id", id));
Node start = record.get("start").asNode();
Relationship relationship = record.get("r").asRelationship();
Node end = record.get("end").asNode();
return datastoreSessionCache.getRelationship(start, relationship, end);
}
示例14: 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;
}
示例15: 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);
}
}