Search in sources :

Example 6 with EntityProjectionMaker

use of com.yahoo.elide.jsonapi.EntityProjectionMaker in project elide by yahoo.

the class IncludedProcessor method addIncludedResources.

/**
 * Adds the requested relation resources to the included block of the JsonApiDocument.
 */
private void addIncludedResources(JsonApiDocument jsonApiDocument, PersistentResource rec, List<String> requestedRelationPaths) {
    EntityProjectionMaker maker = new EntityProjectionMaker(rec.getDictionary(), rec.getRequestScope());
    EntityProjection projection = maker.parseInclude(rec.getResourceType());
    // Process each include relation path
    requestedRelationPaths.forEach(pathParam -> {
        List<String> pathList = Arrays.asList(pathParam.split(RELATION_PATH_SEPARATOR));
        pathList.forEach(requestedRelationPath -> {
            List<String> relationPath = Lists.newArrayList(requestedRelationPath.split(RELATION_PATH_DELIMITER));
            addResourcesForPath(jsonApiDocument, rec, relationPath, projection);
        });
    });
}
Also used : EntityProjection(com.yahoo.elide.core.request.EntityProjection) EntityProjectionMaker(com.yahoo.elide.jsonapi.EntityProjectionMaker)

Aggregations

EntityProjectionMaker (com.yahoo.elide.jsonapi.EntityProjectionMaker)6 RequestScope (com.yahoo.elide.core.RequestScope)4 PatchRequestScope (com.yahoo.elide.jsonapi.extensions.PatchRequestScope)4 JsonApiDocument (com.yahoo.elide.jsonapi.models.JsonApiDocument)4 BaseVisitor (com.yahoo.elide.jsonapi.parser.BaseVisitor)4 BadRequestException (com.yahoo.elide.core.exceptions.BadRequestException)2 EntityProjection (com.yahoo.elide.core.request.EntityProjection)2 Elide (com.yahoo.elide.Elide)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 User (com.yahoo.elide.core.security.User)1 DeleteVisitor (com.yahoo.elide.jsonapi.parser.DeleteVisitor)1 GetVisitor (com.yahoo.elide.jsonapi.parser.GetVisitor)1 PatchVisitor (com.yahoo.elide.jsonapi.parser.PatchVisitor)1 PostVisitor (com.yahoo.elide.jsonapi.parser.PostVisitor)1 URISyntaxException (java.net.URISyntaxException)1 Pair (org.apache.commons.lang3.tuple.Pair)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1