incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1189531 [1/2] - in /incubator/isis/trunk/framework: core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/util/ core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/ tck/tck-dom/src/main/java/org/apache/isis/t...
Date Wed, 26 Oct 2011 23:12:47 GMT
Author: danhaywood
Date: Wed Oct 26 23:12:46 2011
New Revision: 1189531

URL: http://svn.apache.org/viewvc?rev=1189531&view=rev
Log:
ISIS-109: lots more changes; can now set/clear properties, addto collections (not checked removing from), and invoke actions; also tidied up the linkTo stuff for services vs objects throughout, and extended the TCK to have a parent/child entity pair

Added:
    incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/adapter/util/
    incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/FeatureTypeTest_identifierFor.java
    incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/
    incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ChildEntity.java
    incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntity.java
    incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntityRepository.java
    incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assoc/
    incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/
    incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/ParentAndChildEntityFixture.java
    incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/
    incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/ParentEntityRepositoryDefault.java
Modified:
    incubator/isis/trunk/framework/viewer/dnd-tck/src/main/resources/isis.properties
    incubator/isis/trunk/framework/viewer/html-tck/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
    incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectLinkTo.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceLinkTo.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAdapterLinkTo.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/test/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoderTest_asAdapter.java
    incubator/isis/trunk/framework/viewer/scimpi/scimpi-tck/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/viewer/wicket/wicket-tck/src/main/webapp/WEB-INF/isis.properties
    incubator/isis/trunk/framework/viewer/xhtml/xhtml-tck/src/main/webapp/WEB-INF/isis.properties

Added: incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/FeatureTypeTest_identifierFor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/FeatureTypeTest_identifierFor.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/FeatureTypeTest_identifierFor.java (added)
+++ incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facetapi/FeatureTypeTest_identifierFor.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,45 @@
+package org.apache.isis.core.metamodel.facetapi;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+
+import org.apache.isis.applib.Identifier;
+import org.junit.Test;
+
+public class FeatureTypeTest_identifierFor {
+
+    public static class SomeDomainClass {
+        private BigDecimal aBigDecimal;
+        public BigDecimal getABigDecimal() {
+            return aBigDecimal;
+        }
+        public void setABigDecimal(BigDecimal aBigDecimal) {
+            this.aBigDecimal = aBigDecimal;
+        }
+        private BigDecimal anotherBigDecimal;
+        public BigDecimal getAnotherBigDecimal() {
+            return anotherBigDecimal;
+        }
+        public void setAnotherBigDecimal(BigDecimal anotherBigDecimal) {
+            this.anotherBigDecimal = anotherBigDecimal;
+        }
+    }
+    
+    @Test
+    public void property_whenMethodNameIs_XYyyZzz() throws Exception {
+        Method method = SomeDomainClass.class.getMethod("getABigDecimal");
+        final Identifier identifierFor = FeatureType.PROPERTY.identifierFor(SomeDomainClass.class, method);
+        assertThat(identifierFor.getMemberName(), is("ABigDecimal")); // very odd compared to anotherBigDecimal, but arises from Introspector class, so presumably part of the javabeans spec.
+    }
+
+    @Test
+    public void property_whenMethodNameIs_XxxxYyyZzz() throws Exception {
+        Method method = SomeDomainClass.class.getMethod("getAnotherBigDecimal");
+        final Identifier identifierFor = FeatureType.PROPERTY.identifierFor(SomeDomainClass.class, method);
+        assertThat(identifierFor.getMemberName(), is("anotherBigDecimal"));
+    }
+
+}

Added: incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ChildEntity.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ChildEntity.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ChildEntity.java (added)
+++ incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ChildEntity.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.tck.dom.assocs;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.AbstractDomainObject;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.util.TitleBuffer;
+
+public class ChildEntity extends AbstractDomainObject {
+
+    // {{ Identification
+    public String title() {
+        final TitleBuffer buf = new TitleBuffer();
+        if(getParent() != null) {
+            buf.append(getParent().getName()).append("-");
+        }
+        buf.append(getName());
+        return buf.toString();
+    }
+    // }}
+
+    // {{ Name
+    private String name;
+
+    @MemberOrder(sequence = "1")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+    // }}
+
+    // {{ Parent
+    private ParentEntity parent;
+
+    @MemberOrder(sequence = "1")
+    @Optional
+    public ParentEntity getParent() {
+        return parent;
+    }
+
+    public void setParent(final ParentEntity parent) {
+        this.parent = parent;
+    }
+    // }}
+
+
+
+    // {{ moveTo
+    @MemberOrder(sequence = "1")
+    public ChildEntity moveTo(final ParentEntity newParent) {
+        if(newParent == getParent()) {
+            // nothing to do
+            return this;
+        }
+        if(getParent() != null) {
+            getParent().removeChild(this);
+        }
+        newParent.getChildren().add(this);
+        this.setParent(newParent);
+        return this;
+    }
+    public ParentEntity default0MoveTo() {
+        return getParent();
+    }
+    public List<ParentEntity> choices0MoveTo() {
+        return parentEntityRepository.list();
+    }
+    // }}
+
+
+    // {{ injected dependencies
+    // {{ injected: ParentEntityRepository
+    private ParentEntityRepository parentEntityRepository;
+    public void setParentEntityRepository(final ParentEntityRepository parentEntityRepository) {
+        this.parentEntityRepository = parentEntityRepository;
+    }
+    // }}
+
+
+    // }}
+
+
+    
+}

