incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1177860 [2/2] - in /incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer: representations/ resources/ resources/capabilities/ resources/domainobjects/ resources/domaintypes/ resources/home...
Date Fri, 30 Sep 2011 22:19:29 GMT
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.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/DomainServiceResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -32,17 +32,21 @@ import javax.ws.rs.core.Response;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 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.RestfulMediaType;
 import org.apache.isis.viewer.json.applib.domainobjects.DomainServiceResource;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
 import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
 import org.apache.isis.viewer.json.viewer.representations.ReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderFactory;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainResourceHelper.Intent;
 
 @Path("/services")
-public class DomainServiceResourceServerside extends DomainResourceAbstract implements
+public class DomainServiceResourceServerside extends ResourceAbstract implements
         DomainServiceResource {
 
     @Override
@@ -72,14 +76,14 @@ public class DomainServiceResourceServer
         
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
         
-        final TypedReprBuilderFactory factory = builderFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
-        final DomainObjectReprBuilder reprBuilder = 
-                (DomainObjectReprBuilder) factory.newBuilder(getResourceContext());
-        reprBuilder.usingLinkToBuilder(new DomainServiceLinkToBuilder())
-                    .withSelf()
+        final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
+        final DomainObjectReprRenderer renderer = 
+                (DomainObjectReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.usingLinkToBuilder(new DomainServiceLinkToBuilder())
+                    .includesSelf()
                     .with(serviceAdapter);
         
-        return responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.ONE_DAY, reprBuilder).build();
+        return responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.ONE_DAY, renderer).build();
     }
 
 
@@ -95,15 +99,20 @@ public class DomainServiceResourceServer
             @PathParam("propertyId") final String propertyId) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
-        final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
+        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
                 serviceAdapter, propertyId, Intent.ACCESS);
 
-        ResourceContext resourceContext = getResourceContext();
-        final ObjectPropertyReprBuilder builder = ObjectPropertyReprBuilder.newBuilder(
-                resourceContext, serviceAdapter, property);
-
-        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.ONE_DAY, builder).build();
+        RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
+        final ObjectPropertyReprRenderer renderer = 
+                (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        
+        renderer.with(new ObjectAndProperty(serviceAdapter, property))
+                .withDetailsLink();
+        
+        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.ONE_DAY, renderer.render()).build();
     }
 
 
@@ -120,9 +129,11 @@ public class DomainServiceResourceServer
             @PathParam("actionId") final String actionId) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
 
-        return actionPrompt(actionId, serviceAdapter);
+        return helper.actionPrompt(actionId, serviceAdapter);
     }
 
     

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectListReprBuilder.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?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectListReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectListReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -17,39 +17,45 @@
 package org.apache.isis.viewer.json.viewer.resources.domainobjects;
 
 import java.util.Collection;
-import java.util.List;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
-
-public class DomainObjectListReprBuilder extends ReprBuilderAbstract<DomainObjectListReprBuilder> {
-
-    private ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder;
+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);
+        }
 
-    public static DomainObjectListReprBuilder newBuilder(ResourceContext resourceContext, JsonRepresentation representation) {
-        return new DomainObjectListReprBuilder(resourceContext, representation);
+        @Override
+        public ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new ListReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
     }
 
-    public static DomainObjectListReprBuilder newBuilder(ResourceContext resourceContext) {
-        return new DomainObjectListReprBuilder(resourceContext, JsonRepresentation.newMap());
-    }
+    private ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder;
 
-    private DomainObjectListReprBuilder(ResourceContext resourceContext, JsonRepresentation representation) {
-        super(resourceContext, representation);
+    private ListReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
         usingLinkToBuilder(new DomainObjectLinkToBuilder());
     }
     
