use of io.crnk.core.queryspec.IncludeFieldSpec in project crnk-framework by crnk-project.
the class QuerySpecAdapter method addFields.
private void addFields(Map<String, IncludedFieldsParams> params, QuerySpec spec) {
if (!spec.getIncludedFields().isEmpty()) {
Set<String> set = new HashSet<>();
for (IncludeFieldSpec relation : spec.getIncludedFields()) {
set.add(StringUtils.join(".", relation.getAttributePath()));
}
params.put(getResourceType(spec), new IncludedFieldsParams(set));
}
}
use of io.crnk.core.queryspec.IncludeFieldSpec in project crnk-framework by crnk-project.
the class DefaultQueryParamsConverter method applyIncludedFields.
protected void applyIncludedFields(QuerySpec spec, QueryParams queryParams) {
List<IncludeFieldSpec> includedFields = spec.getIncludedFields();
Map<String, IncludedFieldsParams> decodedSparseMap = new LinkedHashMap<>();
if (includedFields != null && !includedFields.isEmpty()) {
String resourceType = getResourceType(spec.getResourceClass());
Set<String> pathSet = new LinkedHashSet<>();
for (IncludeFieldSpec includedField : includedFields) {
String path = joinPath(includedField.getAttributePath());
pathSet.add(path);
}
IncludedFieldsParams includedFieldsParams = new IncludedFieldsParams(pathSet);
decodedSparseMap.put(resourceType, includedFieldsParams);
}
queryParams.setIncludedFields(new TypedParams<>(Collections.unmodifiableMap(decodedSparseMap)));
}
use of io.crnk.core.queryspec.IncludeFieldSpec 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;
}
Aggregations