Package org.apache.isis.viewer.restfulobjects.applib

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation$HasLinkToSelf


        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = restfulResponse.getEntity();

        final JsonRepresentation membersList = repr.getMembers();
        assertThat(membersList, isMap());

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("list");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // followed

        actionRepr = membersList.getRepresentation("newEntity");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(nullValue())); // not followed
    }
View Full Code Here


        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = restfulResponse.getEntity();

        final JsonRepresentation membersList = repr.getMembers();
        assertThat(membersList, isMap());

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("list");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // followed

        actionRepr = membersList.getRepresentation("newEntity");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // also followed
    }
View Full Code Here

                            if (jsonResp.getStatus() != statusCode) {
                                return false;
                            }
                        }
                        if (selfHref != null) {
                            JsonRepresentation entity;
                            try {
                                entity = jsonResp.getEntity();
                            } catch (Exception e) {
                                return false;
                            }
                            if(entity == null) {
                                return false;
                            }
                            LinkRepresentation selfLink = entity.getLink("links[rel=self]");
                            if(selfLink == null) {
                                return false;
                            }
                            if (!selfLink.getHref().equals(selfHref)) {
                                return false;
View Full Code Here

        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = restfulResponse.getEntity();

        final JsonRepresentation actionLinkRepr = repr.getAction(actionId);
        return actionLinkRepr.getRepresentation("links[rel=%s].value", Rel.DETAILS.getName());
    }
View Full Code Here

        // to its details
        walker.walk("values[memberType=action].details");

        // and when find the invoke body for the "newEntity" action and then
        // walk the action using the body
        final JsonRepresentation newEntityActionDetails = walker.getEntity();
        final JsonRepresentation newEntityActionInvokeBody = newEntityActionDetails.getArray("invoke.body");
        walker.walk("invoke", newEntityActionInvokeBody);

        // and when walk the link to the returned object
        walker.walk("link");

        // then the returned object is created with its OID
        final JsonRepresentation newEntityDomainObject = walker.getEntity();
        assertThat(newEntityDomainObject.getString("_self.link.href"), matches(".+/objects/OID:[\\d]+$"));
    }
View Full Code Here

    @Test
    public void jdkPropertiesUpdated() throws Exception {
       
        final DomainObjectRepresentation domainObjectRepr = getObjectRepr("JDKV", "29");
        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
        final JsonRepresentation argRepr = updateLink.getArguments();

        final BigDecimal bd = new BigDecimal("12345678901234567.789");
        final BigInteger bi = new BigInteger("12345678901234567890");
        final java.sql.Date sqld = new java.sql.Date(114,4,1);
        final java.sql.Time sqlt = new java.sql.Time(13,0,0);
        final java.sql.Timestamp sqlts = new java.sql.Timestamp(114,4,1,13,0,0,0);
        final java.util.Date d = new java.util.Date(114,4,1,13,0,0);
        final String e = "ORANGE";
        final String s = "Tangerine";
       
        argRepr.mapPut("bigDecimalProperty.value", bd);
        argRepr.mapPut("bigIntegerProperty.value", bi);
        argRepr.mapPut("javaSqlDateProperty.value", asIsoNoT(sqld)); // 1-may-2014
        argRepr.mapPut("javaSqlTimeProperty.value", asIsoOnlyT(sqlt)); // 1 pm
        argRepr.mapPut("javaSqlTimestampProperty.value", sqlts.getTime());
        argRepr.mapPut("javaUtilDateProperty.value", asIso(d));
        argRepr.mapPut("myEnum.value", e);
        argRepr.mapPut("stringProperty.value", s);
       
        final RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
View Full Code Here

       
        final DomainObjectRepresentation domainObjectRepr = getObjectRepr("JODA", "73");
       
        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
       
        final JsonRepresentation argRepr = updateLink.getArguments();
       
        final LocalDate ld = new LocalDate(2013,5,1);
        final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
        final DateTime dt = new DateTime(2013,2,1,14,15,0);
        final String s = "New string";
       
        argRepr.mapPut("localDateProperty.value", asIsoNoT(ld.toDate()));
        argRepr.mapPut("localDateTimeProperty.value", asIso(ldt.toDate()));
        argRepr.mapPut("dateTimeProperty.value", asIso(dt.toDate()));
        argRepr.mapPut("stringProperty.value", s);

        final RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
View Full Code Here

    public Response persist(@PathParam("domainType") String domainType, final InputStream object) {

        init(RepresentationType.DOMAIN_OBJECT, Where.OBJECT_FORMS);

        final String objectStr = DomainResourceHelper.asStringUtf8(object);
        final JsonRepresentation objectRepr = DomainResourceHelper.readAsMap(objectStr);
        if (!objectRepr.isMap()) {
            throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Body is not a map; got %s", objectRepr);
        }

        final ObjectSpecification domainTypeSpec = getSpecificationLoader().lookupBySpecId(ObjectSpecId.of(domainType));
        if (domainTypeSpec == null) {
            throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Could not determine type of domain object to persist (no class with domainType Id of '%s')", domainType);
        }

        final ObjectAdapter objectAdapter = getResourceContext().getPersistenceSession().createTransientInstance(domainTypeSpec);

        final JsonRepresentation propertiesList = objectRepr.getArrayEnsured("members[memberType=property]");
        if (propertiesList == null) {
            throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Could not find properties list (no members[memberType=property]); got %s", objectRepr);
        }
        if (!DomainResourceHelper.copyOverProperties(getResourceContext(), objectAdapter, propertiesList)) {
            throw RestfulObjectsApplicationException.createWithBody(HttpStatusCode.BAD_REQUEST, objectRepr, "Illegal property value");
View Full Code Here

    public Response object(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, final InputStream object) {

        init(RepresentationType.DOMAIN_OBJECT, Where.OBJECT_FORMS);

        final String objectStr = DomainResourceHelper.asStringUtf8(object);
        final JsonRepresentation argRepr = DomainResourceHelper.readAsMap(objectStr);
        if (!argRepr.isMap()) {
            throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Body is not a map; got %s", argRepr);
        }

        final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId);
View Full Code Here

    @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke")
    @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
    public Response invokeActionQueryOnly(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, @QueryParam("x-isis-querystring") final String xIsisQueryString) {
        init(RepresentationType.ACTION_RESULT, Where.STANDALONE_TABLES, xIsisQueryString);

        final JsonRepresentation arguments = getResourceContext().getQueryStringAsJsonRepr();

        final ObjectAdapter objectAdapter = getObjectAdapterElseThrowNotFound(domainType, instanceId);
        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);

        return helper.invokeActionQueryOnly(actionId, arguments, getResourceContext().getWhere());
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation$HasLinkToSelf

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.