-    public DomainObjectListReprBuilder usingLinkToBuilder(ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder) {
+    public ListReprRenderer usingLinkToBuilder(ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder) {
         this.objectAdapterLinkToBuilder = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
         return this;
     }
 
-    public DomainObjectListReprBuilder withAdapters(Collection<ObjectAdapter> objectAdapters) {
+    @Override
+    public ListReprRenderer with(Collection<ObjectAdapter> objectAdapters) {
         JsonRepresentation list = JsonRepresentation.newArray();
         for(ObjectAdapter adapter: objectAdapters) {
-            JsonRepresentation linkToObject = objectAdapterLinkToBuilder.with(adapter).linkToAdapter().build();
+            JsonRepresentation linkToObject = objectAdapterLinkToBuilder.with(adapter).linkToAdapter().render();
             list.arrayAdd(linkToObject);
         }
         representation.mapPut("values", list);
@@ -57,7 +63,7 @@ public class DomainObjectListReprBuilder
     }
 
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         withLinks();
         withExtensions();
 

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=1177860&r1=1177859&r2=1177860&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 Fri Sep 30 22:19:28 2011
@@ -26,6 +26,7 @@ import org.apache.isis.core.metamodel.fa
 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.ObjectMember;
+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;
@@ -143,4 +144,15 @@ public enum MemberType {
         return name;
     }
 
+    public static MemberType determineFrom(ObjectMember objectMember) {
+        if (objectMember instanceof ObjectAction) {
+            return MemberType.OBJECT_ACTION;
+        }
+        if (objectMember instanceof OneToOneAssociation) {
+            return MemberType.OBJECT_PROPERTY;
+        }
+        return MemberType.OBJECT_COLLECTION;
+    }
+
+
 }

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java (from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprBuilder.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?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprBuilder.java&r1=1176973&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -24,28 +24,40 @@ import org.apache.isis.core.metamodel.sp
 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.viewer.ResourceContext;
+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.DomainTypeReprBuilder;
 import org.apache.isis.viewer.json.viewer.resources.domaintypes.TypeActionReprBuilder;
 import org.codehaus.jackson.node.NullNode;
 
 import com.google.common.collect.Lists;
 
-public class ObjectActionReprBuilder extends AbstractObjectMemberReprBuilder<ObjectActionReprBuilder, ObjectAction> {
+public class ObjectActionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectActionReprRenderer, ObjectAction> {
 
-	public static ObjectActionReprBuilder newBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, ObjectAction objectAction) {
-        return new ObjectActionReprBuilder(resourceContext, objectAdapter, objectAction);
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.OBJECT_ACTION);
+        }
+
+        @Override
+        public ReprRenderer<?,?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new ObjectActionReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
     }
 
-    protected ObjectActionReprBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, ObjectAction objectAction) {
-        super(resourceContext, objectAdapter, MemberType.OBJECT_ACTION, objectAction);
-        
-        putId();
-        putMemberType();
+
+    private ObjectActionReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
     }
 
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
+        putId();
+        putMemberType();
+        
         putDisabledReasonIfDisabled();
         
         JsonRepresentation extensions = JsonRepresentation.newMap();
@@ -66,7 +78,7 @@ public class ObjectActionReprBuilder ext
     /////////////////////////////////////////////////////
 
     @Override
