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 2020/01/20 09:52:39 UTC

[isis] 03/04: ISIS-2062: adds some documentation for config props, is all

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 1ac7e1fc172d10950970e17814ed4a323211a636
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jan 20 09:35:57 2020 +0000

    ISIS-2062: adds some documentation for config props, is all
---
 .../apache/isis/core/config/IsisConfiguration.java | 81 ++++++++++++++++++++++
 .../core/metamodel/progmodel/ProgrammingModel.java | 16 ++---
 .../metamodel/JdoProgrammingModelPlugin.java       |  7 +-
 3 files changed, 91 insertions(+), 13 deletions(-)

diff --git a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
index 0e647be..0a36b62 100644
--- a/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/core/config/IsisConfiguration.java
@@ -47,6 +47,7 @@ import org.apache.isis.applib.annotation.Collection;
 import org.apache.isis.applib.annotation.CollectionLayout;
 import org.apache.isis.applib.annotation.DomainObject;
 import org.apache.isis.applib.annotation.DomainObjectLayout;
+import org.apache.isis.applib.annotation.DomainService;
 import org.apache.isis.applib.annotation.LabelPosition;
 import org.apache.isis.applib.annotation.ParameterLayout;
 import org.apache.isis.applib.annotation.PromptStyle;
@@ -1189,6 +1190,11 @@ public class IsisConfiguration {
             private final ProgrammingModel programmingModel = new ProgrammingModel();
             @Data
             public static class ProgrammingModel {
+
+                /**
+                 * If set, then any aspects of the programming model (as implemented by <code>FacetFactory</code>s that
+                 * have been indicated as deprecated will simply be ignored/excluded from the metamodel.
+                 */
                 private boolean ignoreDeprecated = false;
             }
 
@@ -1256,17 +1262,92 @@ public class IsisConfiguration {
                  */
                 private boolean parallelize = true;
 
+                /**
+                 * This setting is used to determine whether the use of such deprecated features is
+                 * allowed.
+                 *
+                 * <p>
+                 *     If not allowed, then metamodel validation errors will be flagged.
+                 * </p>
+                 *
+                 * <p>
+                 *     Note that this settings has no effect if the programming model has been configured to
+                 *     {@link ProgrammingModel#isIgnoreDeprecated() ignore deprecated} features (because in this case
+                 *     the programming model facets simply won't be included in the introspection process.
+                 * </p>
+                 */
                 private boolean allowDeprecated = true;
+
+                /**
+                 * Whether to ensure that the object type of all objects (which can be set either explicitly using
+                 * {@link DomainObject#objectType()} or {@link DomainService#objectType()}, or can be inferred
+                 * implicitly using a variety of mechanisms) must be unique with respect to all other object types.
+                 *
+                 * <p>
+                 *     It is <i>highly advisable</i> to leave this set as enabled (the default), and to also use
+                 *     explicit types (see {@link #isExplicitObjectType()}.
+                 * </p>
+                 */
                 private boolean ensureUniqueObjectTypes = true;
+
+                // TODO: to remove
                 private boolean checkModuleExtent = true;
+                /**
+                 * If set, then checks that the supports <code>hideXxx</code> and <code>disableXxx</code> methods for
+                 * actions do not have take parameters.
+                 *
+                 * <p>
+                 *     Historically, the programming model allowed these methods to accept the same number of
+                 *     parameters as the action method to which they relate, the rationale being for similarity with
+                 *     the <code>validateXxx</code> method.  However, since these parameters serve no function, the
+                 *     programming model has been simplified so that these supporting methods are discovered if they
+                 *     have exactly no parameters.
+                 * </p>
+                 *
+                 * <p>
+                 *     Note that this aspect of the programming model relates to the <code>hideXxx</code> and
+                 *     <code>disableXxx</code> supporting methods that relate to the entire method.  Do not confuse
+                 *     these with the <code>hideNXxx</code> and <code>disableNXxx</code> supporting methods, which
+                 *     relate to the N-th parameter, and allow up to N-1 parameters to be passed in (allowing the Nth
+                 *     parameter to be dynamically hidden or disabled).
+                 * </p>
+                 */
                 private boolean noParamsOnly = false;
+
+                /**
+                 * Whether to validate that any actions that accept action parameters have either a corresponding
+                 * choices or auto-complete for that action parameter, or are associated with a collection of the
+                 * appropriate type.
+                 */
                 private boolean actionCollectionParameterChoices = true;
 
+                /**
+                 * If set, checks that any domain services have only actions associated with them, not properties
+                 * or collections.
+                 *
+                 * @deprecated - in that in the future the programming model will simply not search for properties or collections of domain services.
+                 */
                 @Deprecated
                 private boolean serviceActionsOnly = true;
+
+                /**
+                 * If set, then domain services actions are not contributed to domain objects.
+                 *
+                 * @deprecated - in that in the future the programming model will simply not support contributed actions from domain services.
+                 */
                 @Deprecated
                 private boolean mixinsOnly = true;
 
+                /**
+                 * Whether to ensure that the object type of all objects must be specified explicitly, using either
+                 * {@link DomainObject#objectType()} or {@link DomainService#objectType()}.
+                 *
+                 * <p>
+                 *     It is <i>highly advisable</i> to leave this set as enabled (the default).  These object types
+                 *     should also (of course) be unique - that can be checked by setting the
+                 *     {@link #isEnsureUniqueObjectTypes()} config property.
+                 * </p>
+                 */
                 private boolean explicitObjectType = false;
 
                 private final JaxbViewModel jaxbViewModel = new JaxbViewModel();
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/progmodel/ProgrammingModel.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/progmodel/ProgrammingModel.java
index 0144278..97cbfd2 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/progmodel/ProgrammingModel.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/progmodel/ProgrammingModel.java
@@ -35,7 +35,7 @@ public interface ProgrammingModel {
 
     // -- ENUM TYPES
     
-    static enum Marker {
+    enum Marker {
         DEPRECATED, 
         INCUBATING,
         JDO,
@@ -49,7 +49,7 @@ public interface ProgrammingModel {
      * Order is defined by {@link FacetProcessingOrder#ordinal()}
      *
      */
-    static enum FacetProcessingOrder {
+    enum FacetProcessingOrder {
         
         A1_FALLBACK_DEFAULTS,
         A2_AFTER_FALLBACK_DEFAULTS,
@@ -85,7 +85,7 @@ public interface ProgrammingModel {
      * Order is defined by {@link ValidationOrder#ordinal()}
      *
      */
-    static enum ValidationOrder {
+    enum ValidationOrder {
         
         A0_BEFORE_BUILTIN,
         A1_BUILTIN,
@@ -101,7 +101,7 @@ public interface ProgrammingModel {
      * Order is defined by {@link PostProcessingOrder#ordinal()}
      *
      */
-    static enum PostProcessingOrder {
+    enum PostProcessingOrder {
         
         A0_BEFORE_BUILTIN,
         A1_BUILTIN,
@@ -134,7 +134,7 @@ public interface ProgrammingModel {
     
     // -- SHORTCUTS
     
-    /** shortcut for see {@link #addFactory(FacetProcessingOrder, Class, Supplier, Marker...)}*/
+    /** shortcut for see {@link #addFactory(FacetProcessingOrder, FacetFactory, Marker...)}*/
     default <T extends FacetFactory> void addFactory(
             FacetProcessingOrder order, 
             Class<T> type, 
@@ -144,7 +144,7 @@ public interface ProgrammingModel {
         addFactory(order, supplier.get(), markers);
     }
     
-    /** shortcut for see {@link #addValidator(ValidationOrder, Class, Supplier, Marker...)} */
+    /** shortcut for see {@link #addValidator(ValidationOrder, MetaModelValidator, Marker...)} */
     default void addValidator(
             MetaModelValidator validator, 
             Marker ... markers) {
@@ -154,7 +154,7 @@ public interface ProgrammingModel {
     }
 
     
-    /** shortcut for see {@link #addValidator(ValidationOrder, Class, Supplier, Marker...)} */
+    /** shortcut for see {@link #addValidator(MetaModelValidator, Marker...)} */
     default void addValidator(MetaModelValidatorVisiting.Visitor visitor, Marker ... markers) {
         addValidator(MetaModelValidatorVisiting.of(visitor), markers);
     }
@@ -165,7 +165,7 @@ public interface ProgrammingModel {
         addValidator(MetaModelValidatorVisiting.of(visitor, specPredicate), markers);
     }
 
-    /** shortcut for see {@link #addPostProcessor(PostProcessingOrder, Class, Supplier, Marker...)}*/
+    /** shortcut for see {@link #addPostProcessor(PostProcessingOrder, ObjectSpecificationPostProcessor, Marker...)}*/
     default <T extends ObjectSpecificationPostProcessor> void addPostProcessor(
             PostProcessingOrder order, 
             Class<T> type, 
diff --git a/persistence/jdo/datanucleus-5/src/main/java/org/apache/isis/persistence/jdo/datanucleus5/metamodel/JdoProgrammingModelPlugin.java b/persistence/jdo/datanucleus-5/src/main/java/org/apache/isis/persistence/jdo/datanucleus5/metamodel/JdoProgrammingModelPlugin.java
index cab6d21..3736f1a 100644
--- a/persistence/jdo/datanucleus-5/src/main/java/org/apache/isis/persistence/jdo/datanucleus5/metamodel/JdoProgrammingModelPlugin.java
+++ b/persistence/jdo/datanucleus-5/src/main/java/org/apache/isis/persistence/jdo/datanucleus5/metamodel/JdoProgrammingModelPlugin.java
@@ -236,6 +236,7 @@ public class JdoProgrammingModelPlugin implements MetaModelRefiner {
                 }
                 final String packageName = aPackage.getName();
 
+                //noinspection StatementWithEmptyBody
                 if (objSpec.isValue() || objSpec.isAbstract() || objSpec.isMixin() ||
                         objSpec.isParentedOrFreeCollection() ||
                         objSpec.getFullIdentifier().startsWith("java") ||
@@ -243,11 +244,7 @@ public class JdoProgrammingModelPlugin implements MetaModelRefiner {
                         objSpec.getFullIdentifier().startsWith("org.apache.isis")) {
                     // ignore
                 } else {
-                    List<String> classNames = domainObjectClassNamesByPackage.get(packageName);
-                    if (classNames == null) {
-                        classNames = _Lists.newArrayList();
-                        domainObjectClassNamesByPackage.put(packageName, classNames);
-                    }
+                    List<String> classNames = domainObjectClassNamesByPackage.computeIfAbsent(packageName, k -> _Lists.newArrayList());
                     classNames.add(objSpec.getFullIdentifier());
                 }
                 return true;