You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/12/05 23:21:54 UTC

git commit: ISIS-624: @Decimal annotation and facet factories.

Updated Branches:
  refs/heads/master c3d8ca29b -> ee0910c76


ISIS-624: @Decimal annotation and facet factories.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/ee0910c7
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/ee0910c7
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/ee0910c7

Branch: refs/heads/master
Commit: ee0910c763db8ac9fbfd7135f5754a825bed304c
Parents: c3d8ca2
Author: Dan Haywood <da...@apache.org>
Authored: Thu Dec 5 22:18:39 2013 +0000
Committer: Dan Haywood <da...@apache.org>
Committed: Thu Dec 5 22:18:39 2013 +0000

----------------------------------------------------------------------
 ...ivedFromJdoColumnAnnotationFacetFactory.java | 12 ++-
 .../prop/column/BigDecimalFacetFallback.java    |  8 +-
 .../scalars/ScalarPanelTextFieldAbstract.java   |  8 +-
 .../apache/isis/applib/annotation/Decimal.java  | 45 +++++++++++
 .../org/apache/isis/applib/annotation/Mask.java |  9 ++-
 .../isis/applib/annotation/MaxLength.java       |  1 -
 ...lFacetForParameterFromDecimalAnnotation.java | 50 ++++++++++++
 ...erivedFromDecimalAnnotationFacetFactory.java | 70 +++++++++++++++++
 ...alFacetForPropertyFromDecimalAnnotation.java | 51 ++++++++++++
 ...erivedFromDecimalAnnotationFacetFactory.java | 63 +++++++++++++++
 .../BigDecimalValueSemanticsProvider.java       |  7 +-
 .../dflt/ProgrammingModelFacetsJava5.java       |  5 ++
 .../BigDecimalAnnotationFacetFactoryTest.java   | 82 ++++++++++++++++++++
 .../dom/src/main/java/dom/todo/ToDoItem.java    |  5 +-
 14 files changed, 394 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.java b/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.java
