]> git.mxchange.org Git - jjobs-war.git/commitdiff
Moved to proper package and fixed interface name from pizzaservice-war cherry-pick
authorRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 16:37:29 +0000 (18:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 16:37:29 +0000 (18:37 +0200)
src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java [deleted file]
src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java [deleted file]

diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationBean.java
new file mode 100644 (file)
index 0000000..aa29d71
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.country;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+
+/**
+ * An administrative country bean
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("adminCountryController")
+@ApplicationScoped
+public class JobsAdminCountryWebApplicationBean implements JobsAdminCountryWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_598_175_719_603L;
+
+       /**
+        * Abroad dial prefix
+        */
+       private String countryAbroadDialPrefix;
+
+       /**
+        * Remote country EJB
+        */
+       private CountrySingletonBeanRemote countryBean;
+
+       /**
+        * 2-letter country code
+        */
+       private String countryCode;
+
+       /**
+        * Regular country controller
+        */
+       @Inject
+       private JobsCountryWebApplicationController countryController;
+
+       /**
+        * Local dial prefix
+        */
+       private String countryExternalDialPrefix;
+
+       /**
+        * i18n bundle key
+        */
+       private String countryI18nKey;
+
+       /**
+        * Whether the local dial prefix is required to use
+        */
+       private Boolean countryIsLocalPrefixRequired;
+
+       /**
+        * Phone code
+        */
+       private Short countryPhoneCode;
+
+       /**
+        * Default constructor
+        */
+       public JobsAdminCountryWebApplicationBean () {
+               // Try this
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public void addCountry () {
+               // Create new country object
+               Country country = new CountryData();
+
+               // Add all data
+               country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
+               country.setCountryCode(this.getCountryCode());
+               country.setCountryExternalDialPrefix(this.getCountryExternalDialPrefix());
+               country.setCountryI18nkey(this.getCountryI18nKey());
+               country.setCountryIsLocalPrefixRequired(this.getCountryIsLocalPrefixRequired());
+               country.setCountryPhoneCode(this.getCountryPhoneCode());
+
+               // Does it already exist?
+               if (this.isCountryAdded(country)) {
+                       // Yes, then abort here
+                       throw new FaceletException(new CountryAlreadyAddedException(country));
+               }
+
+               try {
+                       // Send country to bean
+                       this.countryBean.addCountry(country);
+
+                       // Clear bean
+                       this.clear();
+               } catch (final CountryAlreadyAddedException ex) {
+                       // Throw again
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public List<Country> allCountries () {
+               // Return "cached" version
+               return this.countryController.allCountries();
+       }
+
+       @Override
+       public String getCountryAbroadDialPrefix () {
+               return this.countryAbroadDialPrefix;
+       }
+
+       @Override
+       public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
+               this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+       }
+
+       @Override
+       public String getCountryCode () {
+               return this.countryCode;
+       }
+
+       @Override
+       public void setCountryCode (final String countryCode) {
+               this.countryCode = countryCode;
+       }
+
+       @Override
+       public String getCountryExternalDialPrefix () {
+               return this.countryExternalDialPrefix;
+       }
+
+       @Override
+       public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
+               this.countryExternalDialPrefix = countryExternalDialPrefix;
+       }
+
+       @Override
+       public String getCountryI18nKey () {
+               return this.countryI18nKey;
+       }
+
+       @Override
+       public void setCountryI18nKey (final String countryI18nKey) {
+               this.countryI18nKey = countryI18nKey;
+       }
+
+       @Override
+       public Boolean getCountryIsLocalPrefixRequired () {
+               return this.countryIsLocalPrefixRequired;
+       }
+
+       @Override
+       public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
+               this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+       }
+
+       @Override
+       public Short getCountryPhoneCode () {
+               return this.countryPhoneCode;
+       }
+
+       @Override
+       public void setCountryPhoneCode (final Short countryPhoneCode) {
+               this.countryPhoneCode = countryPhoneCode;
+       }
+
+       @Override
+       public boolean hasCountries () {
+               return (!this.allCountries().isEmpty());
+       }
+
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all
+               this.setCountryAbroadDialPrefix(null);
+               this.setCountryCode(null);
+               this.setCountryExternalDialPrefix(null);
+               this.setCountryI18nKey(null);
+               this.setCountryIsLocalPrefixRequired(null);
+               this.setCountryPhoneCode(null);
+       }
+
+       /**
+        * Checks if given country is already added by iterating over the whole list
+        * and try to find it.
+        * <p>
+        * @param country Country instance to look for
+        * <p>
+        * @return Whether the country was already found
+        */
+       private boolean isCountryAdded (final Country country) {
+               // Default is not found
+               boolean isAdded = false;
+
+               // Now get whole ist
+               List<Country> countries = this.countryController.allCountries();
+
+               // Get iterator from it
+               Iterator<Country> iterator = countries.iterator();
+
+               // Check whole list
+               while (iterator.hasNext()) {
+                       // Get next country
+                       Country next = iterator.next();
+
+                       // Is country code or i18n the same?
+                       if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nkey(), next.getCountryI18nkey()))) {
+                               // Yes, then abort search
+                               isAdded = true;
+                               break;
+                       }
+               }
+
+               // Return result
+               return isAdded;
+       }
+
+}
diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationController.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebApplicationController.java
new file mode 100644 (file)
index 0000000..ad4dc46
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.country;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * An interface for administrative country beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface JobsAdminCountryWebApplicationController extends Serializable {
+
+       /**
+        * A list of all countries
+        * <p>
+        * @return All countries
+        */
+       List<Country> allCountries ();
+
+       /**
+        * Adds country to all relevant beans and sends it to the EJB.
+        */
+       void addCountry ();
+
+       /**
+        * Checks whether countries has been registered
+        * <p>
+        * @return Whether countries has been registered
+        */
+       boolean hasCountries ();
+
+       /**
+        * Getter for abroad dial prefix
+        * <p>
+        * @return Abroad dial prefix
+        */
+       String getCountryAbroadDialPrefix ();
+
+       /**
+        * Setter for abroad dial prefix
+        * <p>
+        * @param countryAbroadDialPrefix Abroad dial prefix
+        */
+       void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
+
+       /**
+        * Getter for 2-characters country code
+        * <p>
+        * @return Country code
+        */
+       String getCountryCode ();
+
+       /**
+        * Setter for 2-characters country code
+        * <p>
+        * @param countryCode Country code
+        */
+       void setCountryCode (final String countryCode);
+
+       /**
+        * Getter for i18n key for country name
+        * <p>
+        * @return i18n key for country name
+        */
+       String getCountryI18nKey ();
+
+       /**
+        * Setter for i18n key for country name
+        * <p>
+        * @param countryI18nKey i18n key for country name
+        */
+       void setCountryI18nKey (final String countryI18nKey);
+
+       /**
+        * Getter for whether the local dial prefix is required for local calls
+        * <p>
+        * @return Whether the local dial prefix is required
+        */
+       Boolean getCountryIsLocalPrefixRequired ();
+
+       /**
+        * Setter for whether the local dial prefix is required for local calls
+        * <p>
+        * @param countryIsLocalPrefixRequired Whether the local dial prefix is
+        *                                     required
+        */
+       void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
+
+       /**
+        * Getter for external dial prefix
+        * <p>
+        * @return External dial prefix
+        */
+       String getCountryExternalDialPrefix ();
+
+       /**
+        * Setter for external dial prefix
+        * <p>
+        * @param countryExternalDialPrefix External dial prefix
+        */
+       void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
+
+       /**
+        * Getter for country code (example: 49 for Germany, 63 for Philippines)
+        * <p>
+        * @return Dial number without prefix
+        */
+       Short getCountryPhoneCode ();
+
+       /**
+        * Setter for country code (example: 49 for Germany, 63 for Philippines)
+        * <p>
+        * @param countryPhoneCode Country code
+        */
+       void setCountryPhoneCode (final Short countryPhoneCode);
+
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java
deleted file mode 100644 (file)
index e366374..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.country;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.ApplicationScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountryData;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
-import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
-
-/**
- * An administrative country bean
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Named ("adminCountryController")
-@ApplicationScoped
-public class PizzaAdminCountryWebApplicationBean implements PizzaAdminCountryWebApplicationController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 18_598_175_719_603L;
-
-       /**
-        * Abroad dial prefix
-        */
-       private String countryAbroadDialPrefix;
-
-       /**
-        * Remote country EJB
-        */
-       private CountrySingletonBeanRemote countryBean;
-
-       /**
-        * 2-letter country code
-        */
-       private String countryCode;
-
-       /**
-        * Regular country controller
-        */
-       @Inject
-       private PizzaCountryWebApplicationController countryController;
-
-       /**
-        * Local dial prefix
-        */
-       private String countryExternalDialPrefix;
-
-       /**
-        * i18n bundle key
-        */
-       private String countryI18nKey;
-
-       /**
-        * Whether the local dial prefix is required to use
-        */
-       private Boolean countryIsLocalPrefixRequired;
-
-       /**
-        * Phone code
-        */
-       private Short countryPhoneCode;
-
-       /**
-        * Default constructor
-        */
-       public PizzaAdminCountryWebApplicationBean () {
-               // Try this
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup the bean
-                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public void addCountry () {
-               // Create new country object
-               Country country = new CountryData();
-
-               // Add all data
-               country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
-               country.setCountryCode(this.getCountryCode());
-               country.setCountryExternalDialPrefix(this.getCountryExternalDialPrefix());
-               country.setCountryI18nkey(this.getCountryI18nKey());
-               country.setCountryIsLocalPrefixRequired(this.getCountryIsLocalPrefixRequired());
-               country.setCountryPhoneCode(this.getCountryPhoneCode());
-
-               // Does it already exist?
-               if (this.isCountryAdded(country)) {
-                       // Yes, then abort here
-                       throw new FaceletException(new CountryAlreadyAddedException(country));
-               }
-
-               try {
-                       // Send country to bean
-                       this.countryBean.addCountry(country);
-
-                       // Clear bean
-                       this.clear();
-               } catch (final CountryAlreadyAddedException ex) {
-                       // Throw again
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public List<Country> allCountries () {
-               // Return "cached" version
-               return this.countryController.allCountries();
-       }
-
-       @Override
-       public String getCountryAbroadDialPrefix () {
-               return this.countryAbroadDialPrefix;
-       }
-
-       @Override
-       public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
-               this.countryAbroadDialPrefix = countryAbroadDialPrefix;
-       }
-
-       @Override
-       public String getCountryCode () {
-               return this.countryCode;
-       }
-
-       @Override
-       public void setCountryCode (final String countryCode) {
-               this.countryCode = countryCode;
-       }
-
-       @Override
-       public String getCountryExternalDialPrefix () {
-               return this.countryExternalDialPrefix;
-       }
-
-       @Override
-       public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
-               this.countryExternalDialPrefix = countryExternalDialPrefix;
-       }
-
-       @Override
-       public String getCountryI18nKey () {
-               return this.countryI18nKey;
-       }
-
-       @Override
-       public void setCountryI18nKey (final String countryI18nKey) {
-               this.countryI18nKey = countryI18nKey;
-       }
-
-       @Override
-       public Boolean getCountryIsLocalPrefixRequired () {
-               return this.countryIsLocalPrefixRequired;
-       }
-
-       @Override
-       public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
-               this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
-       }
-
-       @Override
-       public Short getCountryPhoneCode () {
-               return this.countryPhoneCode;
-       }
-
-       @Override
-       public void setCountryPhoneCode (final Short countryPhoneCode) {
-               this.countryPhoneCode = countryPhoneCode;
-       }
-
-       @Override
-       public boolean hasCountries () {
-               return (!this.allCountries().isEmpty());
-       }
-
-       /**
-        * Clears this bean
-        */
-       private void clear () {
-               // Clear all
-               this.setCountryAbroadDialPrefix(null);
-               this.setCountryCode(null);
-               this.setCountryExternalDialPrefix(null);
-               this.setCountryI18nKey(null);
-               this.setCountryIsLocalPrefixRequired(null);
-               this.setCountryPhoneCode(null);
-       }
-
-       /**
-        * Checks if given country is already added by iterating over the whole list
-        * and try to find it.
-        * <p>
-        * @param country Country instance to look for
-        * <p>
-        * @return Whether the country was already found
-        */
-       private boolean isCountryAdded (final Country country) {
-               // Default is not found
-               boolean isAdded = false;
-
-               // Now get whole ist
-               List<Country> countries = this.countryController.allCountries();
-
-               // Get iterator from it
-               Iterator<Country> iterator = countries.iterator();
-
-               // Check whole list
-               while (iterator.hasNext()) {
-                       // Get next country
-                       Country next = iterator.next();
-
-                       // Is country code or i18n the same?
-                       if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nkey(), next.getCountryI18nkey()))) {
-                               // Yes, then abort search
-                               isAdded = true;
-                               break;
-                       }
-               }
-
-               // Return result
-               return isAdded;
-       }
-
-}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java
deleted file mode 100644 (file)
index 40b581e..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.pizzaapplication.beans.country;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcountry.data.Country;
-
-/**
- * An interface for administrative country beans
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface PizzaAdminCountryWebApplicationController extends Serializable {
-
-       /**
-        * A list of all countries
-        * <p>
-        * @return All countries
-        */
-       List<Country> allCountries ();
-
-       /**
-        * Adds country to all relevant beans and sends it to the EJB.
-        */
-       void addCountry ();
-
-       /**
-        * Checks whether countries has been registered
-        * <p>
-        * @return Whether countries has been registered
-        */
-       boolean hasCountries ();
-
-       /**
-        * Getter for abroad dial prefix
-        * <p>
-        * @return Abroad dial prefix
-        */
-       String getCountryAbroadDialPrefix ();
-
-       /**
-        * Setter for abroad dial prefix
-        * <p>
-        * @param countryAbroadDialPrefix Abroad dial prefix
-        */
-       void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
-
-       /**
-        * Getter for 2-characters country code
-        * <p>
-        * @return Country code
-        */
-       String getCountryCode ();
-
-       /**
-        * Setter for 2-characters country code
-        * <p>
-        * @param countryCode Country code
-        */
-       void setCountryCode (final String countryCode);
-
-       /**
-        * Getter for i18n key for country name
-        * <p>
-        * @return i18n key for country name
-        */
-       String getCountryI18nKey ();
-
-       /**
-        * Setter for i18n key for country name
-        * <p>
-        * @param countryI18nKey i18n key for country name
-        */
-       void setCountryI18nKey (final String countryI18nKey);
-
-       /**
-        * Getter for whether the local dial prefix is required for local calls
-        * <p>
-        * @return Whether the local dial prefix is required
-        */
-       Boolean getCountryIsLocalPrefixRequired ();
-
-       /**
-        * Setter for whether the local dial prefix is required for local calls
-        * <p>
-        * @param countryIsLocalPrefixRequired Whether the local dial prefix is
-        *                                     required
-        */
-       void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
-
-       /**
-        * Getter for external dial prefix
-        * <p>
-        * @return External dial prefix
-        */
-       String getCountryExternalDialPrefix ();
-
-       /**
-        * Setter for external dial prefix
-        * <p>
-        * @param countryExternalDialPrefix External dial prefix
-        */
-       void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
-
-       /**
-        * Getter for country code (example: 49 for Germany, 63 for Philippines)
-        * <p>
-        * @return Dial number without prefix
-        */
-       Short getCountryPhoneCode ();
-
-       /**
-        * Setter for country code (example: 49 for Germany, 63 for Philippines)
-        * <p>
-        * @param countryPhoneCode Country code
-        */
-       void setCountryPhoneCode (final Short countryPhoneCode);
-
-}