Added: incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntity.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntity.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntity.java (added)
+++ incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntity.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.tck.dom.assocs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.isis.applib.AbstractDomainObject;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.util.TitleBuffer;
+
+public class ParentEntity extends AbstractDomainObject {
+
+    // {{ Identification
+    public String title() {
+        final TitleBuffer buf = new TitleBuffer();
+        buf.append(getName());
+        return buf.toString();
+    }
+    // }}
+
+
+    // {{ Name
+    private String name;
+
+    @MemberOrder(sequence = "1")
+    @Optional
+    public String getName() {
+        return name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+    // }}
+
+    // {{ Children
+    private List<ChildEntity> children = new ArrayList<ChildEntity>();
+
+    @MemberOrder(sequence = "1")
+    public List<ChildEntity> getChildren() {
+        return children;
+    }
+
+    public void setChildren(final List<ChildEntity> children) {
+        this.children = children;
+    }
+    // }}
+
+    // {{ newChild (action)
+    public ChildEntity newChild(String name) {
+        final ChildEntity childEntity = newTransientInstance(ChildEntity.class);
+        childEntity.setName(name);
+        childEntity.setParent(this);
+        this.getChildren().add(childEntity);
+        persistIfNotAlready(childEntity);
+        return childEntity;
+    }
+    // }}
+
+    // {{ removeChild (action)
+    public ParentEntity removeChild(ChildEntity childEntity) {
+        if(children.contains(childEntity)) {
+            children.remove(childEntity);
+            childEntity.setParent(null);
+        }
+        return this;
+    }
+    public List<ChildEntity> choices0RemoveChild() {
+        return getChildren();
+    }
+    // }}
+    
+}

Added: incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntityRepository.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntityRepository.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntityRepository.java (added)
+++ incubator/isis/trunk/framework/tck/tck-dom/src/main/java/org/apache/isis/tck/dom/assocs/ParentEntityRepository.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.tck.dom.assocs;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Named;
+
+@Named("Parents")
+public interface ParentEntityRepository {
+
+    @MemberOrder(sequence="1")
+    public List<ParentEntity> list();
+
+    @MemberOrder(sequence="2")
+    public ParentEntity newEntity(String name);
+
+}

Added: incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/ParentAndChildEntityFixture.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/ParentAndChildEntityFixture.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/ParentAndChildEntityFixture.java (added)
+++ incubator/isis/trunk/framework/tck/tck-fixture/src/main/java/org/apache/isis/tck/fixture/assocs/ParentAndChildEntityFixture.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+
+package org.apache.isis.tck.fixture.assocs;
+
+import org.apache.isis.applib.fixtures.AbstractFixture;
+import org.apache.isis.tck.dom.assocs.ParentEntity;
+import org.apache.isis.tck.dom.assocs.ParentEntityRepository;
+
+
+public class ParentAndChildEntityFixture extends AbstractFixture {
+
+    @Override
+    public void install() {
+        createEntity("parent 1");
+        createEntity("parent 2");
+        createEntity("parent 3");
+        createEntity("parent 4");
+        createEntity("parent 5");
+    }
+    
+    private ParentEntity createEntity(String name) {
+        final ParentEntity parent = parentEntityRepository.newEntity(name);
+        parent.newChild("child 1");
+        parent.newChild("child 2");
+        return parent;
+    }
+
+    
+    private ParentEntityRepository parentEntityRepository;
+    public void setParentEntityRepository(ParentEntityRepository parentEntityRepository) {
+        this.parentEntityRepository = parentEntityRepository;
+    }
+    
+}

Added: incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/ParentEntityRepositoryDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/ParentEntityRepositoryDefault.java?rev=1189531&view=auto
==============================================================================
--- incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/ParentEntityRepositoryDefault.java (added)
+++ incubator/isis/trunk/framework/tck/tck-objstore-dflt/src/main/java/org/apache/isis/tck/objstore/dflt/assocs/ParentEntityRepositoryDefault.java Wed Oct 26 23:12:46 2011
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.tck.objstore.dflt.assocs;
+
+import java.util.List;
+
+import org.apache.isis.applib.AbstractFactoryAndRepository;
+import org.apache.isis.applib.annotation.QueryOnly;
+import org.apache.isis.tck.dom.assocs.ParentEntity;
+import org.apache.isis.tck.dom.assocs.ParentEntityRepository;
+
+public class ParentEntityRepositoryDefault extends AbstractFactoryAndRepository implements ParentEntityRepository {
+
+    
+    public String getId() {
+        return "parentEntities";
+    }
+
+    @QueryOnly
+    public List<ParentEntity> list() {
+        return allInstances(ParentEntity.class);
+    }
+
+    public ParentEntity newEntity(String name) {
+        ParentEntity entity = newTransientInstance(ParentEntity.class);
+        entity.setName(name);
+        persist(entity);
+        return entity;
+    }
+    
+}

Modified: incubator/isis/trunk/framework/viewer/dnd-tck/src/main/resources/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/dnd-tck/src/main/resources/isis.properties?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/dnd-tck/src/main/resources/isis.properties (original)
+++ incubator/isis/trunk/framework/viewer/dnd-tck/src/main/resources/isis.properties Wed Oct 26 23:12:46 2011
@@ -21,7 +21,8 @@ isis.services =\
     scalars.PrimitiveValuedEntityRepositoryDefault,\
     scalars.WrapperValuedEntityRepositoryDefault, \
     simples.SimpleEntityRepositoryDefault,\
-    stables.StableEntityRepositoryDefault
+    stables.StableEntityRepositoryDefault,\
+    assocs.ParentEntityRepositoryDefault
 
 isis.fixtures.prefix= org.apache.isis.tck.fixture
 isis.fixtures=\
@@ -31,7 +32,8 @@ isis.fixtures=\
     scalars.PrimitiveValuedEntityFixture,\
     scalars.WrapperValuedEntityFixture,\
     simples.SimpleEntityFixture,\
-    stables.StableEntityFixture
+    stables.StableEntityFixture,\
+    assocs.ParentAndChildEntityFixture
 
 isis.exploration.users=sven, dick, bob
 

Modified: incubator/isis/trunk/framework/viewer/html-tck/src/main/webapp/WEB-INF/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/html-tck/src/main/webapp/WEB-INF/isis.properties?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/html-tck/src/main/webapp/WEB-INF/isis.properties (original)
+++ incubator/isis/trunk/framework/viewer/html-tck/src/main/webapp/WEB-INF/isis.properties Wed Oct 26 23:12:46 2011
@@ -21,7 +21,8 @@ isis.services =\
     scalars.PrimitiveValuedEntityRepositoryDefault,\
     scalars.WrapperValuedEntityRepositoryDefault, \
     simples.SimpleEntityRepositoryDefault,\
-    stables.StableEntityRepositoryDefault
+    stables.StableEntityRepositoryDefault,\
+    assocs.ParentEntityRepositoryDefault
 
 isis.fixtures.prefix= org.apache.isis.tck.fixture
 isis.fixtures=\
@@ -31,7 +32,8 @@ isis.fixtures=\
     scalars.PrimitiveValuedEntityFixture,\
     scalars.WrapperValuedEntityFixture,\
     simples.SimpleEntityFixture,\
-    stables.StableEntityFixture
+    stables.StableEntityFixture,\
+    assocs.ParentAndChildEntityFixture
 
 isis.exploration.users=sven, dick, bob
 

Modified: incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-applib/src/main/java/org/apache/isis/viewer/json/applib/domainobjects/DomainServiceResource.java Wed Oct 26 23:12:46 2011
@@ -83,31 +83,31 @@ public interface DomainServiceResource {
     ////////////////////////////////////////////////////////////
 
     @GET
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
-    public Response serviceInvokeActionQueryOnly(
-        @PathParam("oid") final String oidStr, 
+    public Response invokeActionQueryOnly(
+        @PathParam("serviceId") final String serviceId, 
         @PathParam("actionId") final String actionId,
         @QueryParam("args") final String arguments);
 
     @PUT
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
-    public Response serviceInvokeActionIdempotent(
-        @PathParam("oid") final String oidStr, 
+    public Response invokeActionIdempotent(
+        @PathParam("serviceId") final String serviceId, 
         @PathParam("actionId") final String actionId,
         final InputStream arguments);
 
     @POST
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
     @ClientResponseType(entityType=String.class)
-    public Response serviceInvokeAction(
-        @PathParam("oid") final String oidStr, 
+    public Response invokeAction(
+        @PathParam("serviceId") final String serviceId, 
         @PathParam("actionId") final String actionId,
         final InputStream arguments);
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/main/webapp/WEB-INF/isis.properties Wed Oct 26 23:12:46 2011
@@ -21,7 +21,8 @@ isis.services =\
     scalars.PrimitiveValuedEntityRepositoryDefault,\
     scalars.WrapperValuedEntityRepositoryDefault, \
     simples.SimpleEntityRepositoryDefault,\
-    stables.StableEntityRepositoryDefault
+    stables.StableEntityRepositoryDefault,\
+    assocs.ParentEntityRepositoryDefault
 
 isis.fixtures.prefix= org.apache.isis.tck.fixture
 isis.fixtures=\
@@ -31,7 +32,8 @@ isis.fixtures=\
     scalars.PrimitiveValuedEntityFixture,\
     scalars.WrapperValuedEntityFixture,\
     simples.SimpleEntityFixture,\
-    stables.StableEntityFixture
+    stables.StableEntityFixture,\
+    assocs.ParentAndChildEntityFixture
 
 
 isis.reflector.class-substitutor=org.apache.isis.runtimes.dflt.bytecode.dflt.classsubstitutor.CglibClassSubstitutor

Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java Wed Oct 26 23:12:46 2011
@@ -154,7 +154,7 @@ public class DomainServiceResourceTest_i
         final Response responseBefore = client.follow(linkToSimpleEntity);
         final RestfulResponse<DomainObjectRepresentation> restfulResponseBefore = RestfulResponse.ofT(responseBefore);
         final DomainObjectRepresentation simpleEntityBefore = restfulResponseBefore.getEntity();
-        assertThat(simpleEntityBefore.getProperty("flag").getBoolean("value"), is(true));
+        final Boolean before = simpleEntityBefore.getProperty("flag").getBoolean("value");
 
         // and given 'toggle' action on repo
         JsonRepresentation givenAction = givenAction("simples", "toggle");
@@ -182,7 +182,9 @@ public class DomainServiceResourceTest_i
         final Response responseAfter = client.follow(linkToSimpleEntity);
         final RestfulResponse<DomainObjectRepresentation> restfulResponseAfter = RestfulResponse.ofT(responseAfter);
         final DomainObjectRepresentation simpleEntityAfter = restfulResponseAfter.getEntity();
-        assertThat(simpleEntityAfter.getProperty("flag").getBoolean("value"), is(false));
+        
+        final Boolean after = simpleEntityAfter.getProperty("flag").getBoolean("value");
+        assertThat(after, is(!before)); // ie has been toggled
     }
 
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java Wed Oct 26 23:12:46 2011
@@ -37,6 +37,8 @@ import org.apache.isis.runtimes.dflt.run
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulRequest.QueryParameter;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainServiceLinkTo;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ObjectAdapterLinkTo;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
@@ -201,4 +203,5 @@ public class ResourceContext {
 
 
 
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.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/AbstractObjectMemberReprRenderer.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java Wed Oct 26 23:12:46 2011
@@ -24,6 +24,7 @@ import org.apache.isis.core.metamodel.sp
 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.LinkBuilder;
 import org.apache.isis.viewer.json.viewer.representations.LinkFollower;
 import org.apache.isis.viewer.json.viewer.representations.Rel;
 import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
@@ -48,7 +49,7 @@ public abstract class AbstractObjectMemb
         }
     }
     
-    protected ObjectAdapterLinkTo linkToBuilder;
+    protected ObjectAdapterLinkTo linkTo;
     
     protected ObjectAdapter objectAdapter;
     protected MemberType memberType;
@@ -64,7 +65,7 @@ public abstract class AbstractObjectMemb
         this.objectAdapter = objectAndMember.getObjectAdapter();
         this.objectMember = objectAndMember.getMember();
         this.memberType = MemberType.determineFrom(objectMember);
-        usingLinkToBuilder(new DomainObjectLinkTo());
+        usingLinkTo(new DomainObjectLinkTo());
 
         // done eagerly so can use as criteria for x-ro-follow-links
         representation.mapPut(memberType.getJsProp(), objectMember.getId());
@@ -76,8 +77,8 @@ public abstract class AbstractObjectMemb
     /**
      * Must be called after {@link #with(ObjectAndMember)} (which provides the {@link #objectAdapter}).
      */
-    public R usingLinkToBuilder(ObjectAdapterLinkTo linkToBuilder) {
-        this.linkToBuilder = linkToBuilder.usingResourceContext(resourceContext).with(objectAdapter);
+    public R usingLinkTo(ObjectAdapterLinkTo linkTo) {
+        this.linkTo = linkTo.usingResourceContext(resourceContext).with(objectAdapter);
         return cast(this);
     }
 
@@ -109,6 +110,7 @@ public abstract class AbstractObjectMemb
         
         if (mode.isStandalone()){
             addLinkToSelf();
+            addLinkToUp();
         }
         if (mode.isFollowed() || mode.isStandalone()){
             addMutatorsIfEnabled();
@@ -120,26 +122,39 @@ public abstract class AbstractObjectMemb
         }
     }
     
+
     private void addLinkToSelf() {
-        getLinks().arrayAdd(linkToBuilder.linkToMember(Rel.SELF, memberType, objectMember).build());
+        getLinks().arrayAdd(linkTo.memberBuilder(Rel.SELF, memberType, objectMember).build());
     }
 
+    private void addLinkToUp() {
+        getLinks().arrayAdd(linkTo.builder(Rel.UP).build());
+    }
+    
     protected abstract void addMutatorsIfEnabled();
     
     /**
      * For subclasses to call back to when {@link #addMutatorsIfEnabled() adding mutators}.
      */
     protected void addLinkFor(final MutatorSpec mutatorSpec) {
-        if(hasMemberFacet(mutatorSpec.mutatorFacetType)) {
-            
-            JsonRepresentation arguments = mutatorArgs(mutatorSpec);
-            JsonRepresentation mutatorLink = 
-                    linkToBuilder.linkToMember(mutatorSpec.rel, memberType, objectMember, mutatorSpec.suffix)
-                    .withHttpMethod(mutatorSpec.httpMethod)
-                    .withArguments(arguments)
-                    .build();
-            getLinks().arrayAdd(mutatorLink);
-        }
+        if(!hasMemberFacet(mutatorSpec.mutatorFacetType)) {
+            return;
+        } 
+        JsonRepresentation arguments = mutatorArgs(mutatorSpec);
+        RepresentationType representationType = mutatorRepType();
+        JsonRepresentation mutatorLink = 
+                linkTo.memberBuilder(mutatorSpec.rel, memberType, objectMember, representationType, mutatorSpec.suffix)
+                .withHttpMethod(mutatorSpec.httpMethod)
+                .withArguments(arguments)
+                .build();
+        getLinks().arrayAdd(mutatorLink);
+    }
+
+    /**
+     * Default implementation is suitable for properties and collections
+     */
+    protected RepresentationType mutatorRepType() {
+        return memberType.getRepresentationType();
     }
 
     /**
@@ -161,7 +176,7 @@ public abstract class AbstractObjectMemb
     
     private R addDetailsLink() {
         final JsonRepresentation link = 
-                linkToBuilder.linkToMember(Rel.DETAILS, memberType, objectMember).build();
+                linkTo.memberBuilder(Rel.DETAILS, memberType, objectMember).build();
         getLinks().arrayAdd(link);
         
         final LinkFollower membersLinkFollower = getLinkFollower();

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectLinkTo.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/DomainObjectLinkTo.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectLinkTo.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectLinkTo.java Wed Oct 26 23:12:46 2011
@@ -27,7 +27,6 @@ public class DomainObjectLinkTo implemen
 
     protected ResourceContext resourceContext;
     protected ObjectAdapter objectAdapter;
-    protected Rel rel;
 
     @Override
     public final DomainObjectLinkTo usingResourceContext(ResourceContext resourceContext) {
@@ -44,7 +43,12 @@ public class DomainObjectLinkTo implemen
     
     @Override
     public LinkBuilder builder() {
-        return LinkBuilder.newBuilder(resourceContext, linkRel(), RepresentationType.DOMAIN_OBJECT, linkRef());
+        return builder(null);
+    }
+
+    @Override
+    public LinkBuilder builder(Rel rel) {
+        return LinkBuilder.newBuilder(resourceContext, relElseDefault(rel), RepresentationType.DOMAIN_OBJECT, linkRef());
     }
 
     /**
@@ -62,21 +66,24 @@ public class DomainObjectLinkTo implemen
         return buf.toString();
     }
 
+    private Rel relElseDefault(Rel rel) {
+        return rel != null ? rel : defaultRel();
+    }
+
     /**
-     * hook method
+     * hook method; used by {@link #builder(Rel)}.
      */
-    protected Rel linkRel() {
-        return rel!=null?rel:Rel.OBJECT;
+    protected Rel defaultRel() {
+        return Rel.OBJECT;
     }
 
     @Override
-    public ObjectAdapterLinkTo with(Rel rel) {
-        this.rel = rel;
-        return this;
+    public final LinkBuilder memberBuilder(Rel rel, MemberType memberType, ObjectMember objectMember, String... parts) {
+        return memberBuilder(rel, memberType, objectMember, memberType.getRepresentationType(), parts);
     }
 
     @Override
-    public final LinkBuilder linkToMember(Rel rel, MemberType memberType, ObjectMember objectMember, String... parts) {
+    public final LinkBuilder memberBuilder(Rel rel, MemberType memberType, ObjectMember objectMember, RepresentationType representationType, String... parts) {
         StringBuilder buf = new StringBuilder(linkRef());
         buf.append("/").append(memberType.getUrlPart()).append(objectMember.getId());
         for(String part: parts) {
@@ -86,9 +93,8 @@ public class DomainObjectLinkTo implemen
             buf.append("/").append(part);
         }
         String url = buf.toString();
-        return LinkBuilder.newBuilder(resourceContext, rel, memberType.getRepresentationType(), url);
+        return LinkBuilder.newBuilder(resourceContext, rel, representationType, url);
     }
-
     
 
 }
\ 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/domainobjects/DomainObjectReprRenderer.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/DomainObjectReprRenderer.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java Wed Oct 26 23:12:46 2011
@@ -22,6 +22,7 @@ import org.apache.isis.core.metamodel.ad
 import org.apache.isis.core.metamodel.consent.Consent;
 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.services.ServiceUtil;
 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;
@@ -89,14 +90,18 @@ public class DomainObjectReprRenderer ex
 
         // self
         if(includesSelf && objectAdapter.isPersistent()) {
-            JsonRepresentation self = linkToBuilder.with(Rel.SELF).with(objectAdapter).builder().build();
+            JsonRepresentation self = linkToBuilder.with(objectAdapter).builder(Rel.SELF).build();
             getLinks().arrayAdd(self);
         }
 
         // title
         String title = objectAdapter.titleString();
-        representation.mapPut("oid", OidUtils.getOidStr(resourceContext, objectAdapter));
         representation.mapPut("title", title);
+        representation.mapPut("oid", OidUtils.getOidStr(resourceContext, objectAdapter));
+        final boolean isService = objectAdapter.getSpecification().isService();
+        if(isService) {
+            representation.mapPut("serviceId", ServiceUtil.id(objectAdapter.getObject()));
+        }
         
         // members
         withMembers(objectAdapter);
@@ -107,12 +112,11 @@ public class DomainObjectReprRenderer ex
                 DomainTypeReprRenderer.newLinkToBuilder(getResourceContext(), Rel.DESCRIBEDBY, objectAdapter.getSpecification()).build());
         
         // extensions
-        getExtensions();
+        getExtensions().mapPut("isService", isService);
         
         return representation;
     }
 
-
     private DomainObjectReprRenderer withMembers(ObjectAdapter objectAdapter) {
         JsonRepresentation members = JsonRepresentation.newArray();
         List<ObjectAssociation> associations = objectAdapter.getSpecification().getAssociations();
@@ -140,7 +144,7 @@ public class DomainObjectReprRenderer ex
                         (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
                 
                 renderer.with(new ObjectAndProperty(objectAdapter, property))
-                        .usingLinkToBuilder(linkToBuilder);
+                        .usingLinkTo(linkToBuilder);
                 
                 members.arrayAdd(renderer.render());
             }
@@ -152,7 +156,7 @@ public class DomainObjectReprRenderer ex
                         (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
 
                 renderer.with(new ObjectAndCollection(objectAdapter, collection))
-                    .usingLinkToBuilder(linkToBuilder);
+                    .usingLinkTo(linkToBuilder);
                 
                 members.arrayAdd(renderer.render());
             }
@@ -179,7 +183,7 @@ public class DomainObjectReprRenderer ex
                         (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), linkFollower, JsonRepresentation.newMap());
                 
                 renderer.with(new ObjectAndAction(objectAdapter, action))
-                        .usingLinkToBuilder(linkToBuilder);
+                        .usingLinkTo(linkToBuilder);
 
                 members.arrayAdd(renderer.render());
             }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.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/DomainObjectResourceServerside.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java Wed Oct 26 23:12:46 2011
@@ -76,7 +76,7 @@ public class DomainObjectResourceServers
         
         final DomainObjectReprRenderer renderer = 
                 (DomainObjectReprRenderer) rendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());
-        renderer.with(objectAdapter);
+        renderer.with(objectAdapter).includesSelf();
         
         ResponseBuilder respBuilder = responseOfOk(renderer, Caching.NONE);
         
@@ -114,7 +114,7 @@ public class DomainObjectResourceServers
         init(RepresentationType.OBJECT_PROPERTY);
         
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
         
         return helper.propertyDetails(objectAdapter, propertyId, Caching.NONE);
     }
