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 2012/12/06 12:09:56 UTC
[20/51] [partial] ISIS-188: moving components into correct
directories.
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/src/docbkx/style/screen.css
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/src/docbkx/style/screen.css b/framework/objectstore/jdo/src/docbkx/style/screen.css
new file mode 100644
index 0000000..03f0b7f
--- /dev/null
+++ b/framework/objectstore/jdo/src/docbkx/style/screen.css
@@ -0,0 +1,244 @@
+/*
+ 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.
+*/
+
+BODY {
+ font-family: Tahoma, Arial, Sans-Serif;
+ margin-left: 50px;
+ margin-right: 70px;
+}
+
+/*
+div.figure
+{
+ display: block;
+ margin-left: 3em;
+ margin-right: 3em;
+ margin-bottom: 3em;
+ padding: 1em;
+ font-size: 80%;
+ text-decoration: none;
+ border: 1px solid #330099;
+}
+*/
+h1,h2,h3,h4 {
+ color: #330099;
+}
+
+H1 {
+ font-size: 140%;
+ margin-top: -8px;
+}
+
+H2 {
+ margin-top: 25px;
+}
+
+H3 {
+ font-size: 100%;
+ border-bottom: 1px solid #003399;
+}
+
+H4 {
+ font-size: 80%;
+ border-bottom: 0px solid lightgray;
+}
+
+path {
+ color: #6600CC;
+ font: monospaced;
+}
+
+p.block-label {
+ font-size: 80%;
+ font-style: italic;
+ margin-bottom: -13px;
+}
+
+div.block {
+ margin-left: 10px;
+}
+
+/*
+table { width: 100%;}
+
+td.layout { font-size: 100% ;background-color: white; border: 0px; align: top;}
+
+td.header { padding-top: 10px;
+ padding-bottom: 13px;}
+
+td.footer { background-color: white; border: 0px;}
+
+td.footer p { font-size: 70%; color: #666; margin-top: 30px;
+ margin-bottom: 20px;}
+
+tr.layout { background-color: red; margin-top: 50px; margin-bottom: 50px; }
+
+td { font-size: 80%; background-color: #ddd;
+ padding-left: 1em; padding-right: 1em; }
+
+th { font-size: 80%; background-color: #aaa;
+ text-decoration: none;}
+*/
+img.layout {
+ margin-left: -10px;
+}
+
+p {
+ margin-top: 0px;
+}
+
+p,li {
+ font-size: 100%;
+}
+
+p.b {
+ color: #333;
+}
+
+ul {
+ margin-bottom: 10px;
+}
+
+li {
+ margin-bottom: 0px;
+ clear: both;
+}
+
+img {
+ margin: 0;
+ margin-left: 6px;
+}
+
+img.border {
+ margin-left: 0px;
+}
+
+img.wrapped {
+ margin-right: 10px;
+ margin-bottom: 10px;
+ float: left;
+ clear: left;
+}
+
+pre {
+ background: #eeeeee none repeat scroll 0%;
+ border: 1px solid #dddddd;
+ color: #330099;
+ font-family: Andale Mono, Lucida Typewriter, Monospaced, Courier;
+ font-size: 90%; margin-left: 0.0in;
+ margin-right: 0.25in;
+ padding: 8px;
+ clear: both;
+}
+
+pre.b {
+ color: black;
+}
+
+pre.property-listing {
+ background: #ffdddd;
+}
+
+pre.command-listing {
+ background: #ddffdd;
+}
+
+pre.program-listing {
+ background: #ddddff;
+}
+
+pre.output-listing {
+ background: #ffddff;
+}
+
+code {
+ color: #6600CC;
+ font-family: Andale Mono, Lucida Typewriter, Monospaced, Courier;
+}
+
+.class,.method {
+ font-family: Andale Mono, Lucida Typewriter, Monospaced, Courier;
+ color: blue
+}
+
+.path {
+ font-family: Andale Mono, Lucida Typewriter, Monospaced, Courier;
+ color: green
+}
+/*
+div.navigation {
+ font-size: 80%;
+ margin:5px 0 35px 0;
+ color: black;
+ text-align:center;
+ width:100%;
+}
+
+a.navigation {
+ margin: 0 20px;
+ color: darkGray;
+}
+
+a.navigation:hover {
+ color: blue;
+}
+
+ul.content {
+ border:1px solid blue;
+ clear:right;
+ content:"Contents";
+ float:right;
+ margin:8px;
+ padding:4px;
+ position:relative;
+}
+*/
+
+
+
+dl {
+ margin-left: 20px;
+}
+
+dt {
+ font-style: italic;
+ margin: 0;
+}
+
+dd {
+ margin-left: 25px;
+}
+
+variablelist.title {
+ font-style: italic;
+ font-size: 80%;
+ margin 0px;
+}
+
+
+
+table {
+ border-collapse: collapse;
+}
+
+td, th {
+ border: none;
+ padding: 4px 30px 4px 8px;
+
+}
+
+.mediaobject img {
+ border: 1px solid #330099;
+ margin-bottom: 2em;
+ width: 50%;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/src/site/apt/index.apt b/framework/objectstore/jdo/src/site/apt/index.apt
new file mode 100644
index 0000000..a62f30e
--- /dev/null
+++ b/framework/objectstore/jdo/src/site/apt/index.apt
@@ -0,0 +1,24 @@
+~~ 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.
+
+
+
+JPA ObjectStore
+
+ TODO
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/src/site/apt/jottings.apt b/framework/objectstore/jdo/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/framework/objectstore/jdo/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~ 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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/src/site/resources/images/wicket-objects-banner-background.jpg
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/src/site/resources/images/wicket-objects-banner-background.jpg b/framework/objectstore/jdo/src/site/resources/images/wicket-objects-banner-background.jpg
new file mode 100644
index 0000000..f1f7792
Binary files /dev/null and b/framework/objectstore/jdo/src/site/resources/images/wicket-objects-banner-background.jpg differ
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/jdo/src/site/site.xml
----------------------------------------------------------------------
diff --git a/framework/objectstore/jdo/src/site/site.xml b/framework/objectstore/jdo/src/site/site.xml
new file mode 100644
index 0000000..e5d79c8
--- /dev/null
+++ b/framework/objectstore/jdo/src/site/site.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="${project.name}">
+
+ <body>
+ <breadcrumbs>
+ <item name="JDO" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="JDO ObjectStore">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="JDO Modules">
+ <item name="Applib" href="./jdo-applib/index.html" />
+ <item name="Metamodel" href="./jdo-metamodel/index.html" />
+ <item name="DataNucleus" href="./jdo-datanucleus/index.html" />
+ </menu>
+
+ <menu name="Documentation">
+ <item name="${docbkxGuideTitle} (PDF)" href="docbkx/pdf/${docbkxGuideName}.pdf" />
+ <item name="${docbkxGuideTitle} (HTML)" href="docbkx/html/guide/${docbkxGuideName}.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/NOTICE
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/NOTICE b/framework/objectstore/nosql/NOTICE
new file mode 100644
index 0000000..d391f54
--- /dev/null
+++ b/framework/objectstore/nosql/NOTICE
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/config/logging.properties
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/config/logging.properties b/framework/objectstore/nosql/config/logging.properties
new file mode 100644
index 0000000..323bf75
--- /dev/null
+++ b/framework/objectstore/nosql/config/logging.properties
@@ -0,0 +1,36 @@
+# 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.
+# apache's log4j is used to provide system logging.
+log4j.rootCategory=ALL, Console, File
+
+# The console appender
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+#log4j.appender.Console.threshold=INFO
+log4j.appender.Console.target=System.out
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} [%-20c{1} %-10t %-5p] %m%n
+
+
+# The rolling file appender
+log4j.appender.File=org.apache.log4j.RollingFileAppender
+log4j.appender.File.file=fileserver.log
+log4j.appender.File.append=false
+#log4j.appender.File.maxFileSize=500KB
+#log4j.appender.File.maxBackupIndex=1
+log4j.appender.File.layout=org.apache.log4j.PatternLayout
+log4j.appender.File.layout.ConversionPattern=%d [%-20c{1} %-10t %-5p] %m%n
+
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/config/server.properties
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/config/server.properties b/framework/objectstore/nosql/config/server.properties
new file mode 100644
index 0000000..575d8ed
--- /dev/null
+++ b/framework/objectstore/nosql/config/server.properties
@@ -0,0 +1,26 @@
+# 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.
+fileserver.host = localhost
+fileserver.port = 9100
+fileserver.control-host=localhost
+fileserver.control-port = 9101
+fileserver.sync-host=localhost
+fileserver.sync-port = 9102
+
+#fileserver.data = data
+#fileserver.services = services
+#fileserver.logs = logs
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/pom.xml
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/pom.xml b/framework/objectstore/nosql/pom.xml
new file mode 100644
index 0000000..fd7351a
--- /dev/null
+++ b/framework/objectstore/nosql/pom.xml
@@ -0,0 +1,252 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.isis</groupId>
+ <artifactId>isis</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>nosql</artifactId>
+
+ <name>Default Runtime NOSQL ObjectStore</name>
+
+ <description>
+ Provides file based persistence for a standalone application using a NOSQL database.
+ </description>
+
+ <properties>
+ <siteBaseDir>../..</siteBaseDir>
+ <relativeUrl>objectstore/nosql/</relativeUrl>
+
+ <docbkxGuideTitle>Apache Isis Default Runtime NOSQL ObjectStore</docbkxGuideTitle>
+ <docbkxGuideSubTitle>Configuration and Deployment Guide</docbkxGuideSubTitle>
+ <docbkxGuideName>isis-nosql-objectstore</docbkxGuideName>
+ </properties>
+
+ <!-- used in Site generation for relative references. -->
+ <url>http://incubator.apache.org/isis/${relativeUrl}</url>
+
+ <build>
+ <plugins>
+
+ <!--
+ REVIEW: have removed, cos for some bizarre reason causes maven
+ to restart the build???
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>assembly</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy todir="target/config" preservelastmodified="true">
+ <fileset dir="config" />
+ </copy>
+ <copy file="server.sh" todir="target" />
+ <chmod file="target/server.sh" perm="ugo+rx" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+
+ <plugin>
+ <groupId>com.agilejava.docbkx</groupId>
+ <artifactId>docbkx-maven-plugin</artifactId>
+ <inherited>false</inherited>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>${maven-project-info-reports-plugin}</version>
+ <inherited>false</inherited>
+ <configuration>
+ <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <inherited>false</inherited>
+ <reports>
+ <report>dependency-management</report>
+ <report>dependencies</report>
+ <report>dependency-convergence</report>
+ <report>plugins</report>
+ <report>summary</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <repositories>
+ <repository>
+ <id>Maven Central Repository (UK Mirror)</id>
+ <url>http://uk.maven.org/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ </repositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ <version>2.10.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20090211</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.9</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- compile dependencies -->
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ </dependency>
+
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-unittestsupport</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>isis-integtestsupport</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt.bytecode</groupId>
+ <artifactId>dflt</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>dflt</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt.objectstores</groupId>
+ <artifactId>dflt</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jmock</groupId>
+ <artifactId>jmock-legacy</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/docbkx/guide/isis-nosql-objectstore.xml
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/docbkx/guide/isis-nosql-objectstore.xml b/framework/objectstore/nosql/src/docbkx/guide/isis-nosql-objectstore.xml
new file mode 100644
index 0000000..f8209ec
--- /dev/null
+++ b/framework/objectstore/nosql/src/docbkx/guide/isis-nosql-objectstore.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"file:./src/docbkx/dtd-4.5/docbookx.dtd">
+<!--
+ 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.
+-->
+<book>
+ <bookinfo>
+ <title><?eval ${docbkxGuideTitle}?></title>
+ <subtitle><?eval ${docbkxGuideSubTitle}?></subtitle>
+ <releaseinfo><?eval ${project.version}?></releaseinfo>
+
+ <authorgroup>
+ <author>
+ <firstname>Dan</firstname>
+ <surname>Haywood</surname>
+ </author>
+ </authorgroup>
+
+ <legalnotice>
+ <para>Permission is granted to make and distribute verbatim copies of
+ this manual provided that the copyright notice and this permission
+ notice are preserved on all copies.</para>
+ </legalnotice>
+ </bookinfo>
+
+ <!-- front matter -->
+
+ <toc></toc>
+
+ <preface id="preface">
+ <title>Preface</title>
+
+ <para><emphasis>Apache Isis</emphasis> is designed to allow programmers
+ rapidly develop domain-driven applications following the <ulink
+ url="http://en.wikipedia.org/wiki/Naked_Objects">Naked Objects</ulink>
+ pattern. It is made up of a core framework plus a number of alternate
+ implementations, and supports various viewers and object stores. Apache
+ Isis is hosted at the
+ <ulink url="http://incubator.apache.org/isis">Apache Foundation</ulink>,
+ and is licensed under <ulink
+ url="http://www.apache.org/licenses/LICENSE-2.0.html">Apache Software
+ License v2</ulink>.</para>
+
+
+ <para>This guide is written for ...</para>
+ </preface>
+
+ <!-- main content -->
+
+ <chapter id="chp.Intro">
+ <title>Introduction</title>
+
+ <abstract>
+ <para>*** yada yada</para>
+ </abstract>
+
+ <sect1>
+ <title>***</title>
+
+ <para><emphasis>*** yada yada</emphasis></para>
+ </sect1>
+ </chapter>
+
+ <chapter>
+ <title>***</title>
+
+ <abstract>
+ <para>*** yada yada</para>
+ </abstract>
+
+ <sect1>
+ <title>***</title>
+
+ <para><emphasis>*** yada yada</emphasis></para>
+ </sect1>
+ </chapter>
+
+ <appendix>
+ <title>***</title>
+
+ <abstract>
+ <para>*** yada yada</para>
+ </abstract>
+
+ <sect1 id="sec.module-ui">
+ <title>***</title>
+
+ <para>*** yada yada</para>
+ </sect1>
+ </appendix>
+</book>
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCommandContext.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCommandContext.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCommandContext.java
new file mode 100644
index 0000000..b78c2d3
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCommandContext.java
@@ -0,0 +1,35 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateWriter;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+
+public interface NoSqlCommandContext extends PersistenceCommandContext {
+
+ StateWriter createStateWriter(ObjectSpecId objectSpecId);
+
+ void insert(StateWriter writer);
+ void update(StateWriter writer);
+
+ void delete(ObjectSpecId objectSpecId, String key, String version, Oid oid);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCreateObjectCommand.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCreateObjectCommand.java
new file mode 100644
index 0000000..403676e
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlCreateObjectCommand.java
@@ -0,0 +1,32 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+
+final class NoSqlCreateObjectCommand extends WriteObjectCommand implements CreateObjectCommand {
+
+ public NoSqlCreateObjectCommand(final VersionCreator versionCreator, final DataEncryption dataEncrypter, final ObjectAdapter object) {
+ super(Mode.NON_UPDATE, versionCreator, dataEncrypter, object);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlDestroyObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlDestroyObjectCommand.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlDestroyObjectCommand.java
new file mode 100644
index 0000000..5b11bd2
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlDestroyObjectCommand.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 org.apache.isis.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+
+final class NoSqlDestroyObjectCommand implements DestroyObjectCommand {
+
+ private final KeyCreatorDefault keyCreator = new KeyCreatorDefault();
+
+ private final ObjectAdapter adapter;
+ private final VersionCreator versionCreator;
+
+ public NoSqlDestroyObjectCommand(final VersionCreator versionCreator, final ObjectAdapter adapter) {
+ this.versionCreator = versionCreator;
+ this.adapter = adapter;
+ }
+
+ @Override
+ public void execute(final PersistenceCommandContext context) {
+ final String key = keyCreator.getIdentifierForPersistentRoot(adapter.getOid());
+ final String version = versionCreator.versionString(adapter.getVersion());
+ final ObjectSpecification objectSpec = adapter.getSpecification();
+
+ final NoSqlCommandContext noSqlCommandContext = (NoSqlCommandContext) context;
+ noSqlCommandContext.delete(objectSpec.getSpecId(), key, version, adapter.getOid());
+ }
+
+ @Override
+ public ObjectAdapter onAdapter() {
+ return adapter;
+ }
+
+ @Override
+ public String toString() {
+ final ToString toString = new ToString(this);
+ toString.append("spec", adapter.getSpecification().getFullIdentifier());
+ toString.append("oid", adapter.getOid());
+ return toString.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGenerator.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGenerator.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGenerator.java
new file mode 100644
index 0000000..a3565f2
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGenerator.java
@@ -0,0 +1,147 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.ensure.Assert;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
+
+public class NoSqlIdentifierGenerator implements IdentifierGenerator {
+
+ private static int INITIAL_TRANSIENT_ID = -9999999;
+ private static int DEFAULT_BATCH_SIZE = 50;
+
+ private final NoSqlDataDatabase database;
+ private final IdNumbers ids;
+
+
+ //////////////////////////////////////////////////////////////////
+ // constructor
+ //////////////////////////////////////////////////////////////////
+
+ public NoSqlIdentifierGenerator(final NoSqlDataDatabase database) {
+ this(database, INITIAL_TRANSIENT_ID, DEFAULT_BATCH_SIZE);
+ }
+
+ public NoSqlIdentifierGenerator(final NoSqlDataDatabase database, final int initialTransientId, final int batchSize) {
+ this.database = database;
+ ids = new IdNumbers(initialTransientId, batchSize);
+ }
+
+
+ //////////////////////////////////////////////////////////////////
+ // API
+ //////////////////////////////////////////////////////////////////
+
+ @Override
+ public String createTransientIdentifierFor(ObjectSpecId objectSpecId, Object pojo) {
+ final String identifier = "" + ids.nextTransientId();
+ return identifier;
+ }
+
+ @Override
+ public String createAggregateLocalId(ObjectSpecId objectSpecId, final Object pojo, final ObjectAdapter parentAdapter) {
+ Assert.assertNotNull("No connection set up", database);
+ return Long.toHexString(ids.nextSubId(database));
+ }
+
+ @Override
+ public String createPersistentIdentifierFor(ObjectSpecId objectSpecId, Object pojo, RootOid transientRootOid) {
+ return "" + ids.nextPersistentId(database);
+ }
+
+
+ //////////////////////////////////////////////////////////////////
+ // debug
+ //////////////////////////////////////////////////////////////////
+
+ @Override
+ public void debugData(final DebugBuilder debug) {
+ debug.appendln(this.toString());
+ debug.indent();
+ ids.debugData(debug);
+ debug.unindent();
+ }
+
+ @Override
+ public String debugTitle() {
+ return "NoSql OID Generator";
+ }
+}
+
+class IdNumbers {
+
+ private static final Logger LOG = Logger.getLogger(IdNumbers.class);
+
+ private final int batchSize;
+
+ private long transientNumber;
+ private long nextId = 0;
+ private long newIdBatchAt = 0;
+ private long nextSubId = 0;
+ private long newSubIdBatchAt = 0;
+
+ public IdNumbers(final int initialTransientId, final int batchSize) {
+ transientNumber = initialTransientId;
+ this.batchSize = batchSize;
+ }
+
+ public synchronized long nextTransientId() {
+ return transientNumber++;
+ }
+
+ public synchronized long nextSubId(final NoSqlDataDatabase connectionPool) {
+ if (nextSubId > newSubIdBatchAt) {
+ final String message = "ID exception, last id (" + nextSubId + ") past new batch boundary (" + newSubIdBatchAt + ")";
+ throw new NoSqlStoreException(message);
+ }
+ if (nextSubId == newSubIdBatchAt) {
+ nextSubId = connectionPool.nextSerialNumberBatch(ObjectSpecId.of("_sub-id"), batchSize);
+ newSubIdBatchAt = nextSubId + batchSize;
+ LOG.debug("New Sub-ID batch created, from " + nextSubId + " to " + newSubIdBatchAt);
+ }
+ return nextSubId++;
+ }
+
+ public synchronized long nextPersistentId(final NoSqlDataDatabase connectionPool) {
+ if (nextId > newIdBatchAt) {
+ final String message = "ID exception, last id (" + nextId + ") past new batch boundary (" + newIdBatchAt + ")";
+ throw new NoSqlStoreException(message);
+ }
+ if (nextId == newIdBatchAt) {
+ nextId = connectionPool.nextSerialNumberBatch(ObjectSpecId.of("_id"), batchSize);
+ newIdBatchAt = nextId + batchSize;
+ LOG.debug("New ID batch created, from " + nextId + " to " + newIdBatchAt);
+ }
+ return nextId++;
+ }
+
+ public void debugData(final DebugBuilder debug) {
+ debug.appendln("id", nextId);
+ debug.appendln("sub-id", nextSubId);
+ debug.appendln("transient id", transientNumber);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
new file mode 100644
index 0000000..300d679
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStore.java
@@ -0,0 +1,338 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateReader;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindAllInstances;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByPattern;
+import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+
+public class NoSqlObjectStore implements ObjectStoreSpi {
+
+ private final KeyCreatorDefault keyCreator = new KeyCreatorDefault();
+ private final Map<ObjectSpecId, RootOid> servicesByObjectSpecId = Maps.newHashMap();
+
+ private final NoSqlDataDatabase database;
+ private final VersionCreator versionCreator;
+ private final ObjectReader objectReader = new ObjectReader();
+ private final OidGenerator oidGenerator;
+ private final DataEncryption wrtingDataEncrypter;
+ private final Map<String, DataEncryption> availableDataEncrypters;
+ private final boolean isDataLoaded;
+
+ public NoSqlObjectStore(final NoSqlDataDatabase db, final OidGenerator oidGenerator, final VersionCreator versionCreator, final DataEncryption writingDataEncrypter, final Map<String, DataEncryption> availableDataEncrypters) {
+ this.database = db;
+ this.oidGenerator = oidGenerator;
+ this.versionCreator = versionCreator;
+ this.wrtingDataEncrypter = writingDataEncrypter;
+ this.availableDataEncrypters = availableDataEncrypters;
+
+ db.open();
+ isDataLoaded = db.containsData();
+ db.close();
+ }
+
+ public IdentifierGenerator getIdentifierGenerator() {
+ return oidGenerator.getIdentifierGenerator();
+ }
+
+ @Override
+ public CreateObjectCommand createCreateObjectCommand(final ObjectAdapter object) {
+ // TODO should this be done at a higher level so it is applicable for
+ // all OSes
+ if (object.getSpecification().isParented()) {
+ // throw new
+ // UnexpectedCallException("Aggregated objects should not be created outside of their owner");
+ return null;
+ } else {
+ return new NoSqlCreateObjectCommand(versionCreator, wrtingDataEncrypter, object);
+ }
+ }
+
+ @Override
+ public DestroyObjectCommand createDestroyObjectCommand(final ObjectAdapter adapter) {
+ if (adapter.getSpecification().isParented()) {
+ throw new NoSqlStoreException("Can't delete an aggregated object");
+ } else {
+ return new NoSqlDestroyObjectCommand(versionCreator, adapter);
+ }
+ }
+
+ @Override
+ public SaveObjectCommand createSaveObjectCommand(final ObjectAdapter adapter) {
+
+ // TODO should this be done at a higher level
+ // so it is applicable for all object stores?
+
+ final ObjectAdapter rootAdapter = adapter.getAggregateRoot();
+ if (!(rootAdapter.getOid() instanceof RootOid)) {
+ throw new NoSqlStoreException("Unexpected aggregated object to save: " + rootAdapter + " (" + adapter + ")");
+ }
+ return new NoSqlSaveObjectCommand(versionCreator, wrtingDataEncrypter, rootAdapter);
+ }
+
+ @Override
+ public void execute(final List<PersistenceCommand> commands) {
+ database.write(commands);
+ }
+
+ @Override
+ public List<ObjectAdapter> loadInstancesAndAdapt(final PersistenceQuery persistenceQuery) {
+ if (persistenceQuery instanceof PersistenceQueryFindByTitle) {
+ return getAllInstances((PersistenceQueryFindByTitle) persistenceQuery);
+ } else if (persistenceQuery instanceof PersistenceQueryFindAllInstances) {
+ return getAllInstances((PersistenceQueryFindAllInstances) persistenceQuery);
+ } else if (persistenceQuery instanceof PersistenceQueryFindByPattern) {
+ return findByPattern((PersistenceQueryFindByPattern) persistenceQuery);
+ } else {
+ return findDefaultr(persistenceQuery);
+ }
+ }
+
+ private List<ObjectAdapter> findDefaultr(PersistenceQuery persistenceQuery) {
+ final List<ObjectAdapter> instances = Lists.newArrayList();
+ final ObjectSpecification specification = persistenceQuery.getSpecification();
+ final Iterator<StateReader> instanceData = database.instancesOf(specification.getSpecId());
+ while (instanceData.hasNext()) {
+ final StateReader reader = instanceData.next();
+ final ObjectAdapter instance = objectReader.load(reader, versionCreator, availableDataEncrypters);
+ instances.add(instance);
+ }
+ return instances;
+ }
+
+ private List<ObjectAdapter> findByPattern(PersistenceQueryFindByPattern query) {
+ final ObjectSpecification specification = query.getSpecification();
+ final List<ObjectAdapter> instances = Lists.newArrayList();
+ appendPatternInstances(query, specification, instances);
+ return instances;
+ }
+
+ private void appendPatternInstances(final PersistenceQueryFindByPattern persistenceQuery, final ObjectSpecification specification, final List<ObjectAdapter> instances) {
+ final Iterator<StateReader> instanceData = database.instancesOf(specification.getSpecId(), persistenceQuery.getPattern());
+ while (instanceData.hasNext()) {
+ final StateReader reader = instanceData.next();
+ final ObjectAdapter instance = objectReader.load(reader, versionCreator, availableDataEncrypters);
+ instances.add(instance);
+ }
+ for (final ObjectSpecification spec : specification.subclasses()) {
+ appendPatternInstances(persistenceQuery, spec, instances);
+ }
+ }
+
+
+ private List<ObjectAdapter> getAllInstances(PersistenceQuery query) {
+ final ObjectSpecification specification = query.getSpecification();
+ final List<ObjectAdapter> instances = Lists.newArrayList();
+ appendInstances(query, specification, instances);
+ return instances;
+ }
+
+ private void appendInstances(final PersistenceQuery persistenceQuery, final ObjectSpecification specification, final List<ObjectAdapter> instances) {
+ final Iterator<StateReader> instanceData = database.instancesOf(specification.getSpecId());
+ while (instanceData.hasNext()) {
+ final StateReader reader = instanceData.next();
+ final ObjectAdapter instance = objectReader.load(reader, versionCreator, availableDataEncrypters);
+
+ // TODO deal with this natively
+ if (persistenceQuery instanceof PersistenceQueryBuiltIn) {
+ if (!((PersistenceQueryBuiltIn) persistenceQuery).matches(instance)) {
+ continue;
+ }
+ }
+ instances.add(instance);
+ }
+ for (final ObjectSpecification spec : specification.subclasses()) {
+ appendInstances(persistenceQuery, spec, instances);
+ }
+ }
+
+
+
+ @Override
+ public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid) {
+ final String key = keyCreator.getIdentifierForPersistentRoot(oid);
+ final ObjectSpecification objectSpec = getSpecificationLookup().lookupBySpecId(oid.getObjectSpecId());
+ final StateReader reader = database.getInstance(key, objectSpec.getSpecId());
+ return objectReader.load(reader, versionCreator, availableDataEncrypters);
+ }
+
+ @Override
+ public boolean hasInstances(final ObjectSpecification specification) {
+ return database.hasInstances(specification.getSpecId());
+ }
+
+ @Override
+ public boolean isFixturesInstalled() {
+ return isDataLoaded;
+ }
+
+ @Override
+ public void reset() {
+ }
+
+ @Override
+ public void resolveField(final ObjectAdapter object, final ObjectAssociation field) {
+ final ObjectAdapter fieldValue = field.get(object);
+ if (fieldValue != null && !fieldValue.isResolved() && !fieldValue.getSpecification().isParented()) {
+ resolveImmediately(fieldValue);
+ }
+ }
+
+ @Override
+ public void resolveImmediately(final ObjectAdapter adapter) {
+ final Oid oid = adapter.getOid();
+ if (!(oid instanceof AggregatedOid)) {
+ final ObjectSpecification objectSpec = adapter.getSpecification();
+ final String key = keyCreator.getIdentifierForPersistentRoot(oid);
+ final StateReader reader = database.getInstance(key, objectSpec.getSpecId());
+ objectReader.update(reader, versionCreator, availableDataEncrypters, adapter);
+ }
+ }
+
+ @Override
+ public void debugData(final DebugBuilder debug) {
+ // TODO show details
+ }
+
+ // ////////////////////////////////////////////////////////////////
+ // open, close
+ // ////////////////////////////////////////////////////////////////
+
+ @Override
+ public void close() {
+ database.close();
+ }
+
+ @Override
+ public void open() {
+ database.open();
+ }
+
+ @Override
+ public String name() {
+ return "nosql";
+ }
+
+
+ // ////////////////////////////////////////////////////////////////
+ // Services
+ // ////////////////////////////////////////////////////////////////
+
+ @Override
+ public void registerService(final RootOid rootOid) {
+ final String key = keyCreator.getIdentifierForPersistentRoot(rootOid);
+ database.addService(rootOid.getObjectSpecId(), key);
+ }
+
+ @Override
+ public RootOid getOidForService(ObjectSpecification serviceSpec) {
+ final ObjectSpecId objectSpecId = serviceSpec.getSpecId();
+ RootOid oid = servicesByObjectSpecId.get(objectSpecId);
+ if (oid == null) {
+ final String id = database.getService(objectSpecId);
+ if (id == null) {
+ oid = null;
+ } else {
+ oid = keyCreator.createRootOid(serviceSpec, id);
+ }
+ servicesByObjectSpecId.put(objectSpecId, oid);
+ }
+ return oid;
+ }
+
+
+ // ////////////////////////////////////////////////////////////////
+ // Transaction Mgmt
+ // ////////////////////////////////////////////////////////////////
+
+ @Override
+ public void abortTransaction() {
+ }
+
+ @Override
+ public void endTransaction() {
+ }
+
+ @Override
+ public void startTransaction() {
+ }
+
+
+ // ////////////////////////////////////////////////////////////////
+ // debugging
+ // ////////////////////////////////////////////////////////////////
+
+ @Override
+ public String debugTitle() {
+ return "NoSql Object Store";
+ }
+
+
+ // ////////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ////////////////////////////////////////////////////////////////
+
+ protected AdapterManager getAdapterManager() {
+ return getPersistenceSession().getAdapterManager();
+ }
+
+ protected PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected SpecificationLoader getSpecificationLookup() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlSaveObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlSaveObjectCommand.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlSaveObjectCommand.java
new file mode 100644
index 0000000..552f53d
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlSaveObjectCommand.java
@@ -0,0 +1,32 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+
+final class NoSqlSaveObjectCommand extends WriteObjectCommand implements SaveObjectCommand {
+
+ public NoSqlSaveObjectCommand(final VersionCreator versionCreator, final DataEncryption dataEncrypter, final ObjectAdapter object) {
+ super(Mode.UPDATE, versionCreator, dataEncrypter, object);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlStoreException.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlStoreException.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlStoreException.java
new file mode 100644
index 0000000..74c1d0b
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlStoreException.java
@@ -0,0 +1,47 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class NoSqlStoreException extends IsisException {
+ private static final long serialVersionUID = 1L;
+
+ public NoSqlStoreException() {
+ super();
+ }
+
+ public NoSqlStoreException(final String messageFormat, final Object... args) {
+ super(messageFormat, args);
+ }
+
+ public NoSqlStoreException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoSqlStoreException(final String message) {
+ super(message);
+ }
+
+ public NoSqlStoreException(final Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReader.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReader.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReader.java
new file mode 100644
index 0000000..ba3fe3d
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReader.java
@@ -0,0 +1,249 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociationContainer;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateReader;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.Persistor;
+import org.apache.log4j.Logger;
+
+public class ObjectReader {
+
+ private static final Logger LOG = Logger.getLogger(ObjectReader.class);
+
+ private final KeyCreatorDefault keyCreator = new KeyCreatorDefault();
+
+ public ObjectAdapter load(final StateReader reader, final VersionCreator versionCreator, final Map<String, DataEncryption> dataEncrypters) {
+
+ final String oidStr = reader.readOid();
+ final RootOid rootOid = getOidMarshaller().unmarshal(oidStr, RootOid.class);
+
+ final ObjectAdapter adapter = getAdapter(rootOid);
+ if (adapter.isResolved()) {
+ Version version = null;
+ final String versionString = reader.readVersion();
+ if (!versionString.equals("")) {
+ final String user = reader.readUser();
+ final String time = reader.readTime();
+ version = versionCreator.version(versionString, user, time);
+ }
+ if (version.different(adapter.getVersion())) {
+ // TODO - do we need to CHECK version and update
+ LOG.warn("while reading data into " + oidStr + " version was " + version + " when existing adapter was already " + adapter.getVersion());
+ }
+
+ } else {
+
+ // TODO move lock to common method
+ // object.setOptimisticLock(version);
+ loadState(reader, versionCreator, dataEncrypters, adapter);
+ }
+
+ return adapter;
+ }
+
+ public void update(final StateReader reader, final VersionCreator versionCreator, final Map<String, DataEncryption> dataEncrypters, final ObjectAdapter object) {
+ loadState(reader, versionCreator, dataEncrypters, object);
+ }
+
+ private void loadState(final StateReader reader, final VersionCreator versionCreator, final Map<String, DataEncryption> dataEncrypters, final ObjectAdapter object) {
+ final ResolveState resolveState = ResolveState.RESOLVING;
+ object.changeState(resolveState);
+ Version version = null;
+ final String versionString = reader.readVersion();
+ if (!versionString.equals("")) {
+ final String user = reader.readUser();
+ final String time = reader.readTime();
+ version = versionCreator.version(versionString, user, time);
+ }
+ final String encryptionType = reader.readEncrytionType();
+ readFields(reader, object, dataEncrypters.get(encryptionType));
+ object.setVersion(version);
+ object.changeState(resolveState.getEndState());
+ }
+
+ private void readFields(final StateReader reader, final ObjectAdapter object, final DataEncryption dataEncrypter) {
+ final ObjectAssociationContainer specification = object.getSpecification();
+ final List<ObjectAssociation> associations = specification.getAssociations();
+ for (final ObjectAssociation association : associations) {
+ if (association.isNotPersisted()) {
+ continue;
+ }
+ if (association.isOneToManyAssociation()) {
+ readCollection(reader, dataEncrypter, (OneToManyAssociation) association, object);
+ } else if (association.getSpecification().isValue()) {
+ readValue(reader, dataEncrypter, (OneToOneAssociation) association, object);
+ } else if (association.getSpecification().isParented()) {
+ readAggregate(reader, dataEncrypter, (OneToOneAssociation) association, object);
+ } else {
+ readReference(reader, (OneToOneAssociation) association, object);
+ }
+ }
+ }
+
+ private void readAggregate(final StateReader reader, final DataEncryption dataEncrypter, final OneToOneAssociation association, final ObjectAdapter parentAdapter) {
+ final String id = association.getId();
+ final StateReader aggregateReader = reader.readAggregate(id);
+
+ final ObjectAdapter fieldObject;
+ if (aggregateReader != null) {
+ final String oidStr = aggregateReader.readOid();
+ final AggregatedOid aggregatedOid = getOidMarshaller().unmarshal(oidStr, AggregatedOid.class);
+ fieldObject = restoreAggregatedObject(aggregateReader, aggregatedOid, dataEncrypter);
+ } else {
+ fieldObject = null;
+ }
+
+ association.initAssociation(parentAdapter, fieldObject);
+ }
+
+ private ObjectAdapter restoreAggregatedObject(final StateReader aggregateReader, final AggregatedOid aggregatedOid, final DataEncryption dataEncrypter) {
+ final ObjectAdapter fieldObject = getAdapter(aggregatedOid);
+ final ResolveState resolveState = ResolveState.RESOLVING;
+ fieldObject.changeState(resolveState);
+ readFields(aggregateReader, fieldObject, dataEncrypter);
+ fieldObject.changeState(resolveState.getEndState());
+
+ return fieldObject;
+ }
+
+ private void readValue(final StateReader reader, final DataEncryption dataEncrypter, final OneToOneAssociation association, final ObjectAdapter object) {
+ final String fieldData = reader.readField(association.getId());
+ if (fieldData != null) {
+ if (fieldData.equals("null")) {
+ association.initAssociation(object, null);
+ } else {
+ final EncodableFacet encodeableFacet = association.getSpecification().getFacet(EncodableFacet.class);
+ final String decryptedData = dataEncrypter.decrypt(fieldData);
+ final ObjectAdapter value = encodeableFacet.fromEncodedString(decryptedData);
+ association.initAssociation(object, value);
+ }
+ }
+ }
+
+ private void readReference(final StateReader reader, final OneToOneAssociation association, final ObjectAdapter object) {
+ ObjectAdapter fieldObject;
+ final String ref = reader.readField(association.getId());
+ if (ref == null || ref.equals("null")) {
+ fieldObject = null;
+ } else {
+ if (ref.equals("")) {
+ throw new NoSqlStoreException("Invalid reference field (an empty string) in data for " + association.getName() + " in " + object);
+ }
+ final RootOid oid = keyCreator.unmarshal(ref);
+ fieldObject = getAdapter(oid);
+ }
+ try {
+ association.initAssociation(object, fieldObject);
+ } catch (IllegalArgumentException e) {
+ throw new NoSqlStoreException("Failed to process field data for " + association.getName() + " in " + object + ": " + ref);
+ }
+ }
+
+ private void readCollection(final StateReader reader, final DataEncryption dataEncrypter, final OneToManyAssociation association, final ObjectAdapter parentAdapter) {
+ final ObjectAdapter collectionAdapter = association.get(parentAdapter);
+
+ final CollectionFacet facet = collectionAdapter.getSpecification().getFacet(CollectionFacet.class);
+ if (association.getSpecification().isParented()) {
+ // were persisted inline, so read back inline
+ final List<StateReader> readers = reader.readCollection(association.getId());
+ final ObjectAdapter[] elementAdapters = new ObjectAdapter[readers.size()];
+ int i = 0;
+ for (final StateReader elementReader : readers) {
+
+ final String oidStr = elementReader.readOid();
+ final AggregatedOid aggregatedOid = getOidMarshaller().unmarshal(oidStr, AggregatedOid.class);
+
+ elementAdapters[i++] = restoreAggregatedObject(elementReader, aggregatedOid, dataEncrypter);
+ }
+ facet.init(collectionAdapter, elementAdapters);
+ } else {
+ // were persisted as references, so read back as references
+ final String referencesList = reader.readField(association.getId());
+ if (referencesList == null || referencesList.length() == 0) {
+ facet.init(collectionAdapter, new ObjectAdapter[0]);
+ } else {
+ final ObjectAdapter[] elements = restoreElements(referencesList);
+ facet.init(collectionAdapter, elements);
+ }
+ }
+ }
+
+ private ObjectAdapter[] restoreElements(final String referencesList) {
+ final String[] references = referencesList.split("\\|");
+ final ObjectAdapter[] elements = new ObjectAdapter[references.length];
+ for (int i = 0; i < references.length; i++) {
+
+ // no longer used
+ //final ObjectSpecification specification = keyCreator.specificationFromOidStr(references[i]);
+
+ final RootOid oid = keyCreator.unmarshal(references[i]);
+ elements[i] = getAdapter(oid);
+ }
+ return elements;
+ }
+
+ protected ObjectAdapter getAdapter(final TypedOid oid) {
+ return getAdapterManager().adapterFor(oid);
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ // dependencies (from context)
+ ////////////////////////////////////////////////////////////////////////////
+
+ protected Persistor getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected AdapterManager getAdapterManager() {
+ return getPersistenceSession().getAdapterManager();
+ }
+
+ protected SpecificationLoaderSpi getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+ protected OidMarshaller getOidMarshaller() {
+ return IsisContext.getOidMarshaller();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
new file mode 100644
index 0000000..58e3d4d
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommand.java
@@ -0,0 +1,249 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.spec.DomainModelException;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateWriter;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+
+class WriteObjectCommand implements PersistenceCommand {
+
+ public enum Mode {
+ UPDATE,
+ NON_UPDATE;
+
+ public static Mode modeFor(boolean isUpdate) {
+ return isUpdate?UPDATE:NON_UPDATE;
+ }
+
+ public boolean isUpdate() {
+ return this == UPDATE;
+ }
+ }
+
+ private final KeyCreatorDefault keyCreator = new KeyCreatorDefault();
+ private final ObjectAdapter adapter;
+ private final VersionCreator versionCreator;
+ private final DataEncryption dataEncrypter;
+ private final Mode mode;
+
+ WriteObjectCommand(final Mode mode, final VersionCreator versionCreator, final DataEncryption dataEncrypter, final ObjectAdapter adapter) {
+ this.mode = mode;
+ this.versionCreator = versionCreator;
+ this.dataEncrypter = dataEncrypter;
+ this.adapter = adapter;
+ }
+
+ @Override
+ public void execute(final PersistenceCommandContext context) {
+ final NoSqlCommandContext noSqlCommandContext = (NoSqlCommandContext) context;
+
+ final ObjectSpecification objectSpec = adapter.getSpecification();
+ //final String specName = objectSpec.getFullIdentifier();
+ final StateWriter writer = noSqlCommandContext.createStateWriter(objectSpec.getSpecId());
+
+ //final String key = keyCreator.key(adapter.getOid());
+ //writer.writeId(key);
+ final TypedOid typedOid = (TypedOid) adapter.getOid();
+ writer.writeOid(typedOid);
+
+ writeFields(writer, adapter);
+ final String user = getAuthenticationSession().getUserName();
+
+ final Version currentVersion = adapter.getVersion();
+
+ final Version newVersion = mode.isUpdate() ? versionCreator.nextVersion(currentVersion, user) : versionCreator.newVersion(user);
+ adapter.setVersion(newVersion);
+ if (newVersion != null) {
+ final String version = currentVersion == null ? null : versionCreator.versionString(currentVersion);
+ writer.writeVersion(version, versionCreator.versionString(newVersion));
+ writer.writeUser(newVersion.getUser());
+ writer.writeTime(versionCreator.timeString(newVersion));
+ writer.writeEncryptionType(dataEncrypter.getType());
+ }
+
+ if (mode.isUpdate()) {
+ noSqlCommandContext.update(writer);
+ } else {
+ noSqlCommandContext.insert(writer);
+ }
+ }
+
+ private void writeFields(final StateWriter writer, final ObjectAdapter adapter) {
+
+ final List<ObjectAssociation> associations = adapter.getSpecification().getAssociations();
+
+// final String specName = adapter.getSpecification().getFullIdentifier();
+// writer.writeObjectType(specName);
+
+ writer.writeOid((TypedOid) adapter.getOid());
+
+ for (final ObjectAssociation association : associations) {
+ if (association.isNotPersisted()) {
+ continue;
+ }
+ final ObjectAdapter fieldAdapter = association.get(adapter);
+ if (association.isOneToManyAssociation()) {
+ final OneToManyAssociation oneToManyAssociation = (OneToManyAssociation) association;
+ final ObjectAdapter collectionAdapter = fieldAdapter; // to explain
+ writeCollection(writer, oneToManyAssociation, collectionAdapter);
+ } else {
+ final OneToOneAssociation oneToOneAssociation = (OneToOneAssociation) association;
+ final ObjectAdapter propertyAdapter = fieldAdapter; // to explain
+ writeProperty(writer, oneToOneAssociation, propertyAdapter);
+ }
+ }
+ }
+
+ private void writeProperty(final StateWriter writer, final OneToOneAssociation oneToOneAssociation, final ObjectAdapter propertyAdapter) {
+ if (oneToOneAssociation.getSpecification().isValue()) {
+ final ObjectAdapter valueAdapter = propertyAdapter; // to explain
+ writeValueProperty(writer, oneToOneAssociation, valueAdapter);
+ } else {
+ final ObjectAdapter referencedAdapter = propertyAdapter; // to explain
+ writeReferenceProperty(writer, oneToOneAssociation, referencedAdapter);
+ }
+ }
+
+ private void writeValueProperty(final StateWriter writer, final OneToOneAssociation otoa, final ObjectAdapter valueAdapter) {
+ String data;
+ if (valueAdapter == null) {
+ data = null;
+ } else {
+ final EncodableFacet encodeableFacet = valueAdapter.getSpecification().getFacet(EncodableFacet.class);
+ data = encodeableFacet.toEncodedString(valueAdapter);
+ data = dataEncrypter.encrypt(data);
+ }
+ writer.writeField(otoa.getId(), data);
+ }
+
+ private void writeReferenceProperty(final StateWriter writer, final OneToOneAssociation otoa, final ObjectAdapter referencedAdapter) {
+ if (otoa.getSpecification().isParented()) {
+ writeReferencedAsAggregated(writer, otoa, referencedAdapter);
+ } else {
+ writeReference(writer, otoa, referencedAdapter);
+ }
+ }
+
+ private void writeReferencedAsAggregated(final StateWriter writer, final OneToOneAssociation otoa, final ObjectAdapter referencedAdapter) {
+ if (referencedAdapter == null) {
+ writer.writeField(otoa.getId(), null);
+ return;
+ }
+ final Oid referencedOid = referencedAdapter.getOid();
+ if (!(referencedOid instanceof AggregatedOid)) {
+ throw new NoSqlStoreException("Object type is inconsistent with it OID - it should have an AggregatedOid: " + referencedAdapter);
+ }
+ final AggregatedOid aggregatedOid = (AggregatedOid) referencedOid;
+
+ final String associationId = otoa.getId();
+ final StateWriter aggregateWriter = writer.addAggregate(associationId);
+ //aggregateWriter.writeId(aggregatedOid.getLocalId());
+ aggregateWriter.writeOid(aggregatedOid);
+
+ writeFields(aggregateWriter, referencedAdapter);
+ }
+
+ private void writeReference(final StateWriter writer, final ObjectAssociation association, final ObjectAdapter referencedAdapter) {
+ final String key = keyCreator.oidStrFor(referencedAdapter);
+ writer.writeField(association.getId(), key);
+ }
+
+ private void writeCollection(final StateWriter writer, final OneToManyAssociation association, final ObjectAdapter collectionAdapter) {
+ if (association.getSpecification().isParented()) {
+ writeCollectionOfAggregated(writer, association, collectionAdapter);
+ } else {
+ writeCollectionOfReferences(writer, association, collectionAdapter);
+ }
+ }
+
+ private void writeCollectionOfAggregated(final StateWriter writer, final ObjectAssociation association, final ObjectAdapter collectionAdapter) {
+ final List<StateWriter> elementWriters = Lists.newArrayList();
+ final CollectionFacet collectionFacet = collectionAdapter.getSpecification().getFacet(CollectionFacet.class);
+ for (final ObjectAdapter referencedAdapter : collectionFacet.iterable(collectionAdapter)) {
+ final AggregatedOid elementOid = (AggregatedOid) referencedAdapter.getOid();
+ final StateWriter elementWriter = writer.createElementWriter();
+
+ //elementWriter.writeId(elementOid.getLocalId());
+ elementWriter.writeOid(elementOid);
+
+ writeFields(elementWriter, referencedAdapter);
+ elementWriters.add(elementWriter);
+ }
+ writer.writeCollection(association.getId(), elementWriters);
+ }
+
+ private void writeCollectionOfReferences(final StateWriter writer, final ObjectAssociation association, final ObjectAdapter collectionAdapter) {
+ final CollectionFacet collectionFacet = collectionAdapter.getSpecification().getFacet(CollectionFacet.class);
+
+ final StringBuilder buf = new StringBuilder();
+ for (final ObjectAdapter elementAdapter : collectionFacet.iterable(collectionAdapter)) {
+ if (elementAdapter.isParented()) {
+ throw new DomainModelException("Can't store an aggregated object within a collection that is not expected aggregates: " + elementAdapter + " (" + collectionAdapter + ")");
+ }
+ buf.append(keyCreator.oidStrFor(elementAdapter)).append("|");
+ }
+ if (buf.length() > 0) {
+ writer.writeField(association.getId(), buf.toString());
+ }
+ }
+
+
+ @Override
+ public ObjectAdapter onAdapter() {
+ return adapter;
+ }
+
+ @Override
+ public String toString() {
+ final ToString toString = new ToString(this);
+ toString.append("spec", adapter.getSpecification().getFullIdentifier());
+ toString.append("oid", adapter.getOid());
+ return toString.toString();
+ }
+
+
+ protected AuthenticationSession getAuthenticationSession() {
+ return IsisContext.getAuthenticationSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/cd9f2e4a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/NoSqlDataDatabase.java
----------------------------------------------------------------------
diff --git a/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/NoSqlDataDatabase.java b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/NoSqlDataDatabase.java
new file mode 100644
index 0000000..4868b83
--- /dev/null
+++ b/framework/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/NoSqlDataDatabase.java
@@ -0,0 +1,47 @@
+/*
+ * 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.runtimes.dflt.objectstores.nosql.db;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+
+public interface NoSqlDataDatabase {
+
+ void open();
+ void close();
+
+ boolean containsData();
+
+ void addService(ObjectSpecId objectSpecId, String key);
+ String getService(ObjectSpecId objectSpecId);
+
+ boolean hasInstances(ObjectSpecId objectSpecId);
+ StateReader getInstance(String key, ObjectSpecId objectSpecId);
+ Iterator<StateReader> instancesOf(ObjectSpecId objectSpecId);
+ Iterator<StateReader> instancesOf(ObjectSpecId specId, ObjectAdapter pattern);
+
+ long nextSerialNumberBatch(ObjectSpecId objectSpecId, int batchSize);
+
+ void write(List<PersistenceCommand> commands);
+}