This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch jdo-SNAPSHOT in repository https://gitbox.apache.org/repos/asf/isis-app-simpleapp.git
commit bde58b4476db07a9e74a25831c90f9222dd50379 Merge: 300fab9 a084864 Author: Dan Haywood <[email protected]> AuthorDate: Thu Aug 25 18:27:47 2022 +0100 Merge branch 'jpa-SNAPSHOT' into jdo-SNAPSHOT .run/SimpleApp.run.xml | 4 +- README.adoc | 49 ++++++++++++++++-- .../domainapp/modules/simple/SimpleModule.java | 4 +- .../modules/simple/dom/so/SimpleObject.java | 13 +++-- .../modules/simple/dom/so/SimpleObjects.java | 3 -- .../src/test/resources/application-test.properties | 1 + webapp/pom.xml | 34 ++++++++++++ .../main/java/domainapp/webapp/AppManifest.java | 19 +++++++ .../services/homepage/HomePageViewModel.java | 15 ++++-- webapp/src/main/resources/application.yml | 4 ++ .../main/resources/config/application.properties | 4 +- webapp/src/main/resources/menubars.layout.xml | 60 ++++++++++++++++++++++ 12 files changed, 188 insertions(+), 22 deletions(-) diff --cc .run/SimpleApp.run.xml index 35be0c0,bbb78c4..1b6062f --- a/.run/SimpleApp.run.xml +++ b/.run/SimpleApp.run.xml @@@ -1,10 -1,11 +1,10 @@@ <component name="ProjectRunConfigurationManager"> <configuration default="false" name="SimpleApp" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> <option name="ACTIVE_PROFILES" /> -- <module name="simpleapp-jpa-webapp" /> ++ <module name="simpleapp-jdo-webapp" /> <option name="SPRING_BOOT_MAIN_CLASS" value="domainapp.webapp.SimpleApp" /> - <option name="VM_PARAMETERS" value="-javaagent:lib/spring-instrument.jar" /> <method v="2"> <option name="Make" enabled="true" /> </method> </configuration> --</component> ++</component> diff --cc README.adoc index 5e8d9b5,1269d54..b922b66 --- a/README.adoc +++ b/README.adoc @@@ -40,6 -40,15 +40,15 @@@ cd $REP mvn clean install ---- -* Download the `spring-instrument.jar` for load-time weaving (discussed in more detail xref:#orm-support[below]): -+ -[source,bash] ----- -mvn dependency:get -DgroupId=org.springframework -DartifactId=spring-instrument -Dversion=XXX ----- -+ -Change "XXX" to the value that `${spring-framework.version}` resolves to in the webapp `pom.xml` - ++//* Download the `spring-instrument.jar` for load-time weaving (discussed in more detail xref:#orm-support[below]): ++//+ ++//[source,bash] ++//---- ++//mvn dependency:get -DgroupId=org.springframework -DartifactId=spring-instrument -Dversion=XXX ++//---- ++//+ ++//Change "XXX" to the value that `${spring-framework.version}` resolves to in the webapp `pom.xml` ++// * Run using Maven: + [source,bash] @@@ -96,24 -109,52 +109,52 @@@ Larger applications should consist of m The `pom.xml` also provides goals to run the app from the command line, or to be assembled into a Docker image. + |`webapp-tests` + |Contains application-wide integration tests. + |==================== + It's more common for tests to reside within the same module, but we moved them into their own Maven modules because it makes them easier to be temporarily excluded, eg during initial explorations/prototyping. + + + == ORM Support + -This version of the application uses EclipseLink JPA as its ORM, configured with load-time weaving. -This requires that the application be run with a Java agent. ++//This version of the application uses EclipseLink JPA as its ORM, configured with load-time weaving. ++//This requires that the application be run with a Java agent. ++// ++//The spring-boot plugin is configured to run with this agent already. ++//If you want to run from an IDE: ++// ++//* first, you might wish to copy the file locally: ++//+ ++//[source,bash] ++//---- ++//cp ~/.m2/repository/org/springframework/spring-instrument/XXX/spring-instrument-XXX.jar lib/spring-instrument.jar ++//---- ++//+ ++//Change "XXX" to the value that `${spring-framework.version}` resolves to in the webapp `pom.xml` ++// ++//* Then specify the agent as a VM option: ++//+ ++//[source,bash] ++//---- ++//-javaagent:lib/spring-instrument.jar ++//---- + -The spring-boot plugin is configured to run with this agent already. -If you want to run from an IDE: - == Development -* first, you might wish to copy the file locally: -+ -[source,bash] ----- -cp ~/.m2/repository/org/springframework/spring-instrument/XXX/spring-instrument-XXX.jar lib/spring-instrument.jar ----- -+ -Change "XXX" to the value that `${spring-framework.version}` resolves to in the webapp `pom.xml` - Apache Isis uses DataNucleus as its ORM, which requires that any entities are "enhanced", a post-compile process. -* Then specify the agent as a VM option: -+ ++This version of the application uses DataNucleus as its ORM, which requires that any entities are "enhanced", a post-compile process. + +Normally this is done as part of a "mvn clean install", but the entities can also be enhanced explicity using: + [source,bash] ---- --javaagent:lib/spring-instrument.jar +mvn -pl module-simple datanucleus:enhance -o ---- +This is useful to know if the application or integration test fails to bootstrap, complaining of "unenhanced entities". - -//This version of the application uses DataNucleus as its ORM, which requires that any entities are "enhanced", a post-compile process. -// -//Normally this is done as part of a "mvn clean install", but the entities can also be enhanced explicity using: -// -//[source,bash] -//---- -//mvn -pl module-simple datanucleus:enhance -o -//---- -// -//This is useful to know if the application or integration test fails to bootstrap, complaining of "unenhanced entities". -// -//TIP: You can also use `enhance-all.sh` +TIP: You can also use `enhance-all.sh` == Testing diff --cc module-simple/src/main/java/domainapp/modules/simple/SimpleModule.java index 8a50246,5b85205..1a27b37 --- a/module-simple/src/main/java/domainapp/modules/simple/SimpleModule.java +++ b/module-simple/src/main/java/domainapp/modules/simple/SimpleModule.java @@@ -5,7 -6,8 +5,7 @@@ import org.springframework.context.anno import org.apache.isis.testing.fixtures.applib.fixturescripts.FixtureScript; import org.apache.isis.testing.fixtures.applib.modules.ModuleWithFixtures; --import org.apache.isis.testing.fixtures.applib.teardown.jpa.TeardownFixtureJpaAbstract; ++import org.apache.isis.testing.fixtures.applib.teardown.jdo.TeardownFixtureJdoAbstract; import domainapp.modules.simple.dom.so.SimpleObject; @@@ -18,7 -22,7 +18,7 @@@ public class SimpleModule implements Mo @Override public FixtureScript getTeardownFixture() { -- return new TeardownFixtureJpaAbstract() { ++ return new TeardownFixtureJdoAbstract() { @Override protected void execute(ExecutionContext executionContext) { deleteFrom(SimpleObject.class); diff --cc module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObject.java index 5854996,098a63d..b1ac97f --- a/module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObject.java +++ b/module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObject.java @@@ -46,29 -51,24 +48,30 @@@ import domainapp.modules.simple.types.N import domainapp.modules.simple.types.Notes; -@Entity -@Table( - schema= SimpleModule.SCHEMA, - uniqueConstraints = { - @UniqueConstraint(name = "SimpleObject__name__UNQ", columnNames = {"name"}) - } +@PersistenceCapable( + schema = SimpleModule.SCHEMA, + identityType=IdentityType.DATASTORE) +@Unique( + name = "SimpleObject__name__UNQ", members = { "name" } ) -@NamedQueries({ - @NamedQuery( +@Queries({ + @Query( name = SimpleObject.NAMED_QUERY__FIND_BY_NAME_LIKE, - query = "SELECT so " + - "FROM SimpleObject so " + - "WHERE so.name LIKE :name" + value = "SELECT " + + "FROM domainapp.modules.simple.dom.so.SimpleObject " + + "WHERE name.indexOf(:name) >= 0" + ), + @Query( + name = SimpleObject.NAMED_QUERY__FIND_BY_NAME_EXACT, + value = "SELECT " + + "FROM domainapp.modules.simple.dom.so.SimpleObject " + + "WHERE name == :name" ) }) - @javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="id") - @javax.jdo.annotations.Version(strategy= VersionStrategy.DATE_TIME, column="version") - @DomainObject(logicalTypeName = "simple.SimpleObject", entityChangePublishing = Publishing.ENABLED) -@EntityListeners(IsisEntityListener.class) ++@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="id") ++@Version(strategy= VersionStrategy.DATE_TIME, column="version") + @Named(SimpleModule.NAMESPACE + ".SimpleObject") + @DomainObject(entityChangePublishing = Publishing.ENABLED) @DomainObjectLayout() @NoArgsConstructor(access = AccessLevel.PUBLIC) @XmlJavaTypeAdapter(PersistentEntityAdapter.class) diff --cc module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObjects.java index 9117954,d161c0e..d194677 --- a/module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObjects.java +++ b/module-simple/src/main/java/domainapp/modules/simple/dom/so/SimpleObjects.java @@@ -54,12 -65,8 +54,11 @@@ public class SimpleObjects } - @Programmatic public SimpleObject findByNameExact(final String name) { - return simpleObjectRepository.findByName(name); + return repositoryService.firstMatch( + Query.named(SimpleObject.class, SimpleObject.NAMED_QUERY__FIND_BY_NAME_EXACT) + .withParameter("name", name)) + .orElse(null); } @@@ -72,14 -79,16 +71,12 @@@ - - @Programmatic public void ping() { - jpaSupportService.getEntityManager(SimpleObject.class) - .mapSuccess(entityManager -> { - final TypedQuery<SimpleObject> q = entityManager.createQuery( - "SELECT p FROM SimpleObject p ORDER BY p.name", - SimpleObject.class) - .setMaxResults(1); - return q.getResultList(); - }) - .ifFailureFail(); + JDOQLTypedQuery<SimpleObject> q = jdoSupportService.newTypesafeQuery(SimpleObject.class); + final QSimpleObject candidate = QSimpleObject.candidate(); + q.range(0,2); + q.orderBy(candidate.name.asc()); + q.executeList(); } } diff --cc webapp-tests/src/test/resources/application-test.properties index 0000000,eaf3275..8b13789 mode 000000,100644..100644 --- a/webapp-tests/src/test/resources/application-test.properties +++ b/webapp-tests/src/test/resources/application-test.properties @@@ -1,0 -1,4 +1,1 @@@ -eclipselink.weaving=false -eclipselink.weaving.changetracking=false -eclipselink.weaving.internal=false -eclipselink.weaving.lazy=false ++ diff --cc webapp/pom.xml index 4a6cbbc,f250ae8..5903434 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@@ -93,6 -96,40 +93,40 @@@ <artifactId>isis-extensions-flyway-impl</artifactId> </dependency> + <dependency> + <groupId>org.apache.isis.valuetypes</groupId> + <artifactId>isis-valuetypes-asciidoc-metamodel</artifactId> + </dependency> + <dependency> + <groupId>org.apache.isis.valuetypes</groupId> + <artifactId>isis-valuetypes-asciidoc-ui-wkt</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.isis.extensions</groupId> - <artifactId>isis-extensions-sessionlog-persistence-jpa</artifactId> ++ <artifactId>isis-extensions-sessionlog-persistence-jdo</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.isis.extensions</groupId> - <artifactId>isis-extensions-audittrail-persistence-jpa</artifactId> ++ <artifactId>isis-extensions-audittrail-persistence-jdo</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.isis.extensions</groupId> - <artifactId>isis-extensions-commandlog-persistence-jpa</artifactId> ++ <artifactId>isis-extensions-commandlog-persistence-jdo</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.isis.extensions</groupId> - <artifactId>isis-extensions-executionlog-persistence-jpa</artifactId> ++ <artifactId>isis-extensions-executionlog-persistence-jdo</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.isis.extensions</groupId> - <artifactId>isis-extensions-executionoutbox-persistence-jpa</artifactId> ++ <artifactId>isis-extensions-executionoutbox-persistence-jdo</artifactId> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-quartz</artifactId> diff --cc webapp/src/main/java/domainapp/webapp/AppManifest.java index 557bda8,dc43bf9..20e178d --- a/webapp/src/main/java/domainapp/webapp/AppManifest.java +++ b/webapp/src/main/java/domainapp/webapp/AppManifest.java @@@ -9,8 -9,13 +9,13 @@@ import org.apache.isis.applib.IsisModul import org.apache.isis.applib.IsisModuleApplibMixins; import org.apache.isis.core.config.presets.IsisPresets; import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices; -import org.apache.isis.extensions.audittrail.jpa.IsisModuleExtAuditTrailPersistenceJpa; -import org.apache.isis.extensions.commandlog.jpa.IsisModuleExtCommandLogPersistenceJpa; -import org.apache.isis.extensions.executionlog.jpa.IsisModuleExtExecutionLogPersistenceJpa; -import org.apache.isis.extensions.executionoutbox.jpa.IsisModuleExtExecutionOutboxPersistenceJpa; ++import org.apache.isis.extensions.audittrail.jdo.IsisModuleExtAuditTrailPersistenceJdo; ++import org.apache.isis.extensions.commandlog.jdo.IsisModuleExtCommandLogPersistenceJdo; ++import org.apache.isis.extensions.executionlog.jdo.IsisModuleExtExecutionLogPersistenceJdo; ++import org.apache.isis.extensions.executionoutbox.jdo.IsisModuleExtExecutionOutboxPersistenceJdo; import org.apache.isis.extensions.flyway.impl.IsisModuleExtFlywayImpl; -import org.apache.isis.extensions.sessionlog.jpa.IsisModuleExtSessionLogPersistenceJpa; -import org.apache.isis.persistence.jpa.eclipselink.IsisModulePersistenceJpaEclipselink; ++import org.apache.isis.extensions.sessionlog.jdo.IsisModuleExtSessionLogPersistenceJdo; +import org.apache.isis.persistence.jdo.datanucleus.IsisModulePersistenceJdoDatanucleus; import org.apache.isis.security.shiro.IsisModuleSecurityShiro; import org.apache.isis.testing.fixtures.applib.IsisModuleTestingFixturesApplib; import org.apache.isis.testing.h2console.ui.IsisModuleTestingH2ConsoleUi; @@@ -38,6 -45,16 +45,16 @@@ import domainapp.webapp.quartz.QuartzMo IsisModuleExtFlywayImpl.class, - IsisModuleExtSessionLogPersistenceJpa.class, - IsisModuleExtAuditTrailPersistenceJpa.class, - IsisModuleExtCommandLogPersistenceJpa.class, - IsisModuleExtExecutionLogPersistenceJpa.class, - IsisModuleExtExecutionOutboxPersistenceJpa.class, ++ IsisModuleExtSessionLogPersistenceJdo.class, ++ IsisModuleExtAuditTrailPersistenceJdo.class, ++ IsisModuleExtCommandLogPersistenceJdo.class, ++ IsisModuleExtExecutionLogPersistenceJdo.class, ++ IsisModuleExtExecutionOutboxPersistenceJdo.class, + + IsisModuleValAsciidocMetaModel.class, // for pretty rendering of DTO objects such as CommandDto, InteractionDto + IsisModuleValAsciidocUiWkt.class, + + ApplicationModule.class, CustomModule.class, QuartzModule.class, diff --cc webapp/src/main/resources/config/application.properties index 3549f85,93148bb..1487a85 --- a/webapp/src/main/resources/config/application.properties +++ b/webapp/src/main/resources/config/application.properties @@@ -15,9 -15,21 +15,11 @@@ spring.datasource.url=jdbc:h2:mem:simpl spring.datasource.driver-class-name=org.h2.Driver isis.persistence.schema.create-schema-sql-template=CREATE SCHEMA IF NOT EXISTS %s - isis.persistence.schema.auto-create-schemas=simple + isis.persistence.schema.auto-create-schemas=simple,isisExtAuditTrail,isisExtCommandLog,isisExtExecutionLog,isisExtExecutionOutbox,isisExtSessionLog + + isis.core.meta-model.introspector.policy=encapsulation_enabled -eclipselink.weaving=true -eclipselink.weaving.changetracking=true -eclipselink.weaving.internal=true -eclipselink.weaving.lazy=true - -eclipselink.deploy-on-startup=true -eclipselink.ddl-generation.output-mode=both -eclipselink.ddl-generation=create-tables -eclipselink.create-ddl-jdbc-file-name=create-db-schema.sql -eclipselink.application-location=. -eclipselink.jpa.upper-case-column-names=false +datanucleus.schema.generate-database.mode=create # uncomment to run during bootstrap #isis.testing.fixtures.initial-script = domainapp.webapp.application.fixture.scenarios.DomainAppDemo