@@ -128,11 +128,11 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-        
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+        
         final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
-                objectAdapter, propertyId, Intent.MUTATE);
+                propertyId, Intent.MUTATE);
 
         ObjectSpecification propertySpec = property.getSpecification();
         String bodyAsString = DomainResourceHelper.asStringUtf8(body);
@@ -160,11 +160,11 @@ public class DomainObjectResourceServers
             @PathParam("propertyId") final String propertyId) {
         init();
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+        
         final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
-                objectAdapter, propertyId, Intent.MUTATE);
+                propertyId, Intent.MUTATE);
 
         Consent consent = property.isAssociationValid(objectAdapter, null);
         if (consent.isVetoed()) {
@@ -191,11 +191,11 @@ public class DomainObjectResourceServers
         @PathParam("collectionId") final String collectionId) {
         init(RepresentationType.OBJECT_COLLECTION);
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+
         final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
-                objectAdapter, collectionId, Intent.ACCESS);
+                collectionId, Intent.ACCESS);
 
         RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
         final ObjectCollectionReprRenderer renderer = 
@@ -215,11 +215,11 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+
         final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
-                objectAdapter, collectionId, Intent.MUTATE);
+                collectionId, Intent.MUTATE);
 
         if (!collection.getCollectionSemantics().isSet()) {
             throw JsonApplicationException.create(
@@ -252,11 +252,11 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+
         final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
-                objectAdapter, collectionId, Intent.MUTATE);
+                collectionId, Intent.MUTATE);
 
         if (!collection.getCollectionSemantics().isListOrArray()) {
             throw JsonApplicationException.create(
@@ -290,11 +290,11 @@ public class DomainObjectResourceServers
 
         init();
         
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+
         final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
-                objectAdapter, collectionId, Intent.MUTATE);
+                collectionId, Intent.MUTATE);
 
         ObjectSpecification collectionSpec = collection.getSpecification();
         String bodyAsString = DomainResourceHelper.asStringUtf8(body);
