incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1234515 [11/17] - in /incubator/isis/trunk/framework/viewer: ./ bdd/ bdd/common/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/ bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/components/ bdd/common/src/main/java/or...
Date Sun, 22 Jan 2012 14:19:36 GMT
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java Sun Jan 22 14:18:52 2012
@@ -1,112 +1,112 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import java.util.Collection;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.viewer.json.applib.JsonRepresentation;
-import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.applib.links.Rel;
-import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
-import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
-import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
-
-public class ListReprRenderer extends ReprRendererAbstract<ListReprRenderer, Collection<ObjectAdapter>> {
-
-    public static class Factory extends ReprRendererFactoryAbstract {
-        public Factory() {
-            super(RepresentationType.LIST);
-        }
-
-        @Override
-        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
-            return new ListReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
-        }
-    }
-
-    private ObjectAdapterLinkTo linkTo;
-    private Collection<ObjectAdapter> objectAdapters;
-    private ObjectSpecification elementType;
-    private ObjectSpecification returnType;
-
-    private ListReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
-        super(resourceContext, linkFollower, representationType, representation);
-        usingLinkToBuilder(new DomainObjectLinkTo());
-    }
-
-    public ListReprRenderer usingLinkToBuilder(final ObjectAdapterLinkTo objectAdapterLinkToBuilder) {
-        this.linkTo = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
-        return this;
-    }
-
-    @Override
-    public ListReprRenderer with(final Collection<ObjectAdapter> objectAdapters) {
-        this.objectAdapters = objectAdapters;
-        return this;
-    }
-
-    public ListReprRenderer withReturnType(final ObjectSpecification returnType) {
-        this.returnType = returnType;
-        return this;
-    }
-
-    public ListReprRenderer withElementType(final ObjectSpecification elementType) {
-        this.elementType = elementType;
-        return this;
-    }
-
-    @Override
-    public JsonRepresentation render() {
-        addValue();
-
-        addLink(Rel.RETURN_TYPE, returnType);
-        addLink(Rel.ELEMENT_TYPE, elementType);
-
-        getExtensions();
-
-        return representation;
-    }
-
-    private void addValue() {
-        if (objectAdapters == null) {
-            return;
-        }
-
-        final JsonRepresentation values = JsonRepresentation.newArray();
-        final LinkFollower linkFollower = getLinkFollower().follow("value");
-
-        for (final ObjectAdapter adapter : objectAdapters) {
-            final JsonRepresentation linkToObject = linkTo.with(adapter).builder().build();
-            values.arrayAdd(linkToObject);
-
-            if (linkFollower.matches(linkToObject)) {
-                final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.DOMAIN_OBJECT);
-                final DomainObjectReprRenderer renderer = (DomainObjectReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
-                final JsonRepresentation domainObject = renderer.with(adapter).render();
-                linkToObject.mapPut("value", domainObject);
-            }
-        }
-        representation.mapPut("value", values);
-    }
-
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import java.util.Collection;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.links.Rel;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
+
+public class ListReprRenderer extends ReprRendererAbstract<ListReprRenderer, Collection<ObjectAdapter>> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+        public Factory() {
+            super(RepresentationType.LIST);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+            return new ListReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
+        }
+    }
+
+    private ObjectAdapterLinkTo linkTo;
+    private Collection<ObjectAdapter> objectAdapters;
+    private ObjectSpecification elementType;
+    private ObjectSpecification returnType;
+
+    private ListReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
+        super(resourceContext, linkFollower, representationType, representation);
+        usingLinkToBuilder(new DomainObjectLinkTo());
+    }
+
+    public ListReprRenderer usingLinkToBuilder(final ObjectAdapterLinkTo objectAdapterLinkToBuilder) {
+        this.linkTo = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
+        return this;
+    }
+
+    @Override
+    public ListReprRenderer with(final Collection<ObjectAdapter> objectAdapters) {
+        this.objectAdapters = objectAdapters;
+        return this;
+    }
+
+    public ListReprRenderer withReturnType(final ObjectSpecification returnType) {
+        this.returnType = returnType;
+        return this;
+    }
+
+    public ListReprRenderer withElementType(final ObjectSpecification elementType) {
+        this.elementType = elementType;
+        return this;
+    }
+
+    @Override
+    public JsonRepresentation render() {
+        addValue();
+
+        addLink(Rel.RETURN_TYPE, returnType);
+        addLink(Rel.ELEMENT_TYPE, elementType);
+
+        getExtensions();
+
+        return representation;
+    }
+
+    private void addValue() {
+        if (objectAdapters == null) {
+            return;
+        }
+
+        final JsonRepresentation values = JsonRepresentation.newArray();
+        final LinkFollower linkFollower = getLinkFollower().follow("value");
+
+        for (final ObjectAdapter adapter : objectAdapters) {
+            final JsonRepresentation linkToObject = linkTo.with(adapter).builder().build();
+            values.arrayAdd(linkToObject);
+
+            if (linkFollower.matches(linkToObject)) {
+                final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.DOMAIN_OBJECT);
+                final DomainObjectReprRenderer renderer = (DomainObjectReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
+                final JsonRepresentation domainObject = renderer.with(adapter).render();
+                linkToObject.mapPut("value", domainObject);
+            }
+        }
+        representation.mapPut("value", values);
+    }
+
 }
