From e89a8577b4481006875d1849d242e9eabc5f44d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Apr 2017 20:54:46 +0200 Subject: [PATCH] renamed class + removed generic method as it exists in jcustomer-core, too. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...tomerUtils.java => ShopCustomerUtils.java} | 63 +------------------ 1 file changed, 2 insertions(+), 61 deletions(-) rename src/org/mxchange/jshopcore/model/customer/{CustomerUtils.java => ShopCustomerUtils.java} (58%) diff --git a/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java b/src/org/mxchange/jshopcore/model/customer/ShopCustomerUtils.java similarity index 58% rename from src/org/mxchange/jshopcore/model/customer/CustomerUtils.java rename to src/org/mxchange/jshopcore/model/customer/ShopCustomerUtils.java index b0b33f9..145fa85 100644 --- a/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java +++ b/src/org/mxchange/jshopcore/model/customer/ShopCustomerUtils.java @@ -16,7 +16,6 @@ */ package org.mxchange.jshopcore.model.customer; -import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.EntityNotFoundException; import org.apache.commons.codec.binary.Base64; @@ -30,7 +29,7 @@ import org.mxchange.jshopcore.model.order.ShopOrder; *

* @author Roland Häder */ -public class CustomerUtils { +public class ShopCustomerUtils { /** * Generates an unique access key. @@ -41,9 +40,6 @@ public class CustomerUtils { * @return An unique access key */ public static String generateAccessKey (final EntityManager em, final Customer customer) { - // Trace message - // @TODO: utils.getLogger().logTrace(MessageFormat.format("generateAccessKey: connection={0} - CALLED!", connection)); - // em cannot be null if (null == em) { // Abort here @@ -80,69 +76,14 @@ public class CustomerUtils { } } - // Trace message - // @TODO: utils.getLogger().logTrace(MessageFormat.format("generateAccessKey: accessKey={0} - EXIT!", accessKey)); // Found one return accessKey; } - /** - * Generates an unique customer number by checking is existence - *

- * @param em Entity manager instance - *

- * @return Generated customer number (not used before) - *

- * @throws java.sql.SQLException If any SQL error occured - */ - public static String generateCustomerNumber (final EntityManager em) throws SQLException { - // Trace message - // @TODO: utils.getLogger().logTrace(MessageFormat.format("generateCustomerNumber: connection={0} - CALLED!", connection)); - - // em cannot be null - if (null == em) { - // Abort here - throw new NullPointerException("em is null"); //NOI18N - } else if (!em.isOpen()) { - // Not open - throw new IllegalStateException("Entity manager is closed."); - } - - // Generate number - String customerNumber = null; - - // Default is found - boolean isFound = true; - - // Is the number used? - while (isFound) { - // Both number parts - long part1 = Math.round(Math.random() * 100_000); - long part2 = Math.round(Math.random() * 1_000); - - // Generate new number - customerNumber = String.format("%s-%s", part1, part2); //NOI18N - - // Try it - try { - // Get instance - Customer customer = em.getReference(Customer.class, customerNumber); - } catch (final EntityNotFoundException ex) { - // Not found - isFound = false; - } - } - - // Trace message - // @TODO: utils.getLogger().logTrace(MessageFormat.format("generateCustomerNumber: customerNumber={0} - EXIT!", customerNumber)); - // Found one - return customerNumber; - } - /** * Private constructor */ - private CustomerUtils () { + private ShopCustomerUtils () { // Prevents making instances from utilities classes } -- 2.39.5