+++ /dev/null
-/*
- * 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.beans.financial;
-
-import org.mxchange.jfinancials.FinancialSessionBeanRemote;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.RequestScoped;
-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.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.login.user.FinancialsUserLoginWebSessionController;
-import org.mxchange.jfinancials.model.income.BillableIncome;
-import org.mxchange.jfinancials.model.income.FinancialIncome;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative user bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("financialController")
-@RequestScoped
-public class FinancialsAdminFinancialWebRequestBean extends BaseFinancialsController implements FinancialsAdminFinancialWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 56_189_028_928_371L;
-
- /**
- * Remote contact bean
- */
- private FinancialSessionBeanRemote financialBean;
-
- /**
- * Income interval
- */
- private FinancialInterval incomeInterval;
-
- /**
- * Income single amount
- */
- private Float incomeSingleAmount;
-
- /**
- * Income (type) title
- */
- private String incomeTitle;
-
- /**
- * User instance
- */
- @Inject
- private FinancialsUserLoginWebSessionController userLoginController;
-
- /**
- * Constructor
- */
- public FinancialsAdminFinancialWebRequestBean () {
- // Call super constructor
- super();
- }
-
- public String addFinancialIncome () {
- // Is all data valid?
- if (null == this.getIncomeInterval()) {
- // Throw NPE
- throw new NullPointerException("incomeInterval is null"); //NOI18N
- } else if (null == this.getIncomeSingleAmount()) {
- // Throw again
- throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
- } else if (this.getIncomeSingleAmount() < 0) {
- // Not allowed value
- throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
- } else if (null == this.getIncomeTitle()) {
- // Throw again
- throw new NullPointerException("incomeTitle is null"); //NOI18N
- } else if (this.getIncomeTitle().isEmpty()) {
- // Should not be empty
- throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
- }
-
- // Now that all required data has been entered, prepare new income instance
- BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
-
- // Handle it over to the EJB
- // @TODO Use updated income instance, e.g. fire event
- BillableIncome updatedIncome = this.financialBean.addIncome(income);
-
- // All fine
- return "add_user_fiancial_income"; //NOI18N
- }
-
- @Override
- public List<FinancialInterval> getAllIncomeIntervals () {
- // Init array
- List<FinancialInterval> incomeIntervals = Arrays.asList(FinancialInterval.values());
-
- // Return it
- return incomeIntervals;
- }
-
- @Override
- public FinancialInterval getIncomeInterval () {
- return this.incomeInterval;
- }
-
- @Override
- public void setIncomeInterval (final FinancialInterval incomeInterval) {
- this.incomeInterval = incomeInterval;
- }
-
- @Override
- public Float getIncomeSingleAmount () {
- return this.incomeSingleAmount;
- }
-
- @Override
- public void setIncomeSingleAmount (final Float incomeSingleAmount) {
- this.incomeSingleAmount = incomeSingleAmount;
- }
-
- @Override
- public String getIncomeTitle () {
- return this.incomeTitle;
- }
-
- @Override
- public void setIncomeTitle (final String incomeTitle) {
- this.incomeTitle = incomeTitle;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.financialBean = (FinancialSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/financial!org.mxchange.jfinancials.FinancialSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
-}
+++ /dev/null
-/*
- * 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.beans.financial;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
-
-/**
- * An administrative interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsAdminFinancialWebRequestController extends Serializable {
-
- /**
- * Getter for income single amount
- * <p>
- * @return Income single amount
- */
- Float getIncomeSingleAmount ();
-
- /**
- * Setter for income single amount
- * <p>
- * @param incomeSingleAmount Income single amount
- */
- void setIncomeSingleAmount (final Float incomeSingleAmount);
-
- /**
- * Getter for income (type) title
- * <p>
- * @return Income title
- */
- String getIncomeTitle ();
-
- /**
- * Setter for income (type) title
- * <p>
- * @param incomeTitle Income title
- */
- void setIncomeTitle (final String incomeTitle);
-
- /**
- * Getter for income interval
- * <p>
- * @return Income interval
- */
- FinancialInterval getIncomeInterval ();
-
- /**
- * Setter for income (type) interval
- * <p>
- * @param incomeInterval Income interval
- */
- void setIncomeInterval (final FinancialInterval incomeInterval);
-
- /**
- * Returns a list of all all income intervals
- * <p>
- * @return Income intervals
- */
- List<FinancialInterval> getAllIncomeIntervals ();
-
-}
--- /dev/null
+/*
+ * 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.beans.financial.income;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+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.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jfinancials.beans.login.user.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote;
+import org.mxchange.jfinancials.model.income.BillableIncome;
+import org.mxchange.jfinancials.model.income.FinancialIncome;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative financial income bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("financialIncomeController")
+@RequestScoped
+public class FinancialsAdminFinancialIncomeWebRequestBean extends BaseFinancialsController implements FinancialsAdminFinancialIncomeWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 56_189_028_928_371L;
+
+ /**
+ * Remote contact bean
+ */
+ private FinancialIncomeSessionBeanRemote financialBean;
+
+ /**
+ * Income interval
+ */
+ private FinancialInterval incomeInterval;
+
+ /**
+ * Income single amount
+ */
+ private Float incomeSingleAmount;
+
+ /**
+ * Income (type) title
+ */
+ private String incomeTitle;
+
+ /**
+ * User instance
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * Constructor
+ */
+ public FinancialsAdminFinancialIncomeWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Adds income data by calling proper business method of the EJB.
+ * <p>
+ * @return Redirect outcome
+ */
+ public String addFinancialIncome () {
+ // Is all data valid?
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (null == this.getIncomeInterval()) {
+ // Throw NPE
+ throw new NullPointerException("incomeInterval is null"); //NOI18N
+ } else if (null == this.getIncomeSingleAmount()) {
+ // Throw again
+ throw new NullPointerException("incomeSingleAmount is null"); //NOI18N
+ } else if (this.getIncomeSingleAmount() < 0) {
+ // Not allowed value
+ throw new IllegalArgumentException(MessageFormat.format("incomeSingleAmount={0} is not valid.", this.getIncomeSingleAmount())); //NOI18N
+ } else if (null == this.getIncomeTitle()) {
+ // Throw again
+ throw new NullPointerException("incomeTitle is null"); //NOI18N
+ } else if (this.getIncomeTitle().isEmpty()) {
+ // Should not be empty
+ throw new IllegalArgumentException("incomeTitle is empty"); //NOI18N
+ }
+
+ // Now that all required data has been entered, prepare new income instance
+ BillableIncome income = new FinancialIncome(this.getIncomeTitle(), this.getIncomeSingleAmount(), this.getIncomeInterval(), this.userLoginController.getLoggedInUser());
+
+ // Handle it over to the EJB
+ // @TODO Use updated income instance, e.g. fire event
+ BillableIncome updatedIncome = this.financialBean.addIncome(income);
+
+ // All fine
+ return "add_user_fiancial_income"; //NOI18N
+ }
+
+ @Override
+ public List<FinancialInterval> getAllIncomeIntervals () {
+ // Init array
+ List<FinancialInterval> incomeIntervals = Arrays.asList(FinancialInterval.values());
+
+ // Return it
+ return incomeIntervals;
+ }
+
+ @Override
+ public FinancialInterval getIncomeInterval () {
+ return this.incomeInterval;
+ }
+
+ @Override
+ public void setIncomeInterval (final FinancialInterval incomeInterval) {
+ this.incomeInterval = incomeInterval;
+ }
+
+ @Override
+ public Float getIncomeSingleAmount () {
+ return this.incomeSingleAmount;
+ }
+
+ @Override
+ public void setIncomeSingleAmount (final Float incomeSingleAmount) {
+ this.incomeSingleAmount = incomeSingleAmount;
+ }
+
+ @Override
+ public String getIncomeTitle () {
+ return this.incomeTitle;
+ }
+
+ @Override
+ public void setIncomeTitle (final String incomeTitle) {
+ this.incomeTitle = incomeTitle;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.financialBean = (FinancialIncomeSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/financial!org.mxchange.jfinancials.financial.income.FinancialIncomeSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * 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.beans.financial.income;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+
+/**
+ * An administrative interface for financial income beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminFinancialIncomeWebRequestController extends Serializable {
+
+ /**
+ * Getter for income single amount
+ * <p>
+ * @return Income single amount
+ */
+ Float getIncomeSingleAmount ();
+
+ /**
+ * Setter for income single amount
+ * <p>
+ * @param incomeSingleAmount Income single amount
+ */
+ void setIncomeSingleAmount (final Float incomeSingleAmount);
+
+ /**
+ * Getter for income (type) title
+ * <p>
+ * @return Income title
+ */
+ String getIncomeTitle ();
+
+ /**
+ * Setter for income (type) title
+ * <p>
+ * @param incomeTitle Income title
+ */
+ void setIncomeTitle (final String incomeTitle);
+
+ /**
+ * Getter for income interval
+ * <p>
+ * @return Income interval
+ */
+ FinancialInterval getIncomeInterval ();
+
+ /**
+ * Setter for income (type) interval
+ * <p>
+ * @param incomeInterval Income interval
+ */
+ void setIncomeInterval (final FinancialInterval incomeInterval);
+
+ /**
+ * Returns a list of all all income intervals
+ * <p>
+ * @return Income intervals
+ */
+ List<FinancialInterval> getAllIncomeIntervals ();
+
+}
</div>
<div class="table_right_medium">
- <h:inputText styleClass="input" id="incomeTitle" size="2" maxlength="10" value="#{financialController.incomeTitle}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_TITLE_REQUIRED}">
+ <h:inputText styleClass="input" id="incomeTitle" size="2" maxlength="10" value="#{financialIncomeController.incomeTitle}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_TITLE_REQUIRED}">
<f:validator validatorId="IncomeTitleValidator" />
</h:inputText>
</div>
</div>
<div class="table_right_medium">
- <h:selectOneMenu styleClass="select" id="incomeInterval" value="#{financialController.incomeInterval}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_REQUIRED}">
+ <h:selectOneMenu styleClass="select" id="incomeInterval" value="#{financialIncomeController.incomeInterval}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_REQUIRED}">
<f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
- <f:selectItems value="#{financialController.allIncomeIntervals}" var="incomeInterval" itemValue="#{incomeInterval}" itemLabel="#{msg[incomeInterval.concat('_INTERVAL')]}" />
+ <f:selectItems value="#{financialIncomeController.allIncomeIntervals}" var="incomeInterval" itemValue="#{incomeInterval}" itemLabel="#{msg[incomeInterval.concat('_INTERVAL')]}" />
</h:selectOneMenu>
</div>
</div>
<div class="table_right_medium">
- <h:inputText styleClass="input" id="incomeSingleValue" size="5" maxlength="20" value="#{financialController.incomeSingleAmount}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_SINGLE_VALUE_REQUIRED}">
+ <h:inputText styleClass="input" id="incomeSingleValue" size="5" maxlength="20" value="#{financialIncomeController.incomeSingleAmount}" required="true" requiredMessage="#{msg.FIELD_FINANCIAL_INCOME_SINGLE_VALUE_REQUIRED}">
<f:validator validatorId="CurrencyAmountValidator" />
</h:inputText>
</div>
<div class="table_footer">
<h:commandButton styleClass="reset right_space" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
- <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialController.addFinancialIncome()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
+ <h:commandButton styleClass="submit" id="submit_add_income" type="submit" action="#{financialIncomeController.addFinancialIncome()}" value="#{msg.BUTTON_LOGIN_FINCIAL_ADD_INCOME}" />
</div>
</h:panelGroup>
</h:form>
<h:column>
<h:outputLabel for="totalReceipts" styleClass="data_label" value="#{msg.USER_FINANCIALS_TOTAL_RECEIPTS}" />
- <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_receipts" value="#{financialController.receipts.size()}" />
+ <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_receipts" value="#{financialIncomeController.receipts.size()}" />
</h:column>
<h:column>
<h:outputLabel for="totalReceipts" styleClass="data_label" value="#{msg.USER_FINANCIALS_TOTAL_OTHER_EXPENSES}" />
- <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_other_expenses" value="#{financialController.income.size()}" />
+ <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_other_expenses" value="#{financialIncomeController.otherExpenses.size()}" />
</h:column>
<h:column>
<h:outputLabel for="totalReceipts" styleClass="data_label" value="#{msg.USER_FINANCIALS_TOTAL_INCOME}" />
- <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_income" value="#{financialController.income.size()}" />
+ <h:outputLink id="totalReceipts" styleClass="data_field" target="list_user_financial_income" value="#{financialIncomeController.income.size()}" />
</h:column>
</h:panelGrid>
</h:panelGroup>