Search in sources :

Example 6 with MetaComputedAttribute

use of io.crnk.jpa.internal.query.MetaComputedAttribute in project crnk-framework by crnk-project.

the class JpaCriteriaQueryBackend method getAttribute.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Expression<?> getAttribute(Expression<?> currentCriteriaPath, MetaAttribute pathElement) {
    if (pathElement instanceof MetaComputedAttribute) {
        MetaComputedAttribute projAttr = (MetaComputedAttribute) pathElement;
        JpaCriteriaExpressionFactory expressionFactory = (JpaCriteriaExpressionFactory<?>) queryImpl.getComputedAttrs().get(projAttr);
        From from = (From) currentCriteriaPath;
        return expressionFactory.getExpression(from, getCriteriaQuery());
    } else {
        return ((Path<?>) currentCriteriaPath).get(pathElement.getName());
    }
}
Also used : MetaAttributePath(io.crnk.meta.model.MetaAttributePath) JpaCriteriaExpressionFactory(io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory) MetaComputedAttribute(io.crnk.jpa.internal.query.MetaComputedAttribute)

Aggregations

MetaComputedAttribute (io.crnk.jpa.internal.query.MetaComputedAttribute)6 JpaCriteriaExpressionFactory (io.crnk.jpa.query.criteria.JpaCriteriaExpressionFactory)2 QuerydslExpressionFactory (io.crnk.jpa.query.querydsl.QuerydslExpressionFactory)2 Test (org.junit.Test)2 ComputedAttributeRegistryImpl (io.crnk.jpa.internal.query.ComputedAttributeRegistryImpl)1 MetaAttributePath (io.crnk.meta.model.MetaAttributePath)1 MetaDataObject (io.crnk.meta.model.MetaDataObject)1