You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2020/01/22 18:02:49 UTC

[isis-app-simpleapp] 01/02: adds support for flyway

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

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis-app-simpleapp.git

commit 20644a6ef9f3cf48effca1ac1f3c29769e25e917
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Jan 22 17:48:30 2020 +0000

    adds support for flyway
---
 README.adoc                                        |  7 ++-
 .../modules/simple/dom/impl/SimpleObject.java      |  3 +-
 pom.xml                                            |  2 +-
 webapp/pom.xml                                     | 21 ++++++++
 .../src/main/java/domainapp/webapp/SimpleApp.java  | 28 ++++++-----
 webapp/src/main/resources/application.yml          | 58 +---------------------
 .../config/application-SQLSERVER.properties        | 31 ++++++++++++
 .../main/resources/config/application.properties   |  5 +-
 .../V2020.01.20.14.10__create_schema_simple.sql    |  8 +++
 ....20.14.14__create_table_simple_SimpleObject.sql | 25 ++++++++++
 .../integtests/ApplicationIntegTestAbstract.java   |  1 +
 11 files changed, 115 insertions(+), 74 deletions(-)

diff --git a/README.adoc b/README.adoc
index 24c0b21..70bfe53 100644
--- a/README.adoc
+++ b/README.adoc
@@ -19,9 +19,10 @@ If all you want is get a feel for what the framework is all about, then take a l
 +
 [source,bash]
 ----
-REPO=isis-app-simpleapp
+APP=simpleapp
 BRANCH=master
 
+REPO=isis-app-$APP
 curl "https://codeload.github.com/apache/$REPO/zip/$BRANCH" | jar xv
 mv $REPO-$BRANCH $REPO
 cd $REPO
@@ -41,7 +42,9 @@ mvn clean install
 mvn -pl webapp spring-boot:run
 ----
 
-* Login using:
+* Browse to http://localhost:8080.
+
+* Login to using:
 
 ** username: `sven`
 ** password: `pass`
