Search in sources :

Example 1 with TransformationResource

use of org.structr.rest.resource.TransformationResource in project structr by structr.

the class ResourceHelper method applyViewTransformation.

/**
 * Apply view transformation on final resource, if any
 *
 * @param request
 * @param securityContext
 * @param finalResource
 * @param propertyView
 * @return transformedResource
 * @throws FrameworkException
 */
public static Resource applyViewTransformation(final HttpServletRequest request, final SecurityContext securityContext, final Resource finalResource, final Value<String> propertyView) throws FrameworkException {
    Resource transformedResource = finalResource;
    // add view transformation
    Class type = finalResource.getEntityClass();
    if (type != null) {
        ViewTransformation transformation = StructrApp.getConfiguration().getViewTransformation(type, propertyView.get(securityContext));
        if (transformation != null) {
            transformedResource = transformedResource.tryCombineWith(new TransformationResource(securityContext, transformation));
        }
    }
    return transformedResource;
}
Also used : TransformationResource(org.structr.rest.resource.TransformationResource) ViewFilterResource(org.structr.rest.resource.ViewFilterResource) Resource(org.structr.rest.resource.Resource) ViewTransformation(org.structr.core.ViewTransformation) TransformationResource(org.structr.rest.resource.TransformationResource)

Aggregations

ViewTransformation (org.structr.core.ViewTransformation)1 Resource (org.structr.rest.resource.Resource)1 TransformationResource (org.structr.rest.resource.TransformationResource)1 ViewFilterResource (org.structr.rest.resource.ViewFilterResource)1