isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [isis] branch master updated: ISIS-2480: adds metamodel refiner for JPA (just stubs yet)
Date Fri, 15 Jan 2021 12:29:35 GMT
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 bc54412  ISIS-2480: adds metamodel refiner for JPA (just stubs yet)
bc54412 is described below

commit bc5441221489757c05fd6779c620f2b01b51817b
Author: Andi Huber <ahuber@apache.org>
AuthorDate: Fri Jan 15 13:29:22 2021 +0100

    ISIS-2480: adds metamodel refiner for JPA (just stubs yet)
---
 core/pom.xml                                       |   5 +
 persistence/jpa/integration/pom.xml                |   5 +
 persistence/jpa/{integration => metamodel}/pom.xml |  50 +--------
 .../jpa/metamodel/IsisModuleJpaMetamodel.java      |  41 +++++++
 .../jpa/metamodel/JpaProgrammingModel.java         | 125 +++++++++++++++++++++
 persistence/jpa/pom.xml                            |   1 +
 6 files changed, 182 insertions(+), 45 deletions(-)

diff --git a/core/pom.xml b/core/pom.xml
index 53d0c92..9905c99 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -793,6 +793,11 @@
 			</dependency>
 			<dependency>
 				<groupId>org.apache.isis.persistence</groupId>
+				<artifactId>isis-persistence-jpa-metamodel</artifactId>
+				<version>2.0.0-SNAPSHOT</version>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.isis.persistence</groupId>
 				<artifactId>isis-persistence-jpa-integration</artifactId>
 				<version>2.0.0-SNAPSHOT</version>
 			</dependency>
diff --git a/persistence/jpa/integration/pom.xml b/persistence/jpa/integration/pom.xml
index 0285950..14d197b 100644
--- a/persistence/jpa/integration/pom.xml
+++ b/persistence/jpa/integration/pom.xml
@@ -74,6 +74,11 @@
 		</dependency>
 		
 		<dependency>
+			<groupId>org.apache.isis.persistence</groupId>
+			<artifactId>isis-persistence-jpa-metamodel</artifactId>
+		</dependency>
+		
+		<dependency>
 			<groupId>org.apache.isis.core</groupId>
 			<artifactId>isis-core-runtime</artifactId>
 		</dependency>
diff --git a/persistence/jpa/integration/pom.xml b/persistence/jpa/metamodel/pom.xml
similarity index 57%
copy from persistence/jpa/integration/pom.xml
copy to persistence/jpa/metamodel/pom.xml
index 0285950..30dc02b 100644
--- a/persistence/jpa/integration/pom.xml
+++ b/persistence/jpa/metamodel/pom.xml
@@ -19,53 +19,18 @@
 		<version>2.0.0-SNAPSHOT</version>
 	</parent>
 
-	<artifactId>isis-persistence-jpa-integration</artifactId>
+	<artifactId>isis-persistence-jpa-metamodel</artifactId>
 
-	<name>Apache Isis Persistence - JPA (integration)</name>
+	<name>Apache Isis Persistence - JPA (metamodel)</name>
 	<description>
-        JPA integration (facets, jpa-context)
+        JPA Metamodel Facets / Programming Model
     </description>
 
 	<properties>
-		<jar-plugin.automaticModuleName>org.apache.isis.persistence.jpa.integration</jar-plugin.automaticModuleName>
-		<git-plugin.propertiesDir>org/apache/isis/persistence/jpa/integration</git-plugin.propertiesDir>
+		<jar-plugin.automaticModuleName>org.apache.isis.persistence.jpa.metamodel</jar-plugin.automaticModuleName>
+		<git-plugin.propertiesDir>org/apache/isis/persistence/jpa/metamodel</git-plugin.propertiesDir>
 	</properties>
 