@@ -324,11 +324,10 @@ public class DomainObjectResourceServers
             @PathParam("actionId") final String actionId) {
         init(RepresentationType.OBJECT_ACTION);
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        
-        return helper.actionPrompt(actionId, objectAdapter);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
+
+        return helper.actionPrompt(actionId);
     }
 
 
@@ -346,11 +345,10 @@ public class DomainObjectResourceServers
             @QueryParam("args") final String arguments) {
         init(RepresentationType.GENERIC);
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
 
-        return helper.invokeActionQueryOnly(objectAdapter, actionId, arguments);
+        return helper.invokeActionQueryOnly(actionId, arguments);
     }
 
     @PUT
@@ -362,11 +360,10 @@ public class DomainObjectResourceServers
             final InputStream arguments) {
         init(RepresentationType.GENERIC);
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
         
-        return helper.invokeActionIdempotent(objectAdapter, actionId, arguments);
+        return helper.invokeActionIdempotent(actionId, arguments);
     }
 
 
@@ -379,11 +376,10 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init(RepresentationType.GENERIC);
         
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
         
-        return helper.invokeAction(objectAdapter, actionId, body);
+        return helper.invokeAction(actionId, body);
     }
 
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.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/DomainResourceHelper.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java Wed Oct 26 23:12:46 2011
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map.Entry;
 
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
@@ -33,7 +32,6 @@ import org.apache.isis.core.metamodel.co
 import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
