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

Examples of org.apache.isis.viewer.json.applib.JsonRepresentation.mapPut()


        paramRep.mapPut("id", param.getId());
        paramRep.mapPut("name", param.getName());
        paramRep.mapPut("description", param.getDescription());
        final Object paramChoices = choicesFor(param);
        if (paramChoices != null) {
            paramRep.mapPut("choices", paramChoices);
        }
        final Object paramDefault = defaultFor(param);
        if (paramDefault != null) {
            paramRep.mapPut("default", paramDefault);
        }
View Full Code Here


        if (paramChoices != null) {
            paramRep.mapPut("choices", paramChoices);
        }
        final Object paramDefault = defaultFor(param);
        if (paramDefault != null) {
            paramRep.mapPut("default", paramDefault);
        }
        return paramRep;
    }

    private Object choicesFor(final ObjectActionParameter param) {
View Full Code Here

public class UrlParserUtilsTest {

    @Test
    public void oidFromLink() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/objects/OID:1");
        final String oidFromHref = UrlParserUtils.oidFromLink(link);
        assertEquals("OID:1", oidFromHref);
    }

    @Test
View Full Code Here

    }

    @Test
    public void domainTypeFromLink() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }

    @Test
View Full Code Here

    }

    @Test
    public void domainTypeFromLinkTrailingSlash() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer/");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }

    @Test
View Full Code Here

    }

    @Test
    public void domainTypeFromLinkFollowingStuff() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer/otherStuffHere");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }

}
View Full Code Here

        if (mutatorSpec.arguments.isNone()) {
            return null;
        }
        if (mutatorSpec.arguments.isOne()) {
            final JsonRepresentation repr = JsonRepresentation.newMap();
            repr.mapPut("value", NullNode.getInstance()); // force a null into
                                                          // the map
            return repr;
        }
        // overridden by actions
        throw new UnsupportedOperationException("override mutatorArgs() to populate for many arguments");
View Full Code Here

        selfLinkBuilder.withHttpMethod(mutatorSpec.httpMethod);

        final JsonRepresentation selfLink = selfLinkBuilder.build();

        links.arrayAdd(selfLink);
        selfLink.mapPut("args", bodyArgs);
        return representation;
    }

    protected RendererFactoryRegistry getRendererFactoryRegistry() {
        // TODO: yuck
View Full Code Here

    }

    public static JsonRepresentation readParameterMapAsMap(final Map<String, String[]> parameterMap) {
        final JsonRepresentation map = JsonRepresentation.newMap();
        for (final Map.Entry<String, String[]> parameter : parameterMap.entrySet()) {
            map.mapPut(parameter.getKey(), parameter.getValue()[0]);
        }
        return map;
    }

    public static JsonRepresentation readQueryStringAsMap(final String queryString) {
View Full Code Here

    public static JsonRepresentation argumentsTo(final ResourceContext resourceContext, final String paramName, final ObjectSpecification objectSpec) {
        final JsonRepresentation arguments = JsonRepresentation.newMap();
        final JsonRepresentation link = JsonRepresentation.newMap();
        arguments.mapPut(paramName, link);
        if (objectSpec != null) {
            link.mapPut("href", resourceContext.urlFor("domainTypes/" + objectSpec.getFullIdentifier()));
        } else {
            link.mapPut("href", NullNode.instance);
        }
        return arguments;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.