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


Java RelationTypeMetadata類代碼示例

本文整理匯總了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;
   }
 
開發者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: 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;
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:19,代碼來源:Neo4jRelationManager.java

示例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;
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:28,代碼來源:RelationTypeMetadataResolver.java

示例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();
   }
 
開發者ID:PureSolTechnologies,項目名稱:DuctileDB,代碼行數:9,代碼來源:DucileStoreEdgeManager.java

示例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;
   }
 
開發者ID:PureSolTechnologies,項目名稱:extended-objects-titan,代碼行數:29,代碼來源:TitanStoreEdgeManager.java

示例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);
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:Neo4jRelationManager.java

示例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);
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:RemoteDatastoreRelationManager.java

示例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;
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:RemoteDatastoreRelationManager.java

示例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);
    }
}
 
開發者ID:buschmais,項目名稱:extended-objects,代碼行數:11,代碼來源:RemoteDatastoreRelationManager.java


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