2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jjobs.beans.addressbook;
19 import java.io.Serializable;
20 import java.util.Calendar;
21 import java.util.List;
22 import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
23 import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
24 import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
25 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
26 import org.mxchange.jusercore.model.user.User;
29 * An interface for address book beans
31 * @author Roland Haeder<roland@mxchange.org>
33 public interface JobsAddressbookWebSessionController extends Serializable {
36 * Checks whether the user has created addressbooks. For this method to work
37 * it is vital that the user is logged into his/her account.
39 * @return Whether the user has created at least one addressbook
41 boolean hasCreatedAddressbooks ();
44 * Creates a new address book with a name and redirects to proper target.
45 * For this method to work it is vital that the user is logged into his/her
48 * @return Target to redirect to
50 String addAddressbook ();
53 * Getter for address book name
55 * @return Address book name
57 String getAddressbookName ();
60 * Setter for address book name
62 * @param addressbookName Address book name
64 void setAddressbookName (final String addressbookName);
67 * Checks if the given address book name is already used by the user.
69 * @param addressbookName Address book name to check
71 * @return Whether the name has already been used by the user
73 boolean isAddressbookNameUsed (final String addressbookName);
76 * Returns all address books with this user
78 * @return A list of all address books by this user
80 List<Addressbook> allAddressbooks ();
83 * Returns a list of all address book entries for given address book
85 * @param addressbook Address book instance
87 * @return List of all entries
89 List<AddressbookEntry> allEntries (final Addressbook addressbook);
92 * Size of all entries in given address book
94 * @param addressbook Address book instance
96 * @return Size of the entries in address book
98 int allEntriesSize (final Addressbook addressbook);
101 * Getter for address book id number
103 * @return Address book id number
105 Long getAddressbookId ();
108 * Setter for address book id number
110 * @param addressbookId Address book id number
112 void setAddressbookId (final Long addressbookId);
115 * Getter for address book user (owner)
117 * @return Address book user (owner)
119 User getAddressbookUser ();
122 * Setter for address book user (owner)
124 * @param addressbookUser Address book user (owner)
126 void setAddressbookUser (final User addressbookUser);
129 * Getter for when the address book has been created
131 * @return When the address book has been created
133 Calendar getAddressbookCreated ();
136 * Setter for when the address book has been created
138 * @param addressbookCreated When the address book has been created
140 void setAddressbookCreated (final Calendar addressbookCreated);
143 * This method is called when an address book has been successfully loaded
146 * @param event Event with address book instance
148 void afterAddressbookLoadedEvent (final AddressbookLoadedEvent event);
151 * This method is called when a user has successfully logged in his/her
156 void afterLoginEvent (final UserLoggedInEvent event);
159 * Checks if the user is logged in and if so if it matches the current
160 * address book owner.
162 * @return Whether the owner matches currently logged-in user
164 boolean isOwnAddressbook ();
167 * Checks if the owner of the current address book is NOT matching the
170 * @return Whether the user does NOT match
172 boolean isOtherAddressbook ();
175 * Getter for address book instance
177 * @return Address book instance
179 Addressbook getAddressbook ();
182 * Setter for address book instance
184 * @param addressbook Address book instance
186 void setAddressbook (final Addressbook addressbook);
189 * Checks weather an address book has been loaded by checking the id number.
191 * @return Whether the address book is loaded
193 boolean isAddressbookLoaded ();
196 * Loads address book from current id
198 * @return Whether the address book was found
200 boolean loadAddressbook ();