-	<build>
-		<resources>
-			<resource>
-				<filtering>false</filtering>
-				<directory>src/main/resources</directory>
-			</resource>
-			<resource>
-				<filtering>false</filtering>
-				<directory>src/main/java</directory>
-				<includes>
-					<include>**</include>
-				</includes>
-				<excludes>
-					<exclude>**/*.java</exclude>
-				</excludes>
-			</resource>
-		</resources>
-		<testResources>
-            <testResource>
-                <filtering>false</filtering>
-                <directory>src/test/resources</directory>
-            </testResource>
-            <testResource>
-                <filtering>false</filtering>
-                <directory>src/test/java</directory>
-                <includes>
-                    <include>**</include>
-                </includes>
-                <excludes>
-                    <exclude>**/*.java</exclude>
-                </excludes>
-            </testResource>
-        </testResources>
-	</build>
-
 	<dependencies>
 
 		<dependency>
@@ -77,11 +42,6 @@
 			<groupId>org.apache.isis.core</groupId>
 			<artifactId>isis-core-runtime</artifactId>
 		</dependency>
-		
-		<dependency>
-			<groupId>org.springframework.data</groupId>
-			<artifactId>spring-data-jpa</artifactId>
-		</dependency>
 
 		<!-- TESTING -->
 		
