]> git.mxchange.org Git - jaddressbook-share-core.git/commitdiff
this has been moved out from jaddressbook-core
authorRoland Häder <roland@mxchange.org>
Thu, 27 Apr 2017 12:27:04 +0000 (14:27 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 27 Apr 2017 12:27:04 +0000 (14:27 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
27 files changed:
build.xml
nbproject/build-impl.xml
nbproject/project.properties
nbproject/project.xml
src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java [deleted file]
src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java [deleted file]
src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java [deleted file]
src/org/mxchange/jaddressbookcore/events/sharing/ObservableAddressbookSharingEvent.java [deleted file]
src/org/mxchange/jaddressbookcore/events/sharing/StartedAddressbookSharingEvent.java [deleted file]
src/org/mxchange/jaddressbookcore/events/sharing/type/SharingType.java [deleted file]
src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java [deleted file]
src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java [deleted file]
src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/shared/ShareableAddressbook.java [deleted file]
src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java [deleted file]
src/org/mxchange/jaddressbookshare/events/sharing/EndedAddressbookSharingEvent.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/events/sharing/ObservableAddressbookSharingEvent.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/events/sharing/StartedAddressbookSharingEvent.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/events/sharing/type/SharingType.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/exceptions/UserAlreadySharingAddressbookException.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java [new file with mode: 0644]
src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java [new file with mode: 0644]

index 69c0ac1498e94e3cf6bffe661485c221edfbcc80..6748516e0486330795560eecae725adb8a20a5fc 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -7,8 +7,8 @@
 <!-- the Compile on Save feature is turned off for the project. -->
 <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
 <!-- in the project's Project Properties dialog box.-->
-<project name="jaddressbook-core" default="default" basedir=".">
-    <description>Builds, tests, and runs the project jaddressbook-core.</description>
+<project name="jaddressbook-share-core" default="default" basedir=".">
+    <description>Builds, tests, and runs the project jaddressbook-share-core.</description>
     <import file="nbproject/build-impl.xml"/>
     <!--
 
@@ -58,7 +58,7 @@
 
     An example of overriding the target for project execution could look like this:
 
-        <target name="run" depends="jaddressbook-core-impl.jar">
+        <target name="run" depends="jaddressbook-share-core-impl.jar">
             <exec dir="bin" executable="launcher.exe">
                 <arg file="${dist.jar}"/>
             </exec>
index dfee9b5970cfbd2d6424b008284d10e95ba8ce61..4fb3f85e0849e95a0973a0e6e944b7c8e02f3264 100644 (file)
@@ -19,7 +19,7 @@ is divided into following sections:
   - cleanup
 
         -->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="jaddressbook-core-impl">
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="jaddressbook-share-core-impl">
     <fail message="Please build using Ant 1.8.0 or higher.">
         <condition>
             <not>
@@ -474,7 +474,7 @@ is divided into following sections:
                     </fileset>
                 </union>
                 <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
-                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="jaddressbook-core" testname="TestNG tests" workingDir="${work.dir}">
+                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="jaddressbook-share-core" testname="TestNG tests" workingDir="${work.dir}">
                     <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
                     <propertyset>
                         <propertyref prefix="test-sys-prop."/>
@@ -625,7 +625,7 @@ is divided into following sections:
                 <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
                     <isset property="test.method"/>
                 </condition>
-                <condition else="-suitename jaddressbook-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+                <condition else="-suitename jaddressbook-share-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
                     <matches pattern=".*\.xml" string="@{testClass}"/>
                 </condition>
                 <delete dir="${build.test.results.dir}" quiet="true"/>
@@ -917,7 +917,7 @@ is divided into following sections:
         <delete file="${built-jar.properties}" quiet="true"/>
     </target>
     <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
-        <echo level="warn" message="Cycle detected: jaddressbook-core was already built"/>
+        <echo level="warn" message="Cycle detected: jaddressbook-share-core was already built"/>
     </target>
     <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
         <mkdir dir="${build.dir}"/>
@@ -1402,7 +1402,7 @@ is divided into following sections:
         <delete file="${built-clean.properties}" quiet="true"/>
     </target>
     <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
-        <echo level="warn" message="Cycle detected: jaddressbook-core was already built"/>
+        <echo level="warn" message="Cycle detected: jaddressbook-share-core was already built"/>
     </target>
     <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
         <mkdir dir="${build.dir}"/>
index 413a0d3866b5ac532f6c3079b9225615c0a8739a..b7f0a3c063655cec92fde0fdefa834125cc4356a 100644 (file)
@@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=true
 annotation.processing.processors.list=
 annotation.processing.run.all.processors=true
 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=jaddressbook-core
+application.title=jaddressbook-share-core
 application.vendor=Roland H\u00e4der
 auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
 build.classes.dir=${build.dir}/classes
@@ -26,10 +26,11 @@ debug.test.classpath=\
 dist.archive.excludes=
 # This directory is removed when the project is cleaned:
 dist.dir=dist
-dist.jar=${dist.dir}/jaddressbook-core.jar
+dist.jar=${dist.dir}/jaddressbook-share-core.jar
 dist.javadoc.dir=${dist.dir}/javadoc
 endorsed.classpath=
 excludes=
+file.reference.jaddressbook-core.jar=lib/jaddressbook-core.jar
 file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
 file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
 file.reference.juser-core.jar=lib/juser-core.jar
@@ -41,6 +42,7 @@ javac.classpath=\
     ${file.reference.juser-core.jar}:\
     ${file.reference.jcontacts-core.jar}:\
     ${file.reference.jcontacts-business-core.jar}:\
+    ${file.reference.jaddressbook-core.jar}:\
     ${libs.jpa20-persistence.classpath}
 # Space-separated list of extra javac options
 javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
@@ -65,7 +67,7 @@ javadoc.private=true
 javadoc.splitindex=true
 javadoc.use=true
 javadoc.version=true
-javadoc.windowtitle=JAddressbookCore
+javadoc.windowtitle=Addressbook-Share Model
 jnlp.codebase.type=no.codebase
 jnlp.descriptor=application
 jnlp.enabled=false
@@ -98,6 +100,7 @@ run.test.classpath=\
     ${javac.test.classpath}:\
     ${build.test.classes.dir}
 source.encoding=UTF-8
+source.reference.jaddressbook-core.jar=../jaddressbook-core/src/
 source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
 source.reference.jcontacts-core.jar=../jcontacts-core/src/
 source.reference.juser-core.jar=../juser-core/src/
index 7d531d54650cbfeda69fbac3a0e491eb81ae9057..2270728ac0a0587b2a691e81580b9748b3c13762 100644 (file)
@@ -3,7 +3,7 @@
     <type>org.netbeans.modules.java.j2seproject</type>
     <configuration>
         <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
-            <name>jaddressbook-core</name>
+            <name>jaddressbook-share-core</name>
             <source-roots>
                 <root id="src.dir"/>
             </source-roots>
diff --git a/src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java b/src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java
deleted file mode 100644 (file)
index 93438f7..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.addressbook;
-
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-
-/**
- * An event fired when an address book has been loaded
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class AddressbookLoadedEvent implements ObservableAddressbookLoadedEvent {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 48_305_823_537_427_713L;
-
-       /**
-        * Adress book instance causing this event
-        */
-       private final Addressbook addressbook;
-
-       /**
-        * Constructor with address book instance
-        * <p>
-        * @param addressbook Address book instance
-        */
-       public AddressbookLoadedEvent (final Addressbook addressbook) {
-               this.addressbook = addressbook;
-       }
-
-       @Override
-       public Addressbook getAddressbook () {
-               return this.addressbook;
-       }
-}
diff --git a/src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java b/src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java
deleted file mode 100644 (file)
index 292d28b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.addressbook;
-
-import java.io.Serializable;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-
-/**
- * An interface for an event if an address book has been loaded
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableAddressbookLoadedEvent extends Serializable {
-
-       /**
-        * Getter for address book instance
-        * <p>
-        * @return Address book instance
-        */
-       Addressbook getAddressbook ();
-}
diff --git a/src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java
deleted file mode 100644 (file)
index 34876f9..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.sharing;
-
-import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-
-/**
- * An event fired when a user ends sharing address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class EndedAddressbookSharingEvent implements ObservableAddressbookSharingEvent {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 152_896_748_186_018_497L;
-
-       /**
-        * Shared address book entry
-        */
-       private final ShareableAddressbook shareableAddressbook;
-
-       /**
-        * Constructor with address book share entry
-        * <p>
-        * @param share Address book share entry
-        */
-       public EndedAddressbookSharingEvent (final ShareableAddressbook share) {
-               this.shareableAddressbook = share;
-       }
-
-       @Override
-       public ShareableAddressbook getShareableAddressbook () {
-               return this.shareableAddressbook;
-       }
-
-       @Override
-       public SharingType getSharingType () {
-               // Started sharing
-               return SharingType.ENDED;
-       }
-}
diff --git a/src/org/mxchange/jaddressbookcore/events/sharing/ObservableAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookcore/events/sharing/ObservableAddressbookSharingEvent.java
deleted file mode 100644 (file)
index 70eb008..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.sharing;
-
-import java.io.Serializable;
-import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-
-/**
- * An interface for address book sharing events
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableAddressbookSharingEvent extends Serializable {
-
-       /**
-        * Getter for address book share instance
-        * <p>
-        * @return Address book share instance
-        */
-       ShareableAddressbook getShareableAddressbook ();
-
-       /**
-        * Getter for sharing type enum
-        * <p>
-        * @return Sharing type enum
-        */
-       SharingType getSharingType ();
-}
diff --git a/src/org/mxchange/jaddressbookcore/events/sharing/StartedAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookcore/events/sharing/StartedAddressbookSharingEvent.java
deleted file mode 100644 (file)
index 709065f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.sharing;
-
-import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-
-/**
- * An event fired when a user starts sharing address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class StartedAddressbookSharingEvent implements ObservableAddressbookSharingEvent {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 152_896_748_186_018_497L;
-
-       /**
-        * Shared address book entry
-        */
-       private final ShareableAddressbook shareableAddressbook;
-
-       /**
-        * Constructor with address book share entry
-        * <p>
-        * @param share Address book share entry
-        */
-       public StartedAddressbookSharingEvent (final ShareableAddressbook share) {
-               this.shareableAddressbook = share;
-       }
-
-       @Override
-       public ShareableAddressbook getShareableAddressbook () {
-               return this.shareableAddressbook;
-       }
-
-       @Override
-       public SharingType getSharingType () {
-               // Started sharing
-               return SharingType.STARTED;
-       }
-}
diff --git a/src/org/mxchange/jaddressbookcore/events/sharing/type/SharingType.java b/src/org/mxchange/jaddressbookcore/events/sharing/type/SharingType.java
deleted file mode 100644 (file)
index 81e21ff..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.events.sharing.type;
-
-/**
- * An enumeration for sharing types
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public enum SharingType {
-
-       /**
-        * Sharing has been started
-        */
-       STARTED,
-
-       /**
-        * Sharing has been ended
-        */
-       ENDED;
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java b/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java
deleted file mode 100644 (file)
index bc5cb3d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-
-/**
- * An exception thrown when the user has already used the name.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class AddressbookNameAlreadyUsedException extends Exception {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_169_748_928_767_381L;
-
-       /**
-        * Constructor with address book instance
-        * <p>
-        * @param addressbook Address book instance
-        */
-       public AddressbookNameAlreadyUsedException (final Addressbook addressbook) {
-               super(MessageFormat.format("User {0} has already used the name {1}.", addressbook.getAddressbookUser(), addressbook.getAddressbookName())); //NOI18N
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java b/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java
deleted file mode 100644 (file)
index 815a024..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.exceptions;
-
-import java.text.MessageFormat;
-
-/**
- * An exception thrown when the address book's id number is not valid, so no
- * address book can be found.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class AddressbookNotFoundException extends Exception {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 14_986_976_417_658_920L;
-
-       /**
-        * Creates an exception with given id number that could not be found.
-        * <p>
-        * @param addressbookId Address book id number
-        */
-       public AddressbookNotFoundException (final Long addressbookId) {
-               super(MessageFormat.format("Address book with id number {0} does not exist.", addressbookId));
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java b/src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java
deleted file mode 100644 (file)
index 6031de3..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An exception thrown whent the address book is already shared with given user
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserAlreadySharingAddressbookException extends Exception {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_528_177_571_976_034L;
-
-       /**
-        * Constructor with address book being already shared with sharee
-        * <p>
-        * @param addressbook Address book instance
-        * @param sharee User instance the address book is being shared with
-        */
-       public UserAlreadySharingAddressbookException (final Addressbook addressbook, final User sharee) {
-               super(MessageFormat.format("Address book id {0} owned by user {1} is already shared with user {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), sharee.getUserId()));
-       }
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java b/src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java
deleted file mode 100644 (file)
index e4312fa..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import org.mxchange.jaddressbookcore.model.addressbook.status.AddressbokStatus;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A POJI for addressbooks
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface Addressbook extends Serializable {
-
-       /**
-        * Getter for id number
-        * <p>
-        * @return Id number
-        */
-       Long getAddressbookId ();
-
-       /**
-        * Setter for id number
-        * <p>
-        * @param addressbookId Id number
-        */
-       void setAddressbookId (final Long addressbookId);
-
-       /**
-        * Getter for addressbook creation timestamp
-        * <p>
-        * @return Addressbook creation timestamp
-        */
-       Calendar getAddressbookCreated ();
-
-       /**
-        * Setter for addressbook creation timestamp
-        * <p>
-        * @param addressbookCreated Addressbook creation timestamp
-        */
-       void setAddressbookCreated (final Calendar addressbookCreated);
-
-       /**
-        * Getter for addressbook's name
-        * <p>
-        * @return Addressbook's name
-        */
-       String getAddressbookName ();
-
-       /**
-        * Setter for addressbook's name
-        * <p>
-        * @param addressbookName Addressbook's name
-        */
-       void setAddressbookName (final String addressbookName);
-
-       /**
-        * Getter for addressbook status
-        * <p>
-        * @return Addressbook status
-        */
-       AddressbokStatus getAddressbookStatus ();
-
-       /**
-        * Setter for addressbook status
-        * <p>
-        * @param addressbookStatus Addressbook status
-        */
-       void setAddressbookStatus (final AddressbokStatus addressbookStatus);
-
-       /**
-        * Getter for addressbook's user (owner)
-        * <p>
-        * @return Addressbook's user (owner)
-        */
-       User getAddressbookUser ();
-
-       /**
-        * Setter for addressbook's user (owner)
-        * <p>
-        * @param addressbookUser Addressbook's user (owner)
-        */
-       void setAddressbookUser (final User addressbookUser);
-
-       /**
-        * Getter for last locked timestamp
-        * <p>
-        * @return Last locked timestamp
-        */
-       Calendar getAddressbookLastLocked ();
-
-       /**
-        * Setter for last locked timestamp
-        * <p>
-        * @param addressbookLastLocked Last locked timestamp
-        */
-       void setAddressbookLastLocked (final Calendar addressbookLastLocked);
-
-       /**
-        * Getter for last locked reason
-        * <p>
-        * @return Last locked reason
-        */
-       String getAddressbookLastLockedReason ();
-
-       /**
-        * Getter for last locked reason
-        * <p>
-        * @param addressbookLastLockedReason Last locked reason
-        */
-       void setAddressbookLastLockedReason (final String addressbookLastLockedReason);
-
-       @Override
-       boolean equals (final Object object);
-
-       @Override
-       int hashCode ();
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java b/src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java
deleted file mode 100644 (file)
index 49f7b62..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook;
-
-import java.util.Calendar;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import org.mxchange.jaddressbookcore.model.addressbook.status.AddressbokStatus;
-import org.mxchange.jusercore.model.user.LoginUser;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A POJO for user addressbooks
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Entity (name = "addressbooks")
-@Table (name = "addressbooks")
-@NamedQueries (
-               {
-                       @NamedQuery (name = "AllUsersAddressbooks", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :param ORDER BY a.addressbookId ASC"),
-                       @NamedQuery (name = "SearchUserAddressbookName", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :user AND LOWER(a.addressbookName) LIKE LOWER(:name)"),
-                       @NamedQuery (name = "SearchAddressbookById", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookId = :id")
-               }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class UserAddressbook implements Addressbook {
-
-       /**
-        * Serial number
-        */
-       @Transient
-       private static final long serialVersionUID = 176_573_148_678_169L;
-
-       /**
-        * When this address book has been created
-        */
-       @Basic (optional = false)
-       @Temporal (value = TemporalType.TIMESTAMP)
-       @Column (name = "addressbook_created", nullable = false, updatable = false)
-       private Calendar addressbookCreated;
-
-       /**
-        * Id number
-        */
-       @Id
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "addressbook_id", nullable = false, updatable = false)
-       private Long addressbookId;
-
-       /**
-        * Last locked timestamp
-        */
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "addressbook_last_locked")
-       private Calendar addressbookLastLocked;
-
-       /**
-        * Last locked timestamp
-        */
-       @Lob
-       @Column (name = "addressbook_last_locked_reason")
-       private String addressbookLastLockedReason;
-
-       /**
-        * Name for this address book
-        */
-       @Basic (optional = false)
-       @Column (name = "addressbook_name", length = 50, nullable = false)
-       private String addressbookName;
-
-       /**
-        * Adress book status
-        */
-       @Basic (optional = false)
-       @Enumerated (EnumType.STRING)
-       @Column (name = "addressbook_status", nullable = false, length = 10)
-       private AddressbokStatus addressbookStatus;
-
-       /**
-        * Connection to "users" table
-        */
-       @JoinColumn (name = "addressbook_user_id", nullable = false)
-       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
-       private User addressbookUser;
-
-       /**
-        * Public constructor with address book name
-        * <p>
-        * @param addressbookName Address book name
-        * @param addressbookUser User instance
-        */
-       public UserAddressbook (final String addressbookName, final User addressbookUser) {
-               // Call default constructor
-               this();
-
-               // Set name and user instance
-               this.addressbookName = addressbookName;
-               this.addressbookUser = addressbookUser;
-       }
-
-       /**
-        * Default constructor
-        */
-       public UserAddressbook () {
-               // Set status to UNLOCKED
-               this.addressbookStatus = AddressbokStatus.UNLOCKED;
-       }
-
-       @Override
-       public boolean equals (final Object object) {
-               if (null == object) {
-                       return false;
-               } else if (this.getClass() != object.getClass()) {
-                       return false;
-               }
-
-               final Addressbook other = (Addressbook) object;
-
-               if (!Objects.equals(this.getAddressbookName(), other.getAddressbookName())) {
-                       return false;
-               } else if (!Objects.equals(this.getAddressbookUser(), other.getAddressbookUser())) {
-                       return false;
-               }
-
-               return true;
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 7;
-               hash = 59 * hash + Objects.hashCode(this.getAddressbookName());
-               hash = 59 * hash + Objects.hashCode(this.getAddressbookUser());
-               return hash;
-       }
-
-       @Override
-       public Calendar getAddressbookCreated () {
-               return this.addressbookCreated;
-       }
-
-       @Override
-       public void setAddressbookCreated (final Calendar addressbookCreated) {
-               this.addressbookCreated = addressbookCreated;
-       }
-
-       @Override
-       public Long getAddressbookId () {
-               return this.addressbookId;
-       }
-
-       @Override
-       public void setAddressbookId (final Long addressbookId) {
-               this.addressbookId = addressbookId;
-       }
-
-       @Override
-       public Calendar getAddressbookLastLocked () {
-               return this.addressbookLastLocked;
-       }
-
-       @Override
-       public void setAddressbookLastLocked (final Calendar addressbookLastLocked) {
-               this.addressbookLastLocked = addressbookLastLocked;
-       }
-
-       @Override
-       public String getAddressbookLastLockedReason () {
-               return this.addressbookLastLockedReason;
-       }
-
-       @Override
-       public void setAddressbookLastLockedReason (final String addressbookLastLockedReason) {
-               this.addressbookLastLockedReason = addressbookLastLockedReason;
-       }
-
-       @Override
-       public String getAddressbookName () {
-               return this.addressbookName;
-       }
-
-       @Override
-       public void setAddressbookName (final String addressbookName) {
-               this.addressbookName = addressbookName;
-       }
-
-       @Override
-       public AddressbokStatus getAddressbookStatus () {
-               return this.addressbookStatus;
-       }
-
-       @Override
-       public void setAddressbookStatus (final AddressbokStatus addressbookStatus) {
-               this.addressbookStatus = addressbookStatus;
-       }
-
-       @Override
-       public User getAddressbookUser () {
-               return this.addressbookUser;
-       }
-
-       @Override
-       public void setAddressbookUser (final User addressbookUser) {
-               this.addressbookUser = addressbookUser;
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java b/src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java
deleted file mode 100644 (file)
index 0927ed7..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook.entry;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontactsbusiness.BusinessContact;
-
-/**
- * A POJI for addressbook entries
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookEntry extends Serializable {
-
-       /**
-        * Getter for id number
-        * <p>
-        * @return Id number
-        */
-       Long getAddressbookEntryId ();
-
-       /**
-        * Setter for id number
-        * <p>
-        * @param addressbookEntryId Id number
-        */
-       void setAddressbookEntryId (final Long addressbookEntryId);
-
-       /**
-        * Getter for business contact
-        * <p>
-        * @return Business contact
-        */
-       BusinessContact getAddressbookEntryBusinessContact ();
-
-       /**
-        * Setter for business contact
-        * <p>
-        * @param addressbookEntryBusinessContact Business contact
-        */
-       void setAddressbookEntryBusinessContact (final BusinessContact addressbookEntryBusinessContact);
-
-       /**
-        * Getter for entry created timestamp
-        * <p>
-        * @return Entry created timestamp
-        */
-       Calendar getAddressbookEntryCreated ();
-
-       /**
-        * Setter for entry created timestamp
-        * <p>
-        * @param addressbookEntryCreated Entry created timestamp
-        */
-       void setAddressbookEntryCreated (final Calendar addressbookEntryCreated);
-
-       /**
-        * Getter for private contact
-        * <p>
-        * @return Private contact
-        */
-       Contact getAddressbookEntryPrivateContact ();
-
-       /**
-        * Setter for private contact
-        * <p>
-        * @param addressbookEntryPrivateContact Private contact
-        */
-       void setAddressbookEntryPrivateContact (final Contact addressbookEntryPrivateContact);
-
-       /**
-        * Getter for address book
-        * <p>
-        * @return Address book
-        */
-       Addressbook getAddressbookId ();
-
-       /**
-        * Setter for address book
-        * <p>
-        * @param addressbookId Address book
-        */
-       void setAddressbookId (final Addressbook addressbookId);
-
-       @Override
-       boolean equals (final Object object);
-
-       @Override
-       int hashCode ();
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java b/src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java
deleted file mode 100644 (file)
index 5007393..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook.entry;
-
-import java.util.Calendar;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.UserAddressbook;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontactsbusiness.BusinessContact;
-import org.mxchange.jcontactsbusiness.CompanyContact;
-
-/**
- * A POJO for address book entries
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Entity (name = "addressbook_entries")
-@Table (name = "addressbook_entries")
-@NamedQueries (
-               @NamedQuery (
-                               name = "SearchUsersAddressbookEntries",
-                               query = "SELECT e FROM addressbook_entries AS e INNER JOIN addressbooks AS a ON e.addressbookId = a WHERE e.addressbookId = :addressbook AND a.addressbookUser = :owner ORDER BY e.addressbookEntryId ASC")
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class UserAddressbookEntry implements AddressbookEntry {
-
-       /**
-        * Serial number
-        */
-       @Transient
-       private static final long serialVersionUID = 178_581_768_581_960L;
-
-       /**
-        * Connection to table "business_contacts" (commercial contacts)
-        */
-       @JoinColumn (name = "entry_business_contact_id", updatable = false)
-       @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.REFRESH)
-       private BusinessContact addressbookEntryBusinessContact;
-
-       /**
-        * When this address book entry has been created
-        */
-       @Basic (optional = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "entry_created", nullable = false, updatable = false)
-       private Calendar addressbookEntryCreated;
-
-       /**
-        * Id number
-        */
-       @Id
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "entry_id", nullable = false, updatable = false)
-       private Long addressbookEntryId;
-
-       /**
-        * Connection to table "contacts" (private contacts)
-        */
-       @JoinColumn (name = "entry_private_contact_id", updatable = false)
-       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH)
-       private Contact addressbookEntryPrivateContact;
-
-       /**
-        * Connection to table "addressbooks"
-        */
-       @JoinColumn (name = "entry_addressbook_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.REFRESH, optional = false)
-       private Addressbook addressbookId;
-
-       @Override
-       public boolean equals (final Object object) {
-               if (null == object) {
-                       return false;
-               } else if (this.getClass() != object.getClass()) {
-                       return false;
-               }
-
-               final AddressbookEntry other = (AddressbookEntry) object;
-
-               if (!Objects.equals(this.getAddressbookEntryBusinessContact(), other.getAddressbookEntryBusinessContact())) {
-                       return false;
-               } else if (!Objects.equals(this.getAddressbookEntryPrivateContact(), other.getAddressbookEntryPrivateContact())) {
-                       return false;
-               } else if (!Objects.equals(this.getAddressbookId(), other.getAddressbookId())) {
-                       return false;
-               }
-
-               return true;
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 3;
-
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessContact());
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookId());
-
-               return hash;
-       }
-
-       @Override
-       public BusinessContact getAddressbookEntryBusinessContact () {
-               return this.addressbookEntryBusinessContact;
-       }
-
-       @Override
-       public void setAddressbookEntryBusinessContact (final BusinessContact addressbookEntryBusinessContact) {
-               this.addressbookEntryBusinessContact = addressbookEntryBusinessContact;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Calendar getAddressbookEntryCreated () {
-               return this.addressbookEntryCreated;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setAddressbookEntryCreated (final Calendar addressbookEntryCreated) {
-               this.addressbookEntryCreated = addressbookEntryCreated;
-       }
-
-       @Override
-       public Long getAddressbookEntryId () {
-               return this.addressbookEntryId;
-       }
-
-       @Override
-       public void setAddressbookEntryId (final Long addressbookEntryId) {
-               this.addressbookEntryId = addressbookEntryId;
-       }
-
-       @Override
-       public Contact getAddressbookEntryPrivateContact () {
-               return this.addressbookEntryPrivateContact;
-       }
-
-       @Override
-       public void setAddressbookEntryPrivateContact (final Contact addressbookEntryPrivateContact) {
-               this.addressbookEntryPrivateContact = addressbookEntryPrivateContact;
-       }
-
-       @Override
-       public Addressbook getAddressbookId () {
-               return this.addressbookId;
-       }
-
-       @Override
-       public void setAddressbookId (final Addressbook addressbookId) {
-               this.addressbookId = addressbookId;
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java
deleted file mode 100644 (file)
index 7b379f3..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook.shared;
-
-import java.text.MessageFormat;
-import java.util.Calendar;
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.UserAddressbook;
-import org.mxchange.jusercore.model.user.LoginUser;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A POJO for sharing address books with other users
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Entity (name = "addressbook_shares")
-@Table (name = "addressbook_shares")
-@NamedQueries (
-               {
-                       @NamedQuery (
-                                       name = "SearchUserSharedAddressbooks",
-                                       query = "SELECT s FROM addressbook_shares AS s WHERE s.shareUserOwner = :user ORDER BY s.shareId ASC"
-                       ),
-                       @NamedQuery (
-                                       name = "SearchShareeAddressbookShare",
-                                       query = "SELECT s FROM addressbook_shares AS s WHERE s.shareAddressbook = :addressbook AND s.shareUserSharee = :sharee"
-                       )
-               }
-)
-@SuppressWarnings ("PersistenceUnitPresent")
-public class AddressbookShare implements ShareableAddressbook {
-
-       /**
-        * Serial number
-        */
-       @Transient
-       private static final long serialVersionUID = 167_889_678_177_691_690L;
-
-       /**
-        * Address book this share is for
-        */
-       @JoinColumn (name = "share_addressbook_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.REFRESH, optional = false)
-       private Addressbook shareAddressbook;
-
-       /**
-        * When this share has been created
-        */
-       @Basic (optional = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "share_created", nullable = false, updatable = false)
-       private Calendar shareCreated;
-
-       /**
-        * Id number
-        */
-       @Id
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       @Column (name = "share_id", nullable = false, updatable = false)
-       private Long shareId;
-
-       /**
-        * User who is owning the share
-        */
-       @JoinColumn (name = "share_owner_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
-       private User shareUserOwner;
-
-       /**
-        * User the address book is shared with
-        */
-       @JoinColumn (name = "share_sharee_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
-       private User shareUserSharee;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookShare () {
-       }
-
-       /**
-        * Constructor with address book and sharee instance. Both parameters must
-        * not be null, their id numbers must be set and the adress book's user
-        * instance must be set and have a valid id set.
-        * <p>
-        * @param addressbook Address book instance
-        * @param sharee User sharee instance
-        */
-       public AddressbookShare (final Addressbook addressbook, final User sharee) {
-               // Call default constructor
-               this();
-
-               // Check all conditions
-               if (null == sharee) {
-                       // Throw NPE
-                       throw new NullPointerException("sharee is null"); //NOI18N
-               } else if (sharee.getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("sharee.userId is null"); //NOI18N
-               } else if (sharee.getUserId() < 1) {
-                       // Invalid id number
-                       throw new IllegalStateException(MessageFormat.format("sharee.userId={0} is invalid", sharee.getUserId())); //NOI18N
-               } else if (null == addressbook) {
-                       // Throw NPE again
-                       throw new NullPointerException("addressbook is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
-               } else if (Objects.equals(addressbook.getAddressbookUser(), sharee)) {
-                       // Sharing with yourself!
-                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
-               }
-
-               // Set all instances
-               this.shareAddressbook = addressbook;
-               this.shareUserOwner = addressbook.getAddressbookUser();
-               this.shareUserSharee = sharee;
-       }
-
-       @Override
-       public boolean equals (final Object object) {
-               if (null == object) {
-                       return false;
-               } else if (this.getClass() != object.getClass()) {
-                       return false;
-               }
-
-               final ShareableAddressbook other = (ShareableAddressbook) object;
-
-               if (!Objects.equals(this.getShareAddressbook(), other.getShareAddressbook())) {
-                       return false;
-               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
-                       return false;
-               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
-                       return false;
-               }
-
-               return Objects.equals(this.getShareUserSharee(), other.getShareUserSharee());
-       }
-
-       @Override
-       public int hashCode () {
-               int hash = 7;
-               hash = 19 * hash + Objects.hashCode(this.getShareAddressbook());
-               hash = 19 * hash + Objects.hashCode(this.getShareUserOwner());
-               hash = 19 * hash + Objects.hashCode(this.getShareUserSharee());
-               return hash;
-       }
-
-       @Override
-       public Addressbook getShareAddressbook () {
-               return this.shareAddressbook;
-       }
-
-       @Override
-       public void setShareAddressbook (final Addressbook shareAddressbook) {
-               this.shareAddressbook = shareAddressbook;
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Calendar getShareCreated () {
-               return this.shareCreated;
-       }
-
-       @Override
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setShareCreated (final Calendar shareCreated) {
-               this.shareCreated = shareCreated;
-       }
-
-       @Override
-       public Long getShareId () {
-               return this.shareId;
-       }
-
-       @Override
-       public void setShareId (final Long shareId) {
-               this.shareId = shareId;
-       }
-
-       @Override
-       public User getShareUserOwner () {
-               return this.shareUserOwner;
-       }
-
-       @Override
-       public void setShareUserOwner (final User shareUserOwner) {
-               this.shareUserOwner = shareUserOwner;
-       }
-
-       @Override
-       public User getShareUserSharee () {
-               return this.shareUserSharee;
-       }
-
-       @Override
-       public void setShareUserSharee (final User shareUserSharee) {
-               this.shareUserSharee = shareUserSharee;
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/shared/ShareableAddressbook.java b/src/org/mxchange/jaddressbookcore/model/addressbook/shared/ShareableAddressbook.java
deleted file mode 100644 (file)
index b8f3855..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook.shared;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A POJI for shared address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ShareableAddressbook extends Serializable {
-
-       /**
-        * Getter for shared address book instance
-        * <p>
-        * @return Shared address book instance
-        */
-       Addressbook getShareAddressbook ();
-
-       /**
-        * Setter for shared address book instance
-        * <p>
-        * @param shareAddressbook Shared address book instance
-        */
-       void setShareAddressbook (final Addressbook shareAddressbook);
-
-       /**
-        * Getter for id number
-        * <p>
-        * @return Id number
-        */
-       Long getShareId ();
-
-       /**
-        * Setter for id number
-        * <p>
-        * @param shareId Id number
-        */
-       void setShareId (final Long shareId);
-
-       /**
-        * Getter for address book owner instance
-        * <p>
-        * @return Address book owner instance
-        */
-       User getShareUserOwner ();
-
-       /**
-        * Setter for address book owner instance
-        * <p>
-        * @param shareUserOwner Address book owner instance
-        */
-       void setShareUserOwner (final User shareUserOwner);
-
-       /**
-        * Getter for address book sharee instance
-        * <p>
-        * @return Address book sharee instance
-        */
-       User getShareUserSharee ();
-
-       /**
-        * Setter for address book sharee instance
-        * <p>
-        * @param shareUserSharer Address book sharee instance
-        */
-       void setShareUserSharee (final User shareUserSharer);
-
-       /**
-        * Getter for share creation timestamp
-        * <p>
-        * @return Share creation timestamp
-        */
-       Calendar getShareCreated ();
-
-       /**
-        * Setter for share creation timestamp
-        * <p>
-        * @param shareCreated Share creation timestamp
-        */
-       void setShareCreated (final Calendar shareCreated);
-
-       @Override
-       boolean equals (final Object object);
-
-       @Override
-       int hashCode ();
-}
diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java b/src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java
deleted file mode 100644 (file)
index 544ebe6..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jaddressbookcore.model.addressbook.status;
-
-import java.io.Serializable;
-
-/**
- * An enumeration for the addressbook status
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public enum AddressbokStatus implements Serializable {
-
-       /**
-        * When the addressbook is unlocked
-        */
-       UNLOCKED("ADDRESSBOOK_STATUS_UNLOCKED"), //NOI18N
-
-       /**
-        * When the addressbook is locked by administrator
-        */
-       LOCKED("ADDRESSBOOK_STATUS_LOCKED"); //NOI18N
-
-       /**
-        * Message key
-        */
-       private final String messageKey;
-
-       /**
-        * Constructor
-        * <p>
-        * @param messageKey Message key for this enum
-        */
-       private AddressbokStatus (final String messageKey) {
-               this.messageKey = messageKey;
-       }
-
-       /**
-        * Getter for message key
-        * <p>
-        * @return Message key
-        */
-       public String getMessageKey () {
-               return this.messageKey;
-       }
-
-}
diff --git a/src/org/mxchange/jaddressbookshare/events/sharing/EndedAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookshare/events/sharing/EndedAddressbookSharingEvent.java
new file mode 100644 (file)
index 0000000..19b2eb3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.events.sharing;
+
+import org.mxchange.jaddressbookshare.events.sharing.type.SharingType;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+
+/**
+ * An event fired when a user ends sharing address books
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class EndedAddressbookSharingEvent implements ObservableAddressbookSharingEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 152_896_748_186_018_497L;
+
+       /**
+        * Shared address book entry
+        */
+       private final ShareableAddressbook shareableAddressbook;
+
+       /**
+        * Constructor with address book share entry
+        * <p>
+        * @param share Address book share entry
+        */
+       public EndedAddressbookSharingEvent (final ShareableAddressbook share) {
+               this.shareableAddressbook = share;
+       }
+
+       @Override
+       public ShareableAddressbook getShareableAddressbook () {
+               return this.shareableAddressbook;
+       }
+
+       @Override
+       public SharingType getSharingType () {
+               // Started sharing
+               return SharingType.ENDED;
+       }
+}
diff --git a/src/org/mxchange/jaddressbookshare/events/sharing/ObservableAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookshare/events/sharing/ObservableAddressbookSharingEvent.java
new file mode 100644 (file)
index 0000000..6796045
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.events.sharing;
+
+import java.io.Serializable;
+import org.mxchange.jaddressbookshare.events.sharing.type.SharingType;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+
+/**
+ * An interface for address book sharing events
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableAddressbookSharingEvent extends Serializable {
+
+       /**
+        * Getter for address book share instance
+        * <p>
+        * @return Address book share instance
+        */
+       ShareableAddressbook getShareableAddressbook ();
+
+       /**
+        * Getter for sharing type enum
+        * <p>
+        * @return Sharing type enum
+        */
+       SharingType getSharingType ();
+}
diff --git a/src/org/mxchange/jaddressbookshare/events/sharing/StartedAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookshare/events/sharing/StartedAddressbookSharingEvent.java
new file mode 100644 (file)
index 0000000..16c9b60
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.events.sharing;
+
+import org.mxchange.jaddressbookshare.events.sharing.type.SharingType;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+
+/**
+ * An event fired when a user starts sharing address books
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class StartedAddressbookSharingEvent implements ObservableAddressbookSharingEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 152_896_748_186_018_497L;
+
+       /**
+        * Shared address book entry
+        */
+       private final ShareableAddressbook shareableAddressbook;
+
+       /**
+        * Constructor with address book share entry
+        * <p>
+        * @param share Address book share entry
+        */
+       public StartedAddressbookSharingEvent (final ShareableAddressbook share) {
+               this.shareableAddressbook = share;
+       }
+
+       @Override
+       public ShareableAddressbook getShareableAddressbook () {
+               return this.shareableAddressbook;
+       }
+
+       @Override
+       public SharingType getSharingType () {
+               // Started sharing
+               return SharingType.STARTED;
+       }
+}
diff --git a/src/org/mxchange/jaddressbookshare/events/sharing/type/SharingType.java b/src/org/mxchange/jaddressbookshare/events/sharing/type/SharingType.java
new file mode 100644 (file)
index 0000000..51a5b93
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.events.sharing.type;
+
+/**
+ * An enumeration for sharing types
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public enum SharingType {
+
+       /**
+        * Sharing has been started
+        */
+       STARTED,
+
+       /**
+        * Sharing has been ended
+        */
+       ENDED;
+
+}
diff --git a/src/org/mxchange/jaddressbookshare/exceptions/UserAlreadySharingAddressbookException.java b/src/org/mxchange/jaddressbookshare/exceptions/UserAlreadySharingAddressbookException.java
new file mode 100644 (file)
index 0000000..d6bfe5a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.exceptions;
+
+import java.text.MessageFormat;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An exception thrown whent the address book is already shared with given user
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class UserAlreadySharingAddressbookException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_528_177_571_976_034L;
+
+       /**
+        * Constructor with address book being already shared with sharee
+        * <p>
+        * @param addressbook Address book instance
+        * @param sharee User instance the address book is being shared with
+        */
+       public UserAlreadySharingAddressbookException (final Addressbook addressbook, final User sharee) {
+               super(MessageFormat.format("Address book id {0} owned by user {1} is already shared with user {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), sharee.getUserId()));
+       }
+}
diff --git a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/AddressbookShare.java
new file mode 100644 (file)
index 0000000..b5b6f4e
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.model.addressbook.shared;
+
+import java.text.MessageFormat;
+import java.util.Calendar;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbook.model.addressbook.UserAddressbook;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJO for sharing address books with other users
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Entity (name = "addressbook_shares")
+@Table (name = "addressbook_shares")
+@NamedQueries (
+               {
+                       @NamedQuery (
+                                       name = "SearchUserSharedAddressbooks",
+                                       query = "SELECT s FROM addressbook_shares AS s WHERE s.shareUserOwner = :user ORDER BY s.shareId ASC"
+                       ),
+                       @NamedQuery (
+                                       name = "SearchShareeAddressbookShare",
+                                       query = "SELECT s FROM addressbook_shares AS s WHERE s.shareAddressbook = :addressbook AND s.shareUserSharee = :sharee"
+                       )
+               }
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class AddressbookShare implements ShareableAddressbook {
+
+       /**
+        * Serial number
+        */
+       @Transient
+       private static final long serialVersionUID = 167_889_678_177_691_690L;
+
+       /**
+        * Address book this share is for
+        */
+       @JoinColumn (name = "share_addressbook_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.REFRESH, optional = false)
+       private Addressbook shareAddressbook;
+
+       /**
+        * When this share has been created
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "share_created", nullable = false, updatable = false)
+       private Calendar shareCreated;
+
+       /**
+        * Id number
+        */
+       @Id
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       @Column (name = "share_id", nullable = false, updatable = false)
+       private Long shareId;
+
+       /**
+        * User who is owning the share
+        */
+       @JoinColumn (name = "share_owner_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
+       private User shareUserOwner;
+
+       /**
+        * User the address book is shared with
+        */
+       @JoinColumn (name = "share_sharee_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
+       private User shareUserSharee;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookShare () {
+       }
+
+       /**
+        * Constructor with address book and sharee instance. Both parameters must
+        * not be null, their id numbers must be set and the adress book's user
+        * instance must be set and have a valid id set.
+        * <p>
+        * @param addressbook Address book instance
+        * @param sharee User sharee instance
+        */
+       public AddressbookShare (final Addressbook addressbook, final User sharee) {
+               // Call default constructor
+               this();
+
+               // Check all conditions
+               if (null == sharee) {
+                       // Throw NPE
+                       throw new NullPointerException("sharee is null"); //NOI18N
+               } else if (sharee.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("sharee.userId is null"); //NOI18N
+               } else if (sharee.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalStateException(MessageFormat.format("sharee.userId={0} is invalid", sharee.getUserId())); //NOI18N
+               } else if (null == addressbook) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
+               } else if (Objects.equals(addressbook.getAddressbookUser(), sharee)) {
+                       // Sharing with yourself!
+                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
+               }
+
+               // Set all instances
+               this.shareAddressbook = addressbook;
+               this.shareUserOwner = addressbook.getAddressbookUser();
+               this.shareUserSharee = sharee;
+       }
+
+       @Override
+       public boolean equals (final Object object) {
+               if (null == object) {
+                       return false;
+               } else if (this.getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final ShareableAddressbook other = (ShareableAddressbook) object;
+
+               if (!Objects.equals(this.getShareAddressbook(), other.getShareAddressbook())) {
+                       return false;
+               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
+                       return false;
+               } else if (!Objects.equals(this.getShareUserOwner(), other.getShareUserOwner())) {
+                       return false;
+               }
+
+               return Objects.equals(this.getShareUserSharee(), other.getShareUserSharee());
+       }
+
+       @Override
+       public int hashCode () {
+               int hash = 7;
+               hash = 19 * hash + Objects.hashCode(this.getShareAddressbook());
+               hash = 19 * hash + Objects.hashCode(this.getShareUserOwner());
+               hash = 19 * hash + Objects.hashCode(this.getShareUserSharee());
+               return hash;
+       }
+
+       @Override
+       public Addressbook getShareAddressbook () {
+               return this.shareAddressbook;
+       }
+
+       @Override
+       public void setShareAddressbook (final Addressbook shareAddressbook) {
+               this.shareAddressbook = shareAddressbook;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getShareCreated () {
+               return this.shareCreated;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setShareCreated (final Calendar shareCreated) {
+               this.shareCreated = shareCreated;
+       }
+
+       @Override
+       public Long getShareId () {
+               return this.shareId;
+       }
+
+       @Override
+       public void setShareId (final Long shareId) {
+               this.shareId = shareId;
+       }
+
+       @Override
+       public User getShareUserOwner () {
+               return this.shareUserOwner;
+       }
+
+       @Override
+       public void setShareUserOwner (final User shareUserOwner) {
+               this.shareUserOwner = shareUserOwner;
+       }
+
+       @Override
+       public User getShareUserSharee () {
+               return this.shareUserSharee;
+       }
+
+       @Override
+       public void setShareUserSharee (final User shareUserSharee) {
+               this.shareUserSharee = shareUserSharee;
+       }
+
+}
diff --git a/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java b/src/org/mxchange/jaddressbookshare/model/addressbook/shared/ShareableAddressbook.java
new file mode 100644 (file)
index 0000000..1683e63
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jaddressbookshare.model.addressbook.shared;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJI for shared address books
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ShareableAddressbook extends Serializable {
+
+       /**
+        * Getter for shared address book instance
+        * <p>
+        * @return Shared address book instance
+        */
+       Addressbook getShareAddressbook ();
+
+       /**
+        * Setter for shared address book instance
+        * <p>
+        * @param shareAddressbook Shared address book instance
+        */
+       void setShareAddressbook (final Addressbook shareAddressbook);
+
+       /**
+        * Getter for id number
+        * <p>
+        * @return Id number
+        */
+       Long getShareId ();
+
+       /**
+        * Setter for id number
+        * <p>
+        * @param shareId Id number
+        */
+       void setShareId (final Long shareId);
+
+       /**
+        * Getter for address book owner instance
+        * <p>
+        * @return Address book owner instance
+        */
+       User getShareUserOwner ();
+
+       /**
+        * Setter for address book owner instance
+        * <p>
+        * @param shareUserOwner Address book owner instance
+        */
+       void setShareUserOwner (final User shareUserOwner);
+
+       /**
+        * Getter for address book sharee instance
+        * <p>
+        * @return Address book sharee instance
+        */
+       User getShareUserSharee ();
+
+       /**
+        * Setter for address book sharee instance
+        * <p>
+        * @param shareUserSharer Address book sharee instance
+        */
+       void setShareUserSharee (final User shareUserSharer);
+
+       /**
+        * Getter for share creation timestamp
+        * <p>
+        * @return Share creation timestamp
+        */
+       Calendar getShareCreated ();
+
+       /**
+        * Setter for share creation timestamp
+        * <p>
+        * @param shareCreated Share creation timestamp
+        */
+       void setShareCreated (final Calendar shareCreated);
+
+       @Override
+       boolean equals (final Object object);
+
+       @Override
+       int hashCode ();
+}