\ No newline at end of file

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java Sun Jan 22 14:18:52 2012
@@ -1,151 +1,151 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
-import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacet;
-import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
-import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.progmodel.facets.actions.validate.ActionValidationFacet;
-import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateAddToFacet;
-import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacet;
-import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacet;
-import org.apache.isis.viewer.json.applib.HttpMethod;
-import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.applib.links.Rel;
-import org.apache.isis.viewer.json.applib.util.Enums;
-
-import com.google.common.collect.ImmutableMap;
-
-public enum MemberType {
-
-    PROPERTY("properties/", "id", RepresentationType.OBJECT_PROPERTY, ImmutableMap.of("modify", MutatorSpec.of(Rel.MODIFY, PropertyValidateFacet.class, PropertySetterFacet.class, HttpMethod.PUT, BodyArgs.ONE), "clear",
-            MutatorSpec.of(Rel.CLEAR, PropertyValidateFacet.class, PropertyClearFacet.class, HttpMethod.DELETE, BodyArgs.NONE))) {
-        @Override
-        public ObjectSpecification specFor(final ObjectMember objectMember) {
-            return objectMember.getSpecification();
-        }
-    },
-    /**
-     * {@link #getMutators()} are keyed by
-     * {@link CollectionSemantics#getAddToKey()}
-     */
-    COLLECTION("collections/", "id", RepresentationType.OBJECT_COLLECTION, ImmutableMap.of("addToSet", MutatorSpec.of(Rel.ADD_TO, CollectionValidateAddToFacet.class, CollectionAddToFacet.class, HttpMethod.PUT, BodyArgs.ONE), "addToList",
-            MutatorSpec.of(Rel.ADD_TO, CollectionValidateAddToFacet.class, CollectionAddToFacet.class, HttpMethod.POST, BodyArgs.ONE), "removeFrom", MutatorSpec.of(Rel.REMOVE_FROM, CollectionValidateRemoveFromFacet.class, CollectionRemoveFromFacet.class, HttpMethod.DELETE, BodyArgs.ONE))) {
-        @Override
-        public ObjectSpecification specFor(final ObjectMember objectMember) {
-            return objectMember.getSpecification();
-        }
-    },
-    /**
-     * {@link #getMutators()} are keyed by
-     * {@link ActionSemantics#getInvokeKey()}
-     */
-    ACTION("actions/", "id", RepresentationType.ACTION_RESULT, ImmutableMap.of("invokeQueryOnly", MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.GET, BodyArgs.MANY, "invoke"), "invokeIdempotent",
-            MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.PUT, BodyArgs.MANY, "invoke"), "invoke", MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.POST, BodyArgs.MANY, "invoke"))) {
-        @Override
-        public ObjectSpecification specFor(final ObjectMember objectMember) {
-            final ObjectAction objectAction = (ObjectAction) objectMember;
-            return objectAction.getReturnType();
-        }
-    };
-
-    private final String urlPart;
-    private final String jsProp;
-    private final String name;
-    private final RepresentationType representationType;
-
-    private final Map<String, MutatorSpec> mutators;
-
-    private MemberType(final String urlPart, final String jsProp, final RepresentationType representationType, final Map<String, MutatorSpec> mutators) {
-        this.urlPart = urlPart;
-        this.jsProp = jsProp;
-        this.representationType = representationType;
-        this.mutators = mutators;
-        name = Enums.enumToCamelCase(this);
-    }
-
-    public String getJsProp() {
-        return jsProp;
-    }
-
-    public String getUrlPart() {
-        return urlPart;
-    }
-
-    public Map<String, MutatorSpec> getMutators() {
-        return mutators;
-    }
-
-    public abstract ObjectSpecification specFor(ObjectMember objectMember);
-
-    public boolean isProperty() {
-        return this == MemberType.PROPERTY;
-    }
-
-    public boolean isCollection() {
-        return this == MemberType.COLLECTION;
-    }
-
-    public boolean isAction() {
-        return this == MemberType.ACTION;
-    }
-
-    public static MemberType lookup(final String memberTypeName) {
-        for (final MemberType memberType : values()) {
-            if (memberType.getName().equals(memberTypeName)) {
-                return memberType;
-            }
-        }
-        return null;
-    }
-
-    public static MemberType of(final ObjectMember objectMember) {
-        return objectMember.isAction() ? ACTION : objectMember.isOneToOneAssociation() ? PROPERTY : COLLECTION;
-    }
-
-    public RepresentationType getRepresentationType() {
-        return representationType;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public static MemberType determineFrom(final ObjectFeature objectFeature) {
-        if (objectFeature instanceof ObjectAction) {
-            return MemberType.ACTION;
-        }
-        if (objectFeature instanceof OneToOneAssociation) {
-            return MemberType.PROPERTY;
-        }
-        if (objectFeature instanceof OneToManyAssociation) {
-            return MemberType.COLLECTION;
-        }
-        return null;
-    }
-
-}
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.core.progmodel.facets.actions.validate.ActionValidationFacet;
+import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateAddToFacet;
+import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacet;
+import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacet;
+import org.apache.isis.viewer.json.applib.HttpMethod;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.links.Rel;
+import org.apache.isis.viewer.json.applib.util.Enums;
+
+import com.google.common.collect.ImmutableMap;
+
+public enum MemberType {
+
+    PROPERTY("properties/", "id", RepresentationType.OBJECT_PROPERTY, ImmutableMap.of("modify", MutatorSpec.of(Rel.MODIFY, PropertyValidateFacet.class, PropertySetterFacet.class, HttpMethod.PUT, BodyArgs.ONE), "clear",
+            MutatorSpec.of(Rel.CLEAR, PropertyValidateFacet.class, PropertyClearFacet.class, HttpMethod.DELETE, BodyArgs.NONE))) {
+        @Override
+        public ObjectSpecification specFor(final ObjectMember objectMember) {
+            return objectMember.getSpecification();
+        }
+    },
+    /**
+     * {@link #getMutators()} are keyed by
+     * {@link CollectionSemantics#getAddToKey()}
+     */
+    COLLECTION("collections/", "id", RepresentationType.OBJECT_COLLECTION, ImmutableMap.of("addToSet", MutatorSpec.of(Rel.ADD_TO, CollectionValidateAddToFacet.class, CollectionAddToFacet.class, HttpMethod.PUT, BodyArgs.ONE), "addToList",
+            MutatorSpec.of(Rel.ADD_TO, CollectionValidateAddToFacet.class, CollectionAddToFacet.class, HttpMethod.POST, BodyArgs.ONE), "removeFrom", MutatorSpec.of(Rel.REMOVE_FROM, CollectionValidateRemoveFromFacet.class, CollectionRemoveFromFacet.class, HttpMethod.DELETE, BodyArgs.ONE))) {
+        @Override
+        public ObjectSpecification specFor(final ObjectMember objectMember) {
+            return objectMember.getSpecification();
+        }
+    },
+    /**
+     * {@link #getMutators()} are keyed by
+     * {@link ActionSemantics#getInvokeKey()}
+     */
+    ACTION("actions/", "id", RepresentationType.ACTION_RESULT, ImmutableMap.of("invokeQueryOnly", MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.GET, BodyArgs.MANY, "invoke"), "invokeIdempotent",
+            MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.PUT, BodyArgs.MANY, "invoke"), "invoke", MutatorSpec.of(Rel.INVOKE, ActionValidationFacet.class, ActionInvocationFacet.class, HttpMethod.POST, BodyArgs.MANY, "invoke"))) {
+        @Override
+        public ObjectSpecification specFor(final ObjectMember objectMember) {
+            final ObjectAction objectAction = (ObjectAction) objectMember;
+            return objectAction.getReturnType();
+        }
+    };
+
+    private final String urlPart;
+    private final String jsProp;
+    private final String name;
+    private final RepresentationType representationType;
+
+    private final Map<String, MutatorSpec> mutators;
+
+    private MemberType(final String urlPart, final String jsProp, final RepresentationType representationType, final Map<String, MutatorSpec> mutators) {
+        this.urlPart = urlPart;
+        this.jsProp = jsProp;
+        this.representationType = representationType;
+        this.mutators = mutators;
+        name = Enums.enumToCamelCase(this);
+    }
+
+    public String getJsProp() {
+        return jsProp;
+    }
+
+    public String getUrlPart() {
+        return urlPart;
+    }
+
+    public Map<String, MutatorSpec> getMutators() {
+        return mutators;
+    }
+
+    public abstract ObjectSpecification specFor(ObjectMember objectMember);
+
+    public boolean isProperty() {
+        return this == MemberType.PROPERTY;
+    }
+
+    public boolean isCollection() {
+        return this == MemberType.COLLECTION;
+    }
+
+    public boolean isAction() {
+        return this == MemberType.ACTION;
+    }
+
+    public static MemberType lookup(final String memberTypeName) {
+        for (final MemberType memberType : values()) {
+            if (memberType.getName().equals(memberTypeName)) {
+                return memberType;
+            }
+        }
+        return null;
+    }
+
+    public static MemberType of(final ObjectMember objectMember) {
+        return objectMember.isAction() ? ACTION : objectMember.isOneToOneAssociation() ? PROPERTY : COLLECTION;
+    }
+
+    public RepresentationType getRepresentationType() {
+        return representationType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static MemberType determineFrom(final ObjectFeature objectFeature) {
+        if (objectFeature instanceof ObjectAction) {
+            return MemberType.ACTION;
+        }
+        if (objectFeature instanceof OneToOneAssociation) {
+            return MemberType.PROPERTY;
+        }
+        if (objectFeature instanceof OneToManyAssociation) {
+            return MemberType.COLLECTION;
+        }
+        return null;
+    }
+
+}

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MutatorSpec.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MutatorSpec.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MutatorSpec.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MutatorSpec.java Sun Jan 22 14:18:52 2012
@@ -1,49 +1,49 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.viewer.json.applib.HttpMethod;
-import org.apache.isis.viewer.json.applib.links.Rel;
-
-public class MutatorSpec {
-
-    public static MutatorSpec of(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs argSpec) {
-        return of(rel, validationFacetType, mutatorFacetType, httpMethod, argSpec, null);
-    }
-
-    public static MutatorSpec of(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs argSpec, final String suffix) {
-        return new MutatorSpec(rel, validationFacetType, mutatorFacetType, httpMethod, argSpec, suffix);
-    }
-
-    public final Rel rel;
-    public final Class<? extends Facet> validationFacetType;
-    public final Class<? extends Facet> mutatorFacetType;
-    public final HttpMethod httpMethod;
-    public final String suffix;
-    public final BodyArgs arguments;
-
-    private MutatorSpec(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs bodyArgs, final String suffix) {
-        this.rel = rel;
-        this.validationFacetType = validationFacetType;
-        this.mutatorFacetType = mutatorFacetType;
-        this.httpMethod = httpMethod;
-        this.arguments = bodyArgs;
-        this.suffix = suffix;
-    }
-
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.viewer.json.applib.HttpMethod;
+import org.apache.isis.viewer.json.applib.links.Rel;
+
+public class MutatorSpec {
+
+    public static MutatorSpec of(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs argSpec) {
+        return of(rel, validationFacetType, mutatorFacetType, httpMethod, argSpec, null);
+    }
+
+    public static MutatorSpec of(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs argSpec, final String suffix) {
+        return new MutatorSpec(rel, validationFacetType, mutatorFacetType, httpMethod, argSpec, suffix);
+    }
+
+    public final Rel rel;
+    public final Class<? extends Facet> validationFacetType;
+    public final Class<? extends Facet> mutatorFacetType;
+    public final HttpMethod httpMethod;
+    public final String suffix;
+    public final BodyArgs arguments;
+
+    private MutatorSpec(final Rel rel, final Class<? extends Facet> validationFacetType, final Class<? extends Facet> mutatorFacetType, final HttpMethod httpMethod, final BodyArgs bodyArgs, final String suffix) {
+        this.rel = rel;
+        this.validationFacetType = validationFacetType;
+        this.mutatorFacetType = mutatorFacetType;
+        this.httpMethod = httpMethod;
+        this.arguments = bodyArgs;
+        this.suffix = suffix;
+    }
+
 }
\ No newline at end of file

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MutatorSpec.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java Sun Jan 22 14:18:52 2012
@@ -1,226 +1,226 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-import org.apache.isis.viewer.json.applib.JsonRepresentation;
-import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.applib.links.Rel;
-import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
-import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
-import org.apache.isis.viewer.json.viewer.resources.domaintypes.ActionDescriptionReprRenderer;
-import org.codehaus.jackson.node.NullNode;
-
-import com.google.common.collect.Lists;
-
-public class ObjectActionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectActionReprRenderer, ObjectAction> {
-
-    public static class Factory extends ReprRendererFactoryAbstract {
-
-        public Factory() {
-            super(RepresentationType.OBJECT_ACTION);
-        }
-
-        @Override
-        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
-            return new ObjectActionReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
-        }
-    }
-
-    private ObjectActionReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
-        super(resourceContext, linkFollower, representationType, representation);
-    }
-
-    @Override
-    public JsonRepresentation render() {
-        // id and memberType are rendered eagerly
-
-        renderMemberContent();
-        putDisabledReasonIfDisabled();
-
-        if (mode.isStandalone() || mode.isMutated()) {
-            addParameterDetails();
-        }
-
-        return representation;
-    }
-
-    // ///////////////////////////////////////////////////
-    // details link
-    // ///////////////////////////////////////////////////
-
-    /**
-     * Mandatory hook method to support x-ro-follow-links
-     */
-    @Override
-    protected void followDetailsLink(final JsonRepresentation detailsLink) {
-        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
-        final ObjectActionReprRenderer renderer = (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
-        renderer.with(new ObjectAndAction(objectAdapter, objectMember)).usingLinkTo(linkTo).asFollowed();
-        detailsLink.mapPut("value", renderer.render());
-    }
-
-    // ///////////////////////////////////////////////////
-    // mutators
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addMutatorsIfEnabled() {
-        if (usability().isVetoed()) {
-            return;
-        }
-        final Map<String, MutatorSpec> mutators = memberType.getMutators();
-        final ActionSemantics semantics = ActionSemantics.determine(this.resourceContext, objectMember);
-
-        final String mutator = semantics.getInvokeKey();
-        final MutatorSpec mutatorSpec = mutators.get(mutator);
-
-        addLinkFor(mutatorSpec);
-    }
-
-    @Override
-    protected ObjectAdapterLinkTo linkToForMutatorInvoke() {
-        if (!objectMember.isContributed()) {
-            return super.linkToForMutatorInvoke();
-        }
-        final DomainServiceLinkTo linkTo = new DomainServiceLinkTo();
-        return linkTo.usingResourceContext(getResourceContext()).with(contributingServiceAdapter());
-    }
-
-    private ObjectAdapter contributingServiceAdapter() {
-        final ObjectSpecification serviceType = objectMember.getOnType();
-        final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
-        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
-            if (serviceAdapter.getSpecification() == serviceType) {
-                return serviceAdapter;
-            }
-        }
-        // fail fast
-        throw new IllegalStateException("Unable to locate contributing service");
-    }
-
-    @Override
-    protected JsonRepresentation mutatorArgs(final MutatorSpec mutatorSpec) {
-        final JsonRepresentation argMap = JsonRepresentation.newMap();
-        final List<ObjectActionParameter> parameters = objectMember.getParameters();
-        for (int i = 0; i < objectMember.getParameterCount(); i++) {
-            argMap.mapPut(parameters.get(i).getId(), argValueFor(i));
-        }
-        return argMap;
-    }
-
-    private Object argValueFor(final int i) {
-        if (objectMember.isContributed()) {
-            final ObjectActionParameter actionParameter = objectMember.getParameters().get(i);
-            if (actionParameter.getSpecification().isOfType(objectAdapter.getSpecification())) {
-                return DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.OBJECT, objectAdapter).build();
-            }
-        }
-        // force a null into the map
-        return NullNode.getInstance();
-    }
-
-    // ///////////////////////////////////////////////////
-    // parameter details
-    // ///////////////////////////////////////////////////
-
-    private ObjectActionReprRenderer addParameterDetails() {
-        final List<Object> parameters = Lists.newArrayList();
-        for (int i = 0; i < objectMember.getParameterCount(); i++) {
-            final ObjectActionParameter param = objectMember.getParameters().get(i);
-            parameters.add(paramDetails(param));
-        }
-        representation.mapPut("parameters", parameters);
-        return this;
-    }
-
-    private Object paramDetails(final ObjectActionParameter param) {
-        final JsonRepresentation paramRep = JsonRepresentation.newMap();
-        paramRep.mapPut("num", param.getNumber());
-        paramRep.mapPut("id", param.getId());
-        paramRep.mapPut("name", param.getName());
-        paramRep.mapPut("description", param.getDescription());
-        final Object paramChoices = choicesFor(param);
-        if (paramChoices != null) {
-            paramRep.mapPut("choices", paramChoices);
-        }
-        final Object paramDefault = defaultFor(param);
-        if (paramDefault != null) {
-            paramRep.mapPut("default", paramDefault);
-        }
-        return paramRep;
-    }
-
-    private Object choicesFor(final ObjectActionParameter param) {
-        final ObjectAdapter[] choiceAdapters = param.getChoices(objectAdapter);
-        if (choiceAdapters == null || choiceAdapters.length == 0) {
-            return null;
-        }
-        final List<Object> list = Lists.newArrayList();
-        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
-            final ObjectSpecification objectSpec = param.getSpecification();
-            list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
-        }
-        return list;
-    }
-
-    private Object defaultFor(final ObjectActionParameter param) {
-        final ObjectAdapter defaultAdapter = param.getDefault(objectAdapter);
-        if (defaultAdapter == null) {
-            return null;
-        }
-        final ObjectSpecification objectSpec = param.getSpecification();
-        return DomainObjectReprRenderer.valueOrRef(resourceContext, defaultAdapter, objectSpec);
-    }
-
-    // ///////////////////////////////////////////////////
-    // extensions and links
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addLinksToFormalDomainModel() {
-        getLinks().arrayAdd(ActionDescriptionReprRenderer.newLinkToBuilder(resourceContext, Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember).build());
-    }
-
-    @Override
-    protected void addLinksIsisProprietary() {
-        if (objectMember.isContributed()) {
-            final ObjectAdapter serviceAdapter = contributingServiceAdapter();
-            final JsonRepresentation contributedByLink = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.CONTRIBUTED_BY, serviceAdapter).build();
-            getLinks().arrayAdd(contributedByLink);
-        }
-    }
-
-    @Override
-    protected void putExtensionsIsisProprietary() {
-        getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase());
-
-        final ActionSemantics semantics = ActionSemantics.determine(resourceContext, objectMember);
-        getExtensions().mapPut("actionSemantics", semantics.getName());
-    }
-
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.links.Rel;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
+import org.apache.isis.viewer.json.viewer.resources.domaintypes.ActionDescriptionReprRenderer;
+import org.codehaus.jackson.node.NullNode;
+
+import com.google.common.collect.Lists;
+
+public class ObjectActionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectActionReprRenderer, ObjectAction> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.OBJECT_ACTION);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+            return new ObjectActionReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
+        }
+    }
+
+    private ObjectActionReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
+        super(resourceContext, linkFollower, representationType, representation);
+    }
+
+    @Override
+    public JsonRepresentation render() {
+        // id and memberType are rendered eagerly
+
+        renderMemberContent();
+        putDisabledReasonIfDisabled();
+
+        if (mode.isStandalone() || mode.isMutated()) {
+            addParameterDetails();
+        }
+
+        return representation;
+    }
+
+    // ///////////////////////////////////////////////////
+    // details link
+    // ///////////////////////////////////////////////////
+
+    /**
+     * Mandatory hook method to support x-ro-follow-links
+     */
+    @Override
+    protected void followDetailsLink(final JsonRepresentation detailsLink) {
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
+        final ObjectActionReprRenderer renderer = (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
+        renderer.with(new ObjectAndAction(objectAdapter, objectMember)).usingLinkTo(linkTo).asFollowed();
+        detailsLink.mapPut("value", renderer.render());
+    }
+
+    // ///////////////////////////////////////////////////
+    // mutators
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addMutatorsIfEnabled() {
+        if (usability().isVetoed()) {
+            return;
+        }
+        final Map<String, MutatorSpec> mutators = memberType.getMutators();
+        final ActionSemantics semantics = ActionSemantics.determine(this.resourceContext, objectMember);
+
+        final String mutator = semantics.getInvokeKey();
+        final MutatorSpec mutatorSpec = mutators.get(mutator);
+
+        addLinkFor(mutatorSpec);
+    }
+
+    @Override
+    protected ObjectAdapterLinkTo linkToForMutatorInvoke() {
+        if (!objectMember.isContributed()) {
+            return super.linkToForMutatorInvoke();
+        }
+        final DomainServiceLinkTo linkTo = new DomainServiceLinkTo();
+        return linkTo.usingResourceContext(getResourceContext()).with(contributingServiceAdapter());
+    }
+
+    private ObjectAdapter contributingServiceAdapter() {
+        final ObjectSpecification serviceType = objectMember.getOnType();
+        final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
+        for (final ObjectAdapter serviceAdapter : serviceAdapters) {
+            if (serviceAdapter.getSpecification() == serviceType) {
+                return serviceAdapter;
+            }
+        }
+        // fail fast
+        throw new IllegalStateException("Unable to locate contributing service");
+    }
+
+    @Override
+    protected JsonRepresentation mutatorArgs(final MutatorSpec mutatorSpec) {
+        final JsonRepresentation argMap = JsonRepresentation.newMap();
+        final List<ObjectActionParameter> parameters = objectMember.getParameters();
+        for (int i = 0; i < objectMember.getParameterCount(); i++) {
+            argMap.mapPut(parameters.get(i).getId(), argValueFor(i));
+        }
+        return argMap;
+    }
+
+    private Object argValueFor(final int i) {
+        if (objectMember.isContributed()) {
+            final ObjectActionParameter actionParameter = objectMember.getParameters().get(i);
+            if (actionParameter.getSpecification().isOfType(objectAdapter.getSpecification())) {
+                return DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.OBJECT, objectAdapter).build();
+            }
+        }
+        // force a null into the map
+        return NullNode.getInstance();
+    }
+
+    // ///////////////////////////////////////////////////
+    // parameter details
+    // ///////////////////////////////////////////////////
+
+    private ObjectActionReprRenderer addParameterDetails() {
+        final List<Object> parameters = Lists.newArrayList();
+        for (int i = 0; i < objectMember.getParameterCount(); i++) {
+            final ObjectActionParameter param = objectMember.getParameters().get(i);
+            parameters.add(paramDetails(param));
+        }
+        representation.mapPut("parameters", parameters);
+        return this;
+    }
+
+    private Object paramDetails(final ObjectActionParameter param) {
+        final JsonRepresentation paramRep = JsonRepresentation.newMap();
+        paramRep.mapPut("num", param.getNumber());
+        paramRep.mapPut("id", param.getId());
+        paramRep.mapPut("name", param.getName());
+        paramRep.mapPut("description", param.getDescription());
+        final Object paramChoices = choicesFor(param);
+        if (paramChoices != null) {
+            paramRep.mapPut("choices", paramChoices);
+        }
+        final Object paramDefault = defaultFor(param);
+        if (paramDefault != null) {
+            paramRep.mapPut("default", paramDefault);
+        }
+        return paramRep;
+    }
+
+    private Object choicesFor(final ObjectActionParameter param) {
+        final ObjectAdapter[] choiceAdapters = param.getChoices(objectAdapter);
+        if (choiceAdapters == null || choiceAdapters.length == 0) {
+            return null;
+        }
+        final List<Object> list = Lists.newArrayList();
+        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
+            final ObjectSpecification objectSpec = param.getSpecification();
+            list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
+        }
+        return list;
+    }
+
+    private Object defaultFor(final ObjectActionParameter param) {
+        final ObjectAdapter defaultAdapter = param.getDefault(objectAdapter);
+        if (defaultAdapter == null) {
+            return null;
+        }
+        final ObjectSpecification objectSpec = param.getSpecification();
+        return DomainObjectReprRenderer.valueOrRef(resourceContext, defaultAdapter, objectSpec);
+    }
+
+    // ///////////////////////////////////////////////////
+    // extensions and links
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addLinksToFormalDomainModel() {
+        getLinks().arrayAdd(ActionDescriptionReprRenderer.newLinkToBuilder(resourceContext, Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember).build());
+    }
+
+    @Override
+    protected void addLinksIsisProprietary() {
+        if (objectMember.isContributed()) {
+            final ObjectAdapter serviceAdapter = contributingServiceAdapter();
+            final JsonRepresentation contributedByLink = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.CONTRIBUTED_BY, serviceAdapter).build();
+            getLinks().arrayAdd(contributedByLink);
+        }
+    }
+
+    @Override
+    protected void putExtensionsIsisProprietary() {
+        getExtensions().mapPut("actionType", objectMember.getType().name().toLowerCase());
+
+        final ActionSemantics semantics = ActionSemantics.determine(resourceContext, objectMember);
+        getExtensions().mapPut("actionSemantics", semantics.getName());
+    }
+
 }