-    public ObjectActionReprBuilder withMutatorsIfEnabled() {
+    public ObjectActionReprRenderer withMutatorsIfEnabled() {
         if(usability().isVetoed()) {
             return cast(this);
         }
@@ -89,7 +101,7 @@ public class ObjectActionReprBuilder ext
                 linkToBuilder.linkToMember("invoke", memberType, objectMember, mutatorSpec.suffix)
                 .withHttpMethod(mutatorSpec.httpMethod)
                 .withArguments(arguments)
-                .build();
+                .render();
         representation.mapPut("invoke", detailsLink);
     }
     
@@ -120,7 +132,7 @@ public class ObjectActionReprBuilder ext
 	        if(objectMember.isContributed()) {
 	            ObjectActionParameter actionParameter = objectMember.getParameters().get(i);
 	            if (actionParameter.getSpecification().isOfType(objectAdapter.getSpecification())) {
-	                return DomainObjectReprBuilder.newLinkToBuilder(resourceContext, "object", objectAdapter).build();
+	                return DomainObjectReprRenderer.newLinkToBuilder(resourceContext, "object", objectAdapter).render();
 	            }
 	        }
 	        return NullNode.instance;
@@ -131,7 +143,7 @@ public class ObjectActionReprBuilder ext
     // parameter details
     /////////////////////////////////////////////////////
 
-    public ObjectActionReprBuilder withParameterDetails() {
+    public ObjectActionReprRenderer withParameterDetails() {
     	List<Object> parameters = Lists.newArrayList();
 		for (int i=0; i< objectMember.getParameterCount(); i++) {
 			ObjectActionParameter param = objectMember.getParameters().get(i);
@@ -165,7 +177,7 @@ public class ObjectActionReprBuilder ext
         List<Object> list = Lists.newArrayList();
         for (final ObjectAdapter choiceAdapter : choiceAdapters) {
         	ObjectSpecification objectSpec = param.getSpecification();
-        	list.add(DomainObjectReprBuilder.valueOrRef(resourceContext, choiceAdapter, objectSpec));
+        	list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
         }
         return list;
 	}
@@ -176,7 +188,7 @@ public class ObjectActionReprBuilder ext
 			return null;
 		}
     	ObjectSpecification objectSpec = param.getSpecification();
-    	return DomainObjectReprBuilder.valueOrRef(resourceContext, defaultAdapter, objectSpec);
+    	return DomainObjectReprRenderer.valueOrRef(resourceContext, defaultAdapter, objectSpec);
 	}
 
 	
@@ -194,17 +206,17 @@ public class ObjectActionReprBuilder ext
     }
 
      private void addLinksFormalDomainModel(JsonRepresentation links, ResourceContext resourceContext) {
-         links.arrayAdd(TypeActionReprBuilder.newLinkToBuilder(resourceContext, "typeAction", objectAdapter.getSpecification(), objectMember).build());
+         links.arrayAdd(TypeActionReprBuilder.newLinkToBuilder(resourceContext, "typeAction", objectAdapter.getSpecification(), objectMember).render());
      }
 
      private void addLinksIsisProprietary(JsonRepresentation links, ResourceContext resourceContext) {
        if(objectMember.isContributed()) {
             ObjectAdapter serviceAdapter = contributingServiceAdapter();
-            JsonRepresentation contributedByLink = DomainObjectReprBuilder.newLinkToBuilder(resourceContext, "contributedBy", serviceAdapter).build();
+            JsonRepresentation contributedByLink = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, "contributedBy", serviceAdapter).render();
             links.arrayAdd(contributedByLink);
         }
 