index c6372d8..a5ff082 100644
--- a/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.java
+++ b/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.java
@@ -28,12 +28,13 @@ import org.apache.isis.core.metamodel.facets.Annotations;
 import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
 import org.apache.isis.core.metamodel.facets.FacetedMethod;
 import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueSemanticsProvider;
 
 
 public class BigDecimalDerivedFromJdoColumnAnnotationFacetFactory extends FacetFactoryAbstract {
 
-    private static final int DEFAULT_LENGTH = BigDecimalFacetFallback.DEFAULT_LENGTH;
-    private static final int DEFAULT_SCALE = BigDecimalFacetFallback.DEFAULT_SCALE;
+    private static final int DEFAULT_LENGTH = BigDecimalValueSemanticsProvider.DEFAULT_LENGTH;
+    private static final int DEFAULT_SCALE = BigDecimalValueSemanticsProvider.DEFAULT_SCALE;
 
     public BigDecimalDerivedFromJdoColumnAnnotationFacetFactory() {
         super(FeatureType.PROPERTIES_ONLY);
@@ -53,12 +54,15 @@ public class BigDecimalDerivedFromJdoColumnAnnotationFacetFactory extends FacetF
         if (annotation == null) {
             facet = new BigDecimalFacetFallback(holder);
         } else {
-            facet = new BigDecimalFacetDerivedFromJdoColumn(holder, valueElseDefault(annotation.length(), DEFAULT_LENGTH), valueElseDefault(annotation.scale(), DEFAULT_SCALE));
+            facet = new BigDecimalFacetDerivedFromJdoColumn(
+                            holder, 
+                            valueElseDefault(annotation.length(), DEFAULT_LENGTH), 
+                            valueElseDefault(annotation.scale(), DEFAULT_SCALE));
         }
         FacetUtil.addFacet(facet);
     }
 
-    Integer valueElseDefault(final int value, final int defaultValue) {
+    private final static Integer valueElseDefault(final int value, final int defaultValue) {
         return value != -1? value: defaultValue;
     }
 

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalFacetFallback.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalFacetFallback.java b/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalFacetFallback.java
index f978730..2e11b3e 100644
--- a/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalFacetFallback.java
+++ b/component/objectstore/jdo/jdo-metamodel/src/main/java/org/apache/isis/objectstore/jdo/metamodel/facets/prop/column/BigDecimalFacetFallback.java
@@ -22,13 +22,11 @@ import org.apache.isis.core.metamodel.facetapi.Facet;
 import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
 import org.apache.isis.core.metamodel.facetapi.FacetHolder;
 import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueSemanticsProvider;
 
 
 public class BigDecimalFacetFallback extends FacetAbstract implements BigDecimalValueFacet {
 
-    static final int DEFAULT_LENGTH = 18;
-    static final int DEFAULT_SCALE = 2;
-
     public static Class<? extends Facet> type() {
         return BigDecimalValueFacet.class;
     }
@@ -39,11 +37,11 @@ public class BigDecimalFacetFallback extends FacetAbstract implements BigDecimal
 
     @Override
     public Integer getLength() {
-        return DEFAULT_LENGTH;
+        return BigDecimalValueSemanticsProvider.DEFAULT_LENGTH;
     }
 
     @Override
     public Integer getScale() {
-        return DEFAULT_SCALE;
+        return BigDecimalValueSemanticsProvider.DEFAULT_SCALE;
     }
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
index b9e56cc..0d7c34e 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/ScalarPanelTextFieldAbstract.java
@@ -131,16 +131,10 @@ public abstract class ScalarPanelTextFieldAbstract<T extends Serializable> exten
     }
 
     protected void addStandardSemantics() {
-         setRequiredIfSpecified();
+         textField.setRequired(getModel().isRequired());
          setTextFieldSizeAndMaxLengthIfSpecified(textField);
     }
 
-    private void setRequiredIfSpecified() {
-        final ScalarModel scalarModel = getModel();
-        final boolean required = scalarModel.isRequired();
-        textField.setRequired(required);
-    }
-
     protected void setTextFieldSizeAndMaxLengthIfSpecified(AbstractTextComponent<T> textField) {
 
         final Integer maxLength = getValueOf(getModel(), MaxLengthFacet.class);

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/applib/src/main/java/org/apache/isis/applib/annotation/Decimal.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Decimal.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Decimal.java
new file mode 100644
index 0000000..e4f6320
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Decimal.java
@@ -0,0 +1,45 @@
+/*
+ *  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.applib.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The length and scale for a decimal value.
+ * 
+ * <p>
+ * If using the JDO object store, then the <tt>@Column</tt> annotation should usually be used to indicate
+ * length (precision) and scale of properties.  However, the <tt>@Column</tt> annotation is not, of course, valid for 
+ * action parameters.  This annotation is therefore of use for action parameters whose value is intended to be
+ * compatible with JDO-annotated properties.  If the <tt>@Column</tt> and {@link Decimal} annotations are both
+ * present on a property, then they must be compatible (and Isis' metamodel validator will flag up any 
+ * incompatibility). 
+ */
+@Inherited
+@Target({ ElementType.METHOD, ElementType.PARAMETER })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Decimal {
+    int length() default -1;
+    int scale() default -1;
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/applib/src/main/java/org/apache/isis/applib/annotation/Mask.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/Mask.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/Mask.java
index 1c48af3..69b1e00 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/Mask.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/Mask.java
@@ -26,9 +26,12 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * Provides a mask that a value entry should conform to
+ * Provides a mask that a value entry should conform to.
  * 
- * A mask to apply to string attributes.
+ * <p>
+ * <b>NOTE</b>: this annotation has not been implemented in the Wicket viewer.
+ * Since the Wicket viewer is the only currently released viewer, this annotation
+ * has been marked as deprecated to flag up this fact.
  * 
  * <p>
  * The characters that can be used are shown in the following table (adapted
@@ -191,7 +194,9 @@ import java.lang.annotation.Target;
  * </tr>
  * </table>
  * 
+ * @deprecated - not supported by the Wicket viewer
  */
+@Deprecated
 @Inherited
 @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/applib/src/main/java/org/apache/isis/applib/annotation/MaxLength.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/annotation/MaxLength.java b/core/applib/src/main/java/org/apache/isis/applib/annotation/MaxLength.java
index 35626b7..ccc5abe 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/annotation/MaxLength.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/annotation/MaxLength.java
@@ -30,7 +30,6 @@ import java.lang.annotation.Target;
  * 
  * <p>
  * Can also be specified for types that are annotated as <tt>@Value</tt> types.
- * To apply, the value must have string semantics.
  */
 @Inherited
 @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER })

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalFacetForParameterFromDecimalAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalFacetForParameterFromDecimalAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalFacetForParameterFromDecimalAnnotation.java
new file mode 100644
index 0000000..6d1e474
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalFacetForParameterFromDecimalAnnotation.java
@@ -0,0 +1,50 @@
+/*
+ *  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.core.progmodel.facets.param.decimal;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+
+public class BigDecimalFacetForParameterFromDecimalAnnotation extends FacetAbstract implements BigDecimalValueFacet {
+
+    private final Integer length;
+    private final Integer scale;
+
+    public static Class<? extends Facet> type() {
+        return BigDecimalValueFacet.class;
+    }
+
+    public BigDecimalFacetForParameterFromDecimalAnnotation(final FacetHolder holder, final Integer length, final Integer scale) {
+        super(BigDecimalFacetForParameterFromDecimalAnnotation.type(), holder, Derivation.NOT_DERIVED);
+        this.length = length;
+        this.scale = scale;
+    }
+
+    @Override
+    public Integer getLength() {
+        return length;
+    }
+
+    @Override
+    public Integer getScale() {
+        return scale;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory.java
new file mode 100644
index 0000000..6bb37fc
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/param/decimal/BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory.java
@@ -0,0 +1,70 @@
+/*
+ *  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.core.progmodel.facets.param.decimal;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.apache.isis.applib.annotation.Decimal;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueSemanticsProvider;
+
+public class BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory extends FacetFactoryAbstract {
+
+    private static final int DEFAULT_LENGTH = BigDecimalValueSemanticsProvider.DEFAULT_LENGTH;
+    private static final int DEFAULT_SCALE = BigDecimalValueSemanticsProvider.DEFAULT_SCALE;
+
+    public BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory() {
+        super(FeatureType.PARAMETERS_ONLY);
+    }
+
+    @Override
+    public void processParams(ProcessParameterContext processParameterContext) {
+
+        final Method method = processParameterContext.getMethod();
+        final int paramNum = processParameterContext.getParamNum();
+        
+        final Annotation[] parameterAnnotations = Annotations.getParameterAnnotations(method)[paramNum];
+
+        for (final Annotation parameterAnnotation : parameterAnnotations) {
+            if (parameterAnnotation instanceof Decimal) {
+                FacetUtil.addFacet(create((Decimal) parameterAnnotation, processParameterContext.getFacetHolder()));
+                return;
+            }
+        }
+    }
+
+    private BigDecimalValueFacet create(final Decimal annotation, final FacetHolder holder) {
+        return annotation == null ? null : 
+            new BigDecimalFacetForParameterFromDecimalAnnotation(
+                    holder, 
+                    valueElseDefault(annotation.length(), DEFAULT_LENGTH), 
+                    valueElseDefault(annotation.scale(), DEFAULT_SCALE));
+    }
+
+    private static Integer valueElseDefault(final int value, final int defaultValue) {
+        return value != -1? value: defaultValue;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalFacetForPropertyFromDecimalAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalFacetForPropertyFromDecimalAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalFacetForPropertyFromDecimalAnnotation.java
new file mode 100644
index 0000000..1b743bd
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalFacetForPropertyFromDecimalAnnotation.java
@@ -0,0 +1,51 @@
+/*
+ *  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.core.progmodel.facets.properties.decimal;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+
+
+public class BigDecimalFacetForPropertyFromDecimalAnnotation extends FacetAbstract implements BigDecimalValueFacet {
+
+    private final Integer length;
+    private final Integer scale;
+
+    public static Class<? extends Facet> type() {
+        return BigDecimalValueFacet.class;
+    }
+
+    public BigDecimalFacetForPropertyFromDecimalAnnotation(final FacetHolder holder, final Integer length, final Integer scale) {
+        super(BigDecimalFacetForPropertyFromDecimalAnnotation.type(), holder, Derivation.NOT_DERIVED);
+        this.length = length;
+        this.scale = scale;
+    }
+
+    @Override
+    public Integer getLength() {
+        return length;
+    }
+
+    @Override
+    public Integer getScale() {
+        return scale;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory.java
new file mode 100644
index 0000000..affa82f
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/properties/decimal/BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory.java
@@ -0,0 +1,63 @@
+/*
+ *  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.core.progmodel.facets.properties.decimal;
+
+import java.math.BigDecimal;
+
+import org.apache.isis.applib.annotation.Decimal;
+import org.apache.isis.core.metamodel.facetapi.FacetUtil;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueSemanticsProvider;
+
+public class BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory extends FacetFactoryAbstract {
+
+    private static final int DEFAULT_LENGTH = BigDecimalValueSemanticsProvider.DEFAULT_LENGTH;
+    private static final int DEFAULT_SCALE = BigDecimalValueSemanticsProvider.DEFAULT_SCALE;
+
+    public BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory() {
+        super(FeatureType.PROPERTIES_ONLY);
+    }
+
+    @Override
+    public void process(final ProcessMethodContext processMethodContext) {
+
+        final Decimal annotation = Annotations.getAnnotation(processMethodContext.getMethod(), Decimal.class);
+
+        if(BigDecimal.class != processMethodContext.getMethod().getReturnType()) {
+            return;
+        } 
+        final BigDecimalValueFacet facet;
+        final FacetedMethod holder = processMethodContext.getFacetHolder();
+        
+        if (annotation == null) {
+            return;
+        }
+        facet = new BigDecimalFacetForPropertyFromDecimalAnnotation(holder, valueElseDefault(annotation.length(), DEFAULT_LENGTH), valueElseDefault(annotation.scale(), DEFAULT_SCALE));
+        FacetUtil.addFacet(facet);
+    }
+
+    Integer valueElseDefault(final int value, final int defaultValue) {
+        return value != -1? value: defaultValue;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
index 12372f4..a32875f 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/bigdecimal/BigDecimalValueSemanticsProvider.java
@@ -44,6 +44,9 @@ public class BigDecimalValueSemanticsProvider extends ValueSemanticsProviderAndF
     private static final int TYPICAL_LENGTH = 10;
     private static final BigDecimal DEFAULT_VALUE = new BigDecimal(0);
 
+    public static final int DEFAULT_LENGTH = 18;
+    public static final int DEFAULT_SCALE = 2;
+
     private final NumberFormat format;
 
     /**
@@ -69,12 +72,12 @@ public class BigDecimalValueSemanticsProvider extends ValueSemanticsProviderAndF
     
     @Override
     public Integer getLength() {
-        return 18;
+        return DEFAULT_LENGTH;
     }
 
     @Override
     public Integer getScale() {
-        return 2;
+        return DEFAULT_SCALE;
     }
 
     // //////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
index a41a863..03c3694 100644
--- a/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
+++ b/core/metamodel/src/main/java/org/apache/isis/progmodels/dflt/ProgrammingModelFacetsJava5.java
@@ -132,6 +132,7 @@ import org.apache.isis.core.progmodel.facets.param.autocomplete.ActionParameterA
 import org.apache.isis.core.progmodel.facets.param.choices.enums.ParameterChoicesFacetDerivedFromChoicesFacetFacetFactory;
 import org.apache.isis.core.progmodel.facets.param.choices.method.ActionChoicesFacetFactory;
 import org.apache.isis.core.progmodel.facets.param.choices.methodnum.ActionParameterChoicesFacetFactory;
+import org.apache.isis.core.progmodel.facets.param.decimal.BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory;
 import org.apache.isis.core.progmodel.facets.param.defaults.fromtype.ParameterDefaultDerivedFromTypeFacetFactory;
 import org.apache.isis.core.progmodel.facets.param.defaults.methodnum.ActionParameterDefaultsFacetFactory;
 import org.apache.isis.core.progmodel.facets.param.describedas.annotation.DescribedAsAnnotationOnParameterFacetFactory;
@@ -150,6 +151,7 @@ import org.apache.isis.core.progmodel.facets.properties.accessor.PropertyAccesso
 import org.apache.isis.core.progmodel.facets.properties.autocomplete.PropertyAutoCompleteFacetFactory;
 import org.apache.isis.core.progmodel.facets.properties.choices.enums.PropertyChoicesFacetDerivedFromChoicesFacetFacetFactory;
 import org.apache.isis.core.progmodel.facets.properties.choices.method.PropertyChoicesFacetFactory;
+import org.apache.isis.core.progmodel.facets.properties.decimal.BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory;
 import org.apache.isis.core.progmodel.facets.properties.defaults.fromtype.PropertyDefaultDerivedFromTypeFacetFactory;
 import org.apache.isis.core.progmodel.facets.properties.defaults.method.PropertyDefaultFacetFactory;
 import org.apache.isis.core.progmodel.facets.properties.disabled.fromimmutable.DisabledFacetForPropertyDerivedFromImmutableTypeFacetFactory;
@@ -330,6 +332,9 @@ public final class ProgrammingModelFacetsJava5 extends ProgrammingModelAbstract
         addFactory(DescribedAsAnnotationOnTypeFacetFactory.class);
         addFactory(DescribedAsOnMemberFacetFactory.class);
         addFactory(DescribedAsAnnotationOnParameterFacetFactory.class);
+        
+        addFactory(BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory.class);
+        addFactory(BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory.class);
 
         addFactory(DisabledFacetFactory.class);
         addFactory(EncodableAnnotationFacetFactory.class);

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/propparam/decimal/BigDecimalAnnotationFacetFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/propparam/decimal/BigDecimalAnnotationFacetFactoryTest.java b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/propparam/decimal/BigDecimalAnnotationFacetFactoryTest.java
new file mode 100644
index 0000000..cd4adb8
--- /dev/null
+++ b/core/metamodel/src/test/java/org/apache/isis/core/progmodel/facets/propparam/decimal/BigDecimalAnnotationFacetFactoryTest.java
@@ -0,0 +1,82 @@
+/*
+ *  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.core.progmodel.facets.propparam.decimal;
+
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+
+import org.apache.isis.applib.annotation.Decimal;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessMethodContext;
+import org.apache.isis.core.metamodel.facets.FacetFactory.ProcessParameterContext;
+import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.progmodel.facets.AbstractFacetFactoryTest;
+import org.apache.isis.core.progmodel.facets.param.decimal.BigDecimalFacetForParameterFromDecimalAnnotation;
+import org.apache.isis.core.progmodel.facets.param.decimal.BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory;
+import org.apache.isis.core.progmodel.facets.param.typicallen.annotation.TypicalLengthAnnotationOnParameterFacetFactory;
+import org.apache.isis.core.progmodel.facets.properties.decimal.BigDecimalFacetForPropertyFromDecimalAnnotation;
+import org.apache.isis.core.progmodel.facets.properties.decimal.BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory;
+import org.apache.isis.core.progmodel.facets.value.bigdecimal.BigDecimalValueFacet;
+
+public class BigDecimalAnnotationFacetFactoryTest extends AbstractFacetFactoryTest {
+
+    public void testDecimalAnnotationPickedUpOnProperty() {
+        final BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory facetFactory = new BigDecimalForPropertyDerivedFromDecimalAnnotationFacetFactory();
+
+        class Order {
+            @SuppressWarnings("unused")
+            @Decimal(length=14, scale=4)
+            public BigDecimal getCost() {
+                return null;
+            }
+        }
+        final Method method = findMethod(Order.class, "getCost");
+
+        facetFactory.process(new ProcessMethodContext(Order.class, null, null, method, methodRemover, facetedMethod));
+
+        final Facet facet = facetedMethod.getFacet(BigDecimalValueFacet.class);
+        assertNotNull(facet);
+        assertTrue(facet instanceof BigDecimalFacetForPropertyFromDecimalAnnotation);
+        final BigDecimalFacetForPropertyFromDecimalAnnotation annotation = (BigDecimalFacetForPropertyFromDecimalAnnotation) facet;
+        assertEquals(new Integer(14), annotation.getLength());
+        assertEquals(new Integer(4), annotation.getScale());
+    }
+
+    public void testDecimalAnnotationPickedUpOnActionParameter() {
+        final BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory facetFactory = new BigDecimalForParameterDerivedFromDecimalAnnotationFacetFactory();
+
+        class Order {
+            @SuppressWarnings("unused")
+            public void updateCost(@Decimal(length=14,scale=4) final BigDecimal cost) {
+            }
+        }
+        final Method method = findMethod(Order.class, "updateCost", new Class[] { BigDecimal.class });
+
+        facetFactory.processParams(new ProcessParameterContext(method, 0, facetedMethodParameter));
+
+        final Facet facet = facetedMethodParameter.getFacet(BigDecimalValueFacet.class);
+        assertNotNull(facet);
+        assertTrue(facet instanceof BigDecimalFacetForParameterFromDecimalAnnotation);
+        final BigDecimalFacetForParameterFromDecimalAnnotation annotation = (BigDecimalFacetForParameterFromDecimalAnnotation) facet;
+        assertEquals(new Integer(14), annotation.getLength());
+        assertEquals(new Integer(4), annotation.getScale());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/ee0910c7/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
index bf5b43c..ea0910d 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
@@ -48,8 +48,10 @@ import org.apache.isis.applib.annotation.Bulk;
 import org.apache.isis.applib.annotation.ActionSemantics.Of;
 import org.apache.isis.applib.annotation.Bulk.InteractionContext;
 import org.apache.isis.applib.annotation.ActionSemantics;
+import org.apache.isis.applib.annotation.Decimal;
 import org.apache.isis.applib.annotation.Disabled;
 import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.applib.annotation.Mask;
 import org.apache.isis.applib.annotation.MemberOrder;
 import org.apache.isis.applib.annotation.MinLength;
 import org.apache.isis.applib.annotation.Named;
@@ -358,7 +360,8 @@ public class ToDoItem implements Comparable<ToDoItem> /*, Locatable*/ { // GMAP3
         this.cost = cost!=null?cost.setScale(2):null;
     }
     
-    public ToDoItem updateCost(@Named("New cost") @Optional final BigDecimal cost) {
+    public ToDoItem updateCost(
+            final @Named("New cost") @Decimal(scale=2) @Optional BigDecimal cost) {
         LOG.debug("%s: cost updated: %s -> %s", this.container.titleOf(this), getCost(), cost);
         setCost(cost);
         return this;