use of jetbrains.exodus.query.metadata.EntityMetaData in project xodus by JetBrains.
the class LinksEqualDecorator method instantiateDecorated.
protected Iterable<Entity> instantiateDecorated(String entityType, QueryEngine queryEngine, ModelMetaData metaData) {
Iterable<Entity> result = decorated.instantiate(entityType, queryEngine, metaData);
final EntityMetaData emd = metaData == null ? null : metaData.getEntityMetaData(entityType);
if (emd != null) {
for (String subType : emd.getSubTypes()) {
result = queryEngine.unionAdjusted(result, instantiateDecorated(subType, queryEngine, metaData));
}
}
return result;
}
use of jetbrains.exodus.query.metadata.EntityMetaData in project xodus by JetBrains.
the class PropertyNotNull method instantiate.
@Override
public Iterable<Entity> instantiate(String entityType, QueryEngine queryEngine, ModelMetaData metaData) {
final EntityMetaData emd = metaData == null ? null : metaData.getEntityMetaData(entityType);
final PropertyMetaData pmd = emd == null ? null : emd.getPropertyMetaData(name);
queryEngine.assertOperational();
final PersistentStoreTransaction txn = queryEngine.getPersistentStore().getAndCheckCurrentTransaction();
return pmd == null || pmd.getType() == PropertyType.PRIMITIVE ? txn.findWithProp(entityType, name) : txn.findWithBlob(entityType, name);
}
use of jetbrains.exodus.query.metadata.EntityMetaData in project xodus by JetBrains.
the class QueryEngine method selectManyDistinct.
public Iterable<Entity> selectManyDistinct(Iterable<Entity> it, final String linkName) {
if (it == null) {
return EntityIterableBase.EMPTY;
}
if (mmd != null) {
if (it instanceof StaticTypedEntityIterable) {
final StaticTypedEntityIterable tree = (StaticTypedEntityIterable) it;
it = toEntityIterable(it);
if (isPersistentIterable(it)) {
final String entityType = tree.getEntityType();
final EntityMetaData emd = mmd.getEntityMetaData(entityType);
if (emd != null) {
final AssociationEndMetaData aemd = emd.getAssociationEndMetaData(linkName);
if (aemd != null) {
final String resultType = aemd.getOppositeEntityMetaData().getType();
return new StaticTypedIterableDecorator(resultType, selectManyDistinctImpl((EntityIterableBase) it, linkName), this);
}
}
}
} else if (isPersistentIterable(it)) {
return selectManyDistinctImpl((EntityIterableBase) it, linkName);
}
}
return inMemorySelectManyDistinct(it, linkName);
}
use of jetbrains.exodus.query.metadata.EntityMetaData in project xodus by JetBrains.
the class QueryEngine method selectDistinct.
public Iterable<Entity> selectDistinct(Iterable<Entity> it, final String linkName) {
if (it == null) {
return EntityIterableBase.EMPTY;
}
if (mmd != null) {
if (it instanceof StaticTypedEntityIterable) {
final StaticTypedEntityIterable ktei = (StaticTypedEntityIterable) it;
it = toEntityIterable(it);
if (isPersistentIterable(it)) {
final String entityType = ktei.getEntityType();
final EntityMetaData emd = mmd.getEntityMetaData(entityType);
if (emd != null) {
final AssociationEndMetaData aemd = emd.getAssociationEndMetaData(linkName);
if (aemd != null) {
final String resultType = aemd.getOppositeEntityMetaData().getType();
return new StaticTypedIterableDecorator(resultType, selectDistinctImpl((EntityIterableBase) it, linkName), this);
}
}
}
} else if (isPersistentIterable(it)) {
return selectDistinctImpl((EntityIterableBase) it, linkName);
}
}
return inMemorySelectDistinct(it, linkName);
}
use of jetbrains.exodus.query.metadata.EntityMetaData in project xodus by JetBrains.
the class TreeKeepingEntityIterable method instantiateForWholeHierarchy.
private Iterable<Entity> instantiateForWholeHierarchy(final String entityType, final NodeBase ast) {
final ModelMetaData mmd = queryEngine.getModelMetaData();
final EntityMetaData emd = mmd == null ? null : mmd.getEntityMetaData(entityType);
Iterable<Entity> result = ast.getClone().instantiate(entityType, queryEngine, mmd);
if (!(emd == null || ast.polymorphic())) {
for (String subType : emd.getSubTypes()) {
if (Utils.getUnionSubtypes()) {
// union returns sorted by id results provided its operands are sorted by id
result = queryEngine.unionAdjusted(result, instantiateForWholeHierarchy(subType, ast));
} else {
result = queryEngine.concatAdjusted(result, instantiateForWholeHierarchy(subType, ast));
}
}
}
return queryEngine.adjustEntityIterable(result);
}
Aggregations