-       links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).build());
+       links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).render());
     }
 
 

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndAction.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/ObjectAndAction.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndAction.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndAction.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,12 @@
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+
+public class ObjectAndAction extends ObjectAndMember<ObjectAction>{
+    
+    public ObjectAndAction(ObjectAdapter objectAdapter, ObjectAction action) {
+        super(objectAdapter, action);
+    }
+
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndCollection.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/ObjectAndCollection.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndCollection.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndCollection.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,12 @@
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+
+public class ObjectAndCollection extends ObjectAndMember<OneToManyAssociation>{
+    
+    public ObjectAndCollection(ObjectAdapter objectAdapter, OneToManyAssociation collection) {
+        super(objectAdapter, collection);
+    }
+
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndMember.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/ObjectAndMember.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndMember.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndMember.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,21 @@
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+
+public abstract class ObjectAndMember<T extends ObjectMember> {
+    
+    private ObjectAdapter objectAdapter;
+    private T objectMember;
+    
+    public ObjectAndMember(ObjectAdapter objectAdapter, T objectMember) {
+        this.objectAdapter = objectAdapter;
+        this.objectMember = objectMember;
+    }
+    public ObjectAdapter getObjectAdapter() {
+        return objectAdapter;
+    }
+    public T getMember() {
+        return objectMember;
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndProperty.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/ObjectAndProperty.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndProperty.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndProperty.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,12 @@
+package org.apache.isis.viewer.json.viewer.resources.domainobjects;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+
+public class ObjectAndProperty extends ObjectAndMember<OneToOneAssociation>{
+    
+    public ObjectAndProperty(ObjectAdapter objectAdapter, OneToOneAssociation property) {
+        super(objectAdapter, property);
+    }
+
+}
\ No newline at end of file

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java (from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprBuilder.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?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprBuilder.java&r1=1176973&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -24,28 +24,38 @@ import org.apache.isis.core.metamodel.fa
 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.viewer.ResourceContext;
 import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
+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.DomainTypeReprBuilder;
 import org.apache.isis.viewer.json.viewer.resources.domaintypes.TypeCollectionReprBuilder;
 
 import com.google.common.collect.Lists;
 
-public class ObjectCollectionReprBuilder extends AbstractObjectMemberReprBuilder<ObjectCollectionReprBuilder, OneToManyAssociation> {
+public class ObjectCollectionReprRenderer extends AbstractObjectMemberReprRenderer<ObjectCollectionReprRenderer, OneToManyAssociation> {
 
-    public static ObjectCollectionReprBuilder newBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, OneToManyAssociation otma) {
-        return new ObjectCollectionReprBuilder(resourceContext, objectAdapter, otma);
-    }
+    public static class Factory extends ReprRendererFactoryAbstract {
 
-    public ObjectCollectionReprBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, OneToManyAssociation otma) {
-        super(resourceContext, objectAdapter, MemberType.OBJECT_COLLECTION, otma);
+        public Factory() {
+            super(RepresentationType.OBJECT_COLLECTION);
+        }
 
-        putId();
-        putMemberType();
+        @Override
+        public ReprRenderer<?,?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new ObjectCollectionReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
     }
 
+    private ObjectCollectionReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
+    }
     
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
+        putId();
+        putMemberType();
+        
         putDisabledReasonIfDisabled();
         
         JsonRepresentation extensions = JsonRepresentation.newMap();
@@ -67,7 +77,7 @@ public class ObjectCollectionReprBuilder
     /////////////////////////////////////////////////////
 
     @Override
-    public ObjectCollectionReprBuilder withMutatorsIfEnabled() {
+    public ObjectCollectionReprRenderer withMutatorsIfEnabled() {
         if(usability().isVetoed()) {
             return cast(this);
         }
@@ -81,7 +91,7 @@ public class ObjectCollectionReprBuilder
                         linkToBuilder.linkToMember(mutator, memberType, objectMember, mutatorSpec.suffix)
                         .withHttpMethod(mutatorSpec.httpMethod)
                         .withArguments(arguments)
-                        .build();
+                        .render();
                 representation.mapPut(mutator, detailsLink);
             }
         }
@@ -112,9 +122,9 @@ public class ObjectCollectionReprBuilder
         List<JsonRepresentation> list = Lists.newArrayList();
         for (final ObjectAdapter elementAdapter : facet.iterable(valueAdapter)) {
 
-            LinkReprBuilder newBuilder = DomainObjectReprBuilder.newLinkToBuilder(resourceContext, "object", elementAdapter);
+            LinkReprBuilder newBuilder = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, "object", elementAdapter);
 
-			list.add(newBuilder.build());
+			list.add(newBuilder.render());
         }
         
         return list;
@@ -130,11 +140,11 @@ public class ObjectCollectionReprBuilder
     }
 
     private void addLinksFormalDomainModel(JsonRepresentation links, ResourceContext resourceContext) {
-        links.arrayAdd(TypeCollectionReprBuilder.newLinkToBuilder(resourceContext, "typeCollection", objectAdapter.getSpecification(), objectMember).build());
+        links.arrayAdd(TypeCollectionReprBuilder.newLinkToBuilder(resourceContext, "typeCollection", objectAdapter.getSpecification(), objectMember).render());
     }
 
     private void addLinksIsisProprietary(JsonRepresentation links, ResourceContext resourceContext) {
-        links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).build());
+        links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).render());
     }
 
 

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java (from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprBuilder.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?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprBuilder.java&r1=1176973&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -23,28 +23,40 @@ import org.apache.isis.core.metamodel.ad
 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.viewer.ResourceContext;
+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.DomainTypeReprBuilder;
 import org.apache.isis.viewer.json.viewer.resources.domaintypes.TypePropertyReprBuilder;
 
 import com.google.common.collect.Lists;
 
-public class ObjectPropertyReprBuilder extends AbstractObjectMemberReprBuilder<ObjectPropertyReprBuilder, OneToOneAssociation> {
+public class ObjectPropertyReprRenderer extends AbstractObjectMemberReprRenderer<ObjectPropertyReprRenderer, OneToOneAssociation> {
 
-    public static ObjectPropertyReprBuilder newBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, OneToOneAssociation otoa) {
-        return new ObjectPropertyReprBuilder(resourceContext, objectAdapter, otoa);
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.OBJECT_PROPERTY);
+        }
+
+        @Override
+        public ReprRenderer<?,?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new ObjectPropertyReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
     }
     
