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

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


        return representation;
    }

    private void addResult(final JsonRepresentation representation) {
        final JsonRepresentation result = JsonRepresentation.newMap();
        final ResultType resultType = addResultTo(result);

        if (!resultType.isVoid()) {
            putResultType(representation, resultType);
            representation.mapPut("result", result);
View Full Code Here


    private void putResultType(final JsonRepresentation representation, final ResultType resultType) {
        representation.mapPut("resulttype", resultType.getValue());
    }

    private JsonRepresentation representationWithSelfFor(final ObjectAction action, final JsonRepresentation bodyArgs) {
        final JsonRepresentation links = JsonRepresentation.newArray();
        representation.mapPut("links", links);

        final LinkBuilder selfLinkBuilder = adapterLinkTo.memberBuilder(Rel.SELF, MemberType.ACTION, action, RepresentationType.ACTION_RESULT, "invoke");

        // TODO: remove duplication with AbstractObjectMember#addLinkTo
        final MemberType memberType = MemberType.of(action);
        final Map<String, MutatorSpec> mutators = memberType.getMutators();

        final ActionSemantics semantics = ActionSemantics.determine(getResourceContext(), action);
        final String mutator = semantics.getInvokeKey();
        final MutatorSpec mutatorSpec = mutators.get(mutator);
        selfLinkBuilder.withHttpMethod(mutatorSpec.httpMethod);

        final JsonRepresentation selfLink = selfLinkBuilder.build();

        links.arrayAdd(selfLink);
        selfLink.mapPut("args", bodyArgs);
        return representation;
    }
View Full Code Here

    public void setUp() throws Exception {
        objectSpec = context.mock(ObjectSpecification.class);
        encodableFacet = context.mock(EncodableFacet.class);
        objectAdapter = context.mock(ObjectAdapter.class);

        representation = new JsonRepresentation(TextNode.valueOf("aString"));
        jsonValueEncoder = new JsonValueEncoder();
    }
View Full Code Here

    private void whenReprIsBoolean(final Class<?> correspondingClass) {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(correspondingClass);
        final boolean value = true;
        representation = new JsonRepresentation(BooleanNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    private void whenReprIsInteger(final Class<?> correspondingClass) {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(correspondingClass);
        final int value = 123;
        representation = new JsonRepresentation(IntNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    private void whenReprIsLong(final Class<?> correspondingClass) {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(correspondingClass);
        final long value = 1234567890L;
        representation = new JsonRepresentation(LongNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    private void whenReprIsDouble(final Class<?> correspondingClass) {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(correspondingClass);
        final double value = 123.45;
        representation = new JsonRepresentation(DoubleNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    public void whenReprIsBigInteger() throws Exception {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(BigInteger.class);
        final BigInteger value = BigInteger.valueOf(123);
        representation = new JsonRepresentation(BigIntegerNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    public void whenReprIsBigDecimal() throws Exception {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(BigDecimal.class);
        final BigDecimal value = new BigDecimal("123234234.45612312343535");
        representation = new JsonRepresentation(DecimalNode.valueOf(value));
        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("" + value);
                will(returnValue(objectAdapter));
            }
View Full Code Here

    @Test
    public void whenReprIsString() throws Exception {
        // given
        allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
        allowingObjectSpecCorrespondingClassIs(String.class);
        representation = new JsonRepresentation(TextNode.valueOf("aString"));

        context.checking(new Expectations() {
            {
                one(encodableFacet).fromEncodedString("aString");
                will(returnValue(objectAdapter));
View Full Code Here

TOP

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

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.