Search in sources :

Example 1 with UriBuilder

use of org.springframework.web.util.UriBuilder in project dhis2-core by dhis2.

the class GistPager method computeBaseURL.

public static URI computeBaseURL(GistQuery query, Map<String, String[]> params, Function<Class<?>, Schema> schemaByType) {
    UriBuilder url = UriComponentsBuilder.fromUriString(query.getEndpointRoot());
    Owner owner = query.getOwner();
    if (owner != null) {
        Schema o = schemaByType.apply(owner.getType());
        url.pathSegment(o.getRelativeApiEndpoint().substring(1), owner.getId(), o.getProperty(owner.getCollectionProperty()).key(), "gist");
    } else {
        Schema s = schemaByType.apply(query.getElementType());
        url.pathSegment(s.getRelativeApiEndpoint().substring(1), "gist");
    }
    params.forEach(url::queryParam);
    return url.build();
}
Also used : Owner(org.hisp.dhis.gist.GistQuery.Owner) Schema(org.hisp.dhis.schema.Schema) UriBuilder(org.springframework.web.util.UriBuilder)

Aggregations

Owner (org.hisp.dhis.gist.GistQuery.Owner)1 Schema (org.hisp.dhis.schema.Schema)1 UriBuilder (org.springframework.web.util.UriBuilder)1