-    public ObjectPropertyReprBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, OneToOneAssociation otoa) {
-        super(resourceContext, objectAdapter, MemberType.OBJECT_PROPERTY, otoa);
+
+    private ObjectPropertyReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
+    }
+
+    public JsonRepresentation render() {
 
         putId();
         putMemberType();
         withValue();
-    }
-
 
-    public JsonRepresentation build() {
         putDisabledReasonIfDisabled();
 
         JsonRepresentation extensions = JsonRepresentation.newMap();
@@ -66,7 +78,7 @@ public class ObjectPropertyReprBuilder e
 
 
     @Override
-    public ObjectPropertyReprBuilder withMutatorsIfEnabled() {
+    public ObjectPropertyReprRenderer withMutatorsIfEnabled() {
         if(usability().isVetoed()) {
             return cast(this);
         }
@@ -80,7 +92,7 @@ public class ObjectPropertyReprBuilder e
                         linkToBuilder.linkToMember(mutator, memberType, objectMember, mutatorSpec.suffix)
                         .withHttpMethod(mutatorSpec.httpMethod)
                         .withArguments(arguments)
-                        .build();
+                        .render();
                 representation.mapPut(mutator, detailsLink);
             }
         }
@@ -106,7 +118,7 @@ public class ObjectPropertyReprBuilder e
         if(valueAdapter == null) {
 		    return null;
 		}
-        return DomainObjectReprBuilder.valueOrRef(resourceContext, valueAdapter, objectMember.getSpecification());
+        return DomainObjectReprRenderer.valueOrRef(resourceContext, valueAdapter, objectMember.getSpecification());
     }
 
 	
@@ -114,7 +126,7 @@ public class ObjectPropertyReprBuilder e
     // choices
     /////////////////////////////////////////////////////
 
-	public ObjectPropertyReprBuilder withChoices() {
+	public ObjectPropertyReprRenderer withChoices() {
 		Object propertyChoices = propertyChoices();
 		if(propertyChoices != null) {
 			representation.mapPut("choices", propertyChoices);
@@ -130,7 +142,7 @@ public class ObjectPropertyReprBuilder e
         List<Object> list = Lists.newArrayList();
         for (final ObjectAdapter choiceAdapter : choiceAdapters) {
         	ObjectSpecification objectSpec = objectMember.getSpecification();
-        	list.add(DomainObjectReprBuilder.valueOrRef(resourceContext, choiceAdapter, objectSpec));
+        	list.add(DomainObjectReprRenderer.valueOrRef(resourceContext, choiceAdapter, objectSpec));
         }
         return list;
 	}
@@ -144,11 +156,11 @@ public class ObjectPropertyReprBuilder e
     }
 
     private void addLinksFormalDomainModel(JsonRepresentation links, ResourceContext resourceContext) {
-        links.arrayAdd(TypePropertyReprBuilder.newLinkToBuilder(resourceContext, "typeProperty", objectAdapter.getSpecification(), objectMember).build());
+        links.arrayAdd(TypePropertyReprBuilder.newLinkToBuilder(resourceContext, "typeProperty", objectAdapter.getSpecification(), objectMember).render());
     }
 
     private void addLinksIsisProprietary(JsonRepresentation links, ResourceContext resourceContext) {
-        links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).build());
+        links.arrayAdd(DomainTypeReprBuilder.newLinkToBuilder(resourceContext, "domainType", objectAdapter.getSpecification()).render());
     }
 
 }
\ No newline at end of file

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarValueReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarReprBuilder.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/ScalarValueReprRenderer.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarValueReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarValueReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -19,26 +19,32 @@ package org.apache.isis.viewer.json.view
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
 import org.apache.isis.viewer.json.viewer.JsonApplicationException;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
