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 2017/02/14 15:09:14 UTC
isis git commit: ISIS-1587: extends explicitObjectType checking to
take in view models.
Repository: isis
Updated Branches:
refs/heads/maint-1.14.0 78f034d0e -> 794dce50d
ISIS-1587: extends explicitObjectType checking to take in view models.
Updated 3 view models defined by framework itself so as not to trigger validation error
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/794dce50
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/794dce50
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/794dce50
Branch: refs/heads/maint-1.14.0
Commit: 794dce50d9168b5dd7fe5517e3773446b38d3bb2
Parents: 78f034d
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue Feb 14 15:07:35 2017 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Feb 14 15:08:00 2017 +0000
----------------------------------------------------------------------
.../guides/_rgant-DomainObject_objectType.adoc | 2 +-
.../main/asciidoc/guides/_rgant-ViewModel.adoc | 6 ++
.../guides/_rgant-ViewModel_objectType.adoc | 64 ++++++++++++++++++++
.../asciidoc/guides/_rgant_aaa_deprecated.adoc | 12 ++--
.../applib/fixturescripts/FixtureResult.java | 5 +-
.../services/config/ConfigurationProperty.java | 3 +-
...tSpecIdFacetDerivedFromClassNameFactory.java | 6 ++
.../services/homepage/HomePageService.java | 2 +-
.../services/homepage/HomePageViewModel.java | 8 ++-
9 files changed, 98 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject_objectType.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject_objectType.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject_objectType.adoc
index c081f0d..22b6c12 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject_objectType.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant-DomainObject_objectType.adoc
@@ -40,7 +40,7 @@ public class Order {
The rules of precedence are:
1. xref:rgant.adoc#_rgant_Discriminator[`@Discriminator`]
-2. `@DomainObject#objectType`
+2. `@DomainObject#objectType`, or xref:rgant.adoc#_rgant_aaa_deprecated[`@ObjectType`] (deprecated)
3. xref:rgant.adoc#_rgant_PersistenceCapable[`@PersistenceCapable`], if at least the `schema` attribute is defined. +
+
If both `schema` and `table` are defined, then the value is "`schema.table`".
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel.adoc
index f16f21c..a61db73 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel.adoc
@@ -42,3 +42,9 @@ Only properties supported by the configured xref:rgsvc.adoc#_rgsvc_api_MementoSe
* collections (of either view models or entities) are ignored.
+[WARNING]
+====
+The `@ViewModel` does not allow the objectType to be specified, meaning (as of `1.14.0-SNAPSHOT`) that it is incompatible with the metamodel validation check ennabled by the xref:rgcfg.adoc#_rgcfg_configuring-core_metamodel-validation[`explicitObjectType`] configuration property.
+
+Instead, use xref:rgant.adoc#_rgant_DomainObject_nature[`@DomainObject#nature()`] with `Nature.VIEW_MODEL`, and specify xref:rgant.adoc#_rgant_DomainObject_objectType[`@DomainObject#objectType()`].
+====
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel_objectType.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel_objectType.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel_objectType.adoc
new file mode 100644
index 0000000..d1daf8a
--- /dev/null
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant-ViewModel_objectType.adoc
@@ -0,0 +1,64 @@
+[[_rgant-DomainObject_objectType]]
+= `objectType()`
+:Notice: 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.
+:_basedir: ../
+:_imagesdir: images/
+
+
+The `objectType()` attribute is used to provide a unique alias for the object's class name.
+
+This value is used internally to generate a string representation of an objects identity (the `Oid`).
+This can appear in several contexts, including:
+
+* as the value of `Bookmark#getObjectType()` and in the `toString()` value of `Bookmark`
+ (see xref:rgsvc.adoc#_rgsvc_api_BookmarkService[`BookmarkService`])
+ ** and thus in the "table-of-two-halves" pattern, as per (non-ASF) http://github.com/isisaddons/isis-module-poly[Isis addons' poly] module
+* in the serialization of `OidDto` in the xref:rgcms.adoc#_rgcms_schema-cmd[command] and xref:rgcms.adoc#_rgcms_schema-ixn[interaction] schemas
+* in the URLs of the xref:ugvro.adoc#[RestfulObjects viewer]
+* in the URLs of the xref:ugvw.adoc#[Wicket viewer] (in general and in particular if xref:ugvw.adoc#_ugvw_features_hints-and-copy-url[copying URLs])
+* in XML snapshots generated by the xref:rgsvc.adoc#_rgsvc_api_XmlSnapshotService[`XmlSnapshotService`]
+
+
+
+== Examples
+
+For example:
+
+[source,java]
+----
+@DomainObject(
+ objectType="orders.Order"
+)
+public class Order {
+ ...
+}
+----
+
+
+== Precedence
+
+The rules of precedence are:
+
+1. xref:rgant.adoc#_rgant_Discriminator[`@Discriminator`]
+2. `@DomainObject#objectType`, or xref:rgant.adoc#_rgant_ViewModel_objectType[`@ViewModel#objectType()`] (`1.14.0-SNAPSHOT`), or xref:rgant.adoc#_rgant_aaa_deprecated[`@ObjectType`] (deprecated)
+3. xref:rgant.adoc#_rgant_PersistenceCapable[`@PersistenceCapable`], if at least the `schema` attribute is defined. +
++
+If both `schema` and `table` are defined, then the value is "`schema.table`".
+If only `schema` is defined, then the value is "`schema.className`".
+
+4. Fully qualified class name of the entity.
+
+
+[TIP]
+====
+This might be obvious, but to make explicit: we recommend that you always specify an object type for your domain objects.
+
+Otherwise, if you refactor your code (change class name or move package), then any externally held references to the OID of the object will break.
+At best this will require a data migration in the database; at worst it could cause external clients accessing data through the xref:ugvro.adoc#[Restful Objects] viewer to break.
+====
+
+[NOTE]
+====
+If the object type is not unique across all domain classes then the framework will fail-fast and fail to boot.
+An error message will be printed in the log to help you determine which classes have duplicate object tyoes.
+====
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/adocs/documentation/src/main/asciidoc/guides/_rgant_aaa_deprecated.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgant_aaa_deprecated.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgant_aaa_deprecated.adoc
index e4c6168..504debb 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgant_aaa_deprecated.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgant_aaa_deprecated.adoc
@@ -5,7 +5,8 @@
:_imagesdir: images/
-As Apache Isis has evolved and grown, we found ourselves adding more and more annotations; but most of these related to either an object type (entity, view model, service) or an object member (property, collection, action). Over time it became harder and harder for end programmers to discover these new features.
+As Apache Isis has evolved and grown, we found ourselves adding more and more annotations; but most of these related to either an object type (entity, view model, service) or an object member (property, collection, action).
+Over time it became harder and harder for end programmers to discover these new features.
Accordingly, (in v1.8.0) we decided to unify the semantics into the main (core) annotations listed xref:rgant.adoc#_rgant-aaa_main[above].
@@ -149,7 +150,8 @@ For domain service, use xref:rgant.adoc#_rgant-DomainService_nature[`@DomainServ
|
|`@Immutable`
-|An object's state cannot be changed (properties cannot be edited, collections cannot be added to or removed from). Actions can still be invoked.
+|An object's state cannot be changed (properties cannot be edited, collections cannot be added to or removed from).
+Actions can still be invoked.
|xref:rgant.adoc#_rgant-DomainObject_editing[`@DomainObject#editing()`]
|Domain
|
@@ -198,7 +200,8 @@ For domain service, use xref:rgant.adoc#_rgant-DomainService_nature[`@DomainServ
|Yes
|`@NotContributed`
-|Indicates that a domain service action is not rendered as an action on the (entity) types of its parameters. For 1-arg query-only actions, controls whether the domain service action is rendered as a property or collection on the entity type of its parameter.
+|Indicates that a domain service action is not rendered as an action on the (entity) types of its parameters.
+For 1-arg query-only actions, controls whether the domain service action is rendered as a property or collection on the entity type of its parameter.
|Use xref:rgant.adoc#_rgant-DomainService_nature[`@DomainService#nature()`] to specify whether any of the actions in a domain service should appear in the menu bars (applies at type level, not action level).
For individual actions, use xref:rgant.adoc#_rgant-ActionLayout_contributedAs[`@ActionLayout#` +
`contributedAs()`] to specify whether any individual action should be contributed only as an action or as an association (property or collection).
@@ -218,7 +221,8 @@ For individual actions, use xref:rgant.adoc#_rgant-ActionLayout_contributedAs[`@
|
|`@ObjectType`
-|For constructing the external identifier (URI) of an entity instance (part of its URL in both Wicket viewer and Restful Objects viewer). Also part of the toString representation of bookmarks, if using the Bookmark Service
+|For constructing the external identifier (URI) of an entity instance (part of its URL in both Wicket viewer and Restful Objects viewer).
+Also part of the toString representation of bookmarks, if using the Bookmark Service
|xref:rgant.adoc#_rgant-DomainObject_objectType[`@DomainObject#objectType()`]
|Domain
|
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
index ffdfd01..607903e 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
@@ -20,7 +20,10 @@ package org.apache.isis.applib.fixturescripts;
import org.apache.isis.applib.annotation.*;
-@ViewModel
+@DomainObject(
+ nature = Nature.VIEW_MODEL,
+ objectType = "isisApplib.FixtureResult"
+)
@ViewModelLayout(paged=500)
public class FixtureResult {
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/core/applib/src/main/java/org/apache/isis/applib/services/config/ConfigurationProperty.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/config/ConfigurationProperty.java b/core/applib/src/main/java/org/apache/isis/applib/services/config/ConfigurationProperty.java
index 5760ea1..8d133a5 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/config/ConfigurationProperty.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/config/ConfigurationProperty.java
@@ -38,7 +38,8 @@ import org.apache.isis.applib.annotation.Title;
}
)
@DomainObject(
- editing = Editing.DISABLED
+ editing = Editing.DISABLED,
+ objectType = "isisApplib.ConfigurationProperty"
)
@DomainObjectLayout(
paged = 999
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/objectspecid/classname/ObjectSpecIdFacetDerivedFromClassNameFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/objectspecid/classname/ObjectSpecIdFacetDerivedFromClassNameFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/objectspecid/classname/ObjectSpecIdFacetDerivedFromClassNameFactory.java
index e6ccf72..32731ef 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/objectspecid/classname/ObjectSpecIdFacetDerivedFromClassNameFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/objectspecid/classname/ObjectSpecIdFacetDerivedFromClassNameFactory.java
@@ -127,9 +127,15 @@ public class ObjectSpecIdFacetDerivedFromClassNameFactory extends FacetFactoryAb
}
private boolean check(final ObjectSpecification objectSpec) {
+ if(objectSpec.isAbstract()) {
+ return false;
+ }
if (objectSpec.isPersistenceCapable()) {
return true;
}
+ if (objectSpec.isViewModel()) {
+ return true;
+ }
if (objectSpec.isService()) {
// don't care about domain services.
DomainServiceFacet domainServiceFacet = objectSpec.getFacet(DomainServiceFacet.class);
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageService.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageService.java b/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageService.java
index 206488e..4e65fdc 100644
--- a/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageService.java
+++ b/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageService.java
@@ -27,7 +27,7 @@ import org.apache.isis.applib.services.factory.FactoryService;
@DomainService(
nature = NatureOfService.DOMAIN, // trick to suppress the actions from the top-level menu
- objectType = "internals.HomePageService"
+ objectType = "homepage.HomePageService"
)
public class HomePageService {
http://git-wip-us.apache.org/repos/asf/isis/blob/794dce50/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageViewModel.java
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageViewModel.java b/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageViewModel.java
index 0a0fb6c..4bf5563 100644
--- a/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageViewModel.java
+++ b/example/application/simpleapp/application/src/main/java/domainapp/application/services/homepage/HomePageViewModel.java
@@ -20,13 +20,17 @@ package domainapp.application.services.homepage;
import java.util.List;
-import org.apache.isis.applib.annotation.ViewModel;
+import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.annotation.Nature;
import org.apache.isis.applib.services.i18n.TranslatableString;
import domainapp.modules.simple.dom.impl.SimpleObject;
import domainapp.modules.simple.dom.impl.SimpleObjectRepository;
-@ViewModel
+@DomainObject(
+ nature = Nature.VIEW_MODEL,
+ objectType = "homepage.HomePageViewModel"
+)
public class HomePageViewModel {
public TranslatableString title() {