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.interactions.managed.ManagedAction;
024import org.apache.isis.core.metamodel.interactions.managed.ManagedCollection;
025import org.apache.isis.core.metamodel.interactions.managed.ManagedProperty;
026import org.apache.isis.core.metamodel.spec.ManagedObject;
027import org.apache.isis.viewer.restfulobjects.rendering.IResourceContext;
028import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ObjectAndActionInvocation;
029
030/**
031 * Configure the Restful Objects viewer to emit custom representations (rather than the
032 * standard representations defined in the RO spec).
033 *
034 * <p>
035 * This interface is EXPERIMENTAL and may change in the future.
036 * </p>
037 */
038public interface RepresentationService {
039
040    /**
041     * As returned by {@link resourceContext6#getIntent()}, applies only to the representation of
042     * domain objects.
043     */
044    enum Intent {
045        /**
046         * object just created, ie return a 201
047         */
048        JUST_CREATED,
049        /**
050         * object already persistent, ie return a 200
051         */
052        ALREADY_PERSISTENT,
053        /**
054         * representation is not of a domain object, so does not apply.
055         */
056        NOT_APPLICABLE
057    }
058
059    Response objectRepresentation(
060            IResourceContext resourceContext,
061            ManagedObject objectAdapter);
062
063    Response propertyDetails(
064            IResourceContext resourceContext,
065            ManagedProperty objectAndProperty);
066
067    Response collectionDetails(
068            IResourceContext resourceContext,
069            ManagedCollection objectAndCollection);
070
071    Response actionPrompt(
072            IResourceContext resourceContext,
073            ManagedAction objectAndAction);
074
075    Response actionResult(
076            IResourceContext resourceContext,
077            ObjectAndActionInvocation objectAndActionInvocation);
078
079}