]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 19 Aug 2017 17:56:35 +0000 (19:56 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 19 Aug 2017 17:56:35 +0000 (19:56 +0200)
- expanded business "contact"-s basic_data with all missing fields from entity
- added some fields, like contact person and company founder to backing bean
- added converter for company employees

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/businessdata/FinancialsAdminBusinessDataWebRequestBean.java
src/java/org/mxchange/jfinancials/converter/businesscontact/FinancialsBusinessContactConverter.java
src/java/org/mxchange/jfinancials/converter/company_employee/FinancialsCompanyEmployeeConverter.java [new file with mode: 0644]
web/WEB-INF/templates/admin/business_basic_data/admin_form_business_basic_data.tpl

index 3572dfe5e273a5999dea1ced434672deab86c497..e38872260b26c1fc27d04a87189bd8aea685d71c 100644 (file)
@@ -24,6 +24,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataAdminSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.employee.Employee;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jfinancials.beans.BaseFinancialsController;
 
@@ -91,6 +92,11 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsCon
         */
        private Long landLineNumber;
 
+       /**
+        * An employee as contact person with this company
+        */
+       private Employee companyContactEmployee;
+
        /**
         * Constructor
         */
@@ -117,6 +123,24 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsCon
                this.companyComments = companyComments;
        }
 
+       /**
+        * Getter for employee as contact person
+        * <p>
+        * @return Employee as contact person
+        */
+       public Employee getCompanyContactEmployee () {
+               return this.companyContactEmployee;
+       }
+
+       /**
+        * Setter for employee as contact person
+        * <p>
+        * @param companyContactEmployee Employee as contact person
+        */
+       public void setCompanyContactEmployee (final Employee companyContactEmployee) {
+               this.companyContactEmployee = companyContactEmployee;
+       }
+
        /**
         * Getter for company's (main) email address
         * <p>
index c8df4eea6562304c90a57aa225623d013c043ccc..f22fe9cd639bb9baac63f39e8d8f2d58363e178d 100644 (file)
@@ -28,7 +28,7 @@ import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
-import org.mxchange.jcontactsbusiness.exceptions.BusinessDataNotFoundException;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
 
 /**
  * Converter for contact id <-> valid business contact instance
diff --git a/src/java/org/mxchange/jfinancials/converter/company_employee/FinancialsCompanyEmployeeConverter.java b/src/java/org/mxchange/jfinancials/converter/company_employee/FinancialsCompanyEmployeeConverter.java
new file mode 100644 (file)
index 0000000..645fc22
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * 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.jfinancials.converter.company_employee;
+
+import java.text.MessageFormat;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontactsbusiness.employee.CompanyEmployeeSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.employee.Employee;
+import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
+
+/**
+ * Converter for converting company employee to and from id number
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "CompanyEmployeeConverter")
+public class FinancialsCompanyEmployeeConverter implements Converter {
+
+       /**
+        * CompanyEmployee EJB
+        */
+       private static CompanyEmployeeSessionBeanRemote COMPANY_EMPLOYEE_BEAN;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsCompanyEmployeeConverter () {
+       }
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Is the value null or empty?
+               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+                       // Warning message
+                       // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+                       // Return null
+                       return null;
+               }
+
+               // Is the bean there?
+               // @TODO Requires this synchronization or is it (sync) confusing the container?
+               if (null == FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN) {
+                       // Try to get it
+                       try {
+                               // Get initial context
+                               Context initialContext = new InitialContext();
+
+                               // ... and user controller
+                               FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initialContext.lookup("java:global/jfinancials-ejb/companyEmployee!org.mxchange.jcontactsbusiness.company_employee.CompanyEmployeeSessionBeanRemote"); //NOI18N
+                       } catch (final NamingException ex) {
+                               // Continue to throw it
+                               throw new ConverterException(MessageFormat.format("initialContext.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+                       }
+               }
+
+               // Init instance
+               Employee companyEmployee = null;
+
+               try {
+                       // Try to parse the value as long
+                       Long employeeId = Long.valueOf(submittedValue);
+
+                       // Try to get user instance from it
+                       companyEmployee = FinancialsCompanyEmployeeConverter.COMPANY_EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId);
+               } catch (final NumberFormatException ex) {
+                       // Throw again
+                       throw new ConverterException(ex);
+               } catch (final CompanyEmployeeNotFoundException ex) {
+                       // Debug message
+                       // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
+               }
+
+               // Return it
+               return companyEmployee;
+       }
+
+       @Override
+       public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+               // Is the object null?
+               if ((null == value) || (String.valueOf(value).isEmpty())) {
+                       // Is null
+                       return ""; //NOI18N
+               } else if (!(value instanceof Employee)) {
+                       // Not same interface
+                       throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement Employee.", value.getClass().getSimpleName())); //NOI18N
+               }
+
+               // Return id number
+               return String.valueOf(((Employee) value).getEmployeeId());
+       }
+
+}
index e5938a0ea97a76b768c90d2e8b2326b579c1741e..ab49e92dc73b27d165df4818eead3fb5c8c16351 100644 (file)
 
                        <h:panelGroup styleClass="table_row" layout="block">
                                <div class="table_left_medium">