-
-public class ScalarReprBuilder extends ReprBuilderAbstract<ScalarReprBuilder> {
-
-    public static ScalarReprBuilder newBuilder(final ResourceContext resourceContext) {
-        return new ScalarReprBuilder(resourceContext, JsonRepresentation.newMap());
-    }
+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 ScalarValueReprRenderer extends ReprRendererAbstract<ScalarValueReprRenderer, ObjectAdapter> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+        public Factory() {
+            super(RepresentationType.SCALAR_VALUE);
+        }
 
-    public static ScalarReprBuilder newBuilder(ResourceContext resourceContext, JsonRepresentation representation) {
-        return new ScalarReprBuilder(resourceContext, representation);
+        @Override
+        public ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new ScalarValueReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
     }
 
-    private ScalarReprBuilder(final ResourceContext resourceContext, JsonRepresentation representation) {
-        super(resourceContext, representation);
+    private ScalarValueReprRenderer(final ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
     }
 
-    public ScalarReprBuilder withAdapter(final ObjectAdapter objectAdapter) {
+    public ScalarValueReprRenderer with(final ObjectAdapter objectAdapter) {
         final EncodableFacet facet = objectAdapter.getSpecification().getFacet(EncodableFacet.class);
         if(facet == null) {
             throw JsonApplicationException.create(HttpStatusCode.INTERNAL_SERVER_ERROR, "Not an (encodable) value", objectAdapter.titleString());
@@ -49,7 +55,7 @@ public class ScalarReprBuilder extends R
     }
 
     @Override
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
  
         JsonRepresentation extensions = JsonRepresentation.newMap();
         putExtensionsIsisProprietary(extensions);

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeReprBuilder.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/domaintypes/DomainTypeReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -39,7 +39,7 @@ public class DomainTypeReprBuilder exten
     }
 
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         return representation;
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeResourceServerside.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/domaintypes/DomainTypeResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -50,13 +50,13 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes").build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes").render());
         
         JsonRepresentation specList = JsonRepresentation.newArray();
         final Collection<ObjectSpecification> allSpecifications = getSpecificationLoader().allSpecifications();
         for (ObjectSpecification objectSpec : allSpecifications) {
             final LinkReprBuilder linkBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "domainType", "domainTypes/%s", objectSpec.getFullIdentifier());
-            specList.arrayAdd(linkBuilder.build());
+            specList.arrayAdd(linkBuilder.render());
         }
         
         representation.mapPut("domainTypes", specList);
@@ -72,7 +72,7 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s", domainType).build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s", domainType).render());
         
         return responseOfOk(RepresentationType.DOMAIN_TYPE, Caching.ONE_DAY, representation).build();
     }
@@ -86,7 +86,7 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/properties/%s", domainType, propertyId).build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/properties/%s", domainType, propertyId).render());
         
         return responseOfOk(RepresentationType.TYPE_PROPERTY, Caching.ONE_DAY, representation).build();
     }
@@ -100,7 +100,7 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainType/%s/collections/%s", domainType, collectionId).build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainType/%s/collections/%s", domainType, collectionId).render());
         
         return responseOfOk(RepresentationType.TYPE_COLLECTION, Caching.ONE_DAY, representation).build();
     }
@@ -114,7 +114,7 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/actions/%s", domainType, actionId).build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/actions/%s", domainType, actionId).render());
         
         return responseOfOk(RepresentationType.TYPE_ACTION, Caching.ONE_DAY, representation).build();
     }
@@ -129,7 +129,7 @@ public class DomainTypeResourceServersid
         init();
 
         JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/actions/%s/params/%s", domainType, actionId, paramName).build());
