This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new a4784e1 ISIS-2964: purge RecreatableDomainObject
a4784e1 is described below
commit a4784e126c03420879d3300fa0cd2cbaebc55ea3
Author: Andi Huber <[email protected]>
AuthorDate: Fri Feb 25 11:30:28 2022 +0100
ISIS-2964: purge RecreatableDomainObject
- use ViewModel interface instead
---
.../isis/applib/RecreatableDomainObject.java | 52 --------
.../org/apache/isis/applib/annotation/Nature.java | 13 ++
.../isis/applib/services/user/UserMemento.java | 1 +
.../ViewModelSemanticCheckingFacetFactory.java | 63 +--------
...atableObjectFacetForDomainObjectAnnotation.java | 108 +++++++++++++++-
...ObjectFacetDeclarativeInitializingAbstract.java | 142 ---------------------
.../recreatable/RecreatableObjectFacetFactory.java | 10 +-
...ctFacetForRecreatableDomainObjectInterface.java | 52 --------
...eObjectFacetForRecreatableObjectAnnotation.java | 33 -----
...creatableObjectFacetForViewModelInterface.java} | 4 +-
.../facets/object/viewmodel/ViewModelFacet.java | 6 +-
.../ViewModelSemanticCheckingFacetFactoryTest.java | 63 ---------
.../RecreatableObjectFacetFactoryTest.java | 2 +-
.../factory/FactoryServiceDefault.java | 2 +-
14 files changed, 136 insertions(+), 415 deletions(-)
diff --git
a/api/applib/src/main/java/org/apache/isis/applib/RecreatableDomainObject.java
b/api/applib/src/main/java/org/apache/isis/applib/RecreatableDomainObject.java
deleted file mode 100644
index 79ee2c6..0000000
---
a/api/applib/src/main/java/org/apache/isis/applib/RecreatableDomainObject.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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;
-
-/**
- * Indicates that the domain object can be recreated from a string.
- *
- *
- * <p>
- * Objects that are view models (logically belonging to the
UI/application layer) should instead implement
- * {@link org.apache.isis.applib.ViewModel}.
- * </p>
- *
- * @since 1.x {@index}
- */
-public interface RecreatableDomainObject {
-
- /**
- * Obtain a memento of the recreatable object.
- *
- * <p>
- * Typically this will be the identifier of a backing domain entity, but
it could also be an arbitrary string,
- * for example a bunch of JSON.
- *
- * <p>
- * This method is called by the framework in order that the view model may
be recreated subsequently
- * through {@link #__isis_recreate(String)}.
- */
- public String __isis_memento();
-
- /**
- * Used to recreate a recreatable object with a memento obtained from
{@link #__isis_recreate(String)}.
- */
- public void __isis_recreate(String memento);
-
-}
diff --git
a/api/applib/src/main/java/org/apache/isis/applib/annotation/Nature.java
b/api/applib/src/main/java/org/apache/isis/applib/annotation/Nature.java
index d3ace3d..0e726cb 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/annotation/Nature.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/annotation/Nature.java
@@ -81,6 +81,10 @@ public enum Nature {
BEAN,
;
+ public boolean isNotSpecified() {
+ return this == Nature.NOT_SPECIFIED;
+ }
+
public boolean isEntity() {
return this == Nature.ENTITY;
}
@@ -88,4 +92,13 @@ public enum Nature {
public boolean isMixin() {
return this == Nature.MIXIN;
}
+
+ public boolean isViewModel() {
+ return this == Nature.VIEW_MODEL;
+ }
+
+ public boolean isBean() {
+ return this == Nature.BEAN;
+ }
+
}
diff --git
a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
index 76b1dff..83e5591 100644
---
a/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
+++
b/api/applib/src/main/java/org/apache/isis/applib/services/user/UserMemento.java
@@ -290,6 +290,7 @@ public class UserMemento implements Serializable {
*
* @return true if the names match (is case sensitive).
*/
+ @Programmatic
public boolean isCurrentUser(final @Nullable String userName) {
return name.equals(userName);
}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactory.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactory.java
index b5e4fb7..3034da3 100644
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactory.java
+++
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactory.java
@@ -21,10 +21,7 @@ package org.apache.isis.core.metamodel.facets.object;
import javax.inject.Inject;
import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.RecreatableDomainObject;
import org.apache.isis.applib.annotation.DomainObject;
-import org.apache.isis.applib.annotation.DomainObjectLayout;
-import org.apache.isis.applib.annotation.Nature;
import org.apache.isis.applib.id.LogicalType;
import org.apache.isis.core.metamodel.context.MetaModelContext;
import org.apache.isis.core.metamodel.facetapi.FeatureType;
@@ -53,70 +50,24 @@ extends FacetFactoryAbstract {
val cls = processClassContext.getCls();
val facetHolder = processClassContext.getFacetHolder();
- final DomainObjectLayout domainObjectLayout =
processClassContext.synthesizeOnType(DomainObjectLayout.class).orElse(null);
final DomainObject domainObject =
processClassContext.synthesizeOnType(DomainObject.class).orElse(null);
final boolean implementsViewModel =
org.apache.isis.applib.ViewModel.class.isAssignableFrom(cls);
- final boolean implementsRecreatableDomainObject =
org.apache.isis.applib.RecreatableDomainObject.class.isAssignableFrom(cls);
- final boolean annotatedWithDomainObjectLayout = domainObjectLayout !=
null;
final boolean annotatedWithDomainObject = domainObject != null;
- if(implementsViewModel && implementsRecreatableDomainObject) {
+ if(implementsViewModel
+ && annotatedWithDomainObject
+ && (domainObject.nature().isBean()
+ || domainObject.nature().isEntity())) {
ValidationFailure.raise(
facetHolder.getSpecificationLoader(),
Identifier.classIdentifier(LogicalType.fqcn(cls)),
String.format(
- "Inconsistent view model / domain object semantics; %s
should not implement "
- + "both %s and %s interfaces (implement one or the
other)",
+ "Inconsistent view model / domain object nature
semantics; %1$s should not implement "
+ + "%2$s and be annotated with @%3$s specifying a
nature that conflicts with view-model semantics",
cls.getName(),
org.apache.isis.applib.ViewModel.class.getSimpleName(),
-
org.apache.isis.applib.RecreatableDomainObject.class.getSimpleName())
- );
-
- }
- if(implementsViewModel && annotatedWithDomainObject) {
- ValidationFailure.raise(
- facetHolder.getSpecificationLoader(),
- Identifier.classIdentifier(LogicalType.fqcn(cls)),
- String.format(
- "Inconsistent view model / domain object semantics;
%1$s should not implement "
- + "%2$s and be annotated with @%3$s (annotate with
%4$s instead of %2$s, or implement %5s instead of %2$s)",
- cls.getName(),
- org.apache.isis.applib.ViewModel.class.getSimpleName(),
- DomainObject.class.getSimpleName(),
- "TODO ViewModel removed",
- RecreatableDomainObject.class.getSimpleName())
- );
- }
- if(implementsViewModel && annotatedWithDomainObjectLayout) {
- ValidationFailure.raise(
- facetHolder.getSpecificationLoader(),
- Identifier.classIdentifier(LogicalType.fqcn(cls)),
- String.format(
- "Inconsistent view model / domain object semantics;
%1$s should not implement "
- + "%2$s and be annotated with @%3$s (annotate with
@%4$s instead of %3$s, or implement %5$s instead of %2$s)",
- cls.getName(),
- org.apache.isis.applib.ViewModel.class.getSimpleName(),
- DomainObjectLayout.class.getSimpleName(),
- RecreatableDomainObject.class.getSimpleName())
- );
- }
-
- if(annotatedWithDomainObject
- && (domainObject.nature() == Nature.NOT_SPECIFIED
- || domainObject.nature().isEntity())
- && implementsRecreatableDomainObject) {
- ValidationFailure.raise(
- facetHolder.getSpecificationLoader(),
- Identifier.classIdentifier(LogicalType.fqcn(cls)),
- String.format(
- "Inconsistent view model / domain object semantics;
%1$s should not be annotated with "
- + "@%2$s with nature of %3$s and also implement %4$s
(specify a nature of %5$s)",
- cls.getName(),
- DomainObject.class.getSimpleName(),
- domainObject.nature(),
-
org.apache.isis.applib.RecreatableDomainObject.class.getSimpleName(),
- Nature.VIEW_MODEL)
+ DomainObject.class.getSimpleName())
);
}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobject/recreatable/RecreatableObjectFacetForDomainObjectAnnotation.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobject/recreatable/RecreatableObjectFacetForDomainObjectAnnotation.java
index 2f3ddb8..98cb97c 100644
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobject/recreatable/RecreatableObjectFacetForDomainObjectAnnotation.java
+++
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/domainobject/recreatable/RecreatableObjectFacetForDomainObjectAnnotation.java
@@ -22,13 +22,24 @@ import java.util.Objects;
import java.util.Optional;
import org.apache.isis.applib.annotation.DomainObject;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.urlencoding.UrlEncodingService;
+import org.apache.isis.commons.internal.memento._Mementos;
+import org.apache.isis.commons.internal.memento._Mementos.SerializingAdapter;
+import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
import org.apache.isis.core.metamodel.facetapi.Facet;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.HasPostConstructMethodCache;
-import
org.apache.isis.core.metamodel.facets.object.recreatable.RecreatableObjectFacetDeclarativeInitializingAbstract;
+import
org.apache.isis.core.metamodel.facets.object.recreatable.RecreatableObjectFacetAbstract;
+import
org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
+import org.apache.isis.core.metamodel.spec.ManagedObject;
+import org.apache.isis.core.metamodel.spec.feature.MixedIn;
+
+import lombok.NonNull;
+import lombok.val;
public class RecreatableObjectFacetForDomainObjectAnnotation
-extends RecreatableObjectFacetDeclarativeInitializingAbstract {
+extends RecreatableObjectFacetAbstract {
public static Optional<RecreatableObjectFacetForDomainObjectAnnotation>
create(
final Optional<DomainObject> domainObjectIfAny,
@@ -56,7 +67,10 @@ extends
RecreatableObjectFacetDeclarativeInitializingAbstract {
.filter(Objects::nonNull);
}
- private RecreatableObjectFacetForDomainObjectAnnotation(
+ private UrlEncodingService codec;
+ private SerializingAdapter serializer;
+
+ protected RecreatableObjectFacetForDomainObjectAnnotation(
final FacetHolder holder,
final HasPostConstructMethodCache postConstructMethodCache,
final Facet.Precedence precedence) {
@@ -64,4 +78,92 @@ extends
RecreatableObjectFacetDeclarativeInitializingAbstract {
super(holder, RecreationMechanism.INITIALIZES,
postConstructMethodCache, precedence);
}
+ @Override
+ protected void doInitialize(
+ final Object viewModelPojo,
+ final @NonNull Optional<Bookmark> bookmark) {
+
+ val memento =
parseMemento(bookmark.map(Bookmark::getIdentifier).orElse(null));
+ val mementoKeys = memento.keySet();
+
+ if(mementoKeys.isEmpty()) {
+ return;
+ }
+
+ val objectManager = super.getObjectManager();
+ val viewModelAdapter = objectManager.adapt(viewModelPojo);
+ val spec = viewModelAdapter.getSpecification();
+
+ super.getServiceInjector().injectServicesInto(viewModelPojo);
+
+ spec.streamProperties(MixedIn.EXCLUDED)
+ .filter(property->mementoKeys.contains(property.getId()))
+ .forEach(property->{
+
+ val propertyId = property.getId();
+ val propertyType =
property.getElementType().getCorrespondingClass();
+ val propertyValue = memento.get(propertyId, propertyType);
+
+ if(propertyValue != null) {
+ property.set(viewModelAdapter,
objectManager.adapt(propertyValue), InteractionInitiatedBy.FRAMEWORK);
+ }
+ });
+
+ }
+
+ @Override
+ public String serialize(final ManagedObject viewModel) {
+
+ final _Mementos.Memento memento = newMemento();
+
+ /*
+ * ManagedObject that holds the ObjectSpecification used for
+ * interrogating the domain object's metadata.
+ *
+ * Does _not_ perform dependency injection on the domain object. Also
bypasses
+ * caching (if any), that is each call to this method creates a new
instance.
+ */
+ val spec = viewModel.getSpecification();
+
+ spec.streamProperties(MixedIn.EXCLUDED)
+ // ignore read-only
+
.filter(property->property.containsNonFallbackFacet(PropertySetterFacet.class))
+ // ignore those explicitly annotated as @NotPersisted
+ .filter(property->!property.isNotPersisted())
+ .forEach(property->{
+ final ManagedObject propertyValue =
+ property.get(viewModel, InteractionInitiatedBy.FRAMEWORK);
+ if(propertyValue != null
+ && propertyValue.getPojo()!=null) {
+ memento.put(property.getId(), propertyValue.getPojo());
+ }
+ });
+
+ return memento.asString();
+ }
+
+ // -- HELPER
+
+ private void initDependencies() {
+ val serviceRegistry = getServiceRegistry();
+ this.codec =
serviceRegistry.lookupServiceElseFail(UrlEncodingService.class);
+ this.serializer =
serviceRegistry.lookupServiceElseFail(SerializingAdapter.class);
+ }
+
+ private void ensureDependenciesInited() {
+ if(codec==null) {
+ initDependencies();
+ }
+ }
+
+ private _Mementos.Memento newMemento() {
+ ensureDependenciesInited();
+ return _Mementos.create(codec, serializer);
+ }
+
+ private _Mementos.Memento parseMemento(final String input) {
+ ensureDependenciesInited();
+ return _Mementos.parse(codec, serializer, input);
+ }
+
}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetDeclarativeInitializingAbstract.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetDeclarativeInitializingAbstract.java
deleted file mode 100644
index 2b55c50..0000000
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetDeclarativeInitializingAbstract.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.metamodel.facets.object.recreatable;
-
-import java.util.Optional;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.urlencoding.UrlEncodingService;
-import org.apache.isis.commons.internal.memento._Mementos;
-import org.apache.isis.commons.internal.memento._Mementos.SerializingAdapter;
-import org.apache.isis.core.metamodel.consent.InteractionInitiatedBy;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.HasPostConstructMethodCache;
-import
org.apache.isis.core.metamodel.facets.properties.update.modify.PropertySetterFacet;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-import org.apache.isis.core.metamodel.spec.feature.MixedIn;
-
-import lombok.NonNull;
-import lombok.val;
-
-public abstract class RecreatableObjectFacetDeclarativeInitializingAbstract
-extends RecreatableObjectFacetAbstract {
-
- public RecreatableObjectFacetDeclarativeInitializingAbstract(
- final FacetHolder holder,
- final RecreationMechanism recreationMechanism,
- final HasPostConstructMethodCache postConstructMethodCache,
- final Facet.Precedence precedence) {
-
- super(holder, recreationMechanism, postConstructMethodCache,
precedence);
- }
-
- private UrlEncodingService codec;
- private SerializingAdapter serializer;
-
- @Override
- protected void doInitialize(
- final Object viewModelPojo,
- final @NonNull Optional<Bookmark> bookmark) {
-
- val memento =
parseMemento(bookmark.map(Bookmark::getIdentifier).orElse(null));
- val mementoKeys = memento.keySet();
-
- if(mementoKeys.isEmpty()) {
- return;
- }
-
- val objectManager = super.getObjectManager();
- val viewModelAdapter = objectManager.adapt(viewModelPojo);
- val spec = viewModelAdapter.getSpecification();
-
- super.getServiceInjector().injectServicesInto(viewModelPojo);
-
- spec.streamProperties(MixedIn.EXCLUDED)
- .filter(property->mementoKeys.contains(property.getId()))
- .forEach(property->{
-
- val propertyId = property.getId();
- val propertyType =
property.getElementType().getCorrespondingClass();
- val propertyValue = memento.get(propertyId, propertyType);
-
- if(propertyValue != null) {
- property.set(viewModelAdapter,
objectManager.adapt(propertyValue), InteractionInitiatedBy.FRAMEWORK);
- }
- });
-
- }
-
- @Override
- public String serialize(final ManagedObject viewModel) {
-
- final _Mementos.Memento memento = newMemento();
-
- /*
- * ManagedObject that holds the ObjectSpecification used for
- * interrogating the domain object's metadata.
- *
- * Does _not_ perform dependency injection on the domain object. Also
bypasses
- * caching (if any), that is each call to this method creates a new
instance.
- */
- val spec = viewModel.getSpecification();
-
- spec.streamProperties(MixedIn.EXCLUDED)
- // ignore read-only
-
.filter(property->property.containsNonFallbackFacet(PropertySetterFacet.class))
- // ignore those explicitly annotated as @NotPersisted
- .filter(property->!property.isNotPersisted())
- .forEach(property->{
- final ManagedObject propertyValue =
- property.get(viewModel, InteractionInitiatedBy.FRAMEWORK);
- if(propertyValue != null
- && propertyValue.getPojo()!=null) {
- memento.put(property.getId(), propertyValue.getPojo());
- }
- });
-
- return memento.asString();
- }
-
- // -- HELPER
-
- private void initDependencies() {
- val serviceRegistry = getServiceRegistry();
- this.codec =
serviceRegistry.lookupServiceElseFail(UrlEncodingService.class);
- this.serializer =
serviceRegistry.lookupServiceElseFail(SerializingAdapter.class);
- }
-
- private void ensureDependenciesInited() {
- if(codec==null) {
- initDependencies();
- }
- }
-
- private _Mementos.Memento newMemento() {
- ensureDependenciesInited();
- return _Mementos.create(codec, serializer);
- }
-
- private _Mementos.Memento parseMemento(final String input) {
- ensureDependenciesInited();
- return _Mementos.parse(codec, serializer, input);
- }
-
-
-}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactory.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactory.java
index 44f6f9e..814b999 100644
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactory.java
+++
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactory.java
@@ -21,7 +21,6 @@ package
org.apache.isis.core.metamodel.facets.object.recreatable;
import javax.inject.Inject;
import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.isis.applib.RecreatableDomainObject;
import org.apache.isis.applib.ViewModel;
import org.apache.isis.core.metamodel.context.MetaModelContext;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
@@ -68,14 +67,7 @@ implements
// ViewModel interface
if (ViewModel.class.isAssignableFrom(processClassContext.getCls())) {
FacetUtil.addFacet(
- new RecreatableObjectFacetForRecreatableObjectInterface(
- facetHolder, postConstructMethodCache));
- }
-
- // RecreatableDomainObject interface
- if (RecreatableDomainObject.class.isAssignableFrom(type)) {
- FacetUtil.addFacet(
- new
RecreatableObjectFacetForRecreatableDomainObjectInterface(
+ new RecreatableObjectFacetForViewModelInterface(
facetHolder, postConstructMethodCache));
}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableDomainObjectInterface.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableDomainObjectInterface.java
deleted file mode 100644
index 30a6477..0000000
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableDomainObjectInterface.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.metamodel.facets.object.recreatable;
-
-import java.util.Optional;
-
-import org.apache.isis.applib.RecreatableDomainObject;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.HasPostConstructMethodCache;
-import org.apache.isis.core.metamodel.spec.ManagedObject;
-
-import lombok.NonNull;
-
-public class RecreatableObjectFacetForRecreatableDomainObjectInterface
-extends RecreatableObjectFacetAbstract {
-
- public RecreatableObjectFacetForRecreatableDomainObjectInterface(
- final FacetHolder holder,
- final HasPostConstructMethodCache postConstructMethodCache) {
- super(holder, RecreationMechanism.INITIALIZES,
postConstructMethodCache);
- }
-
- @Override
- protected void doInitialize(final Object pojo, final @NonNull
Optional<Bookmark> bookmark) {
- final RecreatableDomainObject viewModel =
(RecreatableDomainObject)pojo;
-
viewModel.__isis_recreate(bookmark.map(Bookmark::getIdentifier).orElse(null));
- }
-
- @Override
- public String serialize(final ManagedObject viewModel) {
- final RecreatableDomainObject recreatableDomainObject =
(RecreatableDomainObject)viewModel.getPojo();
- return recreatableDomainObject.__isis_memento();
- }
-
-}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectAnnotation.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectAnnotation.java
deleted file mode 100644
index 9ba6b07..0000000
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectAnnotation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.metamodel.facets.object.recreatable;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.HasPostConstructMethodCache;
-
-public class RecreatableObjectFacetForRecreatableObjectAnnotation
-extends RecreatableObjectFacetDeclarativeInitializingAbstract {
-
- public RecreatableObjectFacetForRecreatableObjectAnnotation(
- final FacetHolder holder,
- final HasPostConstructMethodCache postConstructMethodCache) {
- super(holder, RecreationMechanism.INITIALIZES,
postConstructMethodCache, Precedence.DEFAULT);
- }
-
-}
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectInterface.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForViewModelInterface.java
similarity index 93%
rename from
core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectInterface.java
rename to
core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForViewModelInterface.java
index 4ae9b9a..ada8dcc 100644
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForRecreatableObjectInterface.java
+++
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetForViewModelInterface.java
@@ -28,10 +28,10 @@ import org.apache.isis.core.metamodel.spec.ManagedObject;
import lombok.NonNull;
-public class RecreatableObjectFacetForRecreatableObjectInterface
+public class RecreatableObjectFacetForViewModelInterface
extends RecreatableObjectFacetAbstract {
- public RecreatableObjectFacetForRecreatableObjectInterface(
+ public RecreatableObjectFacetForViewModelInterface(
final FacetHolder holder,
final HasPostConstructMethodCache postConstructMethodCache) {
super(holder, RecreationMechanism.INITIALIZES,
postConstructMethodCache);
diff --git
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/viewmodel/ViewModelFacet.java
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/viewmodel/ViewModelFacet.java
index 27a4d64..9927e09 100644
---
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/viewmodel/ViewModelFacet.java
+++
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/viewmodel/ViewModelFacet.java
@@ -80,7 +80,11 @@ public interface ViewModelFacet extends Facet {
}
/**
- * Whether this implementation supports the recreation of objects by
{@link RecreationMechanism#INSTANTIATES instantiating} (and implicitly also
initializing) a new pojo, or by {@link RecreationMechanism#INITIALIZES
initializing} a pojo created and passed to it by the framework.
+ * Whether this implementation supports the recreation of objects
+ * by {@link RecreationMechanism#INSTANTIATES instantiating}
+ * (and implicitly also initializing) a new pojo,
+ * or by {@link RecreationMechanism#INITIALIZES initializing}
+ * a pojo created and passed to it by the framework.
*
* <p>
* Determines whether the framework then calls
diff --git
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactoryTest.java
b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactoryTest.java
index 303fe65..017c207 100644
---
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactoryTest.java
+++
b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/ViewModelSemanticCheckingFacetFactoryTest.java
@@ -23,12 +23,9 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import org.apache.isis.applib.RecreatableDomainObject;
-import org.apache.isis.applib.annotation.Nature;
import org.apache.isis.applib.services.inject.ServiceInjector;
import org.apache.isis.core.config.IsisConfiguration;
import org.apache.isis.core.internaltestsupport.jmocking.JUnitRuleMockery2;
@@ -79,66 +76,6 @@ public class ViewModelSemanticCheckingFacetFactoryTest {
assertThat(validationFailures.getNumberOfFailures(), is(0));
}
- @Test
- public void
whenValidDomainObjectWithViewModelNatureImplementingRecreatableDomainObject()
throws Exception {
-
- @org.apache.isis.applib.annotation.DomainObject(nature =
Nature.VIEW_MODEL)
- class
ValidDomainObjectWithViewModelNatureImplementingRecreatableDomainObject
implements RecreatableDomainObject {
- @Override
- public String __isis_memento() {
- return null;
- }
- @Override
- public void __isis_recreate(final String memento) {
- }
- }
-
- val validationFailures = processThenValidate(
-
ValidDomainObjectWithViewModelNatureImplementingRecreatableDomainObject.class);
- assertThat(validationFailures.getNumberOfFailures(), is(0));
- }
-
- @Test
- public void
whenInvalidDomainObjectWithNatureNotSpecifiedImplementingRecreatableDomainObject()
throws Exception {
-
- @org.apache.isis.applib.annotation.DomainObject(nature =
Nature.NOT_SPECIFIED)
- class
InvalidDomainObjectWithNatureNotSpecifiedImplementingRecreatableDomainObject
implements RecreatableDomainObject {
- @Override
- public String __isis_memento() {
- return null;
- }
- @Override
- public void __isis_recreate(final String memento) {
- }
- }
-
- val validationFailures = processThenValidate(
-
InvalidDomainObjectWithNatureNotSpecifiedImplementingRecreatableDomainObject.class);
- assertThat(validationFailures.getNumberOfFailures(), is(1));
- assertThat(validationFailures.getMessages().iterator().next(),
containsString("should not be annotated with @DomainObject with nature of
NOT_SPECIFIED and also implement RecreatableDomainObject (specify a nature of
VIEW_MODEL)"));
- }
-
- @Test
- public void
whenInvalidDomainObjectWithNatureJdoEntityImplementingRecreatableDomainObject()
throws Exception {
-
- @org.apache.isis.applib.annotation.DomainObject(nature = Nature.ENTITY)
- class
InvalidDomainObjectWithNatureJdoEntityImplementingRecreatableDomainObject
implements RecreatableDomainObject {
- @Override
- public String __isis_memento() {
- return null;
- }
- @Override
- public void __isis_recreate(final String memento) {
- }
- }
-
- val validationFailures = processThenValidate(
-
InvalidDomainObjectWithNatureJdoEntityImplementingRecreatableDomainObject.class);
- assertThat(validationFailures.getNumberOfFailures(), is(1));
- assertThat(validationFailures.getMessages().iterator().next(),
- containsString("should not be annotated with @DomainObject
with nature of ENTITY and also implement RecreatableDomainObject (specify a
nature of VIEW_MODEL)"));
- }
-
// -- HELPER
private ValidationFailures processThenValidate(final Class<?> cls) {
diff --git
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactoryTest.java
b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactoryTest.java
index 12db8bd..a33dfd6 100644
---
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactoryTest.java
+++
b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/object/recreatable/RecreatableObjectFacetFactoryTest.java
@@ -62,7 +62,7 @@ extends AbstractFacetFactoryTest {
final Facet facet = facetedMethod.getFacet(ViewModelFacet.class);
assertNotNull(facet);
- assertTrue(facet instanceof
RecreatableObjectFacetForRecreatableObjectInterface);
+ assertTrue(facet instanceof
RecreatableObjectFacetForViewModelInterface);
assertNoMethodsRemoved();
}
diff --git
a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/factory/FactoryServiceDefault.java
b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/factory/FactoryServiceDefault.java
index bf8fb6c..6d7df92 100644
---
a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/factory/FactoryServiceDefault.java
+++
b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/factory/FactoryServiceDefault.java
@@ -142,7 +142,7 @@ public class FactoryServiceDefault implements
FactoryService {
val spec = loadSpec(viewModelClass);
val viewModelFacet = getViewModelFacet(spec);
- val viewModel = viewModelFacet.createViewModelPojo(spec, bookmark,
__->createObject(spec));
+ val viewModel = viewModelFacet.createViewModelPojo(spec, bookmark,
this::createObject);
return _Casts.uncheckedCast(viewModel);
}