本文整理汇总了Java中com.buschmais.xo.spi.metadata.type.EntityTypeMetadata类的典型用法代码示例。如果您正苦于以下问题:Java EntityTypeMetadata类的具体用法?Java EntityTypeMetadata怎么用?Java EntityTypeMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityTypeMetadata类属于com.buschmais.xo.spi.metadata.type包,在下文中一共展示了EntityTypeMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEntity
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public DuctileVertex createEntity(TypeMetadataSet<EntityTypeMetadata<DuctileVertexMetadata>> types,
Set<String> discriminators,
Map<PrimitivePropertyMethodMetadata<DuctilePropertyMetadata>, Object> exampleEntity) {
DuctileVertex vertex = graph.addVertex();
for (Entry<PrimitivePropertyMethodMetadata<DuctilePropertyMetadata>, Object> propertyEntry : exampleEntity
.entrySet()) {
Object value = propertyEntry.getValue();
if (value == null) {
setProperty(vertex, propertyEntry.getKey(), value);
}
}
for (String discriminator : discriminators) {
vertex.getBaseVertex().addType(discriminator);
}
return vertex;
}
示例2: init
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public void init(Map<Class<?>, TypeMetadata> registeredMetadata) {
try (DS session = createSession()) {
DatastoreTransaction transaction = session.getDatastoreTransaction();
transaction.begin();
try {
for (TypeMetadata typeMetadata : registeredMetadata.values()) {
if (typeMetadata instanceof EntityTypeMetadata) {
EntityTypeMetadata<NodeMetadata<L>> entityTypeMetadata = (EntityTypeMetadata<NodeMetadata<L>>) typeMetadata;
// check for indexed property declared in type
ensureIndex(session, entityTypeMetadata, entityTypeMetadata.getIndexedProperty());
ensureIndex(session, entityTypeMetadata, entityTypeMetadata.getDatastoreMetadata().getUsingIndexedPropertyOf());
}
}
} finally {
transaction.commit();
}
}
}
示例3: getAggregatedDiscriminators
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
/**
* Determine the set of discriminators for one type, i.e. the discriminator
* of the type itself and of all it's super types.
*
* @param typeMetadata
* The type.
* @return The set of discriminators.
*/
private Set<Discriminator> getAggregatedDiscriminators(EntityTypeMetadata<EntityMetadata> typeMetadata) {
Set<Discriminator> discriminators = aggregatedDiscriminators.get(typeMetadata);
if (discriminators == null) {
discriminators = new HashSet<>();
Discriminator discriminator = typeMetadata.getDatastoreMetadata().getDiscriminator();
if (discriminator != null) {
discriminators.add(discriminator);
}
for (TypeMetadata superTypeMetadata : typeMetadata.getSuperTypes()) {
if (superTypeMetadata instanceof EntityTypeMetadata) {
discriminators.addAll(getAggregatedDiscriminators((EntityTypeMetadata<EntityMetadata>) superTypeMetadata));
}
}
aggregatedDiscriminators.put(typeMetadata, discriminators);
}
return discriminators;
}
示例4: getTypes
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
/**
* Return a {@link com.buschmais.xo.spi.datastore.TypeMetadataSet}
* containing all types matching to the given entity discriminators.
*
* @param discriminators
* The discriminators.
* @return The {@link com.buschmais.xo.spi.datastore.TypeMetadataSet}.
*/
public TypeMetadataSet<EntityTypeMetadata<EntityMetadata>> getTypes(Set<Discriminator> discriminators) {
// Get all types matching the discriminators
TypeMetadataSet<EntityTypeMetadata<EntityMetadata>> allEntityTypeMetadatas = new TypeMetadataSet<>();
for (Discriminator discriminator : discriminators) {
Set<EntityTypeMetadata<EntityMetadata>> entityTypeMetadataOfDiscriminator = typeMetadataByDiscriminator.get(discriminator);
if (entityTypeMetadataOfDiscriminator != null) {
for (EntityTypeMetadata<EntityMetadata> entityTypeMetadata : entityTypeMetadataOfDiscriminator) {
Set<Discriminator> entityDiscriminators = aggregatedDiscriminators.get(entityTypeMetadata);
if (discriminators.size() >= entityDiscriminators.size() && discriminators.containsAll(entityDiscriminators)) {
allEntityTypeMetadatas.add(entityTypeMetadata);
}
}
}
}
return allEntityTypeMetadatas;
}
示例5: findEntityById
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public DuctileVertex findEntityById(EntityTypeMetadata<DuctileVertexMetadata> metadata, String discriminator,
Long id) {
Iterator<Vertex> vertices = graph.vertices(id);
if (!vertices.hasNext()) {
return null;
}
return (DuctileVertex) vertices.next();
}
示例6: createEntity
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public Vertex createEntity(
TypeMetadataSet<EntityTypeMetadata<TitanVertexMetadata>> types,
Set<String> discriminators,
Map<PrimitivePropertyMethodMetadata<TitanPropertyMetadata>, Object> exampleEntity) {
Vertex vertex = titanGraph.addVertex(null);
for (String discriminator : discriminators) {
vertex.setProperty(TitanStoreSession.XO_DISCRIMINATORS_PROPERTY
+ discriminator, discriminator);
}
return vertex;
}
示例7: createEntity
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public EmbeddedNode createEntity(TypeMetadataSet<EntityTypeMetadata<NodeMetadata<EmbeddedLabel>>> types, Set<EmbeddedLabel> discriminators,
Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> example) {
Label[] labels = new Label[discriminators.size()];
int i = 0;
for (EmbeddedLabel discriminator : discriminators) {
labels[i++] = discriminator.getDelegate();
}
EmbeddedNode node = new EmbeddedNode(graphDatabaseService.createNode(labels));
setProperties(node, example);
return node;
}
示例8: getIndexedPropertyMetadata
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
public static <L extends Neo4jLabel> PropertyMetadata getIndexedPropertyMetadata(EntityTypeMetadata<NodeMetadata<L>> type,
PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata) {
if (propertyMethodMetadata == null) {
IndexedPropertyMethodMetadata<?> indexedProperty = type.getDatastoreMetadata().getUsingIndexedPropertyOf();
if (indexedProperty == null) {
throw new XOException("Type " + type.getAnnotatedType().getAnnotatedElement().getName() + " has no indexed property.");
}
propertyMethodMetadata = indexedProperty.getPropertyMethodMetadata();
}
return propertyMethodMetadata.getDatastoreMetadata();
}
示例9: ensureIndex
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
/**
* Ensures that an index exists for the given entity and property.
*
* @param entityTypeMetadata
* The entity.
* @param indexedProperty
* The index metadata.
*/
private void ensureIndex(DS session, EntityTypeMetadata<NodeMetadata<L>> entityTypeMetadata,
IndexedPropertyMethodMetadata<IndexedPropertyMetadata> indexedProperty) {
if (indexedProperty != null) {
IndexedPropertyMetadata datastoreMetadata = indexedProperty.getDatastoreMetadata();
if (datastoreMetadata.isCreate()) {
L label = entityTypeMetadata.getDatastoreMetadata().getDiscriminator();
PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata = indexedProperty.getPropertyMethodMetadata();
if (label != null && propertyMethodMetadata != null) {
ensureIndex(session, label, propertyMethodMetadata, datastoreMetadata.isUnique());
}
}
}
}
示例10: find
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
public <T> ResultIterable<T> find(Class<T> type, Object value) {
this.xoSession.flush();
// get the label for the type
EntityTypeMetadata<NodeMetadata<Label>> entityMetadata = xoSession.getEntityMetadata(type);
Label label = entityMetadata.getDatastoreMetadata().getDiscriminator();
// get the name of the indexed property
PrimitivePropertyMethodMetadata<PropertyMetadata> propertyMethodMetadata = entityMetadata.getIndexedProperty().getPropertyMethodMetadata();
PropertyMetadata datastoreMetadata = propertyMethodMetadata.getDatastoreMetadata();
Object datastoreValue = xoSession.toDatastore(value);
return find(label, datastoreMetadata, datastoreValue);
}
示例11: isBatchable
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
/**
* Determine if at least one type is marked as
* {@link com.buschmais.xo.neo4j.api.annotation.Batchable}.
*
* @param types
* The types.
* @return <code>true</code> if batching may be used.
*/
private boolean isBatchable(TypeMetadataSet<EntityTypeMetadata<NodeMetadata<RemoteLabel>>> types) {
for (EntityTypeMetadata<NodeMetadata<RemoteLabel>> type : types) {
if (type.getDatastoreMetadata().isBatchable()) {
return true;
}
}
return false;
}
示例12: findEntity
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public ResultIterator<RemoteNode> findEntity(EntityTypeMetadata<NodeMetadata<RemoteLabel>> type, RemoteLabel remoteLabel,
Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> values) {
if (values.size() > 1) {
throw new XOException("Only one property value is supported for find operation");
}
Map.Entry<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> entry = values.entrySet().iterator().next();
PropertyMetadata propertyMetadata = getIndexedPropertyMetadata(type, entry.getKey());
Object value = entry.getValue();
String statement = String.format("MATCH (n:%s) WHERE n.%s={v} RETURN n", remoteLabel.getName(), propertyMetadata.getName());
StatementResult result = statementExecutor.execute(statement, parameters("v", value));
return new ResultIterator<RemoteNode>() {
@Override
public boolean hasNext() {
return result.hasNext();
}
@Override
public RemoteNode next() {
Record record = result.next();
Node node = record.get("n").asNode();
return datastoreSessionCache.getNode(node);
}
@Override
public void close() {
result.consume();
}
};
}
示例13: createEntity
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public ObjectNode createEntity(TypeMetadataSet<EntityTypeMetadata<JsonNodeMetadata>> types, Set<String> discriminators,Map<PrimitivePropertyMethodMetadata<JsonPropertyMetadata>, Object> exampleEntity) {
ObjectNode rootNode = mapper.createObjectNode();
ArrayNode typesNode = mapper.createArrayNode();
for (String typeName : discriminators) {
typesNode.add(typeName);
}
rootNode.put(TYPES_PROPERTY, typesNode);
UUID uuid = UUID.randomUUID();
rootNode.put(ID_PROPERTY, uuid.toString());
for (Map.Entry<PrimitivePropertyMethodMetadata<JsonPropertyMetadata>, Object> entry : exampleEntity.entrySet()) {
setProperty(rootNode, entry.getKey(), entry.getValue());
}
return rootNode;
}
示例14: add
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public CompositeObject add(Class<?> newType, Class<?>... newTypes) {
TypeMetadataSet<EntityTypeMetadata<EntityMetadata>> types = getDiscriminators(newType, newTypes);
Set<EntityDiscriminator> newDiscriminators = new HashSet<>(metadataProvider.getEntityDiscriminators(types));
Entity entity = invalidateInstance(entityInstanceManager);
Set<EntityDiscriminator> entityDiscriminators = datastoreEntityManager.getEntityDiscriminators(entity);
newDiscriminators.removeAll(entityDiscriminators);
datastoreEntityManager.addDiscriminators(types, entity, newDiscriminators);
return createInstance(entity);
}
示例15: remove
import com.buschmais.xo.spi.metadata.type.EntityTypeMetadata; //导入依赖的package包/类
@Override
public CompositeObject remove(Class<?> obsoleteType, Class<?>... obsoleteTypes) {
TypeMetadataSet<EntityTypeMetadata<EntityMetadata>> types = getDiscriminators(obsoleteType, obsoleteTypes);
Set<EntityDiscriminator> obsoleteDiscriminators = new HashSet<>(metadataProvider.getEntityDiscriminators(types));
Entity entity = invalidateInstance(entityInstanceManager);
Set<EntityDiscriminator> entityDiscriminators = datastoreEntityManager.getEntityDiscriminators(entity);
obsoleteDiscriminators.retainAll(entityDiscriminators);
datastoreEntityManager.removeDiscriminators(types, entity, obsoleteDiscriminators);
return createInstance(entity);
}