+        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "domainTypes/%s/actions/%s/params/%s", domainType, actionId, paramName).render());
         
         return responseOfOk(RepresentationType.TYPE_COLLECTION, Caching.ONE_DAY, representation).build();
     }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeActionReprBuilder.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/domaintypes/TypeActionReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeActionReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeActionReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -41,7 +41,7 @@ public class TypeActionReprBuilder exten
     }
 
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         return representation;
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeCollectionReprBuilder.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/domaintypes/TypeCollectionReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeCollectionReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeCollectionReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -40,7 +40,7 @@ public class TypeCollectionReprBuilder e
         super(resourceContext, objectSpecification, MemberType.OBJECT_COLLECTION, collection);
     }
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         return representation;
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypePropertyReprBuilder.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/domaintypes/TypePropertyReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypePropertyReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypePropertyReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -40,7 +40,7 @@ public class TypePropertyReprBuilder ext
         super(resourceContext, objectSpecification, MemberType.OBJECT_COLLECTION, property);
     }
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         return representation;
     }
 

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.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/home/HomePageReprRenderer.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,96 @@
+package org.apache.isis.viewer.json.viewer.resources.home;
+
+import java.util.List;
+
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.applib.RestfulRequest.QueryParameter;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
+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.ReprBuilder;
+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;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainServiceResourceHelper;
+import org.apache.isis.viewer.json.viewer.resources.user.UserReprRenderer;
+
+public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRenderer, Void> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+        public Factory() {
+            super(RepresentationType.HOME_PAGE);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new HomePageReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
+    }
+
+    private HomePageReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
+    }
+
+    @Override
+    public HomePageReprRenderer with(Void t) {
+        return this;
+    }
+
+    @Override
+    public JsonRepresentation render() {
+        
+        // self
+        if(includesSelf) {
+            withSelf("/");
+        }
+
+        // user
+        putLinkToUser(representation);
+
+        // services
+        putLinkToServices(representation);
+        
+        // capabilities
+        representation.mapPut("capabilities", LinkReprBuilder.newBuilder(getResourceContext(), "capabilities", "capabilities").render());
+
+        // links and extensions
+        representation.mapPut("links", JsonRepresentation.newArray());
+        representation.mapPut("extensions", JsonRepresentation.newMap());
+        
+        return representation;
+    }
+
+    private void putLinkToServices(JsonRepresentation representation) {
+
+        final LinkReprBuilder servicesLinkBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "services", "services");
+        
+        final List<String> followLinks = getResourceContext().getArg(QueryParameter.FOLLOW_LINKS);
+        if(followLinks.contains("services")) {
+            final ReprBuilder reprBuilder = 
+                    new DomainServiceResourceHelper(getResourceContext()).services();
+            servicesLinkBuilder.withValue(reprBuilder.render());
+        }
+        
+        representation.mapPut("services", servicesLinkBuilder.render());
+    }
+
+    private void putLinkToUser(JsonRepresentation representation) {
+        final LinkReprBuilder userLinkBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "user", "user");
+        
+        final List<String> followLinks = getResourceContext().getArg(QueryParameter.FOLLOW_LINKS);
+        if(followLinks.contains("user")) {
+            
+            final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.USER);
+            final UserReprRenderer renderer = 
+                    (UserReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+            renderer.with(getResourceContext().getAuthenticationSession());
+            
+            userLinkBuilder.withValue(renderer.render());
+        }
+        
+        representation.mapPut("user", userLinkBuilder.render());
+    }
+
+}
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.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/home/HomePageResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -18,7 +18,6 @@
  */
 package org.apache.isis.viewer.json.viewer.resources.home;
 
-import java.util.List;
 
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
@@ -28,14 +27,9 @@ import javax.ws.rs.core.Response;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulMediaType;
-import org.apache.isis.viewer.json.applib.RestfulRequest.QueryParameter;
 import org.apache.isis.viewer.json.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
 import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
