incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1144686 - in /incubator/isis/trunk/framework: core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/ viewer/json/applib/src/main/java/org/apache/isis/v...
Date Sat, 09 Jul 2011 15:41:30 GMT
Author: danhaywood
Date: Sat Jul  9 15:41:29 2011
New Revision: 1144686

URL: http://svn.apache.org/viewvc?rev=1144686&view=rev
Log:
json viewer now renders contributed actions; also action parameters show defaults and choices;
property now shows choices; simplified some of the 'rel' values in representations

Modified:
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionContainer.java
    incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/AbstractRestfulClient.java
    incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/resources/DomainObjectResource.java
    incubator/isis/trunk/framework/viewer/json/viewer/pom.xml
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypeBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/AbstractMemberRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/ActionRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/BodyArgs.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/CollectionRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/DomainObjectRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberRepType.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberSelfRepBuilder.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberType.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MutatorSpec.java
    incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/PropertyRepBuilder.java

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionContainer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionContainer.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionContainer.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionContainer.java
Sat Jul  9 15:41:29 2011
@@ -78,7 +78,6 @@ public interface ObjectActionContainer {
      * Returns a list of all object actions, including or excluding contributed actions as
required.
      */
     List<ObjectAction> getObjectActions(Contributed contributed);
-
     
     List<ObjectAction> getServiceActionsReturning(ActionType type);
 

Modified: incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/AbstractRestfulClient.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/AbstractRestfulClient.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/AbstractRestfulClient.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/AbstractRestfulClient.java
Sat Jul  9 15:41:29 2011
@@ -18,12 +18,9 @@
  */
 package org.apache.isis.viewer.json.applib;
 
-import org.apache.log4j.Logger;
 
 public abstract class AbstractRestfulClient {
 
-    private static Logger LOG = Logger.getLogger(AbstractRestfulClient.class);
-
     private final String hostUri;
 
     public String getHostUri() {

Modified: incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/resources/DomainObjectResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/resources/DomainObjectResource.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/resources/DomainObjectResource.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/applib/src/main/java/org/apache/isis/viewer/json/applib/resources/DomainObjectResource.java
Sat Jul  9 15:41:29 2011
@@ -24,7 +24,6 @@ import java.util.List;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
-import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;

Modified: incubator/isis/trunk/framework/viewer/json/viewer/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/pom.xml?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/pom.xml (original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/pom.xml Sat Jul  9 15:41:29 2011
@@ -65,18 +65,15 @@
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-servlet_2.5_spec</artifactId>
-            <version>1.2</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-annotation_1.0_spec</artifactId>
-            <version>1.1.1</version>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-activation_1.1_spec</artifactId>
-            <version>1.1</version>
         </dependency>
 
 	</dependencies>

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -16,26 +16,33 @@
  */
 package org.apache.isis.viewer.json.viewer.representations;
 
-import java.util.List;
-
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.viewer.json.viewer.RepContext;
+import org.apache.isis.viewer.json.viewer.resources.objects.DomainObjectRepBuilder;
 
 public class LinkRepBuilder extends RepresentationBuilder {
 
     public static LinkRepBuilder newBuilder(RepContext repContext, String relSuffix, String
url) {
         return new LinkRepBuilder(repContext, relSuffix, url);
     }
-    public static TypeBuilder newTypeBuilder(RepContext repContext, String relSuffix, ObjectSpecification
objectSpec) {
-        return new TypeBuilder(repContext, relSuffix, objectSpec);
+    public static TypeBuilder newTypeBuilder(RepContext repContext, ObjectSpecification objectSpec)
{
+        return new TypeBuilder(repContext, objectSpec);
     }
 
+	public static LinkRepBuilder newObjectBuilder(RepContext repContext,
+			ObjectAdapter elementAdapter, OidStringifier oidStringifier) {
+    	String url = DomainObjectRepBuilder.urlFor(elementAdapter, oidStringifier);
+        return LinkRepBuilder.newBuilder(repContext, "object", url);
+	}
+
     private final String relSuffix;
     private final String url;
     
     private HttpMethod method = HttpMethod.GET;
     private String title;
-    private List<String> body;
+    private Object body;
     
     public LinkRepBuilder(RepContext repContext, String relSuffix, String url) {
         super(repContext);
@@ -50,12 +57,12 @@ public class LinkRepBuilder extends Repr
         this.title = title;
         return this;
     }
-    public LinkRepBuilder withBody(List<String> body) {
+    public LinkRepBuilder withBody(Object body) {
         this.body = body;
         return this;
     }
     public Representation build() {
-        representation.put("rel", repContext.relFor(relSuffix));
+        representation.put("rel", relSuffix);
         representation.put("url", repContext.urlFor(url));
         representation.put("method", method);
         representation.put("title", title);

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypeBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypeBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypeBuilder.java
Sat Jul  9 15:41:29 2011
@@ -33,14 +33,15 @@ public class TypeBuilder extends LinkRep
             java.lang.Short.class.getName(), "short",
             java.lang.Integer.class.getName(), "int",
             java.lang.Long.class.getName(), "long",
+            java.lang.Boolean.class.getName(), "boolean",
             java.lang.Float.class.getName(), "float",
             java.lang.Double.class.getName(), "double",
             java.math.BigInteger.class.getName(), "bigint",
             java.math.BigDecimal.class.getName(), "bigdec"
             );
 
-    public TypeBuilder(RepContext repContext, String relSuffix, ObjectSpecification objectSpec)
{
-        super(repContext, relSuffix, urlFor(objectSpec));
+    public TypeBuilder(RepContext repContext, ObjectSpecification objectSpec) {
+        super(repContext, "type", urlFor(objectSpec));
     }
     
     private static String urlFor(ObjectSpecification objectSpec) {

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/AbstractMemberRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/AbstractMemberRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/AbstractMemberRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/AbstractMemberRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -16,7 +16,6 @@
  */
 package org.apache.isis.viewer.json.viewer.resources.objects;
 
-import java.util.List;
 import java.util.Map;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -30,8 +29,6 @@ import org.apache.isis.viewer.json.viewe
 import org.apache.isis.viewer.json.viewer.representations.Representation;
 import org.apache.isis.viewer.json.viewer.representations.RepresentationBuilder;
 
-import com.google.common.collect.Lists;
-
 public abstract class AbstractMemberRepBuilder<T extends ObjectMember> extends RepresentationBuilder
{
 
     protected final ObjectAdapter objectAdapter;
@@ -48,23 +45,23 @@ public abstract class AbstractMemberRepB
     }
 
     protected void putSelfIfRequired() {
-        if(memberRepType.hasSelf()) {
+        if(memberRepType.isStandalone()) {
             Representation selfRep = MemberSelfRepBuilder.newBuilder(repContext, objectAdapter,
memberType, objectMember).build();
             representation.put("self", selfRep);
         }
     }
 
     protected void putMemberTypeRep() {
-        representation.put("memberType", memberType);
+        representation.put("memberType", memberType.name().toLowerCase());
     }
 
     protected void putTypeRep() {
-        Representation typeRep = LinkRepBuilder.newTypeBuilder(repContext, "type", memberType.specFor(objectMember)).build();
+        Representation typeRep = LinkRepBuilder.newTypeBuilder(repContext, memberType.specFor(objectMember)).build();
         representation.put("type", typeRep);
     }
 
     protected void putMutatorsIfRequired() {
-        if(!memberRepType.hasMutators() || usability().isVetoed()) {
+        if(!memberRepType.isStandalone() || usability().isVetoed()) {
             return;
         }
         Map<String, MutatorSpec> mutators = memberType.getMutators();
@@ -72,7 +69,7 @@ public abstract class AbstractMemberRepB
             MutatorSpec mutatorSpec = mutators.get(mutator);
             if(hasMemberFacet(mutatorSpec.mutatorFacetType)) {
                 String urlForMember = urlForMember(mutatorSpec.suffix);
-                List<String> body = mutatorArgValues(mutatorSpec);
+                Object body = mutatorArgs(mutatorSpec);
                 Representation detailsLink = 
                     LinkRepBuilder.newBuilder(repContext, mutator, urlForMember)
                         .withHttpMethod(mutatorSpec.httpMethod)
@@ -83,21 +80,21 @@ public abstract class AbstractMemberRepB
         }
     }
 
-    /**
-     * Can be optionally overridden by members that are able
-     * to provide argument values (eg contributed actions).
-     */
-    protected List<String> mutatorArgValues(MutatorSpec mutatorSpec) {
-        List<String> values = Lists.newArrayList();
-        if(mutatorSpec.argSpec.isOne()) {
-            values.add("{arg}");
+    protected Object mutatorArgs(MutatorSpec mutatorSpec) {
+    	if(mutatorSpec.bodyArgs.isNone()) {
+    		return null;
+    	}
+        if(mutatorSpec.bodyArgs.isOne()) {
+    		final Representation argRep = new Representation();
+    		argRep.put("arg", null);
+            return argRep;
         }
-        return values;
+        throw new UnsupportedOperationException("should be overridden if bodyArgs is not
0 or 1");
     }
 
-
+    
     protected void putValueIfRequired() {
-        if(!memberRepType.hasValue(memberType)) {
+        if(!memberRepType.hasValueFor(memberType)) {
             return;
         } 
         representation.put("value", valueRep());
@@ -118,11 +115,11 @@ public abstract class AbstractMemberRepB
     }
 
     protected void putDetailsIfRequired() {
-        if(!memberRepType.hasLinkToDetails()) {
+        if(!memberRepType.isInline()) {
             return;
         } 
         String urlForMember = urlForMember();
-        Representation detailsLink = LinkRepBuilder.newBuilder(repContext, "details", urlForMember).build();
+        Representation detailsLink = LinkRepBuilder.newBuilder(repContext, memberType.name().toLowerCase(),
urlForMember).build();
         representation.put("details", detailsLink);
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/ActionRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/ActionRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/ActionRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/ActionRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -19,15 +19,18 @@ package org.apache.isis.viewer.json.view
 import java.util.List;
 
 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.viewer.RepContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkRepBuilder;
 import org.apache.isis.viewer.json.viewer.representations.Representation;
 
 import com.google.common.collect.Lists;
 
 public class ActionRepBuilder extends AbstractMemberRepBuilder<ObjectAction> {
 
-    public static ActionRepBuilder newBuilder(RepContext repContext, ObjectAdapter objectAdapter,
ObjectAction oa) {
+	public static ActionRepBuilder newBuilder(RepContext repContext, ObjectAdapter objectAdapter,
ObjectAction oa) {
         return new ActionRepBuilder(repContext, objectAdapter, oa);
     }
 
@@ -37,10 +40,12 @@ public class ActionRepBuilder extends Ab
 
     public Representation build() {
         putSelfIfRequired();
+        putContributedByIfRequired();
         putTypeRep();
         putMemberTypeRep();
         representation.put("actionType", objectMember.getType());
         representation.put("numParameters", objectMember.getParameterCount());
+        putParameterDetailsIfRequired();
         putValueIfRequired();
         putDisabledReason();
         putMutatorsIfRequired();
@@ -48,17 +53,96 @@ public class ActionRepBuilder extends Ab
         return representation;
     }
     
-    protected List<String> mutatorArgValues(MutatorSpec mutatorSpec) {
-        List<String> values = Lists.newArrayList();
+	private void putContributedByIfRequired() {
+    	if(!objectMember.isContributed()) {
+    		return;
+    	}
+    	ObjectAdapter serviceAdapter = contributingServiceAdapter();
+        Representation contributedByLink = LinkRepBuilder.newObjectBuilder(repContext, serviceAdapter,
getOidStringifier()).build();
+		representation.put("contributedBy", contributedByLink);
+	}
+
+	private ObjectAdapter contributingServiceAdapter() {
+    	ObjectSpecification serviceType = objectMember.getOnType();
+    	List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
+    	for (ObjectAdapter serviceAdapter : serviceAdapters) {
+			if(serviceAdapter.getSpecification() == serviceType) {
+				return serviceAdapter;
+			}
+		}
+    	// fail fast
+    	throw new IllegalStateException("Unable to locate contributing service");
+	}
+
+    private void putParameterDetailsIfRequired() {
+    	Representation parameters = new Representation();
+    	if (memberRepType.isStandalone()) {
+    		for (int i=0; i< objectMember.getParameterCount(); i++) {
+    			ObjectActionParameter param = objectMember.getParameters().get(i);
+				parameters.put("param" + i, paramDetails(param));
+			}
+    	}
+		representation.put("parameters", parameters);
+	}
+
+	private Object paramDetails(ObjectActionParameter param) {
+		final Representation paramRep = new Representation();
+		paramRep.put("name", param.getName());
+		paramRep.put("type", LinkRepBuilder.newTypeBuilder(repContext, param.getSpecification()).build());
+		paramRep.put("num", param.getNumber());
+		paramRep.put("description", param.getDescription());
+		Object paramChoices = choicesFor(param);
+		if(paramChoices != null) {
+			paramRep.put("choices", paramChoices);
+		}
+		Object paramDefault = defaultFor(param);
+		if(paramDefault != null) {
+			paramRep.put("default", paramDefault);
+		}
+		return paramRep;
+	}
+
+	private Object choicesFor(ObjectActionParameter param) {
+		ObjectAdapter[] choiceAdapters = param.getChoices(objectAdapter);
+		if(choiceAdapters == null || choiceAdapters.length == 0) {
+			return null;
+		}
+        List<Object> list = Lists.newArrayList();
+        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
+        	ObjectSpecification objectSpec = param.getSpecification();
+        	list.add(DomainObjectRepBuilder.valueOrRef(repContext, choiceAdapter, objectSpec,
getOidStringifier(), getLocalization()));
+        }
+        return list;
+	}
+
+	private Object defaultFor(ObjectActionParameter param) {
+		ObjectAdapter defaultAdapter = param.getDefault(objectAdapter);
+		if(defaultAdapter == null) {
+			return null;
+		}
+    	ObjectSpecification objectSpec = param.getSpecification();
+    	return DomainObjectRepBuilder.valueOrRef(repContext, defaultAdapter, objectSpec, getOidStringifier(),
getLocalization());
+	}
+
+	@Override
+	protected Object mutatorArgs(MutatorSpec mutatorSpec) {
+        List<Object> values = Lists.newArrayList();
         for(int i=0; i<objectMember.getParameterCount(); i++) {
-            values.add(argValueFor(i)); 
+    		final Representation argRep = new Representation();
+    		argRep.put("arg" + i, argValueFor(i));
+            values.add(argRep); 
         }
         return values;
     }
 
-    // TODO: expect in future to provide values for contributed actions.
-    private String argValueFor(int i) {
-        return "{arg" + i + "}";
-    }
+	private Object argValueFor(int i) {
+    	if(objectMember.isContributed()) {
+    		ObjectActionParameter actionParameter = objectMember.getParameters().get(i);
+    		if (actionParameter.getSpecification().isOfType(objectAdapter.getSpecification()))
{
+    			return LinkRepBuilder.newObjectBuilder(repContext, objectAdapter, getOidStringifier()).build();
+    		}
+    	}
+    	return null;
+	}
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/BodyArgs.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/BodyArgs.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/BodyArgs.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/BodyArgs.java
Sat Jul  9 15:41:29 2011
@@ -34,4 +34,8 @@ public enum BodyArgs {
         return this == ONE;
     }
 
+	public boolean isNone() {
+		return this == NONE;
+	}
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/CollectionRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/CollectionRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/CollectionRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/CollectionRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -49,12 +49,6 @@ public class CollectionRepBuilder extend
         return representation;
     }
 
-    protected List<String> mutatorArgValues(MutatorSpec mutatorSpec) {
-        List<String> values = Lists.newArrayList();
-        values.add(null);
-        return values;
-    }
-
     @Override
     protected Object valueRep() {
         ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
@@ -64,8 +58,10 @@ public class CollectionRepBuilder extend
         final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(valueAdapter);
         List<Representation> list = Lists.newArrayList();
         for (final ObjectAdapter elementAdapter : facet.iterable(valueAdapter)) {
-            String url = DomainObjectRepBuilder.urlFor(elementAdapter, getOidStringifier());
-            list.add(LinkRepBuilder.newBuilder(repContext, "value", url).build());
+
+            LinkRepBuilder newBuilder = LinkRepBuilder.newObjectBuilder(repContext, elementAdapter,
getOidStringifier());
+
+			list.add(newBuilder.build());
         }
         
         return list;

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/DomainObjectRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/DomainObjectRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/DomainObjectRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/DomainObjectRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -19,9 +19,15 @@ package org.apache.isis.viewer.json.view
 import java.util.List;
 import java.util.Map;
 
+import org.apache.isis.applib.profiles.Localization;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
 import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
+import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
+import org.apache.isis.core.metamodel.spec.ObjectActionSet;
+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.ObjectActionContainer.Contributed;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
@@ -51,8 +57,8 @@ public class DomainObjectRepBuilder exte
     
     public Representation build() {
         RepContext repContext = this.repContext.underAttribute("_self");
-        Representation selfLink = LinkRepBuilder.newBuilder(repContext, "link", url()).build();
-        Representation selfType = LinkRepBuilder.newTypeBuilder(repContext, "type", objectAdapter.getSpecification()).build();
+        Representation selfLink = LinkRepBuilder.newBuilder(repContext, "object", url()).build();
+        Representation selfType = LinkRepBuilder.newTypeBuilder(repContext, objectAdapter.getSpecification()).build();
         String title = objectAdapter.titleString();
         Representation iconLink = LinkRepBuilder.newBuilder(repContext, "icon", icon()).build();
         Representation self = new Representation();
@@ -78,8 +84,7 @@ public class DomainObjectRepBuilder exte
     }
 
     private String url() {
-        OidStringifier oidStringifier = getOidStringifier();
-        return urlFor(objectAdapter, oidStringifier);
+        return urlFor(objectAdapter, getOidStringifier());
     }
 
     private void withAllMembers(final ObjectAdapter objectAdapter) {
@@ -102,17 +107,28 @@ public class DomainObjectRepBuilder exte
             }
         }
         
-        List<ObjectAction> actions = objectAdapter.getSpecification().getObjectActions(Contributed.EXCLUDED);
-        for (ObjectAction action : actions) {
+        List<ObjectAction> actions = objectAdapter.getSpecification().getObjectActions(Contributed.INCLUDED);
+        withActions(objectAdapter, actions);
+    }
+
+	private void withActions(final ObjectAdapter objectAdapter,
+			List<ObjectAction> actions) {
+		for (ObjectAction action : actions) {
             Consent visibility = action.isVisible(getSession(), objectAdapter);
             if(!visibility.isAllowed()) {
                 continue;
             } 
-            String id = action.getId();
-            Representation actionRep = ActionRepBuilder.newBuilder(repContext.underAttribute(id),
objectAdapter, action).build();
-            withMember(id, actionRep);
+        	if(action.getType().isSet()) {
+        		ObjectActionSet objectActionSet = (ObjectActionSet) action;
+        		List<ObjectAction> subactions = objectActionSet.getActions();
+        		withActions(objectAdapter, subactions);
+        	} else {
+                final String id = action.getId();
+                Representation actionRep = ActionRepBuilder.newBuilder(repContext.underAttribute(id),
objectAdapter, action).build();
+                withMember(id, actionRep);
+        	}
         }
-    }
+	}
 
     private void withMember(String id, Representation propertyRep) {
         members.put(id, propertyRep);
@@ -123,7 +139,7 @@ public class DomainObjectRepBuilder exte
     //
     /////////////////////////////////////////////////////////////////////
     
-    public static String urlFor(ObjectAdapter objectAdapter, OidStringifier oidStringifier)
{
+	public static String urlFor(ObjectAdapter objectAdapter, OidStringifier oidStringifier)
{
         String oidStr = oidStringifier.enString(objectAdapter.getOid());
         return "objects/" + oidStr;
     }
@@ -151,4 +167,22 @@ public class DomainObjectRepBuilder exte
         };
     }
 
+
+    /////////////////////////////////////////////////////////////////////
+    //
+    /////////////////////////////////////////////////////////////////////
+
+    public static Object valueOrRef(RepContext repContext,
+			final ObjectAdapter objectAdapter, ObjectSpecification objectSpec, OidStringifier oidStringifier,
Localization localization) {
+		ValueFacet valueFacet = objectSpec.getFacet(ValueFacet.class);
+		if(valueFacet != null) {
+			EncodableFacet encodeableFacet = objectSpec.getFacet(EncodableFacet.class);
+			return encodeableFacet.toEncodedString(objectAdapter);
+		}
+		TitleFacet titleFacet = objectSpec.getFacet(TitleFacet.class);
+		String title = titleFacet.title(objectAdapter, localization);
+		return LinkRepBuilder.newObjectBuilder(repContext, objectAdapter, oidStringifier).withTitle(title).build();
+	}
+
+
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberRepType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberRepType.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberRepType.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberRepType.java
Sat Jul  9 15:41:29 2011
@@ -37,23 +37,15 @@ public enum MemberRepType {
     STANDALONE,
     INLINE;
 
-    public boolean hasSelf() {
-        return this == STANDALONE;
-    }
-
-    public boolean hasMutators() {
-        return this == STANDALONE;
-    }
-
-    public boolean hasLinkToDetails() {
-        return this == INLINE;
-    }
+    public boolean isInline() {
+		return this == INLINE;
+	}
 
-    public boolean hasValue(MemberType memberType) {
-        return memberType.isProperty() || memberType.isCollection() && isStandalone();
+    public boolean hasValueFor(MemberType memberType) {
+        return memberType.isProperty() || memberType.isCollection() && isStandalone();
 
     }
 
-    private boolean isStandalone() {
+	public boolean isStandalone() {
         return this == STANDALONE;
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberSelfRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberSelfRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberSelfRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberSelfRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -48,12 +48,11 @@ public class MemberSelfRepBuilder extend
 
     private Representation memberLinkRep() {
         String url = AbstractMemberRepBuilder.urlForMember(objectAdapter, memberType, objectMember,
getOidStringifier());
-        return LinkRepBuilder.newBuilder(repContext, "link", url).build();
+        return LinkRepBuilder.newBuilder(repContext, "member", url).build();
     }
     
     private Representation domainObjectLinkRep() {
-        String url = DomainObjectRepBuilder.urlFor(objectAdapter, getOidStringifier());
-        return LinkRepBuilder.newBuilder(repContext, "object", url).build();
+        return LinkRepBuilder.newObjectBuilder(repContext, objectAdapter, getOidStringifier()).build();
     }
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberType.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberType.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MemberType.java
Sat Jul  9 15:41:29 2011
@@ -94,4 +94,7 @@ public enum MemberType {
         return this == MemberType.ACTION;
     }
 
+    public static MemberType lookup(final String memberType) {
+    	return valueOf(memberType.toUpperCase());
+    }
 }

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MutatorSpec.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MutatorSpec.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MutatorSpec.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/MutatorSpec.java
Sat Jul  9 15:41:29 2011
@@ -34,13 +34,13 @@ public class MutatorSpec {
     public final Class<? extends Facet> mutatorFacetType;
     public final HttpMethod httpMethod;
     public final String suffix;
-    public final BodyArgs argSpec;
+    public final BodyArgs bodyArgs;
 
-    private MutatorSpec(Class<? extends Facet> validationFacetType, Class<? extends
Facet> mutatorFacetType, HttpMethod httpMethod, BodyArgs argSpec, String suffix) {
+    private MutatorSpec(Class<? extends Facet> validationFacetType, Class<? extends
Facet> mutatorFacetType, HttpMethod httpMethod, BodyArgs bodyArgs, String suffix) {
         this.validationFacetType = validationFacetType;
         this.mutatorFacetType = mutatorFacetType;
         this.httpMethod = httpMethod;
-        this.argSpec = argSpec;
+        this.bodyArgs = bodyArgs;
         this.suffix = suffix;
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/PropertyRepBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/PropertyRepBuilder.java?rev=1144686&r1=1144685&r2=1144686&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/PropertyRepBuilder.java
(original)
+++ incubator/isis/trunk/framework/viewer/json/viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/objects/PropertyRepBuilder.java
Sat Jul  9 15:41:29 2011
@@ -16,15 +16,16 @@
  */
 package org.apache.isis.viewer.json.viewer.resources.objects;
 
+import java.util.List;
+
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.facets.object.title.TitleFacet;
-import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
 import org.apache.isis.viewer.json.viewer.RepContext;
-import org.apache.isis.viewer.json.viewer.representations.LinkRepBuilder;
 import org.apache.isis.viewer.json.viewer.representations.Representation;
 
+import com.google.common.collect.Lists;
+
 public class PropertyRepBuilder extends AbstractMemberRepBuilder<OneToOneAssociation>
{
 
     public static PropertyRepBuilder newBuilder(RepContext repContext, ObjectAdapter objectAdapter,
OneToOneAssociation otoa) {
@@ -41,26 +42,40 @@ public class PropertyRepBuilder extends 
         putMemberTypeRep();
         putValueIfRequired();
         putDisabledReason();
+        putChoices();
         putMutatorsIfRequired();
         putDetailsIfRequired();
         return representation;
     }
 
 
-    @Override
+	@Override
     protected Object valueRep() {
         ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
         if(valueAdapter == null) {
-            return null;
-        } 
-        ValueFacet valueFacet = getMemberSpecFacet(ValueFacet.class);
-        if(valueFacet != null) {
-            EncodableFacet encodableFacet = getMemberSpecFacet(EncodableFacet.class);
-            return encodableFacet.toEncodedString(valueAdapter);
-        } 
-        TitleFacet titleFacet = getMemberSpecFacet(TitleFacet.class);
-        String title = titleFacet.title(valueAdapter, getLocalization());
-        return LinkRepBuilder.newBuilder(repContext, "value", urlForObject()).withTitle(title).build();
+		    return null;
+		}
+        return DomainObjectRepBuilder.valueOrRef(repContext, valueAdapter, objectMember.getSpecification(),
getOidStringifier(), getLocalization());
     }
 
+    private void putChoices() {
+		Object propertyChoices = propertyChoices();
+		if(propertyChoices != null) {
+			representation.put("choices", propertyChoices);
+		}
+	}
+
+	private Object propertyChoices() {
+		ObjectAdapter[] choiceAdapters = objectMember.getChoices(objectAdapter);
+		if(choiceAdapters == null || choiceAdapters.length == 0) {
+			return null;
+		}
+        List<Object> list = Lists.newArrayList();
+        for (final ObjectAdapter choiceAdapter : choiceAdapters) {
+        	ObjectSpecification objectSpec = objectMember.getSpecification();
+        	list.add(DomainObjectRepBuilder.valueOrRef(repContext, choiceAdapter, objectSpec,
getOidStringifier(), getLocalization()));
+        }
+        return list;
+	}
+
 }
\ No newline at end of file



Mime
View raw message