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 e431007  ISIS-2950: demo: fixes property projection child vm
e431007 is described below

commit e4310072beae5a75a7b706383db340f23c30cbe6
Author: Andi Huber <[email protected]>
AuthorDate: Fri Feb 4 10:32:25 2022 +0100

    ISIS-2950: demo: fixes property projection child vm
---
 .../child/PropertyProjectingChildVm.java           | 32 +++++++++++++++++++---
 .../projecting/jdo/PropertyProjectingChildJdo.java |  4 +--
 .../projecting/jpa/PropertyProjectingChildJpa.java |  2 +-
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/child/PropertyProjectingChildVm.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/child/PropertyProjectingChildVm.java
index 6bde686..b7086b8 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/child/PropertyProjectingChildVm.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/child/PropertyProjectingChildVm.java
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlType;
 
 import org.apache.isis.applib.annotation.DomainObject;
 import org.apache.isis.applib.annotation.Nature;
+import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.annotation.Projecting;
 import org.apache.isis.applib.annotation.Property;
 import org.apache.isis.applib.annotation.PropertyLayout;
@@ -37,6 +38,8 @@ import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 import demoapp.dom._infra.asciidocdesc.HasAsciiDocDescription;
+import 
demoapp.dom.domain.properties.Property.projecting.jdo.PropertyProjectingChildJdo;
+import 
demoapp.dom.domain.properties.Property.projecting.jpa.PropertyProjectingChildJpa;
 import 
demoapp.dom.domain.properties.Property.projecting.persistence.PropertyProjectingChildEntity;
 
 //tag::class[]
@@ -52,7 +55,7 @@ public class PropertyProjectingChildVm implements 
HasAsciiDocDescription {
 
 //end::class[]
     public PropertyProjectingChildVm(final PropertyProjectingChildEntity 
backingEntity) {
-        this.backingEntity = backingEntity;
+        setBackingEntity(backingEntity);
     }
 
 //tag::class[]
@@ -67,10 +70,31 @@ public class PropertyProjectingChildVm implements 
HasAsciiDocDescription {
         projecting = Projecting.PROJECTED   // <.>
         , hidden = Where.EVERYWHERE         // <.>
     )
-    @XmlElement(required = true)
-    @Getter @Setter
-    private PropertyProjectingChildEntity backingEntity;
+    public PropertyProjectingChildEntity getBackingEntity() {
+        return backingEntityJpa!=null
+                ? backingEntityJpa
+                : backingEntityJdo;
+    }
+    public void setBackingEntity(final PropertyProjectingChildEntity 
backingEntity) {
+        this.backingEntityJpa = backingEntity instanceof 
PropertyProjectingChildJpa
+                ? (PropertyProjectingChildJpa) backingEntity
+                : null;
+        this.backingEntityJdo = backingEntity instanceof 
PropertyProjectingChildJdo
+                ? (PropertyProjectingChildJdo) backingEntity
+                : null;
+    }
 //end::projecting[]
+//end::class[]
+    @Programmatic
+    @XmlElement(required = false)
+    @Getter @Setter
+    private PropertyProjectingChildJpa backingEntityJpa;
 
+    @Programmatic
+    @XmlElement(required = false)
+    @Getter @Setter
+    private PropertyProjectingChildJdo backingEntityJdo;
+//tag::class[]
+    // ..
 }
 //end::class[]
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jdo/PropertyProjectingChildJdo.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jdo/PropertyProjectingChildJdo.java
index 749ee44..1de2b58 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jdo/PropertyProjectingChildJdo.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jdo/PropertyProjectingChildJdo.java
@@ -44,7 +44,7 @@ import 
demoapp.dom.domain.properties.Property.projecting.persistence.PropertyPro
 @DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
 @DomainObject(
         nature=Nature.ENTITY
-        , logicalTypeName = "demo.PropertyProjectingChildEntity"
+        , logicalTypeName = "demo.PropertyProjectingChildJdo"
         , editing = Editing.DISABLED
 )
 @XmlJavaTypeAdapter(PersistentEntityAdapter.class)
@@ -53,7 +53,7 @@ public class PropertyProjectingChildJdo
     // ...
 //end::class[]
 
-    public PropertyProjectingChildJdo(String initialValue) {
+    public PropertyProjectingChildJdo(final String initialValue) {
         this.name = initialValue;
     }
 
diff --git 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jpa/PropertyProjectingChildJpa.java
 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jpa/PropertyProjectingChildJpa.java
index daf132d..b946d09 100644
--- 
a/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jpa/PropertyProjectingChildJpa.java
+++ 
b/examples/demo/domain/src/main/java/demoapp/dom/domain/properties/Property/projecting/jpa/PropertyProjectingChildJpa.java
@@ -49,7 +49,7 @@ import 
demoapp.dom.domain.properties.Property.projecting.persistence.PropertyPro
 )
 @EntityListeners(IsisEntityListener.class)
 @DomainObject(
-    logicalTypeName = "demo.PropertyProjectingChildEntity"
+    logicalTypeName = "demo.PropertyProjectingChildJpa"
     , editing = Editing.DISABLED
 )
 @XmlJavaTypeAdapter(PersistentEntityAdapter.class)

Reply via email to