Package org.apache.isis.viewer.json.viewer.representations

Examples of org.apache.isis.viewer.json.viewer.representations.Representation


        this.objectAdapter = objectAdapter;
    }
   
    public Representation build() {
        RepContext repContext = this.repContext.underAttribute("_self");
        Representation selfLink = LinkRepBuilder.newBuilder(repContext, "link", url()).build();
        Representation selfType = LinkRepBuilder.newTypeBuilder(repContext, "type", objectAdapter.getSpecification()).build();
        String title = objectAdapter.titleString();
        Representation iconLink = LinkRepBuilder.newBuilder(repContext, "icon", icon()).build();
        Representation self = new Representation();
        self.put("link", selfLink);
        self.put("type", selfType);
        self.put("title", title);
        self.put("icon", iconLink);
        representation.put("_self", self);
        withAllMembers(objectAdapter);
        if(!members.isEmpty()) {
            for(Map.Entry<String, Representation> entry: members.entrySet()) {
                String memberId = entry.getKey();
                Representation memberRep = entry.getValue();
                representation.put(memberId, memberRep);
            }
        }
        return representation;
    }
View Full Code Here


                continue;
            }
            String id = assoc.getId();
            if(assoc instanceof OneToOneAssociation) {
                OneToOneAssociation property = (OneToOneAssociation)assoc;
                Representation propertyRep = PropertyRepBuilder.newBuilder(repContext.underAttribute(id), objectAdapter, property).build();
                withMember(id, propertyRep);
            }
            if(assoc instanceof OneToManyAssociation) {
                OneToManyAssociation collection = (OneToManyAssociation) assoc;
                Representation collectionRep = CollectionRepBuilder.newBuilder(repContext.underAttribute(id), objectAdapter, collection).build();
                withMember(id, collectionRep);
            }
        }
       
        List<ObjectAction> actions = objectAdapter.getSpecification().getObjectActionsAll();
        for (ObjectAction action : actions) {
            Consent visibility = action.isVisible(getSession(), objectAdapter);
            if(!visibility.isAllowed()) {
                continue;
            }
            String id = action.getId();
            Representation actionRep = ActionRepBuilder.newBuilder(repContext.underAttribute(id), objectAdapter, action).build();
            withMember(id, actionRep);
        }
    }
View Full Code Here

        this.memberRepType = repContext.hasAttribute()?MemberRepType.INLINE:MemberRepType.STANDALONE;
    }

    protected void putSelfIfRequired() {
        if(memberRepType.hasSelf()) {
            Representation selfRep = MemberSelfRepBuilder.newBuilder(repContext, objectAdapter, memberType, objectMember).build();
            representation.put("self", selfRep);
        }
    }
View Full Code Here

    protected void putMemberTypeRep() {
        representation.put("memberType", memberType);
    }

    protected void putTypeRep() {
        Representation typeRep = LinkRepBuilder.newTypeBuilder(repContext, "type", memberType.specFor(objectMember)).build();
        representation.put("type", typeRep);
    }
View Full Code Here

        for(String mutator: mutators.keySet()) {
            MutatorSpec mutatorSpec = mutators.get(mutator);
            if(hasMemberFacet(mutatorSpec.mutatorFacetType)) {
                String urlForMember = urlForMember(mutatorSpec.suffix);
                List<String> body = mutatorArgValues(mutatorSpec);
                Representation detailsLink =
                    LinkRepBuilder.newBuilder(repContext, mutator, urlForMember)
                        .withHttpMethod(mutatorSpec.httpMethod)
                        .withBody(body)
                        .build();
                representation.put(mutator, detailsLink);
View Full Code Here

    protected void putDetailsIfRequired() {
        if(!memberRepType.hasLinkToDetails()) {
            return;
        }
        String urlForMember = urlForMember();
        Representation detailsLink = LinkRepBuilder.newBuilder(repContext, "details", urlForMember).build();
        representation.put("details", detailsLink);
    }
View Full Code Here

    @Override
    @Produces(MediaType.APPLICATION_JSON)
    public String resources() {
        init();
       
        Representation representation = new Representation();
        representation.put("user", linkTo("user"));
        representation.put("services", linkTo("services"));
       
        return asJson(representation);
    }
View Full Code Here

    // //////////////////////////////////////////////////////////////
    // Rendering
    // //////////////////////////////////////////////////////////////

    protected String jsonRepresentionFrom(RepresentationBuilder builder) {
        Representation representation = builder.build();
        return asJson(representation);
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.viewer.representations.Representation

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.