Package org.apache.isis.viewer.json.applib

Examples of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions


        final RendererFactory rendererFactory = rendererFactoryRegistry.find(representationType);
        final TypeActionResultReprRenderer renderer = (TypeActionResultReprRenderer) rendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());

        final String url = "domainTypes/" + domainTypeSpec.getFullIdentifier() + "/typeactions/isSupertypeOf/invoke";
        final LinkBuilder linkBuilder = LinkBuilder.newBuilder(getResourceContext(), Rel.SELF, RepresentationType.TYPE_ACTION_RESULT, url);
        final JsonRepresentation arguments = DomainTypeReprRenderer.argumentsTo(getResourceContext(), "subtype", subtypeSpec);
        final JsonRepresentation selfLink = linkBuilder.withArguments(arguments).build();

        final boolean value = subtypeSpec.isOfType(domainTypeSpec);
        renderer.with(domainTypeSpec).withSelf(selfLink).withValue(value);

        return responseOfOk(renderer, Caching.ONE_DAY).build();
View Full Code Here


        final RendererFactory rendererFactory = rendererFactoryRegistry.find(representationType);
        final TypeActionResultReprRenderer renderer = (TypeActionResultReprRenderer) rendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());

        final String url = "domainTypes/" + domainTypeSpec.getFullIdentifier() + "/typeactions/newTransientInstance/invoke";
        final LinkBuilder linkBuilder = LinkBuilder.newBuilder(getResourceContext(), Rel.SELF, RepresentationType.TYPE_ACTION_RESULT, url);
        final JsonRepresentation selfLink = linkBuilder.build();

        final RendererFactory domainObjectRendererFactory = rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
        final DomainObjectReprRenderer domainObjectRenderer = (DomainObjectReprRenderer) domainObjectRendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());
        final ObjectAdapter transientInstance = getResourceContext().getPersistenceSession().createInstance(domainTypeSpec);
        domainObjectRenderer.with(transientInstance).includesSelf();
View Full Code Here

        final String href = linkFromFormalArgs(argumentsQueryString, argsParamName);
        return UrlParserUtils.domainTypeFrom(href);
    }

    private static String linkFromFormalArgs(final String argumentsQueryString, final String paramName) {
        final JsonRepresentation arguments = DomainResourceHelper.readQueryStringAsMap(argumentsQueryString);
        if (!arguments.isLink(paramName)) {
            throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "Args should contain a link '%s'", paramName);
        }

        return arguments.getLink(paramName).getHref();
    }
View Full Code Here

            return "UNKNOWN";
        }
    }

    private void putOptionalCapabilities() {
        final JsonRepresentation optionalCapabilities = JsonRepresentation.newMap();

        optionalCapabilities.mapPut("concurrencyChecking", "no");
        optionalCapabilities.mapPut("transientObjects", "yes");
        optionalCapabilities.mapPut("deleteObjects", "no");
        optionalCapabilities.mapPut("simpleArguments", "no");
        optionalCapabilities.mapPut("partialArguments", "no");
        optionalCapabilities.mapPut("followLinks", "yes");
        optionalCapabilities.mapPut("validateOnly", "no");
        optionalCapabilities.mapPut("pagination", "no");
        optionalCapabilities.mapPut("sorting", "no");
        optionalCapabilities.mapPut("domainModel", "rich");

        representation.mapPut("optionalCapabilities", optionalCapabilities);
    }
View Full Code Here

        }
        return readQueryStringAsMap;
    }

    public <Q> Q getArg(final RequestParameter<Q> requestParameter) {
        final JsonRepresentation queryStringJsonRepr = getQueryStringAsJsonRepr();
        return requestParameter.valueOf(queryStringJsonRepr);
    }
View Full Code Here

        }

    }

    static String jsonFor(final JsonApplicationException ex) {
        final JsonRepresentation jsonRepresentation = ex.getJsonRepresentation();
        if (jsonRepresentation != null) {
            return jsonRepresentation.toString();
        }
        try {
            return JsonMapper.instance().write(ExceptionPojo.create(ex));
        } catch (final Exception e) {
            // fallback
View Full Code Here

        return representation;
    }

    private void addLinkToSelf(final JsonRepresentation representation) {
        final JsonRepresentation link = LinkBuilder.newBuilder(resourceContext, Rel.SELF, getRepresentationType(), "").build();

        final LinkFollower linkFollower = getLinkFollower().follow("links[rel=self]");
        if (linkFollower.matches(link)) {

            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.HOME_PAGE);
            final HomePageReprRenderer renderer = (HomePageReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());

            link.mapPut("value", renderer.render());
        }
        getLinks().arrayAdd(link);
    }
View Full Code Here

        }
        getLinks().arrayAdd(link);
    }

    private void addLinkToVersion() {
        final JsonRepresentation link = LinkBuilder.newBuilder(getResourceContext(), Rel.VERSION, RepresentationType.VERSION, "version").build();

        final LinkFollower linkFollower = getLinkFollower().follow("links[rel=version]");
        if (linkFollower.matches(link)) {

            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.VERSION);
            final VersionReprRenderer renderer = (VersionReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());

            link.mapPut("value", renderer.render());
        }

        getLinks().arrayAdd(link);
    }
View Full Code Here

        getLinks().arrayAdd(link);
    }

    private void addLinkToServices() {

        final JsonRepresentation link = LinkBuilder.newBuilder(getResourceContext(), Rel.SERVICES, RepresentationType.LIST, "services").build();

        final LinkFollower linkFollower = getLinkFollower().follow("links[rel=services]");
        if (linkFollower.matches(link)) {

            final List<ObjectAdapter> serviceAdapters = getResourceContext().getPersistenceSession().getServices();

            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.LIST);

            final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
            renderer.usingLinkToBuilder(new DomainServiceLinkTo()).withSelf("services").with(serviceAdapters);

            link.mapPut("value", renderer.render());
        }

        getLinks().arrayAdd(link);
    }
View Full Code Here

        getLinks().arrayAdd(link);
    }

    private void addLinkToUser() {
        final JsonRepresentation link = LinkBuilder.newBuilder(getResourceContext(), Rel.USER, RepresentationType.USER, "user").build();

        final LinkFollower linkFollower = getLinkFollower().follow("links[rel=user]");
        if (linkFollower.matches(link)) {
            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.USER);
            final UserReprRenderer renderer = (UserReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
            renderer.with(getResourceContext().getAuthenticationSession());

            link.mapPut("value", renderer.render());
        }

        getLinks().arrayAdd(link);
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.