[isis] 10/34: ISIS-1726: generalizes the logic that searches for @PersistenceCapable entities, to also take into account meta-annotations.

2018-02-22 Thread ahuber
This is an automated email from the ASF dual-hosted git repository.

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

commit ecf938944dbf1f55bd89a6b8d6be9416f09a4233
Author: Dan Haywood 
AuthorDate: Tue Sep 19 22:59:43 2017 +0100

ISIS-1726: generalizes the logic that searches for @PersistenceCapable 
entities, to also take into account meta-annotations.
---
 .../isis/applib/internal/reflection/_Reflect.java  |  9 --
 .../internal/reflection/_Reflect_Discovery.java| 24 +++-
 .../IsisComponentProvider.java | 33 ++
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
index 589cf31..e0b213d 100644
--- 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
+++ 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
@@ -23,10 +23,11 @@ import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.isis.applib.internal.context._Context;
 import org.reflections.scanners.SubTypesScanner;
 import org.reflections.util.ClasspathHelper;
 
+import org.apache.isis.applib.internal.context._Context;
+
 /**
  * - internal use only -
  * 
@@ -54,6 +55,9 @@ public final class _Reflect {

//TODO missing java-doc
public  Set> getSubTypesOf(Class type);
+
+   public Set> findPersistenceCapableTypes();
+
}
 
//TODO missing java-doc
@@ -79,5 +83,6 @@ public final class _Reflect {
new SubTypesScanner(false)
);
}
-   
+
+
 }
diff --git 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
index 9059e05..5db08e5 100644
--- 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
+++ 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
@@ -8,11 +8,15 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import javax.jdo.annotations.PersistenceCapable;
 import javax.validation.constraints.NotNull;
 
+import com.google.common.collect.Sets;
+
+import org.reflections.Reflections;
+
 import org.apache.isis.applib.internal.base._NullSafe;
 import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
-import org.reflections.Reflections;
 
 /**
  * 
@@ -80,6 +84,24 @@ class _Reflect_Discovery implements _Reflect.Discovery {
.filter(_NullSafe::isPresent);
}
 
+   public Set> findPersistenceCapableTypes() {
+
+   Set> pcSet = Sets.newLinkedHashSet();
+
+   Set> persistenceCapables = 
reflections.getTypesAnnotatedWith(PersistenceCapable.class);
+   persistenceCapables.stream()
+   .filter(x -> !x.isAnnotation())
+   .forEach(pcSet::add);
+
+   Stream> pcMetaAnnotStream =
+   (Stream)persistenceCapables.stream().filter(x 
-> x.isAnnotation());
+   pcMetaAnnotStream.map(metaAnnot -> 
reflections.getTypesAnnotatedWith(metaAnnot).stream())
+   .flatMap(x -> x)
+   .filter(x -> !x.isAnnotation())
+   .forEach(pcSet::add);
+
+   return pcSet;
+   }
 

 }
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 70c0acb..471b547 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
@@ -19,14 +19,26 @@
 
 package org.apache.isis.core.runtime.systemusinginstallers;
 
+import java.lang.annotation.Annotation;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.annotation.Nullable;
 import javax.jdo.annotations.PersistenceCapable;
+import javax.ws.rs.HEAD;
+
+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;
 
 import org.apache.isis.applib.App

[isis] 10/34: ISIS-1726: generalizes the logic that searches for @PersistenceCapable entities, to also take into account meta-annotations.

2018-02-21 Thread ahuber
This is an automated email from the ASF dual-hosted git repository.

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

commit 627ee81b2ce6275f3a3a45777b3df38f5763
Author: Dan Haywood 
AuthorDate: Tue Sep 19 22:59:43 2017 +0100

ISIS-1726: generalizes the logic that searches for @PersistenceCapable 
entities, to also take into account meta-annotations.
---
 .../isis/applib/internal/reflection/_Reflect.java  |  9 --
 .../internal/reflection/_Reflect_Discovery.java| 24 +++-
 .../IsisComponentProvider.java | 33 ++
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
index 589cf31..e0b213d 100644
--- 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
+++ 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
@@ -23,10 +23,11 @@ import java.lang.annotation.Annotation;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.isis.applib.internal.context._Context;
 import org.reflections.scanners.SubTypesScanner;
 import org.reflections.util.ClasspathHelper;
 
+import org.apache.isis.applib.internal.context._Context;
+
 /**
  * - internal use only -
  * 
@@ -54,6 +55,9 @@ public final class _Reflect {

//TODO missing java-doc
public  Set> getSubTypesOf(Class type);
+
+   public Set> findPersistenceCapableTypes();
+
}
 
//TODO missing java-doc
@@ -79,5 +83,6 @@ public final class _Reflect {
new SubTypesScanner(false)
);
}
-   
+
+
 }
diff --git 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
index 9059e05..5db08e5 100644
--- 
a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
+++ 
b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
@@ -8,11 +8,15 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import javax.jdo.annotations.PersistenceCapable;
 import javax.validation.constraints.NotNull;
 
+import com.google.common.collect.Sets;
+
+import org.reflections.Reflections;
+
 import org.apache.isis.applib.internal.base._NullSafe;
 import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
-import org.reflections.Reflections;
 
 /**
  * 
@@ -80,6 +84,24 @@ class _Reflect_Discovery implements _Reflect.Discovery {
.filter(_NullSafe::isPresent);
}
 
+   public Set> findPersistenceCapableTypes() {
+
+   Set> pcSet = Sets.newLinkedHashSet();
+
+   Set> persistenceCapables = 
reflections.getTypesAnnotatedWith(PersistenceCapable.class);
+   persistenceCapables.stream()
+   .filter(x -> !x.isAnnotation())
+   .forEach(pcSet::add);
+
+   Stream> pcMetaAnnotStream =
+   (Stream)persistenceCapables.stream().filter(x 
-> x.isAnnotation());
+   pcMetaAnnotStream.map(metaAnnot -> 
reflections.getTypesAnnotatedWith(metaAnnot).stream())
+   .flatMap(x -> x)
+   .filter(x -> !x.isAnnotation())
+   .forEach(pcSet::add);
+
+   return pcSet;
+   }
 

 }
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 70c0acb..471b547 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
@@ -19,14 +19,26 @@
 
 package org.apache.isis.core.runtime.systemusinginstallers;
 
+import java.lang.annotation.Annotation;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.annotation.Nullable;
 import javax.jdo.annotations.PersistenceCapable;
+import javax.ws.rs.HEAD;
+
+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;
 
 import org.apache.isis.applib.App