diff --git a/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObject.java b/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObject.java
index c3bc635..6319cc7 100644
--- a/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObject.java
+++ b/module-simple/src/main/java/domainapp/modules/simple/dom/impl/SimpleObject.java
@@ -37,7 +37,8 @@ public class SimpleObject implements Comparable<SimpleObject> {
 
     public static class ActionDomainEvent extends org.apache.isis.applib.events.domain.ActionDomainEvent<SimpleObject> {}
 
-    private SimpleObject() {}
+    private SimpleObject() {
+    }
 
     public String title() {
         return "Object: " + getName();
diff --git a/pom.xml b/pom.xml
index a3c0d71..613fe3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <groupId>org.apache.isis.app</groupId>
         <artifactId>isis-app-starter-parent</artifactId>
-        <version>2.0.0-M2.20200116-1350-2dd6b3a2</version>
+        <version>2.0.0-M2.20200120-1800-910c8085</version>
 <!--
         <version>2.0.0-M3-SNAPSHOT</version>
 -->
diff --git a/webapp/pom.xml b/webapp/pom.xml
index f774f9a..3bb4d5d 100644
--- a/webapp/pom.xml
+++ b/webapp/pom.xml
@@ -115,6 +115,11 @@
             <artifactId>isis-testing-h2console-ui</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.isis.extensions</groupId>
+            <artifactId>isis-extensions-flyway-impl</artifactId>
+        </dependency>
+
         <!-- TESTING -->
         <dependency>
             <groupId>org.apache.isis.mavendeps</groupId>
@@ -217,6 +222,22 @@
                 </plugins>
             </build>
         </profile>
+
+        <profile>
+            <id>jdbc-sqlserver</id>
+            <activation>
+                <property>
+                    <name>!skip.jdbc-sqlserver</name>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>com.microsoft.sqlserver</groupId>
+                    <artifactId>mssql-jdbc</artifactId>
+                    <version>7.4.1.jre8</version>
+                </dependency>
+            </dependencies>
+        </profile>
     </profiles>
 
 </project>
diff --git a/webapp/src/main/java/domainapp/webapp/SimpleApp.java b/webapp/src/main/java/domainapp/webapp/SimpleApp.java
index 8243d99..39c1e56 100644
--- a/webapp/src/main/java/domainapp/webapp/SimpleApp.java
+++ b/webapp/src/main/java/domainapp/webapp/SimpleApp.java
@@ -1,26 +1,26 @@
 package domainapp.webapp;
 
-import domainapp.webapp.application.ApplicationModule;
-import domainapp.webapp.application.fixture.scenarios.DomainAppDemo;
-
-import org.apache.isis.core.runtime.IsisModuleCoreRuntime;
-import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices;
-import org.apache.isis.testing.fixtures.applib.IsisModuleTestingFixturesApplib;
-import org.apache.isis.testing.h2console.ui.IsisModuleTestingH2ConsoleUi;
-import org.apache.isis.persistence.jdo.datanucleus5.IsisModuleJdoDataNucleus5;
-import org.apache.isis.viewer.restfulobjects.jaxrsresteasy4.IsisModuleViewerRestfulObjectsJaxrsResteasy4;
-import org.apache.isis.security.shiro.IsisModuleSecurityShiro;
-import org.apache.isis.viewer.wicket.viewer.IsisModuleViewerWicketViewer;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
-
-import org.apache.isis.core.config.presets.IsisPresets;
 import org.springframework.context.annotation.PropertySource;
 import org.springframework.context.annotation.PropertySources;
 
+import org.apache.isis.core.config.presets.IsisPresets;
+import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices;
+import org.apache.isis.extensions.flyway.impl.IsisModuleExtFlywayImpl;
+import org.apache.isis.persistence.jdo.datanucleus5.IsisModuleJdoDataNucleus5;
+import org.apache.isis.security.shiro.IsisModuleSecurityShiro;
+import org.apache.isis.testing.fixtures.applib.IsisModuleTestingFixturesApplib;
+import org.apache.isis.testing.h2console.ui.IsisModuleTestingH2ConsoleUi;
+import org.apache.isis.viewer.restfulobjects.jaxrsresteasy4.IsisModuleViewerRestfulObjectsJaxrsResteasy4;
+import org.apache.isis.viewer.wicket.viewer.IsisModuleViewerWicketViewer;
+
+import domainapp.webapp.application.ApplicationModule;
+import domainapp.webapp.application.fixture.scenarios.DomainAppDemo;
+
 @SpringBootApplication
 @Import({
     SimpleApp.AppManifest.class,
@@ -43,6 +43,8 @@ public class SimpleApp extends SpringBootServletInitializer {
             IsisModuleTestingFixturesApplib.class,
             IsisModuleTestingH2ConsoleUi.class,
 
+            IsisModuleExtFlywayImpl.class,
+
             ApplicationModule.class,
 
             // discoverable fixtures
diff --git a/webapp/src/main/resources/application.yml b/webapp/src/main/resources/application.yml
index 34c41fe..65ba537 100644
--- a/webapp/src/main/resources/application.yml
+++ b/webapp/src/main/resources/application.yml
@@ -13,54 +13,6 @@ isis:
         command: ignore_safe
         publishing: all
       action-layout:
-        css-class-fa:
-          patterns:
-            new.*:fa-plus,
-            add.*:fa-plus-square,
-            create.*:fa-plus,
-            update.*:fa-edit,
-            delete.*:fa-trash,
-            save.*:fa-floppy-o,
-            change.*:fa-edit,
-            edit.*:fa-pencil-square-o,
-            maintain.*:fa-edit,
-            remove.*:fa-minus-square,
-            copy.*:fa-copy,
-            move.*:fa-exchange,
-            first.*:fa-star,
-            find.*:fa-search,
-            lookup.*:fa-search,
-            search.*:fa-search,
-            view.*:fa-search,
-            clear.*:fa-remove,
-            previous.*:fa-step-backward,
-            next.*:fa-step-forward,
-            list.*:fa-list,
-            all.*:fa-list,
-            download.*:fa-download,
-            upload.*:fa-upload,
-            export.*:fa-download,
-            switch.*:fa-exchange,
-            import.*:fa-upload,
-            execute.*:fa-bolt,
-            run.*:fa-bolt,
-            calculate.*:fa-calculator,
-            verify.*:fa-check-circle,
-            refresh.*:fa-refresh,
-            install.*:fa-wrench,
-            stop.*:fa-stop,
-            terminate.*:fa-stop,
-            cancel.*:fa-stop,
-            discard.*:fa-trash-o,
-            pause.*:fa-pause,
-            suspend.*:fa-pause,
-            resume.*:fa-play,
-            renew.*:fa-repeat,
-            reset.*:fa-repeat,
-            categorise.*:fa-folder-open-o,
-            assign.*:fa-hand-o-right,
-            approve.*:fa-thumbs-o-up,
-            decline.*:fa-thumbs-o-down
         css-class:
           patterns:
             delete.*:btn-danger,
@@ -82,8 +34,6 @@ isis:
         allow-deprecated: false
         no-params-only: true
         explicit-object-type: true
-        service-actions-only: true
-        mixins-only: true
 
   viewer:
     wicket:
@@ -117,8 +67,8 @@ isis:
   persistence:
     jdo-datanucleus:
       impl:
-        # note that properties under 'isis.persistor.datanucleus.impl' are passed through directly
-        # to DataNucleus, and must use camelCase rather than kebab-case
+        # note that properties under 'isis.persistence.jdo-datanucleus.impl' are passed through directly
+        # to DataNucleus, and use variously camelCase or PascalCase rather than kebab-case
         datanucleus:
           schema:
             validateTables: true
@@ -133,10 +83,6 @@ isis:
               type: none
               mode: ENABLE_SELECTIVE
 
-  value:
-    format:
-      date: dd-MM-yyyy
-
 resteasy:
   jaxrs:
     app:
diff --git a/webapp/src/main/resources/config/application-SQLSERVER.properties b/webapp/src/main/resources/config/application-SQLSERVER.properties
new file mode 100644
index 0000000..4747259
--- /dev/null
+++ b/webapp/src/main/resources/config/application-SQLSERVER.properties
@@ -0,0 +1,31 @@
+#
+# Recommend use for configuration that changes between environments.
+#
+# To override externally, see Spring Boot docs
+# https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config
+#
+# See also /application.yml
+#
+
+#
+# to enable this profile use:
+#
+# -Dspring.profiles.active=SQLSERVER
+#
+# Prereq is an empty database called 'simpleapp', with user and password also 'simpleapp'
+#
+
+# note that properties under 'isis.persistence.jdo-datanucleus.impl' are passed through directly
+# to DataNucleus, and must use camelCase rather than kebab-case
+
+isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionURL = jdbc:sqlserver://localhost;databaseName=simpleapp
+isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionDriverName = com.microsoft.sqlserver.jdbc.SQLServerDriver
+isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionUserName = simpleapp
+isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionPassword = simpleapp
+
+spring.flyway.url=${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionURL}
+spring.flyway.user=${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionUserName}
+spring.flyway.password=${isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionPassword}
+
+spring.flyway.enabled=true
+isis.persistence.jdo-datanucleus.impl.datanucleus.schema.autoCreateAll=false
diff --git a/webapp/src/main/resources/config/application.properties b/webapp/src/main/resources/config/application.properties
index 93135ec..8e3d195 100644
--- a/webapp/src/main/resources/config/application.properties
+++ b/webapp/src/main/resources/config/application.properties
@@ -9,9 +9,12 @@
 
 
 # note that properties under 'isis.persistence.jdo-datanucleus.impl' are passed through directly
-# to DataNucleus, and must use camelCase rather than kebab-case
+# to DataNucleus, and use variously camelCase or PascalCase rather than kebab-case
 
 isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionURL = jdbc:h2:mem:test
 isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionDriverName = org.h2.Driver
 isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionUserName = sa
 isis.persistence.jdo-datanucleus.impl.javax.jdo.option.ConnectionPassword =
+
+spring.flyway.enabled=false
+isis.persistence.jdo-datanucleus.impl.datanucleus.schema.autoCreateAll=true
\ No newline at end of file
diff --git a/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.10__create_schema_simple.sql b/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.10__create_schema_simple.sql
new file mode 100644
index 0000000..447a66f
--- /dev/null
+++ b/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.10__create_schema_simple.sql
@@ -0,0 +1,8 @@
+IF NOT EXISTS (
+    SELECT  1
+    FROM    sys.schemas
+    WHERE   name = N'simple'
+)
+    EXEC('CREATE SCHEMA [simple]');
+GO
+
diff --git a/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.14__create_table_simple_SimpleObject.sql b/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.14__create_table_simple_SimpleObject.sql
new file mode 100644
index 0000000..0d727cf
--- /dev/null
+++ b/webapp/src/main/resources/db/migration/SQLSERVER/V2020.01.20.14.14__create_table_simple_SimpleObject.sql
@@ -0,0 +1,25 @@
+SET ANSI_NULLS ON
+GO
+
+SET QUOTED_IDENTIFIER ON
+GO
+
+CREATE TABLE [simple].[SimpleObject](
+    [id]      [bigint]        IDENTITY(1,1) NOT NULL,
+    [name]    [varchar](40)                 NOT NULL,
+    [notes]   [varchar](4000)               NULL,
+    [version] [datetime2](7)                NOT NULL,
+
+    CONSTRAINT [SimpleObject_PK] PRIMARY KEY CLUSTERED
+        ([id] ASC)
+        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
+        ON [PRIMARY],
+
+    CONSTRAINT [SimpleObject_name_UNQ] UNIQUE NONCLUSTERED
+        ([name] ASC)
+        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
+        ON [PRIMARY]
+)
+ON [PRIMARY]
+GO
+
diff --git a/webapp/src/test/java/domainapp/webapp/integtests/ApplicationIntegTestAbstract.java b/webapp/src/test/java/domainapp/webapp/integtests/ApplicationIntegTestAbstract.java
index f848c3b..ab5b46e 100644
--- a/webapp/src/test/java/domainapp/webapp/integtests/ApplicationIntegTestAbstract.java
+++ b/webapp/src/test/java/domainapp/webapp/integtests/ApplicationIntegTestAbstract.java
@@ -13,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.TestPropertySource;
+import org.springframework.transaction.annotation.Transactional;
 
 @SpringBootTest(
         classes = ApplicationIntegTestAbstract.AppManifest.class