Examples of ObjectSpecification


Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

            representation.mapPut("maxLength", maxLength.value());
        }
    }

    private void addLinkToReturnTypeIfAny() {
        final ObjectSpecification returnType = getObjectFeature().getSpecification();
        if (returnType == null) {
            return;
        }
        final LinkBuilder linkBuilder = DomainTypeReprRenderer.newLinkToBuilder(getRendererContext(), Rel.RETURN_TYPE, returnType);
        getLinks().arrayAdd(linkBuilder.build());
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

    public boolean isMemberVisible() {
        return visibility().isAllowed();
    }

    protected <F extends Facet> F getMemberSpecFacet(final Class<F> facetType) {
        final ObjectSpecification otoaSpec = objectMember.getSpecification();
        return otoaSpec.getFacet(facetType);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

   
    public static Object asObject(final ObjectAdapter objectAdapter) {
        if (objectAdapter == null) {
            throw new IllegalArgumentException("objectAdapter cannot be null");
        }
        final ObjectSpecification objectSpec = objectAdapter.getSpecification();

        final JsonValueConverter jvc = converterBySpec.get(objectSpec.getSpecId());
        if(jvc != null) {
            return jvc.asObject(objectAdapter);
        }
       
        // else
        final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
        if (encodableFacet == null) {
            throw new IllegalArgumentException("objectSpec expected to have EncodableFacet");
        }
        return encodableFacet.toEncodedString(objectAdapter);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

        }
    }

    private ResultType addResultTo(final JsonRepresentation result) {

        final ObjectSpecification returnType = this.action.getReturnType();

        if (returnType.getCorrespondingClass() == void.class) {
            // void
            return ResultType.VOID;
        }

        final CollectionFacet collectionFacet = returnType.getFacet(CollectionFacet.class);
        if (collectionFacet != null) {
            // collection

            if(returnedAdapter != null) {
                final Collection<ObjectAdapter> collectionAdapters = collectionFacet.collection(returnedAdapter);
   
                final ListReprRenderer renderer = new ListReprRenderer(rendererContext, null, result).withElementRel(Rel.ELEMENT);
                renderer.with(collectionAdapters).withReturnType(action.getReturnType()).withElementType(returnedAdapter.getElementSpecification());
   
                renderer.render();
            }
            return ResultType.LIST;
        }

        final EncodableFacet encodableFacet = returnType.getFacet(EncodableFacet.class);
        if (encodableFacet != null) {
            // scalar

            if(returnedAdapter != null) {
                final ScalarValueReprRenderer renderer = new ScalarValueReprRenderer(rendererContext, null, result);
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

    private void addValue() {
        final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
       
        // use the runtime type if we have a value, else the compile time type of the member otherwise
        final ObjectSpecification spec = valueAdapter != null? valueAdapter.getSpecification(): objectMember.getSpecification();
       
        final ValueFacet valueFacet = spec.getFacet(ValueFacet.class);
        if (valueFacet != null) {
            JsonValueEncoder.appendValueAndFormat(spec, valueAdapter, representation);
            return;
        }

        final RenderFacet renderFacet = objectMember.getFacet(RenderFacet.class);
        boolean eagerlyRender = renderFacet != null && renderFacet.value() == Type.EAGERLY && rendererContext.canEagerlyRender(valueAdapter);

        if(valueAdapter == null) {
            representation.mapPut("value", NullNode.getInstance());
        } else {
            final TitleFacet titleFacet = spec.getFacet(TitleFacet.class);
            final String title = titleFacet.title(valueAdapter, rendererContext.getLocalization());
           
            final LinkBuilder valueLinkBuilder = DomainObjectReprRenderer.newLinkToBuilder(rendererContext, Rel.VALUE, valueAdapter).withTitle(title);
            if(eagerlyRender) {
                final DomainObjectReprRenderer renderer = new DomainObjectReprRenderer(rendererContext, getLinkFollowSpecs(), JsonRepresentation.newMap());
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
            // REVIEW: previously was using the spec of the member, but think instead it should be the spec of the adapter itself
            // final ObjectSpecification choiceSpec = objectMember.getSpecification();
           
            // REVIEW: check that it works for ToDoItem$Category, though...
            final ObjectSpecification choiceSpec = objectAdapter.getSpecification();
            list.add(DomainObjectReprRenderer.valueOrRef(rendererContext, choiceAdapter, choiceSpec));
        }
        return list;
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

        final DomainServiceLinkTo linkTo = new DomainServiceLinkTo();
        return linkTo.usingUrlBase(getRendererContext()).with(contributingServiceAdapter());
    }

    private ObjectAdapter contributingServiceAdapter() {
        final ObjectSpecification serviceType = objectMember.getOnType();
        final List<ObjectAdapter> serviceAdapters = getServiceAdapters();
        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
            if (serviceAdapter.getSpecification() == serviceType) {
                return serviceAdapter;
            }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

        }
        final List<Object> list = Lists.newArrayList();
        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
            // REVIEW: previously was using the spec of the parameter, but think instead it should be the spec of the adapter itself
            // final ObjectSpecification choiceSpec = param.getSpecification();
            final ObjectSpecification choiceSpec = choiceAdapter.getSpecification();
            list.add(DomainObjectReprRenderer.valueOrRef(rendererContext, choiceAdapter, choiceSpec));
        }
        return list;
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

        if (defaultAdapter == null) {
            return null;
        }
        // REVIEW: previously was using the spec of the parameter, but think instead it should be the spec of the adapter itself
        // final ObjectSpecification defaultSpec = param.getSpecification();
        final ObjectSpecification defaultSpec = defaultAdapter.getSpecification();
        return DomainObjectReprRenderer.valueOrRef(rendererContext, defaultAdapter, defaultSpec);
    }
View Full Code Here

Examples of org.apache.isis.core.metamodel.spec.ObjectSpecification

    protected void addLinkToElementTypeIfAny() {
        final TypeOfFacet facet = getObjectFeature().getFacet(TypeOfFacet.class);
        if (facet == null) {
            return;
        }
        final ObjectSpecification typeOfSpec = facet.valueSpec();
        final LinkBuilder linkBuilder = DomainTypeReprRenderer.newLinkToBuilder(getRendererContext(), Rel.ELEMENT_TYPE, typeOfSpec);
        getLinks().arrayAdd(linkBuilder.build());
    }
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.