use of io.crnk.core.queryspec.IncludeRelationSpec in project crnk-framework by crnk-project.
the class QuerySpecAdapter method addRelations.
private void addRelations(Map<String, IncludedRelationsParams> params, QuerySpec spec) {
if (!spec.getIncludedRelations().isEmpty()) {
Set<Inclusion> set = new HashSet<>();
for (IncludeRelationSpec relation : spec.getIncludedRelations()) {
set.add(new Inclusion(StringUtils.join(".", relation.getAttributePath())));
}
params.put(getResourceType(spec), new IncludedRelationsParams(set));
}
}
use of io.crnk.core.queryspec.IncludeRelationSpec in project crnk-framework by crnk-project.
the class DefaultQueryParamsConverter method applyRelatedFields.
protected void applyRelatedFields(QuerySpec spec, QueryParams queryParams) {
List<IncludeRelationSpec> includedRelations = spec.getIncludedRelations();
Map<String, IncludedRelationsParams> decodedSparseMap = new LinkedHashMap<>();
if (includedRelations != null && !includedRelations.isEmpty()) {
String resourceType = spec.getResourceType() != null ? spec.getResourceType() : getResourceType(spec.getResourceClass());
Set<Inclusion> inclusions = new LinkedHashSet<>();
for (IncludeRelationSpec relationSpec : includedRelations) {
for (String attrPath : relationSpec.getAttributePath()) {
Inclusion inclusion = new Inclusion(attrPath);
inclusions.add(inclusion);
}
}
IncludedRelationsParams includedRelationsParams = new IncludedRelationsParams(Collections.unmodifiableSet(inclusions));
decodedSparseMap.put(resourceType, includedRelationsParams);
}
queryParams.setIncludedRelations(new TypedParams<>(Collections.unmodifiableMap(decodedSparseMap)));
}
Aggregations