diff --git a/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/IsisModuleJpaMetamodel.java
b/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/IsisModuleJpaMetamodel.java
new file mode 100644
index 0000000..718cc48
--- /dev/null
+++ b/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/IsisModuleJpaMetamodel.java
@@ -0,0 +1,41 @@
+/*
+ *  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.persistence.jpa.metamodel;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+import org.apache.isis.core.runtime.IsisModuleCoreRuntime;
+
+@Configuration
+@Import({
+    // modules
+    IsisModuleCoreRuntime.class,
+    //IsisModulePersistenceJpaApplib.class,
+
+    // @Component's
+    JpaProgrammingModel.class,
+    //JpaMetamodelMenu.class,
+    
+    // @Service's
+
+})
+public class IsisModuleJpaMetamodel {
+    
+}
diff --git a/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/JpaProgrammingModel.java
b/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/JpaProgrammingModel.java
new file mode 100644
index 0000000..4656430
--- /dev/null
+++ b/persistence/jpa/metamodel/src/main/java/org/apache/isis/persistence/jpa/metamodel/JpaProgrammingModel.java
@@ -0,0 +1,125 @@
+/*
+ *  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.persistence.jpa.metamodel;
+
+import org.springframework.stereotype.Component;
+
+import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
+import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
+
+import lombok.val;
+
+@Component
+public class JpaProgrammingModel implements MetaModelRefiner {
+
+    //@Inject private IsisConfiguration config;
+
+    @Override
+    public void refineProgrammingModel(ProgrammingModel pm) {
+
+        val step1 = ProgrammingModel.FacetProcessingOrder.C2_AFTER_METHOD_REMOVING;
+//
+//        // come what may, we have to ignore the PersistenceCapable supertype.
+//        pm.addFactory(step1, RemoveJdoEnhancementTypesFacetFactory.class, Marker.JDO);
+//        // so we may as well also just ignore any 'jdo' prefixed methods here also.
+//        pm.addFactory(step1, RemoveJdoPrefixedMethodsFacetFactory.class, Marker.JDO);
+//        // Datanucleus
+//        pm.addFactory(step1, RemoveDatanucleusPersistableTypesFacetFactory.class, Marker.JDO);
+//        pm.addFactory(step1, RemoveDnPrefixedMethodsFacetFactory.class, Marker.JDO);
+
+
+        val step2 = ProgrammingModel.FacetProcessingOrder.A2_AFTER_FALLBACK_DEFAULTS;
+//
+//        pm.addFactory(step2, JdoPersistenceCapableAnnotationFacetFactory.class, Marker.JDO);
+//        pm.addFactory(step2, JdoDatastoreIdentityAnnotationFacetFactory.class, Marker.JDO);
+//
+//        pm.addFactory(step2, JdoPrimaryKeyAnnotationFacetFactory.class, Marker.JDO);
+//        pm.addFactory(step2, JdoNotPersistentAnnotationFacetFactory.class, Marker.JDO);
+//        pm.addFactory(step2, JdoDiscriminatorAnnotationFacetFactory.class, Marker.JDO);
+//        pm.addFactory(step2, JdoVersionAnnotationFacetFactory.class, Marker.JDO);
+//
+//        pm.addFactory(step2, JdoQueryAnnotationFacetFactory.class, Marker.JDO);
+//
+//        pm.addFactory(step2, BigDecimalDerivedFromJdoColumnAnnotationFacetFactory.class,
Marker.JDO);
+//        pm.addFactory(step2, MaxLengthDerivedFromJdoColumnAnnotationFacetFactory.class,
Marker.JDO);
+//        // must appear after JdoPrimaryKeyAnnotationFacetFactory (above)
+//        // and also MandatoryFacetOnPropertyMandatoryAnnotationFactory
+//        // and also PropertyAnnotationFactory
+//        pm.addFactory(step2, MandatoryFromJdoColumnAnnotationFacetFactory.class, Marker.JDO);
+//
+//
+//        // -- validators
+//
+//        addValidatorToEnsureIdentityType(pm);
+//        addValidatorToCheckForUnsupportedAnnotations(pm);
+
+    }
+    
+    // -- HELPER
+
+//    private void addValidatorToEnsureIdentityType(ProgrammingModel pm) {
+//
+//        pm.addValidator((objSpec, validation) -> {
+//
+//            final JdoPersistenceCapableFacet jpcf = objSpec.getFacet(JdoPersistenceCapableFacet.class);
+//            if(jpcf == null) {
+//                return true;
+//            }
+//            final IdentityType identityType = jpcf.getIdentityType();
+//            if(identityType == IdentityType.APPLICATION) {
+//                // ok
+//
+//            } else if(identityType == IdentityType.NONDURABLE) {
+//                // ok; for use with DN view objects (http://www.datanucleus.org/products/accessplatform_3_2/datastores/rdbms_views.html)
+//
+//            } else if(identityType == IdentityType.DATASTORE || identityType == IdentityType.UNSPECIFIED)
{
+//
+//                // TODO: ensure that DATASTORE has recognised @DatastoreIdentity attribute
+//
+//            } else {
+//                // in fact, at the time of writing there are no others, so this is theoretical
in case there is
+//                // a future change to the JDO spec
+//                validation.onFailure(
+//                        objSpec,
+//                        objSpec.getIdentifier(),
+//                        "%s: is annotated with @PersistenceCapable but with an unrecognized
identityType (%s)",
+//                        objSpec.getFullIdentifier(),
+//                        identityType);
+//            }
+//
+//            return true;
+//        }, Marker.JDO);
+//
+//    }
+//
+//    private void addValidatorToCheckForUnsupportedAnnotations(ProgrammingModel pm) {
+//
+//        pm.addValidator((objSpec, validation) -> {
+//            if (objSpec.containsNonFallbackFacet(ParentedCollectionFacet.class) &&
!objSpec.containsNonFallbackFacet(CollectionFacet.class)) {
+//                validation.onFailure(
+//                        objSpec,
+//                        objSpec.getIdentifier(),
+//                        "%s: JDO/DataNucleus object store currently does not supported
Aggregated or EmbeddedOnly annotations",
+//                        objSpec.getFullIdentifier());
+//            }
+//            return true;
+//        }, Marker.JDO);
+//
+//    }
+}
diff --git a/persistence/jpa/pom.xml b/persistence/jpa/pom.xml
index 133f648..abf4ba9 100644
--- a/persistence/jpa/pom.xml
+++ b/persistence/jpa/pom.xml
@@ -32,6 +32,7 @@
 
 	<modules>
 		<module>applib</module>
+		<module>metamodel</module>
 		<module>integration</module>
 		<module>eclipselink</module>
 	</modules>


Mime
View raw message