You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/02/24 22:48:40 UTC

[isis] 06/09: ISIS-1728: uses typesafe queries for helloworld

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

ahuber pushed a commit to branch dev/2.0.0-M2-cherrypicked
in repository https://gitbox.apache.org/repos/asf/isis.git

commit a92f6b9604b52186eaf12a2e2bfffbab60249eb3
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Sep 19 23:02:07 2017 +0100

    ISIS-1728: uses typesafe queries for helloworld
    
    Conflicts:
    	core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
---
 .../systemusinginstallers/IsisComponentProvider.java        | 13 +++++++++++++
 .../src/main/java/domainapp/dom/impl/HelloWorldObject.java  |  4 +++-
 .../src/main/java/domainapp/dom/impl/HelloWorldObjects.java |  9 +++++----
 .../domainapp/modules/simple/dom/impl/SimpleObjects.java    |  7 +++----
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
index 9b2936a..e8b2dc0 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
@@ -25,6 +25,19 @@ import java.util.Map;
 import java.util.Set;
 
 import javax.annotation.Nullable;
+<<<<<<< dev/2.0.0-M2-cherrypicked
+=======
+import javax.jdo.annotations.PersistenceCapable;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import org.reflections.Reflections;
+>>>>>>> e20eec9 ISIS-1728: uses typesafe queries for helloworld
 
 import org.apache.isis.applib.AppManifest;
 import org.apache.isis.applib.annotation.DomainObject;
diff --git a/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObject.java b/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObject.java
index 54a1a35..502b756 100644
--- a/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObject.java
+++ b/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObject.java
@@ -43,7 +43,6 @@ import org.apache.isis.applib.services.title.TitleService;
 @javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "helloworld" )
 @javax.jdo.annotations.DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "id")
 @javax.jdo.annotations.Version(strategy= VersionStrategy.DATE_TIME, column ="version")
-@javax.jdo.annotations.Unique(name="HelloWorldObject_name_UNQ", members = {"name"})
 @DomainObject(auditing = Auditing.ENABLED)
 @DomainObjectLayout()  // causes UI events to be triggered
 public class HelloWorldObject implements Comparable<HelloWorldObject> {
@@ -52,6 +51,8 @@ public class HelloWorldObject implements Comparable<HelloWorldObject> {
         this.name = name;
     }
 
+
+    @javax.jdo.annotations.Unique
     @javax.jdo.annotations.Column(allowsNull = "false", length = 40)
     @Property(editing = Editing.DISABLED)
     @Title(prepend = "Object: ")
@@ -59,6 +60,7 @@ public class HelloWorldObject implements Comparable<HelloWorldObject> {
     public String getName() { return name; }
     public void setName(final String name) { this.name = name; }
 
+
     @javax.jdo.annotations.Column(allowsNull = "true", length = 4000)
     @Property(editing = Editing.ENABLED)
     private String notes;
diff --git a/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObjects.java b/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObjects.java
index 92bd565..2c776f5 100644
--- a/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObjects.java
+++ b/example/application/helloworld/src/main/java/domainapp/dom/impl/HelloWorldObjects.java
@@ -20,7 +20,7 @@ package domainapp.dom.impl;
 
 import java.util.List;
 
-import org.datanucleus.query.typesafe.TypesafeQuery;
+import javax.jdo.JDOQLTypedQuery;
 
 import org.apache.isis.applib.annotation.Action;
 import org.apache.isis.applib.annotation.DomainService;
@@ -31,9 +31,9 @@ import org.apache.isis.applib.annotation.ParameterLayout;
 import org.apache.isis.applib.annotation.RestrictTo;
 import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
-import org.apache.isis.applib.services.registry.ServiceRegistry;
 import org.apache.isis.applib.services.repository.RepositoryService;
 
+
 @DomainService(
         nature = NatureOfService.VIEW_MENU_ONLY,
         objectType = "helloworld.HelloWorldObjects"
@@ -52,7 +52,7 @@ public class HelloWorldObjects {
     @Action(semantics = SemanticsOf.SAFE)
     @MemberOrder(sequence = "2")
     public List<HelloWorldObject> findByName(final String name) {
-        TypesafeQuery<HelloWorldObject> q = isisJdoSupport.newTypesafeQuery(HelloWorldObject.class);
+        JDOQLTypedQuery<HelloWorldObject> q = isisJdoSupport.newTypesafeQuery(HelloWorldObject.class);
         final QHelloWorldObject cand = QHelloWorldObject.candidate();
         q = q.filter(
                 cand.name.indexOf(q.stringParameter("name")).ne(-1)
@@ -64,7 +64,8 @@ public class HelloWorldObjects {
     @Action(semantics = SemanticsOf.SAFE, restrictTo = RestrictTo.PROTOTYPING)
     @MemberOrder(sequence = "3")
     public List<HelloWorldObject> listAll() {
-        return repositoryService.allInstances(HelloWorldObject.class);
+        return isisJdoSupport.newTypesafeQuery(HelloWorldObject.class)
+                .executeList();
     }
 
     @javax.inject.Inject
diff --git a/example/application/simpleapp/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObjects.java b/example/application/simpleapp/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObjects.java
index 335f9d0..d77fe47 100644
--- a/example/application/simpleapp/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObjects.java
+++ b/example/application/simpleapp/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObjects.java
@@ -20,7 +20,7 @@ package domainapp.modules.simple.dom.impl;
 
 import java.util.List;
 
-import org.datanucleus.query.typesafe.TypesafeQuery;
+import javax.jdo.JDOQLTypedQuery;
 
 import org.apache.isis.applib.annotation.Action;
 import org.apache.isis.applib.annotation.ActionLayout;
@@ -35,7 +35,6 @@ import org.apache.isis.applib.annotation.SemanticsOf;
 import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
 import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
 import org.apache.isis.applib.services.repository.RepositoryService;
-import org.apache.isis.applib.services.xactn.TransactionService;
 
 @DomainService(
         nature = NatureOfService.VIEW_MENU_ONLY,
@@ -63,7 +62,7 @@ public class SimpleObjects {
             @ParameterLayout(named="Name")
             final String name
     ) {
-        TypesafeQuery<SimpleObject> q = isisJdoSupport.newTypesafeQuery(SimpleObject.class);
+        JDOQLTypedQuery<SimpleObject> q = isisJdoSupport.newTypesafeQuery(SimpleObject.class);
         final QSimpleObject cand = QSimpleObject.candidate();
         q = q.filter(
                 cand.name.indexOf(q.stringParameter("name")).ne(-1)
@@ -74,7 +73,7 @@ public class SimpleObjects {
 
     @Programmatic
     public SimpleObject findByNameExact(final String name) {
-        TypesafeQuery<SimpleObject> q = isisJdoSupport.newTypesafeQuery(SimpleObject.class);
+        JDOQLTypedQuery<SimpleObject> q = isisJdoSupport.newTypesafeQuery(SimpleObject.class);
         final QSimpleObject cand = QSimpleObject.candidate();
         q = q.filter(
                 cand.name.eq(q.stringParameter("name"))

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.