Search in sources :

Example 1 with TypedParams

use of io.crnk.legacy.queryParams.params.TypedParams in project crnk-framework by crnk-project.

the class QuerySpecAdapter method getIncludedRelations.

@Override
public TypedParams<IncludedRelationsParams> getIncludedRelations() {
    Map<String, IncludedRelationsParams> params = new HashMap<>();
    addRelations(params, querySpec);
    for (QuerySpec relatedSpec : querySpec.getNestedSpecs()) {
        addRelations(params, relatedSpec);
    }
    return new TypedParams<>(params);
}
Also used : HashMap(java.util.HashMap) TypedParams(io.crnk.legacy.queryParams.params.TypedParams) IncludedRelationsParams(io.crnk.legacy.queryParams.params.IncludedRelationsParams) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 2 with TypedParams

use of io.crnk.legacy.queryParams.params.TypedParams in project crnk-framework by crnk-project.

the class JsonApiQueryParamsParser method parseSortingParameters.

@Override
protected TypedParams<SortingParams> parseSortingParameters(final QueryParamsParserContext context) {
    String sortingKey = RestrictedQueryParamsMembers.sort.name();
    Set<String> rawSortingQueryParams = parseDelimitedParameters(context.getParameterValue(sortingKey));
    Map<String, SortingParams> decodedSortingMap = new LinkedHashMap<>();
    if (!rawSortingQueryParams.isEmpty()) {
        Map<String, RestrictedSortingValues> temporarySortingMap = new LinkedHashMap<>();
        for (String sortParam : rawSortingQueryParams) {
            if (sortParam.startsWith(JSON_API_SORT_INDICATOR_DESC)) {
                temporarySortingMap.put(sortParam.substring(1), RestrictedSortingValues.desc);
            } else {
                temporarySortingMap.put(sortParam, RestrictedSortingValues.asc);
            }
        }
        decodedSortingMap.put(context.getRequestedResourceInformation().getResourceType(), new SortingParams(temporarySortingMap));
    }
    return new TypedParams<>(Collections.unmodifiableMap(decodedSortingMap));
}
Also used : TypedParams(io.crnk.legacy.queryParams.params.TypedParams) SortingParams(io.crnk.legacy.queryParams.params.SortingParams)

Example 3 with TypedParams

use of io.crnk.legacy.queryParams.params.TypedParams in project crnk-framework by crnk-project.

the class JsonApiQueryParamsParser method parseIncludedRelationsParameters.

@Override
protected TypedParams<IncludedRelationsParams> parseIncludedRelationsParameters(QueryParamsParserContext context) {
    String includeKey = RestrictedQueryParamsMembers.include.name();
    Map<String, Set<String>> inclusions = filterQueryParamsByKey(context, includeKey);
    Map<String, IncludedRelationsParams> decodedInclusions = new LinkedHashMap<>();
    if (inclusions.containsKey(RestrictedQueryParamsMembers.include.name())) {
        Set<Inclusion> inclusionSet = new LinkedHashSet<>();
        for (String inclusion : inclusions.get(RestrictedQueryParamsMembers.include.name())) {
            inclusionSet.add(new Inclusion(inclusion));
        }
        decodedInclusions.put(context.getRequestedResourceInformation().getResourceType(), new IncludedRelationsParams(inclusionSet));
    }
    return new TypedParams<>(Collections.unmodifiableMap(decodedInclusions));
}
Also used : Inclusion(io.crnk.legacy.queryParams.include.Inclusion) TypedParams(io.crnk.legacy.queryParams.params.TypedParams) IncludedRelationsParams(io.crnk.legacy.queryParams.params.IncludedRelationsParams)

Example 4 with TypedParams

use of io.crnk.legacy.queryParams.params.TypedParams in project crnk-framework by crnk-project.

the class QuerySpecAdapter method getIncludedFields.

@Override
public TypedParams<IncludedFieldsParams> getIncludedFields() {
    Map<String, IncludedFieldsParams> params = new HashMap<>();
    addFields(params, querySpec);
    for (QuerySpec relatedSpec : querySpec.getNestedSpecs()) {
        addFields(params, relatedSpec);
    }
    return new TypedParams<>(params);
}
Also used : IncludedFieldsParams(io.crnk.legacy.queryParams.params.IncludedFieldsParams) HashMap(java.util.HashMap) TypedParams(io.crnk.legacy.queryParams.params.TypedParams) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Aggregations

TypedParams (io.crnk.legacy.queryParams.params.TypedParams)4 QuerySpec (io.crnk.core.queryspec.QuerySpec)2 IncludedRelationsParams (io.crnk.legacy.queryParams.params.IncludedRelationsParams)2 HashMap (java.util.HashMap)2 Inclusion (io.crnk.legacy.queryParams.include.Inclusion)1 IncludedFieldsParams (io.crnk.legacy.queryParams.params.IncludedFieldsParams)1 SortingParams (io.crnk.legacy.queryParams.params.SortingParams)1