import java.util.Objects;
import java.util.Properties;
import javax.ejb.EJBException;
-import javax.faces.FacesException;
-import javax.jms.Connection;
import javax.jms.JMSException;
-import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.Session;
import javax.mail.Address;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcoreee.database.BaseDatabaseBean;
import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
*/
private static final long serialVersionUID = 12_895_410_275_811_963L;
- /**
- * Connection
- */
- private Connection connection;
-
- /**
- * Message producer
- */
- private MessageProducer messageProducer;
-
- /**
- * Mailer message queue
- */
- private Queue queue;
-
- /**
- * Session instance
- */
- private Session session;
-
/**
* Protected constructor
*/
protected BaseFinancialsDatabaseBean () {
// Call super constructor
- super();
-
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Get factory from JMS resource
- QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup("jms/jfinancials-queue-factory"); //NOI18N
-
- // Lookup queue
- this.queue = (Queue) context.lookup("jms/jfinancials-email-queue"); //NOI18N
-
- // Create connection
- this.connection = connectionFactory.createConnection();
-
- // Init session instance
- this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // And message producer
- this.messageProducer = this.session.createProducer(this.queue);
- } catch (final NamingException | JMSException e) {
- // Continued to throw
- throw new FacesException(e);
- }
+ super("jms/jfinancials-queue-factory", "jms/jfinancials-email-queue"); //NOI18N
}
/**
try {
// Send out email change
- ObjectMessage message = this.session.createObjectMessage();
+ ObjectMessage message = this.getSession().createObjectMessage();
message.setObject(emailWrapper);
// Send message
- this.sendMessage(message, this.messageProducer);
+ this.sendMessage(message);
} catch (final JMSException ex) {
// Throw again
throw new EJBException(ex);
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.model.income;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for billable income
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface BillableIncome extends Serializable {
+
+ /**
+ * Getter for income id (primary key)
+ * <p>
+ * @return Income id (primary key)
+ */
+ Long getIncomeId ();
+
+ /**
+ * Setter for income id (primary key)
+ * <p>
+ * @param incomeId Income id (primary key)
+ */
+ void setIncomeId (final Long incomeId);
+
+ /**
+ * Getter for income-created timestamp
+ * <p>
+ * @return Income-created timestamp
+ */
+ Calendar getIncomeCreated ();
+
+ /**
+ * Setter for income-created timestamp
+ * <p>
+ * @param incomeCreated Income-created timestamp
+ */
+ void setIncomeCreated (final Calendar incomeCreated);
+
+ /**
+ * Getter for whether income is enabled
+ * <p>
+ * @return Whether income is enabled
+ */
+ Boolean getIncomeEnabled ();
+
+ /**
+ * Setter for whether income is enabled
+ * <p>
+ * @param incomeEnabled Whether income is enabled
+ */
+ void setIncomeEnabled (final Boolean incomeEnabled);
+
+ /**
+ * Getter for income interval
+ * <p>
+ * @return Income interval
+ */
+ FinancialInterval getIncomeInterval ();
+
+ /**
+ * Setter for income interval
+ * <p>
+ * @param incomeInterval Income interval
+ */
+ void setIncomeInterval (final FinancialInterval incomeInterval);
+
+ /**
+ * 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 title
+ * <p>
+ * @return Income title
+ */
+ String getIncomeTitle ();
+
+ /**
+ * Setter for income title
+ * <p>
+ * @param incomeTitle Income title
+ */
+ void setIncomeTitle (final String incomeTitle);
+
+ /**
+ * Getter for income-updated timestamp
+ * <p>
+ * @return Income-updated timestamp
+ */
+ Calendar getIncomeUpdated ();
+
+ /**
+ * Setter for income-updated timestamp
+ * <p>
+ * @param incomeUpdated Income-updated timestamp
+ */
+ void setIncomeUpdated (final Calendar incomeUpdated);
+
+ /**
+ * Getter for connected user account
+ * <p>
+ * @return Connected user account
+ */
+ User getIncomeUser ();
+
+ /**
+ * Setter for connected user account
+ * <p>
+ * @param incomeUser Connected user account
+ */
+ void setIncomeUser (final User incomeUser);
+
+ @Override
+ boolean equals (final Object object);
+
+ @Override
+ int hashCode ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.model.income;
+
+import java.util.Calendar;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.mxchange.jfinancials.model.income.interval.FinancialInterval;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An entity for income data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Entity (name = "income")
+@Table (name = "income")
+@SuppressWarnings ("PersistenceUnitPresent")
+public class FinancialIncome implements BillableIncome {
+
+ /**
+ * Serial number
+ */
+ @Transient
+ private static final long serialVersionUID = 173_587_690_625_524L;
+
+ /**
+ * Income created timestamp
+ */
+ @Basic (optional = false)
+ @Temporal (TemporalType.TIMESTAMP)
+ @Column (name = "income_created", nullable = false, updatable = false)
+ private Calendar incomeCreated;
+
+ /**
+ * Income enabled (default) or disabled (no longer receiving income but need
+ * to keep it for statistics).
+ */
+ @Basic (optional = false)
+ @Column (name = "income_enabled", nullable = false)
+ private Boolean incomeEnabled;
+
+ /**
+ * Income id (primary key)
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "income_id", nullable = false, updatable = false)
+ private Long incomeId;
+
+ /**
+ * Income interval
+ */
+ @Basic (optional = false)
+ @Column (name = "income_interval", nullable = false)
+ @Enumerated (EnumType.STRING)
+ private FinancialInterval incomeInterval;
+
+ /**
+ * Income single amount
+ */
+ @Basic (optional = false)
+ @Column (name = "income_single_amount", nullable = false)
+ private Float incomeSingleAmount;
+
+ /**
+ * Income title
+ */
+ @Basic (optional = false)
+ @Column (name = "income_title", nullable = false)
+ private String incomeTitle;
+
+ /**
+ * Income updated timestamp
+ */
+ @Temporal (TemporalType.TIMESTAMP)
+ @Column (name = "income_updated", insertable = false)
+ private Calendar incomeUpdated;
+
+ /**
+ * Connected user account
+ */
+ @JoinColumn (name = "income_user_id", referencedColumnName = "user_id", nullable = false, updatable = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
+ private User incomeUser;
+
+ /**
+ * Default constructor
+ */
+ public FinancialIncome () {
+ }
+
+ /**
+ * Constructor with all fields, except timestamps. These have to be set at a
+ * proper place
+ * <p>
+ * @param incomeTitle Income (type) title
+ * @param incomeSingleAmount Single amount
+ * @param incomeInterval Interval
+ * @param incomeUser Connected user
+ */
+ public FinancialIncome (final String incomeTitle, final Float incomeSingleAmount, final FinancialInterval incomeInterval, final User incomeUser) {
+ // Call default constructor
+ this();
+
+ // Set all fields
+ this.incomeTitle = incomeTitle;
+ this.incomeSingleAmount = incomeSingleAmount;
+ this.incomeInterval = incomeInterval;
+ this.incomeUser = incomeUser;
+
+ // Enable this income by default
+ this.incomeEnabled = Boolean.TRUE;
+ }
+
+ @Override
+ public boolean equals (final Object object) {
+ if (this == object) {
+ return true;
+ } else if (null == object) {
+ return false;
+ } else if (this.getClass() != object.getClass()) {
+ return false;
+ }
+
+ final BillableIncome other = (BillableIncome) object;
+
+ if (!Objects.equals(this.getIncomeTitle(), other.getIncomeTitle())) {
+ return false;
+ } else if (!Objects.equals(this.getIncomeId(), other.getIncomeId())) {
+ return false;
+ } else if (!Objects.equals(this.getIncomeUser(), other.getIncomeUser())) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getIncomeCreated () {
+ return this.incomeCreated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setIncomeCreated (Calendar incomeCreated) {
+ this.incomeCreated = incomeCreated;
+ }
+
+ @Override
+ public Boolean getIncomeEnabled () {
+ return this.incomeEnabled;
+ }
+
+ @Override
+ public void setIncomeEnabled (Boolean incomeEnabled) {
+ this.incomeEnabled = incomeEnabled;
+ }
+
+ @Override
+ public Long getIncomeId () {
+ return this.incomeId;
+ }
+
+ @Override
+ public void setIncomeId (final Long incomeId) {
+ this.incomeId = incomeId;
+ }
+
+ @Override
+ public FinancialInterval getIncomeInterval () {
+ return this.incomeInterval;
+ }
+
+ @Override
+ public void setIncomeInterval (FinancialInterval incomeInterval) {
+ this.incomeInterval = incomeInterval;
+ }
+
+ @Override
+ public Float getIncomeSingleAmount () {
+ return this.incomeSingleAmount;
+ }
+
+ @Override
+ public void setIncomeSingleAmount (Float incomeSingleAmount) {
+ this.incomeSingleAmount = incomeSingleAmount;
+ }
+
+ @Override
+ public String getIncomeTitle () {
+ return this.incomeTitle;
+ }
+
+ @Override
+ public void setIncomeTitle (String incomeTitle) {
+ this.incomeTitle = incomeTitle;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getIncomeUpdated () {
+ return this.incomeUpdated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setIncomeUpdated (Calendar incomeUpdated) {
+ this.incomeUpdated = incomeUpdated;
+ }
+
+ @Override
+ public User getIncomeUser () {
+ return this.incomeUser;
+ }
+
+ @Override
+ public void setIncomeUser (User incomeUser) {
+ this.incomeUser = incomeUser;
+ }
+
+ @Override
+ public int hashCode () {
+ int hash = 3;
+
+ hash = 29 * hash + Objects.hashCode(this.getIncomeId());
+ hash = 29 * hash + Objects.hashCode(this.getIncomeTitle());
+ hash = 29 * hash + Objects.hashCode(this.getIncomeUser());
+
+ return hash;
+ }
+
+}
--- /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 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.model.income;
+
+import java.io.Serializable;
+
+/**
+ * An utilities class for incomes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class IncomeUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 145_986_981_751L;
+
+}
--- /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 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.model.income.interval;
+
+import java.io.Serializable;
+
+/**
+ * An enumeration for income/expenses intervals
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public enum FinancialInterval implements Serializable {
+
+ /**
+ * Daily
+ */
+ DAILY("FINANCIAL_INTERVAL_DAILY", "financial_interval_daily"), //NOI18N
+
+ /**
+ * Weekly
+ */
+ WEEKLY("FINANCIAL_INTERVAL_WEEKLY", "financial_interval_weekly"), //NOI18N
+
+ /**
+ * Monthly
+ */
+ MONTHLY("FINANCIAL_INTERVAL_MONTHLY", "financial_interval_monthly"), //NOI18N
+
+ /**
+ * Yearly
+ */
+ YEARLY("FINANCIAL_INTERVAL_YEARLY", "financial_interval_yearly"); //NOI18N
+
+ /**
+ * Message key
+ */
+ private final String messageKey;
+
+ /**
+ * CSS style class
+ */
+ private final String styleClass;
+
+ /**
+ * Constructor with i18n translation key and CSS style class
+ * <p>
+ * @param messageKey Message key (i18n)
+ * @param styleClass CSS style class
+ */
+ private FinancialInterval (final String messageKey, final String styleClass) {
+ // Set it here
+ this.messageKey = messageKey;
+ this.styleClass = styleClass;
+ }
+
+ /**
+ * Getter for message key
+ * <p>
+ * @return Message key (i18n)
+ */
+ public String getMessageKey () {
+ return this.messageKey;
+ }
+
+ /**
+ * Getter for CSS style class
+ * <p>
+ * @return CSS style class
+ */
+ public String getStyleClass () {
+ return this.styleClass;
+ }
+
+}
// Call other constructor first
this();
- // Set all
+ // Set all values
this.receiptPaymentType = receiptPaymentType;
this.receiptSeller = receiptSeller;
this.receiptUser = receiptUser;
import java.io.Serializable;
import java.util.Calendar;
-import org.mxchange.jproduct.model.product.Product;
import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jproduct.model.product.Product;
/**
* An interface for receipt entries
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
import org.mxchange.jproduct.model.product.GenericProduct;
import org.mxchange.jproduct.model.product.Product;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
/**
* A class for entryReceipt entries
* Product being linked in this entryReceipt item
*/
@JoinColumn (name = "entry_product_id", referencedColumnName = "product_id", nullable = false, updatable = false, unique = true)
- @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.ALL, optional = false)
+ @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false)
private Product entryProduct;
/**
* @param entryReceipt FinancialReceipt instance
*/
public ReceiptEntry (final Product entryProduct, final Float entryProductPrice, final Long entryProductQuantity, final BillableReceipt entryReceipt) {
+ // Call other constructor
+ this();
+
+ // Set all values
this.entryProduct = entryProduct;
this.entryProductPrice = entryProductPrice;
this.entryProductQuantity = entryProductQuantity;