\ No newline at end of file

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAdapterLinkTo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndActionInvocation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndMember.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java Sun Jan 22 14:18:52 2012
@@ -1,156 +1,156 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.viewer.json.applib.JsonRepresentation;
-import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.applib.links.Rel;
-import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.LinkBuilder;
-import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
-import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
-import org.apache.isis.viewer.json.viewer.resources.domaintypes.CollectionDescriptionReprRenderer;
-
-import com.google.common.collect.Lists;
-
-public class ObjectCollectionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectCollectionReprRenderer, OneToManyAssociation> {
-
-    public static class Factory extends ReprRendererFactoryAbstract {
-
-        public Factory() {
-            super(RepresentationType.OBJECT_COLLECTION);
-        }
-
-        @Override
-        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
-            return new ObjectCollectionReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
-        }
-    }
-
-    private ObjectCollectionReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
-        super(resourceContext, linkFollower, representationType, representation);
-    }
-
-    @Override
-    public JsonRepresentation render() {
-        // id and memberType are rendered eagerly
-
-        renderMemberContent();
-        if (mode.isStandalone() || mode.isMutated() || !objectAdapter.isPersistent()) {
-            addValue();
-        }
-        putDisabledReasonIfDisabled();
-
-        if (mode.isStandalone() || mode.isMutated()) {
-            addExtensionsIsisProprietaryChangedObjects();
-        }
-
-        return representation;
-    }
-
-    // ///////////////////////////////////////////////////
-    // value
-    // ///////////////////////////////////////////////////
-
-    private void addValue() {
-        final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
-        if (valueAdapter == null) {
-            return;
-        }
-
-        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(valueAdapter);
-        final List<JsonRepresentation> list = Lists.newArrayList();
-        for (final ObjectAdapter elementAdapter : facet.iterable(valueAdapter)) {
-
-            final LinkBuilder newBuilder = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.OBJECT, elementAdapter);
-
-            list.add(newBuilder.build());
-        }
-
-        representation.mapPut("value", list);
-    }
-
-    // ///////////////////////////////////////////////////
-    // details link
-    // ///////////////////////////////////////////////////
-
-    /**
-     * Mandatory hook method to support x-ro-follow-links
-     */
-    @Override
-    protected void followDetailsLink(final JsonRepresentation detailsLink) {
-        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
-        final ObjectCollectionReprRenderer renderer = (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
-        renderer.with(new ObjectAndCollection(objectAdapter, objectMember)).asFollowed();
-        detailsLink.mapPut("value", renderer.render());
-    }
-
-    // ///////////////////////////////////////////////////
-    // mutators
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addMutatorsIfEnabled() {
-        if (usability().isVetoed()) {
-            return;
-        }
-
-        final CollectionSemantics semantics = CollectionSemantics.determine(this.resourceContext, objectMember);
-        addMutatorLink(semantics.getAddToKey());
-        addMutatorLink(semantics.getRemoveFromKey());
-
-        return;
-    }
-
-    private void addMutatorLink(final String key) {
-        final Map<String, MutatorSpec> mutators = memberType.getMutators();
-        final MutatorSpec mutatorSpec = mutators.get(key);
-        addLinkFor(mutatorSpec);
-    }
-
-    // ///////////////////////////////////////////////////
-    // extensions and links
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addLinksToFormalDomainModel() {
-        final LinkBuilder linkBuilder = CollectionDescriptionReprRenderer.newLinkToBuilder(resourceContext, Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember);
-        getLinks().arrayAdd(linkBuilder.build());
-    }
-
-    @Override
-    protected void addLinksIsisProprietary() {
-        // none
-    }
-
-    @Override
-    protected void putExtensionsIsisProprietary() {
-        final CollectionSemantics semantics = CollectionSemantics.determine(resourceContext, objectMember);
-        getExtensions().mapPut("collectionSemantics", semantics.name().toLowerCase());
-    }
-
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.links.Rel;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkBuilder;
+import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
+import org.apache.isis.viewer.json.viewer.resources.domaintypes.CollectionDescriptionReprRenderer;
+
+import com.google.common.collect.Lists;
+
+public class ObjectCollectionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectCollectionReprRenderer, OneToManyAssociation> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.OBJECT_COLLECTION);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+            return new ObjectCollectionReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
+        }
+    }
+
+    private ObjectCollectionReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
+        super(resourceContext, linkFollower, representationType, representation);
+    }
+
+    @Override
+    public JsonRepresentation render() {
+        // id and memberType are rendered eagerly
+
+        renderMemberContent();
+        if (mode.isStandalone() || mode.isMutated() || !objectAdapter.isPersistent()) {
+            addValue();
+        }
+        putDisabledReasonIfDisabled();
+
+        if (mode.isStandalone() || mode.isMutated()) {
+            addExtensionsIsisProprietaryChangedObjects();
+        }
+
+        return representation;
+    }
+
+    // ///////////////////////////////////////////////////
+    // value
+    // ///////////////////////////////////////////////////
+
+    private void addValue() {
+        final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
+        if (valueAdapter == null) {
+            return;
+        }
+
+        final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(valueAdapter);
+        final List<JsonRepresentation> list = Lists.newArrayList();
+        for (final ObjectAdapter elementAdapter : facet.iterable(valueAdapter)) {
+
+            final LinkBuilder newBuilder = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.OBJECT, elementAdapter);
+
+            list.add(newBuilder.build());
+        }
+
+        representation.mapPut("value", list);
+    }
+
+    // ///////////////////////////////////////////////////
+    // details link
+    // ///////////////////////////////////////////////////
+
+    /**
+     * Mandatory hook method to support x-ro-follow-links
+     */
+    @Override
+    protected void followDetailsLink(final JsonRepresentation detailsLink) {
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
+        final ObjectCollectionReprRenderer renderer = (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
+        renderer.with(new ObjectAndCollection(objectAdapter, objectMember)).asFollowed();
+        detailsLink.mapPut("value", renderer.render());
+    }
+
+    // ///////////////////////////////////////////////////
+    // mutators
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addMutatorsIfEnabled() {
+        if (usability().isVetoed()) {
+            return;
+        }
+
+        final CollectionSemantics semantics = CollectionSemantics.determine(this.resourceContext, objectMember);
+        addMutatorLink(semantics.getAddToKey());
+        addMutatorLink(semantics.getRemoveFromKey());
+
+        return;
+    }
+
+    private void addMutatorLink(final String key) {
+        final Map<String, MutatorSpec> mutators = memberType.getMutators();
+        final MutatorSpec mutatorSpec = mutators.get(key);
+        addLinkFor(mutatorSpec);
+    }
+
+    // ///////////////////////////////////////////////////
+    // extensions and links
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addLinksToFormalDomainModel() {
+        final LinkBuilder linkBuilder = CollectionDescriptionReprRenderer.newLinkToBuilder(resourceContext, Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember);
+        getLinks().arrayAdd(linkBuilder.build());
+    }
+
+    @Override
+    protected void addLinksIsisProprietary() {
+        // none
+    }
+
+    @Override
+    protected void putExtensionsIsisProprietary() {
+        final CollectionSemantics semantics = CollectionSemantics.determine(resourceContext, objectMember);
+        getExtensions().mapPut("collectionSemantics", semantics.name().toLowerCase());
+    }
+
 }
