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 2014/05/09 18:40:32 UTC
[1/3] git commit: ISIS-764: removing ToDoItem#foo and #bar
Repository: isis
Updated Branches:
refs/heads/ISIS-764 a95a5c7b5 -> c6be9ca60
refs/heads/master 31acb0fcd -> 55c4ea853
ISIS-764: removing ToDoItem#foo and #bar
... accidentally committed.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c6be9ca6
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c6be9ca6
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c6be9ca6
Branch: refs/heads/ISIS-764
Commit: c6be9ca60d3103b26052480d5624d83dee1512e9
Parents: a95a5c7
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri May 9 15:14:27 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri May 9 15:14:27 2014 +0100
----------------------------------------------------------------------
.../dom/src/main/java/dom/todo/ToDoItem.java | 38 --------------------
1 file changed, 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/c6be9ca6/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
index e2d5e1e..e7ddd99 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.java
@@ -907,43 +907,5 @@ public class ToDoItem implements Comparable<ToDoItem> {
//endregion
- // //////////////////////////////////////
- // foo (property)
- // //////////////////////////////////////
-
- private ToDoItem foo;
-
- @javax.jdo.annotations.Persistent()
- @javax.jdo.annotations.Column(allowsNull="true")
- @MemberOrder(sequence = "1")
- public ToDoItem getFoo() {
- return foo;
- }
-
- public void setFoo(final ToDoItem foo) {
- this.foo = foo;
- }
-
- // //////////////////////////////////////
- // bar (property)
- // //////////////////////////////////////
-
- private ToDoItem bar;
-
- @javax.jdo.annotations.Persistent()
- @javax.jdo.annotations.Column(allowsNull="true")
- @MemberOrder(sequence = "1")
- public ToDoItem getBar() {
- return bar;
- }
-
- public void setBar(final ToDoItem bar) {
- this.bar = bar;
- }
-
- public List<ToDoItem> choicesBar() {
- return toDoItems.allToDos();
- }
-
}
[3/3] git commit: ISIS-776: retroft with applib.InstallableFixture;
decouple org.reflections...
Posted by da...@apache.org.
ISIS-776: retroft with applib.InstallableFixture; decouple org.reflections...
dependency by introducing a new ClassDiscoveryService.
Also:
- fixes for todo app's integration tests, to use the ToDoItemsFixtureService rather than ToDoItemFixture directly (ie uses fixture scripts to setup).
- ignored RO TCK test (ISIS-421)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/55c4ea85
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/55c4ea85
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/55c4ea85
Branch: refs/heads/master
Commit: 55c4ea85334373661ad4f21f01f4638c51b207a6
Parents: 98758f7
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri May 9 17:23:28 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri May 9 17:23:28 2014 +0100
----------------------------------------------------------------------
...Put_whenArgValid_thenPropertyUpdated_ok.java | 262 ------------------
...henArgValid_thenPropertyUpdated_ok_TODO.java | 267 +++++++++++++++++++
core/applib/pom.xml | 6 +
.../applib/fixturescripts/FixtureScript.java | 22 +-
.../applib/fixturescripts/FixtureScripts.java | 15 +-
.../classdiscovery/ClassDiscoveryService.java | 30 +++
.../ClassDiscoveryServiceUsingReflections.java | 42 +++
.../src/main/java/dom/todo/ToDoItem.layout.json | 6 +-
.../fixture/todo/ToDoItemsCreateForUser.java | 105 ++++++++
.../fixture/todo/ToDoItemsDeleteForUser.java | 60 +++++
.../java/fixture/todo/ToDoItemsFixture.java | 75 +-----
.../fixture/todo/ToDoItemsFixturesService.java | 34 +++
.../fixture/todo/ToDoItemsResetForUser.java | 75 ++++++
.../java/integration/ToDoSystemInitializer.java | 12 +-
.../integration/glue/CatalogOfFixturesGlue.java | 3 +-
.../webapp/prototyping/DeveloperUtilities.java | 2 +
.../prototyping/ToDoItemResetForUser.java | 64 -----
.../prototyping/ToDoItemsCreateForUser.java | 96 -------
.../prototyping/ToDoItemsDeleteForUser.java | 51 ----
.../prototyping/ToDoItemsFixturesService.java | 92 -------
.../src/main/webapp/WEB-INF/isis.properties | 3 +-
21 files changed, 663 insertions(+), 659 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok.java
deleted file mode 100644
index a24c2e3..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * 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.viewer.restfulobjects.tck.domainobject.oid.property;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.joda.time.format.ISODateTimeFormat;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class Put_whenArgValid_thenPropertyUpdated_ok {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- protected RestfulClient client;
-
- private DomainObjectResource domainObjectResource;
-
- private LinkRepresentation modifyLink;
- private JsonRepresentation argRepr;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- domainObjectResource = client.getDomainObjectResource();
- }
-
- /**
- * Tests change state, so discard such that will be recreated by next test.
- */
- @After
- public void tearDown() throws Exception {
- webServerRule.discardWebApp();
- }
-
- @Test
- public void primitivePropertiesUpdated() throws Exception {
-
- // byte
- final byte b = (byte)99;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "byteProperty");
- argRepr = modifyLink.getArguments().mapPut("value", b);
- assertThat(followedRepr(modifyLink,argRepr).getByte("value"), is(b));
-
- // char
- final char c = 'b';
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "charProperty");
- argRepr = modifyLink.getArguments().mapPut("value", c);
- assertThat(followedRepr(modifyLink,argRepr).getChar("value"), is(c));
-
- // double
- final double d = 12345.678;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "doubleProperty");
- argRepr = modifyLink.getArguments().mapPut("value", d);
- assertThat(followedRepr(modifyLink,argRepr).getDouble("value"), is(d));
-
- // float
- final float f = 54321.123F;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "floatProperty");
- argRepr = modifyLink.getArguments().mapPut("value", f);
- assertThat(followedRepr(modifyLink,argRepr).getFloat("value"), is(f));
-
- // int
- final int i = 999999;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "intProperty");
- argRepr = modifyLink.getArguments().mapPut("value", i);
- assertThat(followedRepr(modifyLink,argRepr).getInt("value"), is(i));
-
- // long
- final long l = 99999999999L;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "longProperty");
- argRepr = modifyLink.getArguments().mapPut("value", l);
- assertThat(followedRepr(modifyLink,argRepr).getLong("value"), is(l));
-
- // short
- final short s = (short)999;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "shortProperty");
- argRepr = modifyLink.getArguments().mapPut("value", s);
- assertThat(followedRepr(modifyLink,argRepr).getShort("value"), is(s));
-
- // boolean
- final boolean z = false;
- modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "booleanProperty");
- argRepr = modifyLink.getArguments().mapPut("value", z);
- assertThat(followedRepr(modifyLink,argRepr).getBoolean("value"), is(z));
-
- }
-
- @Test
- public void jdkPropertiesUpdated() throws Exception {
-
- // big decimal
- final BigDecimal bd = new BigDecimal("12345678901234567.789");
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "bigDecimalProperty");
- argRepr = modifyLink.getArguments().mapPut("value", bd);
- assertThat(followedRepr(modifyLink,argRepr).getBigDecimal("value"), is(new BigDecimal("12345678901234567.7890000000"))); // big-decimal(30,10)
-
- // big integer
- final BigInteger bi = new BigInteger("123456789012345678");
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "bigIntegerProperty");
- argRepr = modifyLink.getArguments().mapPut("value", bi);
- assertThat(followedRepr(modifyLink,argRepr).getBigInteger("value"), is(bi));
-
- // java.sql.Date
- final java.sql.Date sqld = new java.sql.Date(new DateTime(2014,5,1, 0,0, DateTimeZone.UTC).getMillis());
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlDateProperty");
- argRepr = modifyLink.getArguments().mapPut("value", asIsoNoT(sqld));
- assertThat(followedRepr(modifyLink,argRepr).getDate("value"), is((java.util.Date)sqld));
-
- // java.sql.Time
- final java.sql.Time sqlt = new java.sql.Time(13,0,0);
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlTimeProperty");
- argRepr = modifyLink.getArguments().mapPut("value", asIsoOnlyT(sqlt));
- assertThat(followedRepr(modifyLink,argRepr).getTime("value"), is((java.util.Date)sqlt));
-
- // java.sql.Timestamp
- final java.sql.Timestamp sqlts = new java.sql.Timestamp(114,4,1,13,0,0,0);
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlTimestampProperty");
- argRepr = modifyLink.getArguments().mapPut("value", sqlts.getTime());
- assertThat(followedRepr(modifyLink,argRepr).getLong("value"), is(sqlts.getTime()));
-
- // java.util.Date
- final java.util.Date d = new java.util.Date(114,4,1,13,0,0);
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaUtilDateProperty");
- argRepr = modifyLink.getArguments().mapPut("value", asIso(d));
- assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(d));
-
- // enum
- final String e = "ORANGE";
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "myEnum");
- argRepr = modifyLink.getArguments().mapPut("value", e);
- assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(e));
-
- // String
- final String s = "Tangerine";
- modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "stringProperty");
- argRepr = modifyLink.getArguments().mapPut("value", s);
- assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(s));
-
- }
-
-
- @Test
- public void jodaPropertiesUpdated() throws Exception {
-
- // LocalDate
- final LocalDate ld = new LocalDate(2013,5,1);
- modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "localDateProperty");
- argRepr = modifyLink.getArguments().mapPut("value", "2013-05-01");
- assertThat(followedRepr(modifyLink,argRepr).getString("value"), is("2013-05-01")); // hacky
-
- // LocalDateTime
- final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
- modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "localDateTimeProperty");
- argRepr = modifyLink.getArguments().mapPut("value", asIso(ldt.toDate()));
- assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(ldt.toDate()));
-
- // DateTime
- final DateTime dt = new DateTime(2013,2,1,14,15,0);
- modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "dateTimeProperty");
- argRepr = modifyLink.getArguments().mapPut("value", asIso(dt.toDate()));
- assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(dt.toDate()));
-
- // String
- final String s = "New string";
- modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "stringProperty");
- argRepr = modifyLink.getArguments().mapPut("value", s);
- assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(s));
- }
-
- private ObjectPropertyRepresentation getObjectPropertyRepr(final String domainType, final String instanceId, String propertyId) throws JsonParseException, JsonMappingException, IOException {
- final Response domainObjectResp = domainObjectResource.propertyDetails(domainType, instanceId, propertyId);
- final RestfulResponse<ObjectPropertyRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
- assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- final ObjectPropertyRepresentation repr = domainObjectJsonResp.getEntity();
- return repr;
- }
-
- private LinkRepresentation getObjectPropertyReprModifyLink(String domainType, String instanceId, String propertyId) throws JsonParseException, JsonMappingException, IOException {
- ObjectPropertyRepresentation objectPropertyRepr = getObjectPropertyRepr(domainType, instanceId, propertyId);
- return objectPropertyRepr.getLinkWithRel(Rel.MODIFY);
- }
-
- private JsonRepresentation followedRepr(LinkRepresentation modifyLink, JsonRepresentation argRepr) throws Exception {
- RestfulResponse<JsonRepresentation> result = client.follow(modifyLink, argRepr);
- assertThat(result.getStatus(), is(HttpStatusCode.OK));
- return result.getEntity().as(ObjectPropertyRepresentation.class);
- }
-
-
- private static String asIso(final java.util.Date d) {
- final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
- return asIso(dt);
- }
-
- private static String asIso(final org.joda.time.DateTime dt) {
- return ISODateTimeFormat.basicDateTimeNoMillis().withZoneUTC().print(dt);
- }
-
-
- private static String asIsoNoT(final java.util.Date d) {
- final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
- return asIsoNoT(dt);
- }
-
- private static String asIsoNoT(final org.joda.time.DateTime dt) {
- return ISODateTimeFormat.basicDate().withZoneUTC().print(dt);
- }
-
- private static String asIsoOnlyT(final java.util.Date d) {
- final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
- return asIsoOnlyT(dt);
- }
-
- private static String asIsoOnlyT(final org.joda.time.DateTime dt) {
- return ISODateTimeFormat.basicTime().withZoneUTC().print(dt);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok_TODO.java
new file mode 100644
index 0000000..6feb0ff
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Put_whenArgValid_thenPropertyUpdated_ok_TODO.java
@@ -0,0 +1,267 @@
+/*
+ * 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.viewer.restfulobjects.tck.domainobject.oid.property;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+import org.joda.time.format.ISODateTimeFormat;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Put_whenArgValid_thenPropertyUpdated_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectResource domainObjectResource;
+
+ private LinkRepresentation modifyLink;
+ private JsonRepresentation argRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+ }
+
+ /**
+ * Tests change state, so discard such that will be recreated by next test.
+ */
+ @After
+ public void tearDown() throws Exception {
+ webServerRule.discardWebApp();
+ }
+
+ @Test
+ public void primitivePropertiesUpdated() throws Exception {
+
+ // byte
+ final byte b = (byte)99;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "byteProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", b);
+ assertThat(followedRepr(modifyLink,argRepr).getByte("value"), is(b));
+
+ // char
+ final char c = 'b';
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "charProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", c);
+ assertThat(followedRepr(modifyLink,argRepr).getChar("value"), is(c));
+
+ // double
+ final double d = 12345.678;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "doubleProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", d);
+ assertThat(followedRepr(modifyLink,argRepr).getDouble("value"), is(d));
+
+ // float
+ final float f = 54321.123F;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "floatProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", f);
+ assertThat(followedRepr(modifyLink,argRepr).getFloat("value"), is(f));
+
+ // int
+ final int i = 999999;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "intProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", i);
+ assertThat(followedRepr(modifyLink,argRepr).getInt("value"), is(i));
+
+ // long
+ final long l = 99999999999L;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "longProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", l);
+ assertThat(followedRepr(modifyLink,argRepr).getLong("value"), is(l));
+
+ // short
+ final short s = (short)999;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "shortProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", s);
+ assertThat(followedRepr(modifyLink,argRepr).getShort("value"), is(s));
+
+ // boolean
+ final boolean z = false;
+ modifyLink = getObjectPropertyReprModifyLink("PRMV", "31", "booleanProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", z);
+ assertThat(followedRepr(modifyLink,argRepr).getBoolean("value"), is(z));
+
+ }
+
+ @Test
+ public void jdkPropertiesUpdated() throws Exception {
+
+ // big decimal
+ final BigDecimal bd = new BigDecimal("12345678901234567.789");
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "bigDecimalProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", bd);
+ assertThat(followedRepr(modifyLink,argRepr).getBigDecimal("value"), is(new BigDecimal("12345678901234567.7890000000"))); // big-decimal(30,10)
+
+ // big integer
+ final BigInteger bi = new BigInteger("123456789012345678");
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "bigIntegerProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", bi);
+ assertThat(followedRepr(modifyLink,argRepr).getBigInteger("value"), is(bi));
+
+ // java.sql.Date
+ final java.sql.Date sqld = new java.sql.Date(new DateTime(2014,5,1, 0,0, DateTimeZone.UTC).getMillis());
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlDateProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", asIsoNoT(sqld));
+ assertThat(followedRepr(modifyLink,argRepr).getDate("value"), is((java.util.Date)sqld));
+
+ // java.sql.Time
+ final java.sql.Time sqlt = new java.sql.Time(13,0,0);
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlTimeProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", asIsoOnlyT(sqlt));
+ assertThat(followedRepr(modifyLink,argRepr).getTime("value"), is((java.util.Date)sqlt));
+
+ // java.sql.Timestamp
+ final java.sql.Timestamp sqlts = new java.sql.Timestamp(114,4,1,13,0,0,0);
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaSqlTimestampProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", sqlts.getTime());
+ assertThat(followedRepr(modifyLink,argRepr).getLong("value"), is(sqlts.getTime()));
+
+ // java.util.Date
+ final java.util.Date d = new java.util.Date(114,4,1,13,0,0);
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "javaUtilDateProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", asIso(d));
+ assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(d));
+
+ // enum
+ final String e = "ORANGE";
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "myEnum");
+ argRepr = modifyLink.getArguments().mapPut("value", e);
+ assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(e));
+
+ // String
+ final String s = "Tangerine";
+ modifyLink = getObjectPropertyReprModifyLink("JDKV", "29", "stringProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", s);
+ assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(s));
+
+ }
+
+
+ @Ignore("breaking in CET")
+ @Test
+ public void jodaPropertiesUpdated() throws Exception {
+
+ // LocalDate
+ final LocalDate ld = new LocalDate(2013,5,1);
+ modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "localDateProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", "2013-05-01");
+ assertThat(followedRepr(modifyLink,argRepr).getString("value"), is("2013-05-01")); // hacky
+
+ // LocalDateTime
+ final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
+ modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "localDateTimeProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", asIso(ldt.toDate()));
+ assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(ldt.toDate()));
+
+ // DateTime
+ final DateTime dt = new DateTime(2013,2,1,14,15,0);
+ modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "dateTimeProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", asIso(dt.toDate()));
+ assertThat(followedRepr(modifyLink,argRepr).getDateTime("value"), is(dt.toDate()));
+
+ // String
+ final String s = "New string";
+ modifyLink = getObjectPropertyReprModifyLink("JODA", "73", "stringProperty");
+ argRepr = modifyLink.getArguments().mapPut("value", s);
+ assertThat(followedRepr(modifyLink,argRepr).getString("value"), is(s));
+ }
+
+ private ObjectPropertyRepresentation getObjectPropertyRepr(final String domainType, final String instanceId, String propertyId) throws JsonParseException, JsonMappingException, IOException {
+ final Response domainObjectResp = domainObjectResource.propertyDetails(domainType, instanceId, propertyId);
+ final RestfulResponse<ObjectPropertyRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
+ assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ final ObjectPropertyRepresentation repr = domainObjectJsonResp.getEntity();
+ return repr;
+ }
+
+ private LinkRepresentation getObjectPropertyReprModifyLink(String domainType, String instanceId, String propertyId) throws JsonParseException, JsonMappingException, IOException {
+ ObjectPropertyRepresentation objectPropertyRepr = getObjectPropertyRepr(domainType, instanceId, propertyId);
+ return objectPropertyRepr.getLinkWithRel(Rel.MODIFY);
+ }
+
+ private JsonRepresentation followedRepr(LinkRepresentation modifyLink, JsonRepresentation argRepr) throws Exception {
+ RestfulResponse<JsonRepresentation> result = client.follow(modifyLink, argRepr);
+ assertThat(result.getStatus(), is(HttpStatusCode.OK));
+ return result.getEntity().as(ObjectPropertyRepresentation.class);
+ }
+
+
+ private static String asIso(final java.util.Date d) {
+ final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
+ return asIso(dt);
+ }
+
+ private static String asIso(final org.joda.time.DateTime dt) {
+ return ISODateTimeFormat.basicDateTimeNoMillis().withZoneUTC().print(dt);
+ }
+
+
+ private static String asIsoNoT(final java.util.Date d) {
+ final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
+ return asIsoNoT(dt);
+ }
+
+ private static String asIsoNoT(final org.joda.time.DateTime dt) {
+ return ISODateTimeFormat.basicDate().withZoneUTC().print(dt);
+ }
+
+ private static String asIsoOnlyT(final java.util.Date d) {
+ final org.joda.time.DateTime dt = new org.joda.time.DateTime(d.getTime());
+ return asIsoOnlyT(dt);
+ }
+
+ private static String asIsoOnlyT(final org.joda.time.DateTime dt) {
+ return ISODateTimeFormat.basicTime().withZoneUTC().print(dt);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/core/applib/pom.xml
----------------------------------------------------------------------
diff --git a/core/applib/pom.xml b/core/applib/pom.xml
index e1a8171..c94741e 100644
--- a/core/applib/pom.xml
+++ b/core/applib/pom.xml
@@ -90,6 +90,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <optional>true</optional>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
index 53262e0..befb5e8 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
@@ -25,9 +25,13 @@ import org.apache.isis.applib.annotation.Hidden;
import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.Title;
+import org.apache.isis.applib.fixtures.FixtureType;
+import org.apache.isis.applib.fixtures.InstallableFixture;
@Named("Script")
-public abstract class FixtureScript extends AbstractViewModel {
+public abstract class FixtureScript
+ extends AbstractViewModel
+ implements InstallableFixture {
protected static final String PATH_SEPARATOR = "/";
@@ -176,16 +180,24 @@ public abstract class FixtureScript extends AbstractViewModel {
protected abstract void doRun(FixtureResultList fixtureResults);
// //////////////////////////////////////
+
+ @Override
+ public FixtureType getType() {
+ return FixtureType.DOMAIN_OBJECTS;
+ }
@Programmatic
- String pathWith(String subkey) {
- return (getQualifiedName() != null? getQualifiedName() + PATH_SEPARATOR: "") + subkey;
+ public final void install() {
+ run();
}
// //////////////////////////////////////
-
-
+ @Programmatic
+ String pathWith(String subkey) {
+ return (getQualifiedName() != null? getQualifiedName() + PATH_SEPARATOR: "") + subkey;
+ }
+
// //////////////////////////////////////
@javax.inject.Inject
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
index d8f6b0a..4dc983a 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
@@ -37,6 +37,7 @@ import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.annotation.Prototype;
import org.apache.isis.applib.services.bookmark.Bookmark;
import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.classdiscovery.ClassDiscoveryService;
import org.apache.isis.applib.services.memento.MementoService;
import org.apache.isis.applib.services.memento.MementoService.Memento;
import org.apache.isis.applib.util.ObjectContracts;
@@ -62,7 +63,7 @@ public abstract class FixtureScripts extends AbstractService {
}
private void findAndInstantiateFixtureScripts(List<FixtureScript> fixtureScriptList) {
- final Set<Class<? extends FixtureScript>> classes = findFixtureScriptClasses();
+ final Set<Class<? extends FixtureScript>> classes = classDiscoveryService.findSubTypesOfClasses(FixtureScript.class);
for (final Class<? extends FixtureScript> fixtureScriptCls : classes) {
final String packageName = fixtureScriptCls.getPackage().getName();
if(!packageName.startsWith(packagePrefix)) {
@@ -81,14 +82,6 @@ public abstract class FixtureScripts extends AbstractService {
});
}
- private static Set<Class<? extends FixtureScript>> findFixtureScriptClasses() {
- final Reflections reflections = new Reflections(
- ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()),
- ClasspathHelper.forClass(Object.class),
- new SubTypesScanner(false));
- return reflections.getSubTypesOf(FixtureScript.class);
- }
-
private FixtureScript newFixtureScript(Class<? extends FixtureScript> fixtureScriptCls) {
try {
final Constructor<? extends FixtureScript> constructor = fixtureScriptCls.getConstructor();
@@ -164,4 +157,8 @@ public abstract class FixtureScripts extends AbstractService {
@javax.inject.Inject
private DomainObjectContainer container;
+
+ @javax.inject.Inject
+ private ClassDiscoveryService classDiscoveryService;
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryService.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryService.java b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryService.java
new file mode 100644
index 0000000..0f32664
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryService.java
@@ -0,0 +1,30 @@
+/*
+ * 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.applib.services.classdiscovery;
+
+import java.util.Set;
+
+import org.apache.isis.applib.annotation.Programmatic;
+
+public interface ClassDiscoveryService {
+
+ @Programmatic
+ public <T> Set<Class<? extends T>> findSubTypesOfClasses(Class<T> type);
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
new file mode 100644
index 0000000..f88bf2c
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/classdiscovery/ClassDiscoveryServiceUsingReflections.java
@@ -0,0 +1,42 @@
+/*
+ * 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.applib.services.classdiscovery;
+
+import java.util.Set;
+
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+
+import org.apache.isis.applib.AbstractService;
+
+public class ClassDiscoveryServiceUsingReflections
+ extends AbstractService
+ implements ClassDiscoveryService {
+
+ @Override
+ public <T> Set<Class<? extends T>> findSubTypesOfClasses(Class<T> type) {
+ final Reflections reflections = new Reflections(
+ ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()),
+ ClasspathHelper.forClass(Object.class),
+ new SubTypesScanner(false));
+ return reflections.getSubTypesOf(type);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.layout.json
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.layout.json b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.layout.json
index 81cdea3..4db6560 100644
--- a/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.layout.json
+++ b/example/application/quickstart_wicket_restful_jdo/dom/src/main/java/dom/todo/ToDoItem.layout.json
@@ -54,12 +54,12 @@
},
cssClass: { value: "x-highlight" }
},
+ notYetCompleted: {
+ named: { value: "Not done" }
+ },
scheduleExplicitly: {
},
scheduleImplicitly: {
- },
- notYetCompleted: {
- named: { value: "Not done" }
}
},
describedAs: {
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsCreateForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsCreateForUser.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsCreateForUser.java
new file mode 100644
index 0000000..33c7ada
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsCreateForUser.java
@@ -0,0 +1,105 @@
+/*
+ * 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 fixture.todo;
+
+import java.math.BigDecimal;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItem.Category;
+import dom.todo.ToDoItem.Subcategory;
+import dom.todo.ToDoItems;
+
+import org.joda.time.LocalDate;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.fixturescripts.FixtureResultList;
+import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
+
+public class ToDoItemsCreateForUser extends SimpleFixtureScript {
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private final String user;
+
+ public ToDoItemsCreateForUser(String user) {
+ super(friendlyNameFor(user), localNameFor(user));
+ this.user = user;
+ }
+
+ static String localNameFor(String user) {
+ return user != null? user: "current";
+ }
+
+ static String friendlyNameFor(String user) {
+ return "Create ToDoItems for " + (user != null ? "'" + user + "'" : "current user");
+ }
+
+ @Override
+ protected void doRun(final FixtureResultList resultList) {
+ final String ownedBy = user != null? user: getContainer().getUser().getName();
+ installFor(ownedBy, resultList);
+ getContainer().flush();
+ }
+
+ private void installFor(final String user, final FixtureResultList resultList) {
+
+ createToDoItemForUser("Buy milk", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("0.75"), resultList);
+ createToDoItemForUser("Buy bread", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("1.75"), resultList);
+ createToDoItemForUser("Buy stamps", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("10.00"), resultList).setComplete(true);
+ createToDoItemForUser("Pick up laundry", Category.Domestic, Subcategory.Chores, user, daysFromToday(6), new BigDecimal("7.50"), resultList);
+ createToDoItemForUser("Mow lawn", Category.Domestic, Subcategory.Garden, user, daysFromToday(6), null, resultList);
+ createToDoItemForUser("Vacuum house", Category.Domestic, Subcategory.Housework, user, daysFromToday(3), null, resultList);
+ createToDoItemForUser("Sharpen knives", Category.Domestic, Subcategory.Chores, user, daysFromToday(14), null, resultList);
+
+ createToDoItemForUser("Write to penpal", Category.Other, Subcategory.Other, user, null, null, resultList);
+
+ createToDoItemForUser("Write blog post", Category.Professional, Subcategory.Marketing, user, daysFromToday(7), null, resultList).setComplete(true);
+ createToDoItemForUser("Organize brown bag", Category.Professional, Subcategory.Consulting, user, daysFromToday(14), null, resultList);
+ createToDoItemForUser("Submit conference session", Category.Professional, Subcategory.Education, user, daysFromToday(21), null, resultList);
+ createToDoItemForUser("Stage Isis release", Category.Professional, Subcategory.OpenSource, user, null, null, resultList);
+
+ getContainer().flush();
+ }
+
+ // //////////////////////////////////////
+
+ private ToDoItem createToDoItemForUser(
+ final String description,
+ final Category category, Subcategory subcategory,
+ final String user,
+ final LocalDate dueBy, final BigDecimal cost, FixtureResultList resultList) {
+ ToDoItem newToDo = toDoItems.newToDo(description, category, subcategory, user, dueBy, cost);
+ return resultList.add(this, newToDo);
+ }
+
+ private static LocalDate daysFromToday(final int i) {
+ final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
+ return date.plusDays(i);
+ }
+
+
+ // //////////////////////////////////////
+ // Injected services
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ private ToDoItems toDoItems;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsDeleteForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsDeleteForUser.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsDeleteForUser.java
new file mode 100644
index 0000000..ed3b242
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsDeleteForUser.java
@@ -0,0 +1,60 @@
+/*
+ * 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 fixture.todo;
+
+import org.apache.isis.applib.fixturescripts.FixtureResultList;
+import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
+import org.apache.isis.objectstore.jdo.applib.service.support.IsisJdoSupport;
+
+public class ToDoItemsDeleteForUser extends SimpleFixtureScript {
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private final String user;
+
+ public ToDoItemsDeleteForUser(final String user) {
+ super(friendlyNameFor(user), localNameFor(user));
+ this.user = user;
+ }
+
+ static String localNameFor(final String user) {
+ return user != null? user: "current";
+ }
+
+ static String friendlyNameFor(final String user) {
+ return "Delete ToDoItems for " + (user != null ? "'" + user + "'" : "current user");
+ }
+
+ @Override
+ protected void doRun(final FixtureResultList resultList) {
+ final String ownedBy = user != null? user: getContainer().getUser().getName();
+ isisJdoSupport.executeUpdate("delete from \"ToDoItem\" where \"ownedBy\" = '" + ownedBy + "'");
+ getContainer().flush();
+ }
+
+ // //////////////////////////////////////
+ // Injected services
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ private IsisJdoSupport isisJdoSupport;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
index 10f12f3..ece3726 100644
--- a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixture.java
@@ -19,84 +19,15 @@
package fixture.todo;
-import java.math.BigDecimal;
-import dom.todo.ToDoItem;
-import dom.todo.ToDoItem.Category;
-import dom.todo.ToDoItem.Subcategory;
-import dom.todo.ToDoItems;
-
-import org.joda.time.LocalDate;
-
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.fixtures.AbstractFixture;
-import org.apache.isis.objectstore.jdo.applib.service.support.IsisJdoSupport;
-
-public class ToDoItemsFixture extends AbstractFixture {
-
- private final String user;
+public class ToDoItemsFixture extends ToDoItemsResetForUser {
public ToDoItemsFixture() {
this(null);
}
- public ToDoItemsFixture(String ownedBy) {
- this.user = ownedBy;
- }
-
- @Override
- public void install() {
-
- final String ownedBy = this.user != null? this.user : getContainer().getUser().getName();
-
- isisJdoSupport.executeUpdate("delete from \"ToDoItem\" where \"ownedBy\" = '" + ownedBy + "'");
-
- installFor(ownedBy);
-
- getContainer().flush();
- }
-
- private void installFor(String user) {
-
- createToDoItemForUser("Buy milk", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("0.75"));
- createToDoItemForUser("Buy bread", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("1.75"));
- createToDoItemForUser("Buy stamps", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("10.00")).setComplete(true);
- createToDoItemForUser("Pick up laundry", Category.Domestic, Subcategory.Chores, user, daysFromToday(6), new BigDecimal("7.50"));
- createToDoItemForUser("Mow lawn", Category.Domestic, Subcategory.Garden, user, daysFromToday(6), null);
- createToDoItemForUser("Vacuum house", Category.Domestic, Subcategory.Housework, user, daysFromToday(3), null);
- createToDoItemForUser("Sharpen knives", Category.Domestic, Subcategory.Chores, user, daysFromToday(14), null);
-
- createToDoItemForUser("Write to penpal", Category.Other, Subcategory.Other, user, null, null);
-
- createToDoItemForUser("Write blog post", Category.Professional, Subcategory.Marketing, user, daysFromToday(7), null).setComplete(true);
- createToDoItemForUser("Organize brown bag", Category.Professional, Subcategory.Consulting, user, daysFromToday(14), null);
- createToDoItemForUser("Submit conference session", Category.Professional, Subcategory.Education, user, daysFromToday(21), null);
- createToDoItemForUser("Stage Isis release", Category.Professional, Subcategory.OpenSource, user, null, null);
-
- getContainer().flush();
- }
-
-
- // //////////////////////////////////////
-
- private ToDoItem createToDoItemForUser(final String description, final Category category, Subcategory subcategory, String user, final LocalDate dueBy, final BigDecimal cost) {
- return toDoItems.newToDo(description, category, subcategory, user, dueBy, cost);
+ public ToDoItemsFixture(String user) {
+ super(user);
}
- private static LocalDate daysFromToday(final int i) {
- final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
- return date.plusDays(i);
- }
-
-
- // //////////////////////////////////////
- // Injected services
- // //////////////////////////////////////
-
- @javax.inject.Inject
- private ToDoItems toDoItems;
-
- @javax.inject.Inject
- private IsisJdoSupport isisJdoSupport;
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixturesService.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixturesService.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixturesService.java
new file mode 100644
index 0000000..76d7d63
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsFixturesService.java
@@ -0,0 +1,34 @@
+/*
+ * 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 fixture.todo;
+
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
+
+/**
+ * Enables fixtures to be installed from the application.
+ */
+@Named("Prototyping") // has the effect of defining a "Prototyping" menu item
+public class ToDoItemsFixturesService extends FixtureScripts {
+
+ public ToDoItemsFixturesService() {
+ super("fixture.todo");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsResetForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsResetForUser.java b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsResetForUser.java
new file mode 100644
index 0000000..49793a3
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/fixture/src/main/java/fixture/todo/ToDoItemsResetForUser.java
@@ -0,0 +1,75 @@
+/*
+ * 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 fixture.todo;
+
+import org.apache.isis.applib.fixturescripts.CompositeFixtureScript;
+
+public class ToDoItemsResetForUser extends CompositeFixtureScript {
+
+ // //////////////////////////////////////
+ // Subclasses
+ // //////////////////////////////////////
+
+ public static final class ToDoItemResetForDick extends ToDoItemsResetForUser {
+ public ToDoItemResetForDick() {
+ super("dick");
+ }
+ }
+
+ public static final class ToDoItemResetForJoe extends ToDoItemsResetForUser {
+ public ToDoItemResetForJoe() {
+ super("joe");
+ }
+ }
+
+ public static final class ToDoItemResetForSven extends ToDoItemsResetForUser {
+ public ToDoItemResetForSven() {
+ super("sven");
+ }
+ }
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private String user;
+
+ public ToDoItemsResetForUser() {
+ this(null);
+ }
+
+ public ToDoItemsResetForUser(String user) {
+ super(friendlyNameFor(localNameFor(user)), localNameFor(user));
+ this.user = user;
+ }
+
+ static String localNameFor(String user) {
+ return user != null? user: "current";
+ }
+
+ static String friendlyNameFor(String user) {
+ return "Reset ToDoItems for " + (user != null ? "'" + user + "'" : "current user");
+ }
+
+ @Override
+ protected void addChildren() {
+ add("delete", new ToDoItemsDeleteForUser(user));
+ add("create", new ToDoItemsCreateForUser(user));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
index 66f90b5..7fbd36c 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/ToDoSystemInitializer.java
@@ -19,11 +19,15 @@ package integration;
import app.ToDoItemAnalysis;
import dom.todo.ToDoItemContributions;
import dom.todo.ToDoItems;
+import fixture.todo.ToDoItemsFixturesService;
import org.apache.isis.applib.annotation.Bulk;
+import org.apache.isis.applib.services.classdiscovery.ClassDiscoveryServiceUsingReflections;
import org.apache.isis.applib.services.queryresultscache.QueryResultsCache;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.integtestsupport.IsisSystemForTest;
+import org.apache.isis.core.metamodel.services.bookmarks.BookmarkServiceDefault;
+import org.apache.isis.core.runtime.services.memento.MementoServiceDefault;
import org.apache.isis.core.wrapper.WrapperFactoryDefault;
import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;
@@ -59,11 +63,15 @@ public class ToDoSystemInitializer {
new ToDoItems(),
new ToDoItemAnalysis(),
new ToDoItemContributions(),
+ new ToDoItemsFixturesService(),
+ new ClassDiscoveryServiceUsingReflections(),
new WrapperFactoryDefault(),
new IsisJdoSupportImpl(),
new Bulk.InteractionContext(),
new EventBusServiceJdo(),
- new QueryResultsCache()
+ new QueryResultsCache(),
+ new MementoServiceDefault(),
+ new BookmarkServiceDefault()
);
}
@@ -72,7 +80,5 @@ public class ToDoSystemInitializer {
testConfiguration.addRegisterEntitiesPackagePrefix("dom");
return testConfiguration;
}
-
}
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/glue/CatalogOfFixturesGlue.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/glue/CatalogOfFixturesGlue.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/glue/CatalogOfFixturesGlue.java
index 9115a71..af0d92d 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/glue/CatalogOfFixturesGlue.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integration/glue/CatalogOfFixturesGlue.java
@@ -18,6 +18,7 @@ package integration.glue;
import cucumber.api.java.Before;
import dom.todo.ToDoItem;
+import fixture.todo.ToDoItemsResetForUser;
import fixture.todo.ToDoItemsFixture;
import org.apache.isis.core.specsupport.scenarios.InMemoryDB;
@@ -40,7 +41,7 @@ public class CatalogOfFixturesGlue extends CukeGlueAbstract {
@Before(value={"@integration", "@ToDoItemsFixture"}, order=20000)
public void integrationFixtures() throws Throwable {
- scenarioExecution().install(new ToDoItemsFixture());
+ scenarioExecution().install(new ToDoItemsResetForUser());
}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/DeveloperUtilities.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/DeveloperUtilities.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/DeveloperUtilities.java
index 19b342d..e1e8792 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/DeveloperUtilities.java
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/DeveloperUtilities.java
@@ -16,6 +16,8 @@
*/
package webapp.prototyping;
+import fixture.todo.ToDoItemsFixturesService;
+
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.value.Blob;
import org.apache.isis.applib.value.Clob;
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
deleted file mode 100644
index 2586c17..0000000
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 webapp.prototyping;
-
-import org.apache.isis.applib.fixturescripts.CompositeFixtureScript;
-
-public abstract class ToDoItemResetForUser extends CompositeFixtureScript {
-
- // //////////////////////////////////////
- // Subclasses
- // //////////////////////////////////////
-
- public static final class ToDoItemResetForDick extends ToDoItemResetForUser {
- public ToDoItemResetForDick() {
- super("dick");
- }
- }
-
- public static final class ToDoItemResetForJoe extends ToDoItemResetForUser {
- public ToDoItemResetForJoe() {
- super("joe");
- }
- }
-
- public static final class ToDoItemResetForSven extends ToDoItemResetForUser {
- public ToDoItemResetForSven() {
- super("sven");
- }
- }
-
- // //////////////////////////////////////
- // Constructor
- // //////////////////////////////////////
-
- private String user;
-
- public ToDoItemResetForUser(String user) {
- super("Reset ToDoItems for '" + user + "'", user);
- this.user = user;
- }
-
- @Override
- protected void addChildren() {
- add("delete", new ToDoItemsDeleteForUser(user));
- add("create", new ToDoItemsCreateForUser(user));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
deleted file mode 100644
index b70e5b0..0000000
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 webapp.prototyping;
-
-import java.math.BigDecimal;
-
-import dom.todo.ToDoItem;
-import dom.todo.ToDoItem.Category;
-import dom.todo.ToDoItem.Subcategory;
-import dom.todo.ToDoItems;
-
-import org.joda.time.LocalDate;
-
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.fixturescripts.FixtureResultList;
-import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
-
-public class ToDoItemsCreateForUser extends SimpleFixtureScript {
-
- // //////////////////////////////////////
- // Constructor
- // //////////////////////////////////////
-
- private final String user;
-
- public ToDoItemsCreateForUser(String user) {
- super("Create ToDoItems for '" + user + "'", user);
- this.user = user;
- }
-
- @Override
- protected void doRun(final FixtureResultList resultList) {
- installFor(user, resultList);
- getContainer().flush();
- }
-
- private void installFor(final String user, final FixtureResultList resultList) {
-
- createToDoItemForUser("Buy milk", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("0.75"), resultList);
- createToDoItemForUser("Buy bread", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("1.75"), resultList);
- createToDoItemForUser("Buy stamps", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("10.00"), resultList).setComplete(true);
- createToDoItemForUser("Pick up laundry", Category.Domestic, Subcategory.Chores, user, daysFromToday(6), new BigDecimal("7.50"), resultList);
- createToDoItemForUser("Mow lawn", Category.Domestic, Subcategory.Garden, user, daysFromToday(6), null, resultList);
- createToDoItemForUser("Vacuum house", Category.Domestic, Subcategory.Housework, user, daysFromToday(3), null, resultList);
- createToDoItemForUser("Sharpen knives", Category.Domestic, Subcategory.Chores, user, daysFromToday(14), null, resultList);
-
- createToDoItemForUser("Write to penpal", Category.Other, Subcategory.Other, user, null, null, resultList);
-
- createToDoItemForUser("Write blog post", Category.Professional, Subcategory.Marketing, user, daysFromToday(7), null, resultList).setComplete(true);
- createToDoItemForUser("Organize brown bag", Category.Professional, Subcategory.Consulting, user, daysFromToday(14), null, resultList);
- createToDoItemForUser("Submit conference session", Category.Professional, Subcategory.Education, user, daysFromToday(21), null, resultList);
- createToDoItemForUser("Stage Isis release", Category.Professional, Subcategory.OpenSource, user, null, null, resultList);
-
- getContainer().flush();
- }
-
- // //////////////////////////////////////
-
- private ToDoItem createToDoItemForUser(
- final String description,
- final Category category, Subcategory subcategory,
- final String user,
- final LocalDate dueBy, final BigDecimal cost, FixtureResultList resultList) {
- ToDoItem newToDo = toDoItems.newToDo(description, category, subcategory, user, dueBy, cost);
- return resultList.add(this, newToDo);
- }
-
- private static LocalDate daysFromToday(final int i) {
- final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
- return date.plusDays(i);
- }
-
-
- // //////////////////////////////////////
- // Injected services
- // //////////////////////////////////////
-
- @javax.inject.Inject
- private ToDoItems toDoItems;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
deleted file mode 100644
index 81f0b65..0000000
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 webapp.prototyping;
-
-import org.apache.isis.applib.fixturescripts.FixtureResultList;
-import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
-import org.apache.isis.objectstore.jdo.applib.service.support.IsisJdoSupport;
-
-public class ToDoItemsDeleteForUser extends SimpleFixtureScript {
-
- // //////////////////////////////////////
- // Constructor
- // //////////////////////////////////////
-
- private final String user;
-
- public ToDoItemsDeleteForUser(String user) {
- super("Delete ToDoItems for '" + user + "'", user);
- this.user = user;
- }
-
- @Override
- protected void doRun(final FixtureResultList resultList) {
- isisJdoSupport.executeUpdate("delete from \"ToDoItem\" where \"ownedBy\" = '" + user + "'");
- getContainer().flush();
- }
-
- // //////////////////////////////////////
- // Injected services
- // //////////////////////////////////////
-
- @javax.inject.Inject
- private IsisJdoSupport isisJdoSupport;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
deleted file mode 100644
index 2eebaab..0000000
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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 webapp.prototyping;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import dom.todo.ToDoItem;
-import dom.todo.ToDoItems;
-import fixture.todo.ToDoItemsFixture;
-
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.annotation.Prototype;
-import org.apache.isis.applib.fixturescripts.FixtureScripts;
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
-
-/**
- * Enables fixtures to be installed from the application.
- */
-@Named("Prototyping") // has the effect of defining a "Prototyping" menu item
-public class ToDoItemsFixturesService extends FixtureScripts {
-
- public ToDoItemsFixturesService() {
- super("webapp.prototyping");
- }
-
- @Hidden
- @Prototype
- public String installFixtures() {
- installFixturesFor(null); // ie current user
- return "Example fixtures installed";
- }
-
- // //////////////////////////////////////
-
- @Hidden
- @Prototype
- public String installFixturesForUser(@Named("User") String user) {
- installFixturesFor(user);
- return "Example fixtures installed for " + user;
- }
- public String default0InstallFixturesForUser() {
- return "guest";
- }
- public List<String> choices0InstallFixturesForUser() {
- return Lists.newArrayList("guest", "sven", "dick", "bob", "joe");
- }
-
- // //////////////////////////////////////
-
- @Hidden
- @Prototype
- public ToDoItem installFixturesAndReturnFirst() {
- installFixtures();
- List<ToDoItem> notYetComplete = toDoItems.notYetComplete();
- return !notYetComplete.isEmpty() ? notYetComplete.get(0) : null;
- }
-
- // //////////////////////////////////////
-
- private static void installFixturesFor(String user) {
- final FixturesInstallerDelegate installer = new FixturesInstallerDelegate().withOverride();
- installer.addFixture(new ToDoItemsFixture(user));
- installer.installFixtures();
- }
-
- // //////////////////////////////////////
-
- private ToDoItems toDoItems;
- public void injectToDoItems(ToDoItems toDoItems) {
- this.toDoItems = toDoItems;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/55c4ea85/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
index 87f1857..a6f1e96 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/webapp/WEB-INF/isis.properties
@@ -163,7 +163,7 @@ isis.services = \
30:webapp.admin.Admin,\
30:webapp.admin.AdminContributions,\
\
- 40:webapp.prototyping.ToDoItemsFixturesService,\
+ 40:fixture.todo.ToDoItemsFixturesService,\
40:webapp.prototyping.DeveloperUtilities,\
40:webapp.prototyping.ExternalLinksService,\
\
@@ -189,6 +189,7 @@ isis.services = \
org.apache.isis.applib.annotation.Bulk$InteractionContext,\
org.apache.isis.applib.services.scratchpad.Scratchpad,\
org.apache.isis.applib.services.queryresultscache.QueryResultsCache,\
+ org.apache.isis.applib.services.classdiscovery.ClassDiscoveryServiceUsingReflections,\
\
# JDO implementation of the EventBusService, \
org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo,\
[2/3] git commit: ISIS-776: initial implementation
Posted by da...@apache.org.
ISIS-776: initial implementation
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/98758f7c
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/98758f7c
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/98758f7c
Branch: refs/heads/master
Commit: 98758f7c65479a56c685a3b494ca20257ec82d5e
Parents: 31acb0f
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri May 9 15:26:07 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Fri May 9 15:29:49 2014 +0100
----------------------------------------------------------------------
.../components/widgets/cssmenu/CssMenuPanel.css | 2 +-
.../viewer/wicket/ui/pages/PageAbstract.css | 2 +-
.../isis/applib/DomainObjectContainer.java | 6 +
.../fixturescripts/CompositeFixtureScript.java | 90 +++++++++
.../applib/fixturescripts/FixtureResult.java | 68 +++++++
.../fixturescripts/FixtureResultList.java | 72 +++++++
.../applib/fixturescripts/FixtureScript.java | 196 +++++++++++++++++++
.../applib/fixturescripts/FixtureScripts.java | 167 ++++++++++++++++
.../fixturescripts/SimpleFixtureScript.java | 56 ++++++
.../metamodel/adapter/DomainObjectServices.java | 2 +
.../noruntime/RuntimeContextNoRuntime.java | 5 +
.../container/DomainObjectContainerDefault.java | 11 ++
.../internal/RuntimeContextFromSession.java | 5 +
.../prototyping/ToDoItemResetForUser.java | 64 ++++++
.../prototyping/ToDoItemsCreateForUser.java | 96 +++++++++
.../prototyping/ToDoItemsDeleteForUser.java | 51 +++++
.../prototyping/ToDoItemsFixturesService.java | 14 +-
17 files changed, 902 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuPanel.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuPanel.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuPanel.css
index 74df67a..89991d0 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuPanel.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/widgets/cssmenu/CssMenuPanel.css
@@ -318,7 +318,7 @@
}
.entityActions a.prototype span {
- color: #CCCC00;
+ color: #DBDB4D;
font-style: italic;
}
.entityActions a.prototype {
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
index dc580e7..a6557f6 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.css
@@ -286,7 +286,7 @@ colors
}
#applicationActions .cssMenuPanel .menuh a.prototype span {
- color: #CCCC00;
+ color: #DBDB4D;
font-style: italic;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
index edabe32..170e86d 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/DomainObjectContainer.java
@@ -210,6 +210,12 @@ public interface DomainObjectContainer {
<T> T newInstance(final Class<T> ofType, final Object object);
// ////////////////////////////////////////////////////////////////
+ // injectServicesInto
+ // ////////////////////////////////////////////////////////////////
+
+ <T> T injectServicesInto(final T domainObject);
+
+ // ////////////////////////////////////////////////////////////////
// isValid, validate
// ////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/CompositeFixtureScript.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/CompositeFixtureScript.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/CompositeFixtureScript.java
new file mode 100644
index 0000000..aec034a
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/CompositeFixtureScript.java
@@ -0,0 +1,90 @@
+/*
+ * 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.applib.fixturescripts;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.applib.annotation.Named;
+
+@Named("Composite Script")
+public abstract class CompositeFixtureScript extends FixtureScript {
+
+ private static Discoverability defaultDiscoverability() {
+ return Discoverability.DISCOVERABLE;
+ }
+
+ public CompositeFixtureScript(final String localName) {
+ this(localName, localName, defaultDiscoverability());
+ }
+ public CompositeFixtureScript(String friendlyName, final String localName) {
+ this(friendlyName, localName, defaultDiscoverability());
+ }
+ public CompositeFixtureScript(final FixtureScript parent, String friendlyName, final String localName) {
+ this(parent, friendlyName, localName, defaultDiscoverability());
+ }
+
+ public CompositeFixtureScript(final String localName, Discoverability discoverability) {
+ super(localName, localName, discoverability);
+ }
+ public CompositeFixtureScript(String friendlyName, final String localName, Discoverability discoverability) {
+ super(friendlyName, localName, discoverability);
+ }
+ public CompositeFixtureScript(final FixtureScript parent, String friendlyName, final String localName, Discoverability discoverability) {
+ super(parent, friendlyName, localName, discoverability);
+ }
+
+ // //////////////////////////////////////
+
+ private final List<FixtureScript> children = Lists.newArrayList();
+ /**
+ * Adds a child {@link FixtureScript fixture script} (simply using its default name).
+ */
+ protected final void add(FixtureScript fixtureScript) {
+ add(null, fixtureScript);
+ }
+ /**
+ * Adds a child {@link FixtureScript fixture script}, overriding its default name with one more
+ * meaningful in the context of this fixture.
+ */
+ protected final void add(String localNameOverride, FixtureScript fixtureScript) {
+ fixtureScript.setParentPath(pathWith(""));
+ if(localNameOverride != null) {
+ fixtureScript.setLocalName(localNameOverride);
+ }
+ getContainer().injectServicesInto(fixtureScript);
+ children.add(fixtureScript);
+ }
+
+ // //////////////////////////////////////
+
+ /**
+ * Mandatory hook method.
+ */
+ protected abstract void addChildren();
+
+ protected void doRun(FixtureResultList fixtureResults) {
+ addChildren();
+ for (final FixtureScript child : children) {
+ child.doRun(fixtureResults);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
new file mode 100644
index 0000000..095327f
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResult.java
@@ -0,0 +1,68 @@
+/*
+ * 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.applib.fixturescripts;
+
+import org.apache.isis.applib.AbstractViewModel;
+import org.apache.isis.applib.annotation.MemberOrder;
+import org.apache.isis.applib.annotation.Title;
+
+public class FixtureResult extends AbstractViewModel {
+
+ @Override
+ public String viewModelMemento() {
+ return fixtureScripts.mementoFor(this);
+ }
+
+ @Override
+ public void viewModelInit(String memento) {
+ fixtureScripts.initOf(memento, this);
+ }
+
+ // //////////////////////////////////////
+
+ private String key;
+
+ @Title(sequence="1", append=": ")
+ @MemberOrder(sequence="1")
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ // //////////////////////////////////////
+
+ private Object object;
+
+ @Title(sequence="2")
+ @MemberOrder(sequence="1")
+ public Object getObject() {
+ return object;
+ }
+ public void setObject(Object object) {
+ this.object = object;
+ }
+
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ FixtureScripts fixtureScripts;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResultList.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResultList.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResultList.java
new file mode 100644
index 0000000..7527675
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureResultList.java
@@ -0,0 +1,72 @@
+/*
+ * 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.applib.fixturescripts;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * Collecting parameter.
+ */
+public class FixtureResultList {
+
+ private final FixtureScripts fixtureScripts;
+
+ FixtureResultList(FixtureScripts fixtureScripts) {
+ this.fixtureScripts = fixtureScripts;
+ }
+
+ // //////////////////////////////////////
+
+
+ private final List<FixtureResult> list = Lists.newArrayList();
+
+ public <T> T add(final FixtureScript script, final T object) {
+ return add(script, nextItemFor(script), object);
+ }
+
+ public <T> T add(final FixtureScript script, final String key, final T object) {
+ final FixtureResult fr = fixtureScripts.newFixtureResult(script, key, object);
+ list.add(fr);
+ return object;
+ }
+
+ public List<FixtureResult> getResults() {
+ return list;
+ }
+
+ // //////////////////////////////////////
+
+ private final Map<FixtureScript, AtomicInteger> itemNumberByScript = Maps.newHashMap();
+
+ String nextItemFor(final FixtureScript script) {
+ AtomicInteger atomicInteger = itemNumberByScript.get(script);
+ if(atomicInteger == null) {
+ atomicInteger = new AtomicInteger();
+ itemNumberByScript.put(script, atomicInteger);
+ }
+ return "item-"+atomicInteger.incrementAndGet();
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
new file mode 100644
index 0000000..53262e0
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
@@ -0,0 +1,196 @@
+/*
+ * 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.applib.fixturescripts;
+
+import java.util.List;
+
+import org.apache.isis.applib.AbstractViewModel;
+import org.apache.isis.applib.annotation.Hidden;
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.Programmatic;
+import org.apache.isis.applib.annotation.Title;
+
+@Named("Script")
+public abstract class FixtureScript extends AbstractViewModel {
+
+ protected static final String PATH_SEPARATOR = "/";
+
+ // //////////////////////////////////////
+
+ /**
+ * Whether this fixture script should be automatically discoverable or not.
+ */
+ public enum Discoverability {
+ /**
+ * the fixture script is discoverable and so will be listed by the
+ * {@link FixtureScripts#runFixtureScript(FixtureScript) run fixture script} action
+ */
+ DISCOVERABLE,
+ /**
+ * The fixture script is non-discoverable and so will <i>not</i> be listed by the
+ * {@link FixtureScripts#runFixtureScript(FixtureScript) run fixture script} action
+ */
+ NON_DISCOVERABLE
+ }
+
+ // //////////////////////////////////////
+
+ public FixtureScript(
+ final String friendlyName,
+ final String localName,
+ final Discoverability discoverability) {
+ this(null, friendlyName, localName, discoverability);
+ }
+ public FixtureScript(
+ final FixtureScript parent,
+ final String friendlyName,
+ final String localName,
+ final Discoverability discoverability) {
+ this.localName = ensureNotNull("localName", localName);
+ this.friendlyName = ensureNotNull("friendlyName", friendlyName);
+ this.parentPath = parentPathOf(parent);
+ this.discoverability = discoverability;
+ }
+
+ private static String parentPathOf(FixtureScript parent) {
+ return parent != null? parent.getParentPath() + PATH_SEPARATOR : "";
+ }
+
+ // for subclasses
+ protected static String ensureNotNull(String name, String val) {
+ if(val == null) {
+ throw new IllegalArgumentException(name + " cannot be null");
+ }
+ return val;
+ }
+
+ // //////////////////////////////////////
+
+ @Override
+ public String viewModelMemento() {
+ return fixtureScripts.mementoFor(this);
+ }
+
+ @Override
+ public void viewModelInit(String mementoStr) {
+ fixtureScripts.initOf(mementoStr, this);
+ }
+
+ // //////////////////////////////////////
+
+ @Hidden
+ public String getQualifiedName() {
+ return getParentPath() + getLocalName();
+ }
+
+ // //////////////////////////////////////
+
+ private String friendlyName;
+
+ @Title
+ @Hidden
+ public String getFriendlyName() {
+ return friendlyName;
+ }
+ public void setFriendlyName(String friendlyName) {
+ this.friendlyName = friendlyName;
+ }
+
+ // //////////////////////////////////////
+
+ private String localName;
+ /**
+ * Will always be populated, initially by the default name, but can be
+ * {@link #setLocalName(String) overridden} if {@link CompositeFixtureScript#add(String, FixtureScript) reused} within a {@link CompositeFixtureScript composite fixture script}.
+ */
+ @Hidden
+ public String getLocalName() {
+ return localName;
+ }
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+ // //////////////////////////////////////
+
+ private String parentPath;
+
+ /**
+ * Path of the parent of this script (if any), with trailing period.
+ */
+ @Hidden
+ public String getParentPath() {
+ return parentPath;
+ }
+ public void setParentPath(String parentPath) {
+ this.parentPath = parentPath;
+ }
+
+ // //////////////////////////////////////
+
+ private Discoverability discoverability;
+
+ /**
+ * Whether this fixture script is {@link Discoverability discoverable} (in other words
+ * whether it will be listed to be run in the {@link FixtureScripts#runFixtureScript(FixtureScript) run fixture script} action.
+ *
+ * <p>
+ * By default {@link CompositeFixtureScript}s are {@link Discoverability#DISCOVERABLE discoverable}, while
+ * {@link SimpleFixtureScript}s are {@link Discoverability#NON_DISCOVERABLE not}. This can be overridden in the
+ * constructor, however.
+ */
+ @Hidden
+ public boolean isDiscoverable() {
+ return discoverability == Discoverability.DISCOVERABLE;
+ }
+ public void setDiscoverability(Discoverability discoverability) {
+ this.discoverability = discoverability;
+ }
+
+ // //////////////////////////////////////
+
+ @Programmatic
+ public final List<FixtureResult> run() {
+ FixtureResultList fixtureResults = new FixtureResultList(fixtureScripts);
+ doRun(fixtureResults);
+ return fixtureResults.getResults();
+ }
+
+ @Programmatic
+ protected abstract void doRun(FixtureResultList fixtureResults);
+
+ // //////////////////////////////////////
+
+ @Programmatic
+ String pathWith(String subkey) {
+ return (getQualifiedName() != null? getQualifiedName() + PATH_SEPARATOR: "") + subkey;
+ }
+
+ // //////////////////////////////////////
+
+
+
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ protected FixtureScripts fixtureScripts;
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
new file mode 100644
index 0000000..d8f6b0a
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScripts.java
@@ -0,0 +1,167 @@
+/*
+ * 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.applib.fixturescripts;
+
+import java.lang.reflect.Constructor;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.PostConstruct;
+
+import com.google.common.collect.Lists;
+
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+
+import org.apache.isis.applib.AbstractService;
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.annotation.Prototype;
+import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.services.memento.MementoService;
+import org.apache.isis.applib.services.memento.MementoService.Memento;
+import org.apache.isis.applib.util.ObjectContracts;
+
+public abstract class FixtureScripts extends AbstractService {
+
+ private final String packagePrefix;
+
+ /**
+ * @param packagePrefix - to search for fixture script implementations, eg "com.mycompany"
+ */
+ public FixtureScripts(String packagePrefix) {
+ this.packagePrefix = packagePrefix;
+ }
+
+ // //////////////////////////////////////
+
+ private final List<FixtureScript> fixtureScriptList = Lists.newArrayList();
+
+ @PostConstruct
+ public void init() {
+ findAndInstantiateFixtureScripts(fixtureScriptList);
+ }
+
+ private void findAndInstantiateFixtureScripts(List<FixtureScript> fixtureScriptList) {
+ final Set<Class<? extends FixtureScript>> classes = findFixtureScriptClasses();
+ for (final Class<? extends FixtureScript> fixtureScriptCls : classes) {
+ final String packageName = fixtureScriptCls.getPackage().getName();
+ if(!packageName.startsWith(packagePrefix)) {
+ continue;
+ }
+ final FixtureScript fs = newFixtureScript(fixtureScriptCls);
+ if(fs != null) {
+ fixtureScriptList.add(fs);
+ }
+ }
+ Collections.sort(fixtureScriptList, new Comparator<FixtureScript>() {
+ @Override
+ public int compare(FixtureScript o1, FixtureScript o2) {
+ return ObjectContracts.compare(o1, o2, "friendlyName,qualifiedName");
+ }
+ });
+ }
+
+ private static Set<Class<? extends FixtureScript>> findFixtureScriptClasses() {
+ final Reflections reflections = new Reflections(
+ ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()),
+ ClasspathHelper.forClass(Object.class),
+ new SubTypesScanner(false));
+ return reflections.getSubTypesOf(FixtureScript.class);
+ }
+
+ private FixtureScript newFixtureScript(Class<? extends FixtureScript> fixtureScriptCls) {
+ try {
+ final Constructor<? extends FixtureScript> constructor = fixtureScriptCls.getConstructor();
+ final FixtureScript template = constructor.newInstance();
+ if(!template.isDiscoverable()) {
+ return null;
+ }
+ return container.newViewModelInstance(fixtureScriptCls, mementoFor(template));
+ } catch(Exception ex) {
+ // ignore if does not have a no-arg constructor or cannot be instantiated
+ return null;
+ }
+ }
+
+ // //////////////////////////////////////
+
+ @Prototype
+ public List<FixtureResult> runFixtureScript(final FixtureScript fixtureScript) {
+ return fixtureScript.run();
+ }
+ public List<FixtureScript> choices0RunFixtureScript() {
+ return fixtureScriptList;
+ }
+ public String disableRunFixtureScript(final FixtureScript fixtureScript) {
+ return fixtureScriptList.isEmpty()? "No fixture scripts found under package '" + packagePrefix + "'": null;
+ }
+
+ // //////////////////////////////////////
+
+ String mementoFor(FixtureScript fs) {
+ return mementoService.create()
+ .set("path", fs.getParentPath())
+ .asString();
+ }
+ void initOf(String mementoStr, FixtureScript fs) {
+ Memento memento = mementoService.parse(mementoStr);
+ fs.setParentPath(memento.get("path", String.class));
+ }
+
+ // //////////////////////////////////////
+
+ String mementoFor(FixtureResult fr) {
+ return mementoService.create()
+ .set("key", fr.getKey())
+ .set("object", bookmarkService.bookmarkFor(fr.getObject()))
+ .asString();
+ }
+ void initOf(String mementoStr, FixtureResult fr) {
+ Memento memento = mementoService.parse(mementoStr);
+ fr.setKey(memento.get("key", String.class));
+ fr.setObject(bookmarkService.lookup(memento.get("object", Bookmark.class)));
+ }
+
+ FixtureResult newFixtureResult(FixtureScript script, String subkey, Object object) {
+ String mementoFor = mementoFor(script, subkey, object);
+ return container.newViewModelInstance(FixtureResult.class, mementoFor);
+ }
+
+ private String mementoFor(FixtureScript script, String subkey, Object object) {
+ final FixtureResult template = new FixtureResult();
+ template.setKey(script.pathWith(subkey));
+ template.setObject(object);
+ return mementoFor(template);
+ }
+
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ private MementoService mementoService;
+
+ @javax.inject.Inject
+ private BookmarkService bookmarkService;
+
+ @javax.inject.Inject
+ private DomainObjectContainer container;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/SimpleFixtureScript.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/SimpleFixtureScript.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/SimpleFixtureScript.java
new file mode 100644
index 0000000..a9f4079
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/SimpleFixtureScript.java
@@ -0,0 +1,56 @@
+/*
+ * 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.applib.fixturescripts;
+
+import org.apache.isis.applib.annotation.Named;
+import org.apache.isis.applib.annotation.Programmatic;
+
+@Named("Simple Script")
+public abstract class SimpleFixtureScript extends FixtureScript {
+
+ private static Discoverability defaultDiscoverability() {
+ return Discoverability.NON_DISCOVERABLE;
+ }
+
+ public SimpleFixtureScript(String localName) {
+ this(localName, defaultDiscoverability());
+ }
+ public SimpleFixtureScript(String friendlyName, String localName) {
+ this(friendlyName, localName, defaultDiscoverability());
+ }
+ public SimpleFixtureScript(FixtureScript parent, String friendlyName, String localName) {
+ this(parent, friendlyName, localName, defaultDiscoverability());
+ }
+
+ public SimpleFixtureScript(String localName, Discoverability discoverability) {
+ this(localName, localName, discoverability);
+ }
+ public SimpleFixtureScript(String friendlyName, String localName, Discoverability discoverability) {
+ super(friendlyName, localName, discoverability);
+ }
+ public SimpleFixtureScript(FixtureScript parent, String friendlyName, String localName, Discoverability discoverability) {
+ super(parent, friendlyName, localName, discoverability);
+ }
+
+ // //////////////////////////////////////
+
+ @Programmatic
+ protected abstract void doRun(FixtureResultList fixtureResults);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java
index a365b05..f559c4c 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/DomainObjectServices.java
@@ -56,6 +56,8 @@ public interface DomainObjectServices extends Injectable {
*/
ObjectAdapter createAggregatedInstance(ObjectSpecification spec, ObjectAdapter parent);
+ void injectServicesInto(Object domainObject);
+
// ///////////////////////////////////////////
// retrieve
// ///////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java
index 2f1da7c..f9dfa76 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/runtimecontext/noruntime/RuntimeContextNoRuntime.java
@@ -257,6 +257,11 @@ public class RuntimeContextNoRuntime extends RuntimeContextAbstract {
throw new UnsupportedOperationException("Not supported by this implementation of RuntimeContext");
}
+ @Override
+ public void injectServicesInto(Object domainObject) {
+ throw new UnsupportedOperationException("Not supported by this implementation of RuntimeContext");
+ }
+
};
localizationProvider = new LocalizationProviderAbstract() {
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
index 8204559..59973a0 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/container/DomainObjectContainerDefault.java
@@ -201,6 +201,17 @@ public class DomainObjectContainerDefault implements DomainObjectContainer, Que
remove(object);
}
+
+ // //////////////////////////////////////////////////////////////////
+ // injectServicesInto
+ // //////////////////////////////////////////////////////////////////
+
+ @Override
+ public <T> T injectServicesInto(T domainObject) {
+ getDomainObjectServices().injectServicesInto(domainObject);
+ return domainObject;
+ }
+
// //////////////////////////////////////////////////////////////////
// resolve, objectChanged
// //////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/internal/RuntimeContextFromSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/internal/RuntimeContextFromSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/internal/RuntimeContextFromSession.java
index 02fa73e..09437cc 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/internal/RuntimeContextFromSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/internal/RuntimeContextFromSession.java
@@ -264,6 +264,11 @@ public class RuntimeContextFromSession extends RuntimeContextAbstract {
return RuntimeContextFromSession.this.getPropertyNames();
}
+ @Override
+ public void injectServicesInto(Object domainObject) {
+ getPersistenceSession().getServicesInjector().injectServicesInto(domainObject);
+ }
+
};
this.querySubmitter = new QuerySubmitterAbstract() {
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
new file mode 100644
index 0000000..2586c17
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemResetForUser.java
@@ -0,0 +1,64 @@
+/*
+ * 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 webapp.prototyping;
+
+import org.apache.isis.applib.fixturescripts.CompositeFixtureScript;
+
+public abstract class ToDoItemResetForUser extends CompositeFixtureScript {
+
+ // //////////////////////////////////////
+ // Subclasses
+ // //////////////////////////////////////
+
+ public static final class ToDoItemResetForDick extends ToDoItemResetForUser {
+ public ToDoItemResetForDick() {
+ super("dick");
+ }
+ }
+
+ public static final class ToDoItemResetForJoe extends ToDoItemResetForUser {
+ public ToDoItemResetForJoe() {
+ super("joe");
+ }
+ }
+
+ public static final class ToDoItemResetForSven extends ToDoItemResetForUser {
+ public ToDoItemResetForSven() {
+ super("sven");
+ }
+ }
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private String user;
+
+ public ToDoItemResetForUser(String user) {
+ super("Reset ToDoItems for '" + user + "'", user);
+ this.user = user;
+ }
+
+ @Override
+ protected void addChildren() {
+ add("delete", new ToDoItemsDeleteForUser(user));
+ add("create", new ToDoItemsCreateForUser(user));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
new file mode 100644
index 0000000..b70e5b0
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsCreateForUser.java
@@ -0,0 +1,96 @@
+/*
+ * 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 webapp.prototyping;
+
+import java.math.BigDecimal;
+
+import dom.todo.ToDoItem;
+import dom.todo.ToDoItem.Category;
+import dom.todo.ToDoItem.Subcategory;
+import dom.todo.ToDoItems;
+
+import org.joda.time.LocalDate;
+
+import org.apache.isis.applib.clock.Clock;
+import org.apache.isis.applib.fixturescripts.FixtureResultList;
+import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
+
+public class ToDoItemsCreateForUser extends SimpleFixtureScript {
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private final String user;
+
+ public ToDoItemsCreateForUser(String user) {
+ super("Create ToDoItems for '" + user + "'", user);
+ this.user = user;
+ }
+
+ @Override
+ protected void doRun(final FixtureResultList resultList) {
+ installFor(user, resultList);
+ getContainer().flush();
+ }
+
+ private void installFor(final String user, final FixtureResultList resultList) {
+
+ createToDoItemForUser("Buy milk", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("0.75"), resultList);
+ createToDoItemForUser("Buy bread", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("1.75"), resultList);
+ createToDoItemForUser("Buy stamps", Category.Domestic, Subcategory.Shopping, user, daysFromToday(0), new BigDecimal("10.00"), resultList).setComplete(true);
+ createToDoItemForUser("Pick up laundry", Category.Domestic, Subcategory.Chores, user, daysFromToday(6), new BigDecimal("7.50"), resultList);
+ createToDoItemForUser("Mow lawn", Category.Domestic, Subcategory.Garden, user, daysFromToday(6), null, resultList);
+ createToDoItemForUser("Vacuum house", Category.Domestic, Subcategory.Housework, user, daysFromToday(3), null, resultList);
+ createToDoItemForUser("Sharpen knives", Category.Domestic, Subcategory.Chores, user, daysFromToday(14), null, resultList);
+
+ createToDoItemForUser("Write to penpal", Category.Other, Subcategory.Other, user, null, null, resultList);
+
+ createToDoItemForUser("Write blog post", Category.Professional, Subcategory.Marketing, user, daysFromToday(7), null, resultList).setComplete(true);
+ createToDoItemForUser("Organize brown bag", Category.Professional, Subcategory.Consulting, user, daysFromToday(14), null, resultList);
+ createToDoItemForUser("Submit conference session", Category.Professional, Subcategory.Education, user, daysFromToday(21), null, resultList);
+ createToDoItemForUser("Stage Isis release", Category.Professional, Subcategory.OpenSource, user, null, null, resultList);
+
+ getContainer().flush();
+ }
+
+ // //////////////////////////////////////
+
+ private ToDoItem createToDoItemForUser(
+ final String description,
+ final Category category, Subcategory subcategory,
+ final String user,
+ final LocalDate dueBy, final BigDecimal cost, FixtureResultList resultList) {
+ ToDoItem newToDo = toDoItems.newToDo(description, category, subcategory, user, dueBy, cost);
+ return resultList.add(this, newToDo);
+ }
+
+ private static LocalDate daysFromToday(final int i) {
+ final LocalDate date = new LocalDate(Clock.getTimeAsDateTime());
+ return date.plusDays(i);
+ }
+
+
+ // //////////////////////////////////////
+ // Injected services
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ private ToDoItems toDoItems;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
new file mode 100644
index 0000000..81f0b65
--- /dev/null
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsDeleteForUser.java
@@ -0,0 +1,51 @@
+/*
+ * 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 webapp.prototyping;
+
+import org.apache.isis.applib.fixturescripts.FixtureResultList;
+import org.apache.isis.applib.fixturescripts.SimpleFixtureScript;
+import org.apache.isis.objectstore.jdo.applib.service.support.IsisJdoSupport;
+
+public class ToDoItemsDeleteForUser extends SimpleFixtureScript {
+
+ // //////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////
+
+ private final String user;
+
+ public ToDoItemsDeleteForUser(String user) {
+ super("Delete ToDoItems for '" + user + "'", user);
+ this.user = user;
+ }
+
+ @Override
+ protected void doRun(final FixtureResultList resultList) {
+ isisJdoSupport.executeUpdate("delete from \"ToDoItem\" where \"ownedBy\" = '" + user + "'");
+ getContainer().flush();
+ }
+
+ // //////////////////////////////////////
+ // Injected services
+ // //////////////////////////////////////
+
+ @javax.inject.Inject
+ private IsisJdoSupport isisJdoSupport;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/98758f7c/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
index 1417ff4..2eebaab 100644
--- a/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
+++ b/example/application/quickstart_wicket_restful_jdo/webapp/src/main/java/webapp/prototyping/ToDoItemsFixturesService.java
@@ -26,17 +26,23 @@ import dom.todo.ToDoItem;
import dom.todo.ToDoItems;
import fixture.todo.ToDoItemsFixture;
-import org.apache.isis.applib.AbstractService;
+import org.apache.isis.applib.annotation.Hidden;
import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.Prototype;
+import org.apache.isis.applib.fixturescripts.FixtureScripts;
import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
/**
* Enables fixtures to be installed from the application.
*/
@Named("Prototyping") // has the effect of defining a "Prototyping" menu item
-public class ToDoItemsFixturesService extends AbstractService {
+public class ToDoItemsFixturesService extends FixtureScripts {
+ public ToDoItemsFixturesService() {
+ super("webapp.prototyping");
+ }
+
+ @Hidden
@Prototype
public String installFixtures() {
installFixturesFor(null); // ie current user
@@ -45,6 +51,7 @@ public class ToDoItemsFixturesService extends AbstractService {
// //////////////////////////////////////
+ @Hidden
@Prototype
public String installFixturesForUser(@Named("User") String user) {
installFixturesFor(user);
@@ -59,6 +66,7 @@ public class ToDoItemsFixturesService extends AbstractService {
// //////////////////////////////////////
+ @Hidden
@Prototype
public ToDoItem installFixturesAndReturnFirst() {
installFixtures();
@@ -75,7 +83,7 @@ public class ToDoItemsFixturesService extends AbstractService {
}
// //////////////////////////////////////
-
+
private ToDoItems toDoItems;
public void injectToDoItems(ToDoItems toDoItems) {
this.toDoItems = toDoItems;