Search in sources :

Example 6 with MetaAttributePath

use of io.crnk.meta.model.MetaAttributePath in project crnk-framework by crnk-project.

the class JoinRegistry method getOrCreateJoin.

public F getOrCreateJoin(MetaAttributePath path) {
    if (path.length() == 0)
        return backend.getRoot();
    MetaAttributePath subPath = new MetaAttributePath();
    F from = backend.getRoot();
    for (int i = 0; i < path.length(); i++) {
        MetaAttribute pathElement = path.getElement(i);
        from = getOrCreateJoin(subPath, pathElement);
        subPath = subPath.concat(pathElement);
    }
    return from;
}
Also used : MetaAttribute(io.crnk.meta.model.MetaAttribute) MetaAttributePath(io.crnk.meta.model.MetaAttributePath)

Example 7 with MetaAttributePath

use of io.crnk.meta.model.MetaAttributePath in project crnk-framework by crnk-project.

the class QueryBuilder method applySelectionSpec.

public Map<String, Integer> applySelectionSpec() {
    MetaDataObject meta = query.getMeta();
    Map<String, Integer> selectionBindings = new HashMap<>();
    int index = 1;
    List<IncludeFieldSpec> includedFields = query.getIncludedFields();
    for (IncludeFieldSpec includedField : includedFields) {
        MetaAttributePath path = meta.resolvePath(includedField.getAttributePath(), attributeFinder);
        E attr = backend.getAttribute(path);
        backend.addSelection(attr, path.toString());
        selectionBindings.put(path.toString(), index++);
    }
    return selectionBindings;
}
Also used : HashMap(java.util.HashMap) MetaDataObject(io.crnk.meta.model.MetaDataObject) IncludeFieldSpec(io.crnk.core.queryspec.IncludeFieldSpec) MetaAttributePath(io.crnk.meta.model.MetaAttributePath)

Aggregations

MetaAttributePath (io.crnk.meta.model.MetaAttributePath)7 MetaDataObject (io.crnk.meta.model.MetaDataObject)3 MetaAttribute (io.crnk.meta.model.MetaAttribute)2 IncludeFieldSpec (io.crnk.core.queryspec.IncludeFieldSpec)1 AnyTypeObject (io.crnk.jpa.query.AnyTypeObject)1 MetaMapAttribute (io.crnk.meta.model.MetaMapAttribute)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 JoinType (javax.persistence.criteria.JoinType)1