\ No newline at end of file

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java?rev=1234515&r1=1234514&r2=1234515&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java Sun Jan 22 14:18:52 2012
@@ -1,166 +1,166 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.isis.viewer.json.viewer.resources.domainobjects;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.viewer.json.applib.JsonRepresentation;
-import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.applib.links.Rel;
-import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
-import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
-import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
-import org.apache.isis.viewer.json.viewer.resources.domaintypes.PropertyDescriptionReprRenderer;
-import org.codehaus.jackson.node.NullNode;
-
-import com.google.common.collect.Lists;
-
-public class ObjectPropertyReprRenderer extends AbstractObjectMemberReprRenderer<ObjectPropertyReprRenderer, OneToOneAssociation> {
-
-    public static class Factory extends ReprRendererFactoryAbstract {
-
-        public Factory() {
-            super(RepresentationType.OBJECT_PROPERTY);
-        }
-
-        @Override
-        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
-            return new ObjectPropertyReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
-        }
-    }
-
-    private ObjectPropertyReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
-        super(resourceContext, linkFollower, representationType, representation);
-    }
-
-    @Override
-    public JsonRepresentation render() {
-        // id and memberType are rendered eagerly
-
-        renderMemberContent();
-        addValue();
-
-        putDisabledReasonIfDisabled();
-
-        if (mode.isStandalone() || mode.isMutated()) {
-            addChoices();
-            addExtensionsIsisProprietaryChangedObjects();
-        }
-
-        return representation;
-    }
-
-    // ///////////////////////////////////////////////////
-    // value
-    // ///////////////////////////////////////////////////
-
-    private void addValue() {
-        representation.mapPut("value", valueRep());
-    }
-
-    private Object valueRep() {
-        final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
-        if (valueAdapter == null) {
-            return NullNode.getInstance();
-        }
-        return DomainObjectReprRenderer.valueOrRef(resourceContext, valueAdapter, objectMember.getSpecification());
-    }
-
-    // ///////////////////////////////////////////////////
-    // details link
-    // ///////////////////////////////////////////////////
-
-    /**
-     * Mandatory hook method to support x-ro-follow-links
-     */
-    @Override
-    protected void followDetailsLink(final JsonRepresentation detailsLink) {
-        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
-        final ObjectPropertyReprRenderer renderer = (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
-        renderer.with(new ObjectAndProperty(objectAdapter, objectMember)).asFollowed();
-        detailsLink.mapPut("value", renderer.render());
-    }
-
-    // ///////////////////////////////////////////////////
-    // mutators
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addMutatorsIfEnabled() {
-        if (usability().isVetoed()) {
-            return;
-        }
-        final Map<String, MutatorSpec> mutators = memberType.getMutators();
-        for (final String mutator : mutators.keySet()) {
-            final MutatorSpec mutatorSpec = mutators.get(mutator);
-            addLinkFor(mutatorSpec);
-        }
-        return;
-    }
-
-    // ///////////////////////////////////////////////////
-    // choices
-    // ///////////////////////////////////////////////////
-
-    private ObjectPropertyReprRenderer addChoices() {
-        final Object propertyChoices = propertyChoices();
-        if (propertyChoices != null) {
-            representation.mapPut("choices", propertyChoices);
-        }
-        return this;
-    }
-
-    private Object propertyChoices() {
-        final ObjectAdapter[] choiceAdapters = objectMember.getChoices(objectAdapter);
-        if (choiceAdapters == null || choiceAdapters.length == 0) {
-            return null;
-        }
-        final List<Object> list = Lists.newArrayList();
-        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
-            final ObjectSpecification objectSpec = objectMember.getSpecification();
-            list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
-        }
-        return list;
-    }
-
-    // ///////////////////////////////////////////////////
-    // extensions and links
-    // ///////////////////////////////////////////////////
-
-    @Override
-    protected void addLinksToFormalDomainModel() {
-        getLinks().arrayAdd(PropertyDescriptionReprRenderer.newLinkToBuilder(getResourceContext(), Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember).build());
-    }
-
-    @Override
-    protected void addLinksIsisProprietary() {
-        // none
-    }
-
-    @Override
-    protected void putExtensionsIsisProprietary() {
-        // none
-    }
-
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.links.Rel;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
+import org.apache.isis.viewer.json.viewer.resources.domaintypes.PropertyDescriptionReprRenderer;
+import org.codehaus.jackson.node.NullNode;
+
+import com.google.common.collect.Lists;
+
+public class ObjectPropertyReprRenderer extends AbstractObjectMemberReprRenderer<ObjectPropertyReprRenderer, OneToOneAssociation> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.OBJECT_PROPERTY);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+            return new ObjectPropertyReprRenderer(resourceContext, linkFollower, getRepresentationType(), representation);
+        }
+    }
+
+    private ObjectPropertyReprRenderer(final ResourceContext resourceContext, final LinkFollower linkFollower, final RepresentationType representationType, final JsonRepresentation representation) {
+        super(resourceContext, linkFollower, representationType, representation);
+    }
+
+    @Override
+    public JsonRepresentation render() {
+        // id and memberType are rendered eagerly
+
+        renderMemberContent();
+        addValue();
+
+        putDisabledReasonIfDisabled();
+
+        if (mode.isStandalone() || mode.isMutated()) {
+            addChoices();
+            addExtensionsIsisProprietaryChangedObjects();
+        }
+
+        return representation;
+    }
+
+    // ///////////////////////////////////////////////////
+    // value
+    // ///////////////////////////////////////////////////
+
+    private void addValue() {
+        representation.mapPut("value", valueRep());
+    }
+
+    private Object valueRep() {
+        final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
+        if (valueAdapter == null) {
+            return NullNode.getInstance();
+        }
+        return DomainObjectReprRenderer.valueOrRef(resourceContext, valueAdapter, objectMember.getSpecification());
+    }
+
+    // ///////////////////////////////////////////////////
+    // details link
+    // ///////////////////////////////////////////////////
+
+    /**
+     * Mandatory hook method to support x-ro-follow-links
+     */
+    @Override
+    protected void followDetailsLink(final JsonRepresentation detailsLink) {
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
+        final ObjectPropertyReprRenderer renderer = (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
+        renderer.with(new ObjectAndProperty(objectAdapter, objectMember)).asFollowed();
+        detailsLink.mapPut("value", renderer.render());
+    }
+
+    // ///////////////////////////////////////////////////
+    // mutators
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addMutatorsIfEnabled() {
+        if (usability().isVetoed()) {
+            return;
+        }
+        final Map<String, MutatorSpec> mutators = memberType.getMutators();
+        for (final String mutator : mutators.keySet()) {
+            final MutatorSpec mutatorSpec = mutators.get(mutator);
+            addLinkFor(mutatorSpec);
+        }
+        return;
+    }
+
+    // ///////////////////////////////////////////////////
+    // choices
+    // ///////////////////////////////////////////////////
+
+    private ObjectPropertyReprRenderer addChoices() {
+        final Object propertyChoices = propertyChoices();
+        if (propertyChoices != null) {
+            representation.mapPut("choices", propertyChoices);
+        }
+        return this;
+    }
+
+    private Object propertyChoices() {
+        final ObjectAdapter[] choiceAdapters = objectMember.getChoices(objectAdapter);
+        if (choiceAdapters == null || choiceAdapters.length == 0) {
+            return null;
+        }
+        final List<Object> list = Lists.newArrayList();
+        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
+            final ObjectSpecification objectSpec = objectMember.getSpecification();
+            list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
+        }
+        return list;
+    }
+
+    // ///////////////////////////////////////////////////
+    // extensions and links
+    // ///////////////////////////////////////////////////
+
+    @Override
+    protected void addLinksToFormalDomainModel() {
+        getLinks().arrayAdd(PropertyDescriptionReprRenderer.newLinkToBuilder(getResourceContext(), Rel.DESCRIBEDBY, objectAdapter.getSpecification(), objectMember).build());
+    }
+
+    @Override
+    protected void addLinksIsisProprietary() {
+        // none
+    }
+
+    @Override
+    protected void putExtensionsIsisProprietary() {
+        // none
+    }
+
 }
\ No newline at end of file

Propchange: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message