-import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainServiceResourceHelper;
-import org.apache.isis.viewer.json.viewer.resources.user.UserReprBuilder;
-import org.apache.isis.viewer.json.viewer.resources.user.UserResourceHelper;
 
 /**
  * Implementation note: it seems to be necessary to annotate the implementation with {@link Path} rather than the
@@ -43,60 +37,18 @@ import org.apache.isis.viewer.json.viewe
  */
 public class HomePageResourceServerside extends ResourceAbstract implements HomePageResource {
 
-
     @Override
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_HOME_PAGE} )
     public Response resources() {
         init();
         
-        JsonRepresentation representation = JsonRepresentation.newMap();
-        
-        // self
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "").build());
-
-        // user
-        putLinkToUser(representation);
-
-        // services
-        putLinkToServices(representation);
-        
-        // capabilities
-        representation.mapPut("capabilities", LinkReprBuilder.newBuilder(getResourceContext(), "capabilities", "capabilities").build());
-
-        //
-        representation.mapPut("links", JsonRepresentation.newArray());
-        representation.mapPut("extensions", JsonRepresentation.newMap());
-
-        return responseOfOk(RepresentationType.HOME_PAGE, Caching.ONE_DAY, representation).build();
-    }
-
-    private void putLinkToServices(JsonRepresentation representation) {
-
-        final LinkReprBuilder servicesLinkBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "services", "services");
-        
-        final List<String> followLinks = getResourceContext().getArg(QueryParameter.FOLLOW_LINKS);
-        if(followLinks.contains("services")) {
-            final ReprBuilder reprBuilder = 
-                    new DomainServiceResourceHelper(getResourceContext()).services();
-            servicesLinkBuilder.withValue(reprBuilder.build());
-        }
-        
-        representation.mapPut("services", servicesLinkBuilder.build());
-    }
+        final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.HOME_PAGE);
+        final HomePageReprRenderer renderer = 
+                (HomePageReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.includesSelf();
 
-    private void putLinkToUser(JsonRepresentation representation) {
-        final LinkReprBuilder userLinkBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "user", "user");
-        
-        final List<String> followLinks = getResourceContext().getArg(QueryParameter.FOLLOW_LINKS);
-        if(followLinks.contains("user")) {
-            final ReprBuilder reprBuilder = 
-                    new UserResourceHelper(getResourceContext()).user();
-            userLinkBuilder.withValue(reprBuilder.build());
-        }
-        
-        representation.mapPut("user", userLinkBuilder.build());
+        return responseOfOk(RepresentationType.HOME_PAGE, Caching.ONE_DAY, renderer).build();
     }
 
 
-
 }
\ No newline at end of file

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilder.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/user/UserReprRenderer.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -18,23 +18,32 @@ package org.apache.isis.viewer.json.view
 
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderAbstract;
+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 UserReprBuilder extends TypedReprBuilderAbstract<UserReprBuilder, AuthenticationSession> {
+public class UserReprRenderer extends ReprRendererAbstract<UserReprRenderer, AuthenticationSession> {
 
-    public static UserReprBuilder newBuilder(ResourceContext resourceContext) {
-        return new UserReprBuilder(resourceContext);
-    }
+    public static class Factory extends ReprRendererFactoryAbstract {
 
-    private boolean includesSelf;
+        public Factory() {
+            super(RepresentationType.USER);
+        }
 
-    private UserReprBuilder(ResourceContext resourceContext) {
-        super(resourceContext);
+        @Override
+        public ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new UserReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
+    }
+    
+    private UserReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
     }
 
     @Override
-    public UserReprBuilder with(AuthenticationSession authenticationSession) {
+    public UserReprRenderer with(AuthenticationSession authenticationSession) {
         representation.mapPut("username", authenticationSession.getUserName());
         JsonRepresentation roles = JsonRepresentation.newArray();
         for (String role : authenticationSession.getRoles()) {
@@ -44,7 +53,7 @@ public class UserReprBuilder extends Typ
         return this;
     }
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         if(includesSelf) {
             withSelf("user");
         }
@@ -53,9 +62,4 @@ public class UserReprBuilder extends Typ
         return representation;
     }
 
-    public UserReprBuilder withSelf() {
-        this.includesSelf = true;
-        return this;
-    }
-
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.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/user/UserResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -22,11 +22,11 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulMediaType;
 import org.apache.isis.viewer.json.applib.user.UserResource;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
 import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
 
 public class UserResourceServerside extends ResourceAbstract implements UserResource {
@@ -36,12 +36,13 @@ public class UserResourceServerside exte
     public Response user() {
         init();
 
-        final TypedReprBuilderFactory factory = builderFactoryRegistry.find(RepresentationType.USER);
-        final UserReprBuilder reprBuilder = 
-                (UserReprBuilder) factory.newBuilder(getResourceContext());
-        reprBuilder.with(getAuthenticationSession());
+        final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.USER);
+        final UserReprRenderer renderer = 
+                (UserReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.includesSelf()
+                .with(getAuthenticationSession());
 
-        return responseOfOk(RepresentationType.USER, Caching.ONE_HOUR, reprBuilder.build()).build();
+        return responseOfOk(RepresentationType.USER, Caching.ONE_HOUR, renderer.render()).build();
     }
 
 



Mime
View raw message