incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1204499 - in /incubator/isis/trunk/framework: ./ core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ core/metamodel/src/test/java/org/ap...
Date Mon, 21 Nov 2011 13:57:55 GMT
Author: danhaywood
Date: Mon Nov 21 13:57:54 2011
New Revision: 1204499

URL: http://svn.apache.org/viewvc?rev=1204499&view=rev
Log:
ISIS-109: fixing regression (parameter.getName() was returning camelCase instead of 'Proper
name')

Added:
    incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getId_and_getName.java
      - copied, changed from r1198408, incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getName.java
Removed:
    incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getName.java
Modified:
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionParameter.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectFeature.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectMember.java
    incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstract.java
    incubator/isis/trunk/framework/pom.xml

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionParameter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionParameter.java?rev=1204499&r1=1204498&r2=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionParameter.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectActionParameter.java
Mon Nov 21 13:57:54 2011
@@ -94,4 +94,5 @@ public interface ObjectActionParameter e
     ObjectAdapter[] getChoices(ObjectAdapter adapter);
 
     ObjectAdapter getDefault(ObjectAdapter adapter);
+
 }

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectFeature.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectFeature.java?rev=1204499&r1=1204498&r2=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectFeature.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectFeature.java
Mon Nov 21 13:57:54 2011
@@ -34,6 +34,12 @@ import org.apache.isis.core.metamodel.sp
 public interface ObjectFeature extends Specification {
 
     /**
+     * Returns the identifier of the member, which must not change. This should be all camel-case
with no spaces: so if
+     * the member is called 'Return Date' then the a suitable id would be 'ReturnDate'.
+     */
+    String getId();
+
+    /**
      * Return the name for this member - the field or action. This is based on the name of
this member.
      * 
      * @see #getIdentifier()

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectMember.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectMember.java?rev=1204499&r1=1204498&r2=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectMember.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectMember.java
Mon Nov 21 13:57:54 2011
@@ -34,15 +34,6 @@ import org.apache.isis.core.metamodel.in
  */
 public interface ObjectMember extends ObjectFeature {
 
-    // /////////////////////////////////////////////////////////////
-    // Identifiers
-    // /////////////////////////////////////////////////////////////
-
-    /**
-     * Returns the identifier of the member, which must not change. This should be all camel-case
with no spaces: so if
-     * the member is called 'Return Date' then the a suitable id would be 'ReturnDate'.
-     */
-    String getId();
 
     // /////////////////////////////////////////////////////////////
     // Name, Description, Help (convenience for facets)

Modified: incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstract.java?rev=1204499&r1=1204498&r2=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstract.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstract.java
Mon Nov 21 13:57:54 2011
@@ -106,7 +106,7 @@ public abstract class ObjectActionParame
     }
 
     @Override
-    public String getName() {
+    public String getId() {
         final NamedFacet facet = getFacet(NamedFacet.class);
         if (facet != null && facet.value() != null) {
             return StringUtils.camelLowerFirst(facet.value());
@@ -130,6 +130,32 @@ public abstract class ObjectActionParame
         return StringUtils.camelLowerFirst(name + (indexOf+1));
     }
 
+    
+    @Override
+    public String getName() {
+        final NamedFacet facet = getFacet(NamedFacet.class);
+        if (facet != null && facet.value() != null) {
+            return facet.value();
+        }
+        final String name = getSpecification().getSingularName();
+        List<ObjectActionParameter> parameters = getAction().getParameters(new Filter<ObjectActionParameter>()
{
+
+            @Override
+            public boolean accept(ObjectActionParameter t) {
+                return equalsShortIdentifier(t.getSpecification(), getSpecification());
+            }
+
+            protected boolean equalsShortIdentifier(final ObjectSpecification spec1, final
ObjectSpecification spec2) {
+                return spec1.getShortIdentifier().toLowerCase().equals(spec2.getShortIdentifier().toLowerCase());
+            }
+        });
+        if (parameters.size() == 1) {
+            return name;
+        }
+        int indexOf = parameters.indexOf(this);
+        return name + " " + (indexOf+1);
+    }
+
     @Override
     public String getDescription() {
         final DescribedAsFacet facet = getFacet(DescribedAsFacet.class);

Copied: incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getId_and_getName.java
(from r1198408, incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getName.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getId_and_getName.java?p2=incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getId_and_getName.java&p1=incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getName.java&r1=1198408&r2=1204499&rev=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getName.java
(original)
+++ incubator/isis/trunk/framework/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/specimpl/ObjectActionParameterAbstractTest_getId_and_getName.java
Mon Nov 21 13:57:54 2011
@@ -42,7 +42,7 @@ import org.junit.runner.RunWith;
 import com.google.common.collect.Lists;
 
 @RunWith(JMock.class)
-public class ObjectActionParameterAbstractTest_getName {
+public class ObjectActionParameterAbstractTest_getId_and_getName {
 
     private final static class ObjectActionParameterAbstractToTest extends ObjectActionParameterAbstract
{
         private ObjectActionParameterAbstractToTest(int number, ObjectActionImpl objectAction,
TypedHolder peer) {
@@ -130,7 +130,7 @@ public class ObjectActionParameterAbstra
     }
 
     @Test
-    public void whenNamedFacetPresent() throws Exception {
+    public void getId_whenNamedFacetPresent() throws Exception {
 
         objectActionParameter = new ObjectActionParameterAbstractToTest(0, parentAction,
actionParamPeer);
 
@@ -144,7 +144,25 @@ public class ObjectActionParameterAbstra
             }
         });
 
-        assertThat(objectActionParameter.getName(), is("someParameterName"));
+        assertThat(objectActionParameter.getId(), is("someParameterName"));
+    }
+
+    @Test
+    public void getName_whenNamedFacetPresent() throws Exception {
+
+        objectActionParameter = new ObjectActionParameterAbstractToTest(0, parentAction,
actionParamPeer);
+
+        context.checking(new Expectations() {
+            {
+                one(actionParamPeer).getFacet(NamedFacet.class);
+                will(returnValue(namedFacet));
+
+                atLeast(1).of(namedFacet).value();
+                will(returnValue("Some parameter name"));
+            }
+        });
+
+        assertThat(objectActionParameter.getName(), is("Some parameter name"));
     }
 
     @SuppressWarnings("unchecked")
@@ -168,7 +186,27 @@ public class ObjectActionParameterAbstra
     }
 
     @Test
-    public void whenNamedFaceNotPresentAndMultipleParamsOfSameType() throws Exception {
+    public void getId_whenNamedFaceNotPresentAndMultipleParamsOfSameType() throws Exception
{
+
+        objectActionParameter = new ObjectActionParameterAbstractToTest(2, parentAction,
actionParamPeer);
+        objectActionParameter.setSpecification(stubSpecForString);
+
+        context.checking(new Expectations() {
+            {
+                one(actionParamPeer).getFacet(NamedFacet.class);
+                will(returnValue(null));
+
+                one(parentAction).getParameters((Filter<ObjectActionParameter>) with(anything()));
+                will(returnValue(Lists.newArrayList(stubObjectActionParameterString, objectActionParameter,
+                    stubObjectActionParameterString2)));
+            }
+        });
+
+        assertThat(objectActionParameter.getId(), is("string2"));
+    }
+
+    @Test
+    public void getName_whenNamedFaceNotPresentAndMultipleParamsOfSameType() throws Exception
{
 
         objectActionParameter = new ObjectActionParameterAbstractToTest(2, parentAction,
actionParamPeer);
         objectActionParameter.setSpecification(stubSpecForString);
@@ -184,7 +222,7 @@ public class ObjectActionParameterAbstra
             }
         });
 
-        assertThat(objectActionParameter.getName(), is("string2"));
+        assertThat(objectActionParameter.getName(), is("string 2"));
     }
 
 

Modified: incubator/isis/trunk/framework/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/pom.xml?rev=1204499&r1=1204498&r2=1204499&view=diff
==============================================================================
--- incubator/isis/trunk/framework/pom.xml (original)
+++ incubator/isis/trunk/framework/pom.xml Mon Nov 21 13:57:54 2011
@@ -1100,17 +1100,6 @@ archetype includes this explicit depende
 			    <version>1.3</version>
 			</dependency>
 
-            <dependency>
-                <!-- dependency of net.sf.json-lib -->
-                <groupId>xom</groupId>
-                <artifactId>xom</artifactId>
-                <version>1.1</version>
-                <!-- dependency is optional because XOM is under LGPL, so not compatible
with ASF licensing-->
-                <!-- it is required for XML/xpath support in the JSON viewer, and only
used in the json applib tests -->
-                <optional>true</optional>
-                <scope>test</scope>
-            </dependency>   
-
 
             <!-- JSON libraries -->
             <dependency>
@@ -1128,12 +1117,6 @@ archetype includes this explicit depende
                 <artifactId>jackson-mapper-asl</artifactId>
                 <version>1.8.2</version>
             </dependency>
-	        <dependency>
-	            <groupId>net.sf.json-lib</groupId>
-	            <artifactId>json-lib</artifactId>
-	            <version>2.4</version>
-	            <classifier>jdk15</classifier>
-	        </dependency>
             
 
 			<!-- Databases -->



Mime
View raw message