-import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
 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;
@@ -44,7 +42,6 @@ import org.apache.isis.core.metamodel.sp
 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.applib.blocks.LinkRepresentation;
 import org.apache.isis.viewer.json.applib.util.JsonMapper;
 import org.apache.isis.viewer.json.applib.util.UrlEncodingUtils;
 import org.apache.isis.viewer.json.viewer.JsonApplicationException;
@@ -69,12 +66,23 @@ import com.google.common.io.ByteStreams;
 public class DomainResourceHelper {
     
     private final ResourceContext resourceContext;
+    private ObjectAdapterLinkTo adapterLinkTo;
 
     // TODO: inject somehow instead
     private final RendererFactoryRegistry rendererFactoryRegistry = RendererFactoryRegistry.instance;
+    private final ObjectAdapter objectAdapter;
 
-    public DomainResourceHelper(ResourceContext resourceContext) {
+
+    public DomainResourceHelper(ResourceContext resourceContext, ObjectAdapter objectAdapter) {
         this.resourceContext = resourceContext;
+        this.objectAdapter = objectAdapter;
+        using(new DomainObjectLinkTo());
+    }
+
+    public DomainResourceHelper using(ObjectAdapterLinkTo linkTo) {
+        adapterLinkTo = linkTo;
+        adapterLinkTo.usingResourceContext(resourceContext).with(objectAdapter);
+        return this;
     }
 
     // //////////////////////////////////////////////////////////////
@@ -87,13 +95,13 @@ public class DomainResourceHelper {
             final Caching caching) {
 
         final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
-                objectAdapter, propertyId, Intent.ACCESS);
+                propertyId, Intent.ACCESS);
 
         RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
         final ObjectPropertyReprRenderer renderer = 
                 (ObjectPropertyReprRenderer) factory.newRenderer(resourceContext, null, JsonRepresentation.newMap());
         
-        renderer.with(new ObjectAndProperty(objectAdapter, property))
+        renderer.with(new ObjectAndProperty(objectAdapter, property)).usingLinkTo(adapterLinkTo)
                 .asStandalone();
         
         return ResourceAbstract.responseOfOk(renderer, caching).build();
@@ -103,15 +111,16 @@ public class DomainResourceHelper {
     // action Prompt
     // //////////////////////////////////////////////////////////////
 
-    Response actionPrompt(final String actionId, final ObjectAdapter serviceAdapter) {
+    Response actionPrompt(final String actionId) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
-                serviceAdapter, actionId, Intent.ACCESS);
+                actionId, Intent.ACCESS);
 
         RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
         final ObjectActionReprRenderer renderer = 
                 (ObjectActionReprRenderer) factory.newRenderer(resourceContext, null, JsonRepresentation.newMap());
         
-        renderer.with(new ObjectAndAction(serviceAdapter, action))
+        renderer.with(new ObjectAndAction(objectAdapter, action))
+                .usingLinkTo(adapterLinkTo)
                 .asStandalone();
 
         return ResourceAbstract.responseOfOk(renderer, Caching.NONE).build();
@@ -131,11 +140,10 @@ public class DomainResourceHelper {
     }
 
     Response invokeActionQueryOnly(
-            final ObjectAdapter objectAdapter, 
             final String actionId, 
             final String argumentsQueryString) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
-                objectAdapter, actionId, Intent.ACCESS);
+                actionId, Intent.ACCESS);
 
         final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext, action);
         if(!actionSemantics.isQueryOnly()) {
@@ -145,7 +153,7 @@ public class DomainResourceHelper {
 
         JsonRepresentation arguments = parseQueryString(action, argumentsQueryString);
         
-        return invokeActionUsingAdapters(objectAdapter, action, arguments);
+        return invokeActionUsingAdapters(action, arguments);
     }
 
 
@@ -167,12 +175,11 @@ public class DomainResourceHelper {
     }
 
     Response invokeActionIdempotent(
-            final ObjectAdapter objectAdapter, 
             final String actionId, 
             final InputStream body) {
         
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
-                objectAdapter, actionId, Intent.MUTATE);
+                actionId, Intent.MUTATE);
 
         final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext, action);
         if(!actionSemantics.isIdempotent()) {
@@ -183,21 +190,20 @@ public class DomainResourceHelper {
         String bodyAsString = asStringUtf8(body);
         final JsonRepresentation arguments = readBodyAsMap(bodyAsString);
 
-        return invokeActionUsingAdapters(objectAdapter, action, arguments);
+        return invokeActionUsingAdapters(action, arguments);
     }
 
-    Response invokeAction(final ObjectAdapter objectAdapter, final String actionId, final InputStream body) {
+    Response invokeAction(final String actionId, final InputStream body) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
-                objectAdapter, actionId, Intent.MUTATE);
+                actionId, Intent.MUTATE);
         
         String bodyAsString = asStringUtf8(body);
         final JsonRepresentation arguments = readBodyAsMap(bodyAsString);
 
