From 7d8636fa76427c2dff18439392c4f8f3c82bcd23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 27 Apr 2017 14:24:56 +0200 Subject: [PATCH] moved out to new project jaddressbook-share-core + renamed package MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- nbproject/project.properties | 2 +- .../addressbook/AddressbookLoadedEvent.java | 4 +- .../ObservableAddressbookLoadedEvent.java | 4 +- .../AddressbookNameAlreadyUsedException.java | 4 +- .../AddressbookNotFoundException.java | 2 +- .../model/addressbook/Addressbook.java | 4 +- .../model/addressbook/UserAddressbook.java | 4 +- .../addressbook/entry/AddressbookEntry.java | 4 +- .../entry/UserAddressbookEntry.java | 6 +- .../addressbook/status/AddressbokStatus.java | 2 +- .../sharing/EndedAddressbookSharingEvent.java | 58 ----- .../ObservableAddressbookSharingEvent.java | 43 ---- .../StartedAddressbookSharingEvent.java | 58 ----- .../events/sharing/type/SharingType.java | 36 --- ...serAlreadySharingAddressbookException.java | 44 ---- .../addressbook/shared/AddressbookShare.java | 237 ------------------ .../shared/ShareableAddressbook.java | 106 -------- 17 files changed, 18 insertions(+), 600 deletions(-) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/events/addressbook/AddressbookLoadedEvent.java (91%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/events/addressbook/ObservableAddressbookLoadedEvent.java (89%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/exceptions/AddressbookNameAlreadyUsedException.java (92%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/exceptions/AddressbookNotFoundException.java (96%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/model/addressbook/Addressbook.java (95%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/model/addressbook/UserAddressbook.java (97%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/model/addressbook/entry/AddressbookEntry.java (95%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/model/addressbook/entry/UserAddressbookEntry.java (96%) rename src/org/mxchange/{jaddressbookcore => jaddressbook}/model/addressbook/status/AddressbokStatus.java (95%) delete mode 100644 src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java delete mode 100644 src/org/mxchange/jaddressbookcore/events/sharing/ObservableAddressbookSharingEvent.java delete mode 100644 src/org/mxchange/jaddressbookcore/events/sharing/StartedAddressbookSharingEvent.java delete mode 100644 src/org/mxchange/jaddressbookcore/events/sharing/type/SharingType.java delete mode 100644 src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java delete mode 100644 src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java delete mode 100644 src/org/mxchange/jaddressbookcore/model/addressbook/shared/ShareableAddressbook.java diff --git a/nbproject/project.properties b/nbproject/project.properties index 413a0d3..6fdd9b2 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -65,7 +65,7 @@ javadoc.private=true javadoc.splitindex=true javadoc.use=true javadoc.version=true -javadoc.windowtitle=JAddressbookCore +javadoc.windowtitle=Addressbook Model jnlp.codebase.type=no.codebase jnlp.descriptor=application jnlp.enabled=false diff --git a/src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java b/src/org/mxchange/jaddressbook/events/addressbook/AddressbookLoadedEvent.java similarity index 91% rename from src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java rename to src/org/mxchange/jaddressbook/events/addressbook/AddressbookLoadedEvent.java index 93438f7..5d1e49c 100644 --- a/src/org/mxchange/jaddressbookcore/events/addressbook/AddressbookLoadedEvent.java +++ b/src/org/mxchange/jaddressbook/events/addressbook/AddressbookLoadedEvent.java @@ -14,9 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.events.addressbook; +package org.mxchange.jaddressbook.events.addressbook; -import org.mxchange.jaddressbookcore.model.addressbook.Addressbook; +import org.mxchange.jaddressbook.model.addressbook.Addressbook; /** * An event fired when an address book has been loaded diff --git a/src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java b/src/org/mxchange/jaddressbook/events/addressbook/ObservableAddressbookLoadedEvent.java similarity index 89% rename from src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java rename to src/org/mxchange/jaddressbook/events/addressbook/ObservableAddressbookLoadedEvent.java index 292d28b..f999909 100644 --- a/src/org/mxchange/jaddressbookcore/events/addressbook/ObservableAddressbookLoadedEvent.java +++ b/src/org/mxchange/jaddressbook/events/addressbook/ObservableAddressbookLoadedEvent.java @@ -14,10 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.events.addressbook; +package org.mxchange.jaddressbook.events.addressbook; import java.io.Serializable; -import org.mxchange.jaddressbookcore.model.addressbook.Addressbook; +import org.mxchange.jaddressbook.model.addressbook.Addressbook; /** * An interface for an event if an address book has been loaded diff --git a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java b/src/org/mxchange/jaddressbook/exceptions/AddressbookNameAlreadyUsedException.java similarity index 92% rename from src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java rename to src/org/mxchange/jaddressbook/exceptions/AddressbookNameAlreadyUsedException.java index bc5cb3d..b30209e 100644 --- a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNameAlreadyUsedException.java +++ b/src/org/mxchange/jaddressbook/exceptions/AddressbookNameAlreadyUsedException.java @@ -14,10 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.exceptions; +package org.mxchange.jaddressbook.exceptions; import java.text.MessageFormat; -import org.mxchange.jaddressbookcore.model.addressbook.Addressbook; +import org.mxchange.jaddressbook.model.addressbook.Addressbook; /** * An exception thrown when the user has already used the name. diff --git a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java b/src/org/mxchange/jaddressbook/exceptions/AddressbookNotFoundException.java similarity index 96% rename from src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java rename to src/org/mxchange/jaddressbook/exceptions/AddressbookNotFoundException.java index 815a024..2b7265b 100644 --- a/src/org/mxchange/jaddressbookcore/exceptions/AddressbookNotFoundException.java +++ b/src/org/mxchange/jaddressbook/exceptions/AddressbookNotFoundException.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.exceptions; +package org.mxchange.jaddressbook.exceptions; import java.text.MessageFormat; diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java b/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java similarity index 95% rename from src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java rename to src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java index e4312fa..3def9bd 100644 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/Addressbook.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/Addressbook.java @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.model.addressbook; +package org.mxchange.jaddressbook.model.addressbook; import java.io.Serializable; import java.util.Calendar; -import org.mxchange.jaddressbookcore.model.addressbook.status.AddressbokStatus; +import org.mxchange.jaddressbook.model.addressbook.status.AddressbokStatus; import org.mxchange.jusercore.model.user.User; /** diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java similarity index 97% rename from src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java rename to src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java index 49f7b62..dbe9094 100644 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/UserAddressbook.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/UserAddressbook.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.model.addressbook; +package org.mxchange.jaddressbook.model.addressbook; import java.util.Calendar; import java.util.Objects; @@ -36,7 +36,7 @@ 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.jaddressbook.model.addressbook.status.AddressbokStatus; import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java b/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java similarity index 95% rename from src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java rename to src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java index 0927ed7..a62c902 100644 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/AddressbookEntry.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/entry/AddressbookEntry.java @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.model.addressbook.entry; +package org.mxchange.jaddressbook.model.addressbook.entry; import java.io.Serializable; import java.util.Calendar; -import org.mxchange.jaddressbookcore.model.addressbook.Addressbook; +import org.mxchange.jaddressbook.model.addressbook.Addressbook; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontactsbusiness.BusinessContact; diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java b/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java similarity index 96% rename from src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java rename to src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java index 5007393..0dc6272 100644 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/entry/UserAddressbookEntry.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/entry/UserAddressbookEntry.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.model.addressbook.entry; +package org.mxchange.jaddressbook.model.addressbook.entry; import java.util.Calendar; import java.util.Objects; @@ -33,8 +33,8 @@ 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.jaddressbook.model.addressbook.Addressbook; +import org.mxchange.jaddressbook.model.addressbook.UserAddressbook; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontactsbusiness.BusinessContact; diff --git a/src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java b/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java similarity index 95% rename from src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java rename to src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java index 544ebe6..49e32d2 100644 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/status/AddressbokStatus.java +++ b/src/org/mxchange/jaddressbook/model/addressbook/status/AddressbokStatus.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jaddressbookcore.model.addressbook.status; +package org.mxchange.jaddressbook.model.addressbook.status; import java.io.Serializable; diff --git a/src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java b/src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java deleted file mode 100644 index 34876f9..0000000 --- a/src/org/mxchange/jaddressbookcore/events/sharing/EndedAddressbookSharingEvent.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -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 - *

- * @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 index 70eb008..0000000 --- a/src/org/mxchange/jaddressbookcore/events/sharing/ObservableAddressbookSharingEvent.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -public interface ObservableAddressbookSharingEvent extends Serializable { - - /** - * Getter for address book share instance - *

- * @return Address book share instance - */ - ShareableAddressbook getShareableAddressbook (); - - /** - * Getter for sharing type enum - *

- * @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 index 709065f..0000000 --- a/src/org/mxchange/jaddressbookcore/events/sharing/StartedAddressbookSharingEvent.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -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 - *

- * @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 index 81e21ff..0000000 --- a/src/org/mxchange/jaddressbookcore/events/sharing/type/SharingType.java +++ /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 . - */ -package org.mxchange.jaddressbookcore.events.sharing.type; - -/** - * An enumeration for sharing types - *

- * @author Roland Häder - */ -public enum SharingType { - - /** - * Sharing has been started - */ - STARTED, - - /** - * Sharing has been ended - */ - ENDED; - -} diff --git a/src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java b/src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java deleted file mode 100644 index 6031de3..0000000 --- a/src/org/mxchange/jaddressbookcore/exceptions/UserAlreadySharingAddressbookException.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -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 - *

- * @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/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java deleted file mode 100644 index 7b379f3..0000000 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/shared/AddressbookShare.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -@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. - *

- * @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 index b8f3855..0000000 --- a/src/org/mxchange/jaddressbookcore/model/addressbook/shared/ShareableAddressbook.java +++ /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 . - */ -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 - *

- * @author Roland Häder - */ -public interface ShareableAddressbook extends Serializable { - - /** - * Getter for shared address book instance - *

- * @return Shared address book instance - */ - Addressbook getShareAddressbook (); - - /** - * Setter for shared address book instance - *

- * @param shareAddressbook Shared address book instance - */ - void setShareAddressbook (final Addressbook shareAddressbook); - - /** - * Getter for id number - *

- * @return Id number - */ - Long getShareId (); - - /** - * Setter for id number - *

- * @param shareId Id number - */ - void setShareId (final Long shareId); - - /** - * Getter for address book owner instance - *

- * @return Address book owner instance - */ - User getShareUserOwner (); - - /** - * Setter for address book owner instance - *

- * @param shareUserOwner Address book owner instance - */ - void setShareUserOwner (final User shareUserOwner); - - /** - * Getter for address book sharee instance - *

- * @return Address book sharee instance - */ - User getShareUserSharee (); - - /** - * Setter for address book sharee instance - *

- * @param shareUserSharer Address book sharee instance - */ - void setShareUserSharee (final User shareUserSharer); - - /** - * Getter for share creation timestamp - *

- * @return Share creation timestamp - */ - Calendar getShareCreated (); - - /** - * Setter for share creation timestamp - *

- * @param shareCreated Share creation timestamp - */ - void setShareCreated (final Calendar shareCreated); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); -} -- 2.39.5