From 351f5a49188546b31e1d27cb2fdbdf9c2c08c60e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 6 Oct 2015 15:39:45 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20renamed=20exception=20+=20added?= =?utf8?q?=20new=20one=20-=20updated=20jar=20Signed-off-by:Roland=20H?= =?utf8?q?=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcontacts-core.jar | Bin 18203 -> 18203 bytes ...ailAddressAlreadyRegisteredException.java} | 6 +-- .../UserNameAlreadyRegisteredException.java | 43 ++++++++++++++++++ .../jusercore/model/user/LoginUser.java | 10 ++++ 4 files changed, 56 insertions(+), 3 deletions(-) rename src/org/mxchange/jusercore/exceptions/{UserAlreadyRegisteredException.java => EmailAddressAlreadyRegisteredException.java} (85%) create mode 100644 src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 5fd68dc8f80098600ff320c77eef156f7e79d9d2..ceeaa29af8efe058726733354565e73674c2bba6 100644 GIT binary patch delta 199 zcmbQ;$2hx>kte{LnT3mifrEizdc{N@O{QrT6V0bH0ofN6K;$P)AURo<(HKMpFytA5Vg>)3IL)l BMe+au delta 199 zcmbQ;$2hx>kte{LnT3mifrEiTG;bo0CX-0sMDyuPK=uU%5cx?HNKTezGzL*YjMgBk zpV0|KU1qccQk#XDSlK|d6o;iEhz`|M;|9^SCZ{<;w3pou79c&D#n}>Q_+)!$2N18( z*#Jas1_}bHch1fr%GkvlL^Zesfv77kejrN4H3CG{xyFE~JFamc%Em1jL@jiy0svUn BH@W}- diff --git a/src/org/mxchange/jusercore/exceptions/UserAlreadyRegisteredException.java b/src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java similarity index 85% rename from src/org/mxchange/jusercore/exceptions/UserAlreadyRegisteredException.java rename to src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java index 453fd69..13a783b 100644 --- a/src/org/mxchange/jusercore/exceptions/UserAlreadyRegisteredException.java +++ b/src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java @@ -20,11 +20,11 @@ import java.text.MessageFormat; import org.mxchange.jusercore.model.user.User; /** - * An exception thrown when the customer is already registered + * An exception thrown when the user's email address is already registered. *

* @author Roland Haeder */ -public class UserAlreadyRegisteredException extends Exception { +public class EmailAddressAlreadyRegisteredException extends Exception { /** * Serial number @@ -36,7 +36,7 @@ public class UserAlreadyRegisteredException extends Exception { *

* @param user User instance */ - public UserAlreadyRegisteredException (final User user) { + public EmailAddressAlreadyRegisteredException (final User user) { // Call super contructor super(MessageFormat.format("User {0} already registered with number {1} at record id {2}. Maybe forgot to call isRegistered(user) ?", user, user.getUserName(), user.getUserId())); } diff --git a/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java b/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java new file mode 100644 index 0000000..7e356aa --- /dev/null +++ b/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * 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.jusercore.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An exception thrown when the user name is already registered + *

+ * @author Roland Haeder + */ +public class UserNameAlreadyRegisteredException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 16_435_892_878_271L; + + /** + * Constructor with already registered user instance + *

+ * @param user User instance + */ + public UserNameAlreadyRegisteredException (final User user) { + // Call super contructor + super(MessageFormat.format("User name {0} already registered at record id {2}. Maybe forgot to call isRegistered(user) ?", user.getUserName(), user.getUserId())); + } +} diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index c592e6e..f066460 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -26,6 +26,8 @@ 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; @@ -41,6 +43,14 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; */ @Entity (name = "users") @Table (name = "users") +@NamedQueries( + { + @NamedQuery(name = "AllUserNames", query = "SELECT DISTINCT u.userName FROM users AS u ORDER BY u.userId ASC"), + @NamedQuery(name = "AllEmailAddresses", query = "SELECT DISTINCT c.emailAddress FROM contacts AS c ORDER BY c.contactId ASC"), + @NamedQuery(name = "SearchUserName", query = "SELECT u FROM users AS u WHERE LOWER(u.userName) LIKE LOWER(:param)"), + @NamedQuery(name = "SearchEmailAddress", query = "SELECT u FROM users AS u INNER JOIN contacts AS c ON u.userContact = c WHERE LOWER(c.emailAddress) LIKE LOWER(:param)") + } +) public class LoginUser implements User { /** -- 2.39.5