-        return invokeActionUsingAdapters(objectAdapter, action, arguments);
+        return invokeActionUsingAdapters(action, arguments);
     }
 
     Response invokeActionUsingAdapters(
-        final ObjectAdapter objectAdapter,
         final ObjectAction action,
         final JsonRepresentation arguments) {
         
@@ -241,15 +247,15 @@ public class DomainResourceHelper {
         
         final CollectionFacet collectionFacet = returnedAdapter.getSpecification().getFacet(CollectionFacet.class);
         if (collectionFacet != null) {
-            representation = representationWithSelfFor(RepresentationType.LIST, objectAdapter, action, arguments);
+            representation = representationWithSelfFor(RepresentationType.LIST, action, arguments);
             
             final Collection<ObjectAdapter> collectionAdapters = collectionFacet.collection(returnedAdapter);
 
             final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.LIST);
             final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(resourceContext, null, representation);
-            renderer.with(collectionAdapters);
-            renderer.withReturnType(action.getReturnType());
-            renderer.withElementType(returnedAdapter.getElementSpecification());
+            renderer.with(collectionAdapters)
+                    .withReturnType(action.getReturnType())
+                    .withElementType(returnedAdapter.getElementSpecification());
             
             return ResourceAbstract.responseOfOk(renderer, Caching.NONE).build();
         }
@@ -257,13 +263,14 @@ public class DomainResourceHelper {
         
         final EncodableFacet encodableFacet = returnedAdapter.getSpecification().getFacet(EncodableFacet.class);
         if(encodableFacet != null) {
-            representation = representationWithSelfFor(RepresentationType.SCALAR_VALUE, objectAdapter, action, arguments);
+            representation = representationWithSelfFor(RepresentationType.SCALAR_VALUE, action, arguments);
             
             final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.SCALAR_VALUE);
 
             ScalarValueReprRenderer renderer = (ScalarValueReprRenderer) factory.newRenderer(resourceContext, null, representation);
-            renderer.with(returnedAdapter);
-            renderer.withReturnType(action.getReturnType());
+            renderer.with(returnedAdapter)
+                    .withReturnType(action.getReturnType());
+            
             return ResourceAbstract.responseOfOk(renderer, Caching.NONE).build();
         }
 
@@ -282,14 +289,18 @@ public class DomainResourceHelper {
     }
 
 
-    private JsonRepresentation representationWithSelfFor(final RepresentationType representationType, final ObjectAdapter objectAdapter, final ObjectAction action, final JsonRepresentation bodyArgs) {
+    private JsonRepresentation representationWithSelfFor(final RepresentationType representationType, final ObjectAction action, final JsonRepresentation bodyArgs) {
         JsonRepresentation representation = JsonRepresentation.newMap();
         final JsonRepresentation links = JsonRepresentation.newArray();
         representation.mapPut("links", links);
         
-        String oid = OidUtils.getOidStr(resourceContext, objectAdapter);
-        final JsonRepresentation selfLink = 
-                LinkBuilder.newBuilder(resourceContext, Rel.SELF, representationType.getMediaType(), "objects/%s/actions/%s/invoke", oid, action.getId()).build();
+        final LinkBuilder memberBuilder = adapterLinkTo.memberBuilder(Rel.SELF, MemberType.ACTION, action, representationType, "invoke");
+        final JsonRepresentation selfLink = memberBuilder.build();
+
+        // TODO: delete this stuff
+        //String oid = OidUtils.getOidStr(resourceContext, objectAdapter);
+        //LinkBuilder.newBuilder(resourceContext, Rel.SELF, representationType.getMediaType(), "objects/%s/actions/%s/invoke", oid, action.getId()).build();
+        
         links.arrayAdd(selfLink);
         selfLink.mapPut("args", bodyArgs);
         return representation;
@@ -344,7 +355,7 @@ public class DomainResourceHelper {
      * @throws JsonMappingException 
      * @throws JsonParseException 
      */
-    private ObjectAdapter objectAdapterFor(
+    ObjectAdapter objectAdapterFor(
             final ObjectSpecification spec,
             final String urlEncodedJson) throws JsonParseException, JsonMappingException, IOException {
 
@@ -370,20 +381,19 @@ public class DomainResourceHelper {
     // ///////////////////////////////////////////////////////////////////
 
     protected OneToOneAssociation getPropertyThatIsVisibleAndUsable(
-        final ObjectAdapter objectAdapter,
-        final String propertyId, final Intent intent) {
+        final String propertyId,
+        final Intent intent) {
+        
         ObjectAssociation association = objectAdapter.getSpecification()
                 .getAssociation(propertyId);
         if (association == null || !association.isOneToOneAssociation()) {
             throwNotFoundException(propertyId, MemberType.PROPERTY);
         }
         OneToOneAssociation property = (OneToOneAssociation) association;
-        return memberThatIsVisibleAndUsable(objectAdapter, property, MemberType.PROPERTY,
-                intent);
+        return memberThatIsVisibleAndUsable(property, MemberType.PROPERTY, intent);
     }
 
     protected OneToManyAssociation getCollectionThatIsVisibleAndUsable(
-        final ObjectAdapter objectAdapter,
         final String collectionId,
         final Intent intent) {
 
@@ -393,27 +403,24 @@ public class DomainResourceHelper {
             throwNotFoundException(collectionId, MemberType.COLLECTION);
         }
         OneToManyAssociation collection = (OneToManyAssociation) association;
-        return memberThatIsVisibleAndUsable(objectAdapter, collection, MemberType.COLLECTION,
-                intent);
+        return memberThatIsVisibleAndUsable(collection, MemberType.COLLECTION, intent);
     }
 
     protected ObjectAction getObjectActionThatIsVisibleAndUsable(
-        final ObjectAdapter objectAdapter,
-        final String actionId,
-        Intent intent) {
+            final String actionId,
+            Intent intent) {
 
         ObjectAction action = objectAdapter.getSpecification().getObjectAction(actionId);
         if (action == null) {
             throwNotFoundException(actionId, MemberType.ACTION);
         }
         
-        return memberThatIsVisibleAndUsable(objectAdapter, action, MemberType.ACTION, intent);
+        return memberThatIsVisibleAndUsable(action, MemberType.ACTION, intent);
     }
 
     protected <T extends ObjectMember> T memberThatIsVisibleAndUsable(
-        final ObjectAdapter objectAdapter,
-        T objectMember, final MemberType memberType,
-        final Intent intent) {
+            T objectMember,
+            final MemberType memberType, final Intent intent) {
         String memberId = objectMember.getId();
         AuthenticationSession authenticationSession = resourceContext.getAuthenticationSession();
         if (objectMember.isVisible(authenticationSession, objectAdapter).isVetoed()) {
@@ -467,7 +474,7 @@ public class DomainResourceHelper {
                     resourceFor(objectSpec));
         }
 
-        ObjectAdapter proposedValueAdapter = objectAdapterFor(resourceContext, objectSpec, arguments);
+        ObjectAdapter proposedValueAdapter = objectAdapterFor(resourceContext, objectSpec, representation);
         return proposedValueAdapter;
     }
 
@@ -588,4 +595,5 @@ public class DomainResourceHelper {
     }
 
 
+
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceLinkTo.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/DomainServiceLinkTo.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceLinkTo.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceLinkTo.java Wed Oct 26 23:12:46 2011
@@ -22,7 +22,6 @@ import org.apache.isis.viewer.json.viewe
 import org.apache.isis.viewer.json.viewer.representations.Rel;
 
 public class DomainServiceLinkTo extends DomainObjectLinkTo {
-
     private String serviceId;
 
     @Override
@@ -38,13 +37,13 @@ public class DomainServiceLinkTo extends
     }
     
     @Override
-    protected Rel linkRel() {
-         return rel!=null?rel:Rel.SERVICE;
+    protected Rel defaultRel() {
+         return Rel.SERVICE;
     }
     
     @Override
-    public LinkBuilder builder() {
-        return super.builder().withId(serviceId);
+    public LinkBuilder builder(Rel rel) {
+        return super.builder(rel).withId(serviceId);
     }
 
 }
\ 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/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=1189531&r1=1189530&r2=1189531&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 Wed Oct 26 23:12:46 2011
@@ -70,21 +70,20 @@ public class DomainServiceResourceServer
     @GET
     @Path("/{serviceId}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
-    @Override
     public Response service(
             @PathParam("serviceId") String serviceId) {
-        RepresentationType representationType = RepresentationType.DOMAIN_OBJECT;
-        init(representationType);
+        init(RepresentationType.DOMAIN_OBJECT);
         
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
         
-        final RendererFactory factory = rendererFactoryRegistry.find(representationType);
+        final RendererFactory rendererFactory = 
+                rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
+        
         final DomainObjectReprRenderer renderer = 
-                (DomainObjectReprRenderer) factory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());
+                (DomainObjectReprRenderer) rendererFactory.newRenderer(getResourceContext(), null, JsonRepresentation.newMap());
         renderer.usingLinkToBuilder(new DomainServiceLinkTo())
-                    .includesSelf()
-                    .with(serviceAdapter);
-        
+                    .with(serviceAdapter)
+                    .includesSelf();
 
         return responseOfOk(renderer, Caching.ONE_DAY).build();
     }
@@ -103,7 +102,7 @@ public class DomainServiceResourceServer
         init(RepresentationType.OBJECT_PROPERTY);
 
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo());
 
         return helper.propertyDetails(serviceAdapter, propertyId, Caching.ONE_DAY);
     }
@@ -122,11 +121,10 @@ public class DomainServiceResourceServer
             @PathParam("actionId") final String actionId) {
         init(RepresentationType.OBJECT_ACTION);
 
-        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
-
         final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo());
 
-        return helper.actionPrompt(actionId, serviceAdapter);
+        return helper.actionPrompt(actionId);
     }
 
     
@@ -135,44 +133,50 @@ public class DomainServiceResourceServer
     ////////////////////////////////////////////////////////////
 
     @GET
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
-    public Response serviceInvokeActionQueryOnly(
-            @PathParam("oid") final String oidStr, 
+    public Response invokeActionQueryOnly(
+            @PathParam("serviceId") final String serviceId, 
             @PathParam("actionId") final String actionId,
             @QueryParam("args") final String arguments) {
         init(RepresentationType.GENERIC);
 
-        // TODO
-        throw new UnsupportedOperationException();
+        final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo());
+
+        return helper.invokeActionQueryOnly(actionId, arguments);
     }
 
     @PUT
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
-    public Response serviceInvokeActionIdempotent(
-            @PathParam("oid") final String oidStr, 
+    public Response invokeActionIdempotent(
+            @PathParam("serviceId") final String serviceId, 
             @PathParam("actionId") final String actionId,
             final InputStream arguments) {
         init(RepresentationType.GENERIC);
 
-        // TODO
-        throw new UnsupportedOperationException();
+        final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo());
+
+        return helper.invokeActionIdempotent(actionId, arguments);
     }
 
     @POST
-    @Path("/{oid}/actions/{actionId}/invoke")
+    @Path("/{serviceId}/actions/{actionId}/invoke")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
-    public Response serviceInvokeAction(
-            @PathParam("oid") final String oidStr, 
+    public Response invokeAction(
+            @PathParam("serviceId") final String serviceId, 
             @PathParam("actionId") final String actionId,
             final InputStream arguments) {
         init(RepresentationType.GENERIC);
 
-        // TODO
-        throw new UnsupportedOperationException();
+        final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId);
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo());
+
+        return helper.invokeAction(actionId, arguments);
     }
 
 }

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.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/JsonValueEncoder.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/JsonValueEncoder.java Wed Oct 26 23:12:46 2011
@@ -60,11 +60,17 @@ public final class JsonValueEncoder {
         }
         
         if(isInteger(objectSpec)) {
-            if(!representation.isInt()) {
-                throwIncompatibleException(objectSpec, representation);
-            } 
-            String argStr = ""+representation.asInt();
-            return encodableFacet.fromEncodedString(argStr);
+            if(representation.isInt()) {
+                String argStr = ""+representation.asInt();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            // best effort
+            if(representation.isString()) {
+                String argStr = representation.asString();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            // give up
+            throwIncompatibleException(objectSpec, representation);
         }
         
         if(isLong(objectSpec)) {
@@ -76,27 +82,77 @@ public final class JsonValueEncoder {
         }
         
         if(isBigInteger(objectSpec)) {
-            if(!representation.isBigInteger()) {
-                throwIncompatibleException(objectSpec, representation);
-            } 
-            String argStr = ""+representation.asBigInteger();
-            return encodableFacet.fromEncodedString(argStr);
+            if(representation.isBigInteger()) {
+                String argStr = ""+representation.asBigInteger();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            // best effort
+            if(representation.isLong()) {
+                String argStr = ""+representation.asLong();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isInt()) {
+                String argStr = ""+representation.asInt();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isString()) {
+                String argStr = representation.asString();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            // give up
+            throwIncompatibleException(objectSpec, representation);
         }
         
         if(isBigDecimal(objectSpec)) {
-            if(!representation.isBigDecimal()) {
-                throwIncompatibleException(objectSpec, representation);
-            } 
-            String argStr = ""+representation.asBigDecimal();
-            return encodableFacet.fromEncodedString(argStr);
+            if(representation.isBigDecimal()) { 
+                String argStr = ""+representation.asBigDecimal();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            // best effort
+            if(representation.isBigInteger()) { 
+                String argStr = ""+representation.asBigInteger();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isDouble()) {
+                String argStr = ""+representation.asDouble();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            if(representation.isLong()) {
+                String argStr = ""+representation.asLong();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isInt()) {
+                String argStr = ""+representation.asInt();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isString()) {
+                String argStr = representation.asString();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            // give up
+            throwIncompatibleException(objectSpec, representation);
         }
         
         if(isDouble(objectSpec)) {
-            if(!representation.isDouble()) {
-                throwIncompatibleException(objectSpec, representation);
-            } 
-            String argStr = ""+representation.asDouble();
-            return encodableFacet.fromEncodedString(argStr);
+            if(representation.isDouble()) {
+                String argStr = ""+representation.asDouble();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            // best effort
+            if(representation.isLong()) {
+                String argStr = ""+representation.asLong();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isInt()) {
+                String argStr = ""+representation.asInt();
+                return encodableFacet.fromEncodedString(argStr);
+            } 
+            if(representation.isString()) {
+                String argStr = representation.asString();
+                return encodableFacet.fromEncodedString(argStr);
+            }
+            // give up
+            throwIncompatibleException(objectSpec, representation);
         }
         
         if(!representation.isString()) {

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java Wed Oct 26 23:12:46 2011
@@ -47,7 +47,7 @@ public class ListReprRenderer extends Re
         }
     }
 
-    private ObjectAdapterLinkTo linkToBuilder;
+    private ObjectAdapterLinkTo linkTo;
     private Collection<ObjectAdapter> objectAdapters;
     private ObjectSpecification elementType;
     private ObjectSpecification returnType;
@@ -58,7 +58,7 @@ public class ListReprRenderer extends Re
     }
     
     public ListReprRenderer usingLinkToBuilder(ObjectAdapterLinkTo objectAdapterLinkToBuilder) {
-        this.linkToBuilder = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
+        this.linkTo = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
         return this;
     }
 
@@ -98,7 +98,7 @@ public class ListReprRenderer extends Re
         final LinkFollower linkFollower = getLinkFollower().follow("values");
 
         for(ObjectAdapter adapter: objectAdapters) {
-            JsonRepresentation linkToObject = linkToBuilder.with(adapter).builder().build();
+            JsonRepresentation linkToObject = linkTo.with(adapter).builder().build();
             values.arrayAdd(linkToObject);
 
             if(linkFollower.matches(linkToObject)) {
@@ -112,13 +112,5 @@ public class ListReprRenderer extends Re
         representation.mapPut("values", values);
     }
 
-    private void addLinkToReturnType() {
-        addLink(Rel.RETURN_TYPE, returnType);
-    }
-
-    private void addLinkToElementType() {
-        addLink(Rel.ELEMENT_TYPE, elementType);
-    }
-
 
 }
\ 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/domainobjects/ObjectActionReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java?rev=1189531&r1=1189530&r2=1189531&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java Wed Oct 26 23:12:46 2011
@@ -20,6 +20,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.object.value.ValueFacet;
 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;
@@ -83,7 +85,9 @@ public class ObjectActionReprRenderer ex
         RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
         final ObjectActionReprRenderer renderer = 
                 (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), getLinkFollower(), JsonRepresentation.newMap());
-        renderer.with(new ObjectAndAction(objectAdapter, objectMember)).asFollowed();
+        renderer.with(new ObjectAndAction(objectAdapter, objectMember))
+                .usingLinkTo(linkTo)
+                .asFollowed();
         detailsLink.mapPut("value", renderer.render());
     }
 
@@ -129,6 +133,21 @@ public class ObjectActionReprRenderer ex
         return argMap;
     }
 
+    @Override
+    protected RepresentationType mutatorRepType() {
+        final ObjectSpecification returnType = objectMember.getReturnType();
+        if(returnType == null) {
+            return RepresentationType.GENERIC;
+        }
+        if(returnType.containsFacet(CollectionFacet.class)) {
+            return RepresentationType.LIST;
+        }
+        if(returnType.containsFacet(ValueFacet.class)) {
+            return RepresentationType.SCALAR_VALUE;
+        }
+        return RepresentationType.DOMAIN_OBJECT;
+    }
+    
     private Object argValueFor(int i) {
         if(objectMember.isContributed()) {
             ObjectActionParameter actionParameter = objectMember.getParameters().get(i);



Mime
View raw message