-                                       <h:outputLabel for="companyComments" value="#{msg.ADMIN_BUSINESS_DATA_COMPANY_COMMENTS}" />
+                                       <h:outputLabel for="companyContactEmployee" value="#{msg.ADMIN_SELECT_BUSINESS_DATA_COMPANY_CONTACT_EMPLOYEE}" />
                                </div>
 
                                <div class="table_right_medium">
-                                       <h:inputTextarea styleClass="input" id="companyComments" rows="7" cols="25" value="#{adminBusinessDataController.companyComments}" />
+                                       <h:selectOneMenu styleClass="select" id="companyContactEmployee" value="#{adminBusinessDataController.companyContactEmployee}">
+                                               <f:converter converterId="CompanyEmployeeConverter" />
+                                               <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+                                               <f:selectItems value="#{adminCompanyEmployeeController.allCompanyEmployees()}" var="companyEmployee" itemValue="#{companyEmployee}" itemLabel="#{companyEmployee.foo})" />
+                                       </h:selectOneMenu>
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyContactEmployee" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyFounder" value="#{msg.ADMIN_SELECT_BUSINESS_DATA_COMPANY_FOUNDER}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:selectOneMenu styleClass="select" id="companyFounder" value="#{adminBusinessDataController.companyFounder}">
+                                               <f:converter converterId="CompanyEmployeeConverter" />
+                                               <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+                                               <f:selectItems value="#{adminCompanyEmployeeController.allCompanyEmployees()}" var="companyEmployee" itemValue="#{companyEmployee}" itemLabel="#{companyEmployee.foo})" />
+                                       </h:selectOneMenu>
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyFounder" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyLogo" value="#{msg.ADMIN_SELECT_BUSINESS_DATA_COMPANY_FOUNDER}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:outputText styleClass="warnings" value="#{msg.ADMIN_BUSINESS_DATA_UPLOAD_LOGO_UNFINISHED}" />
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyLogo" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyTaxNumber" value="#{msg.ADMIN_BUSINESS_DATA_COMPANY_TAX_NUMBER}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText styleClass="input" id="companyTaxNumber" size="30" maxlength="200" required="true" requiredMessage="#{msg.ADMIN_BUSINESS_DATA_COMPANY_NAME_REQUIRED}" value="#{adminBusinessDataController.companyTaxNumber}" />
                                </div>
 
                                <div class="clear"></div>
                        </h:panelGroup>
 
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyTaxNumber" errorClass="errors" fatalClass="errors" warnClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyWebsiteUrl" value="#{msg.ADMIN_BUSINESS_DATA_COMPANY_WEBSITE_URL}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText styleClass="input" id="companyWebsiteUrl" size="30" maxlength="200" required="true" requiredMessage="#{msg.ADMIN_BUSINESS_DATA_COMPANY_NAME_REQUIRED}" value="#{adminBusinessDataController.companyWebsiteUrl}" />
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyWebsiteUrl" errorClass="errors" fatalClass="errors" warnClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="contactCompanyUserOwner" value="#{msg.ADMIN_SELECT_BUSINESS_DATA_COMPANY_FOUNDER}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:selectOneMenu styleClass="select" id="contactCompanyUserOwner" value="#{adminBusinessDataController.contactCompanyUserOwner}">
+                                               <f:converter converterId="UserConverter" />
+                                               <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+                                               <f:selectItems value="#{userController.allUsers()}" var="companyUserOwner" itemValue="#{companyUserOwner}" itemLabel="#{companyUserOwner.foo})" />
+                                       </h:selectOneMenu>
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="contactCompanyUserOwner" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyHeadQuarters" value="#{msg.ADMIN_SELECT_BUSINESS_DATA_COMPANY_FOUNDER}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:selectOneMenu styleClass="select" id="companyHeadQuarters" value="#{adminBusinessDataController.companyHeadQuarters}">
+                                               <f:converter converterId="CompanyEmployeeConverter" />
+                                               <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
+                                               <f:selectItems value="#{adminCompanyHeadquartersController.allCompanyHeadquarters()}" var="companyHeadQuarters" itemValue="#{companyHeadQuarters}" itemLabel="#{companyHeadQuarters.foo})" />
+                                       </h:selectOneMenu>
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
+
+                       <h:panelGroup styleClass="error_container" layout="block">
+                               <h:message for="companyHeadQuarters" errorClass="errors" warnClass="warnings" fatalClass="errors" />
+                       </h:panelGroup>
+
                        <h:panelGroup styleClass="table_row" layout="block">
                                <div class="table_left_medium">
                                        <h:outputLabel for="landLineCountryCode" value="#{msg.ADMIN_BUSINESS_DATA_PHONE_NUMBER}" />
 
                                <div class="clear"></div>
                        </h:panelGroup>
+
+                       <h:panelGroup styleClass="table_row" layout="block">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="companyComments" value="#{msg.ADMIN_BUSINESS_DATA_COMPANY_COMMENTS}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputTextarea styleClass="input" id="companyComments" rows="7" cols="25" value="#{adminBusinessDataController.companyComments}" />
+                               </div>
+
+                               <div class="clear"></div>
+                       </h:panelGroup>
                </fieldset>
        </div>
 </ui:composition>