001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *        http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 */
019package org.apache.isis.viewer.restfulobjects.rendering.service;
020
021import javax.ws.rs.core.Response;
022
023import org.apache.isis.core.metamodel.spec.ManagedObject;
024import org.apache.isis.viewer.restfulobjects.rendering.IResourceContext;
025import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ActionResultReprRenderer;
026import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.MemberReprMode;
027import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAndAction;
028import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAndActionInvocation;
029import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAndCollection;
030import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAndProperty;
031
032/**
033 * Configure the Restful Objects viewer to emit custom representations (rather than the
034 * standard representations defined in the RO spec).
035 *
036 * <p>
037 * This interface is EXPERIMENTAL and may change in the future.
038 * </p>
039 */
040public interface RepresentationService {
041
042    /**
043     * As returned by {@link resourceContext6#getIntent()}, applies only to the representation of
044     * domain objects.
045     */
046    enum Intent {
047        /**
048         * object just created, ie return a 201
049         */
050        JUST_CREATED,
051        /**
052         * object already persistent, ie return a 200
053         */
054        ALREADY_PERSISTENT,
055        /**
056         * representation is not of a domain object, so does not apply.
057         */
058        NOT_APPLICABLE
059    }
060
061    Response objectRepresentation(
062            IResourceContext resourceContext,
063            ManagedObject objectAdapter);
064
065    Response propertyDetails(
066            IResourceContext resourceContext,
067            ObjectAndProperty objectAndProperty,
068            MemberReprMode memberReprMode);
069
070    Response collectionDetails(
071            IResourceContext resourceContext,
072            ObjectAndCollection objectAndCollection,
073            MemberReprMode memberReprMode);
074
075    Response actionPrompt(
076            IResourceContext resourceContext,
077            ObjectAndAction objectAndAction);
078
079    Response actionResult(
080            IResourceContext resourceContext,
081            ObjectAndActionInvocation objectAndActionInvocation,
082            ActionResultReprRenderer.SelfLink selfLink);
083    
084
085}