diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dd82ebf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+/ace-controller/target/
+/ace-layout/target/
+/ace-web/target/
+/ace-security/target/
+/ace-controller-mobile/target/
+/ace-model/target/
+/ace-ws-rest/target/
diff --git a/ace-controller-mobile/nb-configuration.xml b/ace-controller-mobile/nb-configuration.xml
new file mode 100644
index 0000000..a65c451
--- /dev/null
+++ b/ace-controller-mobile/nb-configuration.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ JDK_1.8
+
+
diff --git a/ace-controller-mobile/pom.xml b/ace-controller-mobile/pom.xml
new file mode 100644
index 0000000..bda5bee
--- /dev/null
+++ b/ace-controller-mobile/pom.xml
@@ -0,0 +1,81 @@
+
+
+ 4.0.0
+ com.arrebol
+ ace-controller-mobile
+ 1.0.0
+ jar
+
+ UTF-8
+ 1.8
+ 1.8
+ 2.17.0
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.12.4
+
+ true
+
+
+
+
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.12
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ ${log4j.version}
+
+
+
+ com.arrebol
+ ace-model
+ 1.0.0
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ ace-controller-mobile
+
\ No newline at end of file
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/ClosingDayController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/ClosingDayController.java
new file mode 100644
index 0000000..a983418
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/ClosingDayController.java
@@ -0,0 +1,91 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.admin;
+
+import com.arrebol.apc.controller.mobile.repository.admin.ClosingDayRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.admin.constance.ClosingDayCfg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.enums.ActiveStatus;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class ClosingDayController implements Serializable {
+
+ /**
+ *
+ * @param idEmployee
+ * @param idOffice
+ * @return
+ * @throws Exception
+ */
+ public String findIdClosingDayByEmployee(String idEmployee, String idOffice) throws Exception {
+ try {
+ ClosingDayRepository repository = new ClosingDayRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_USER, new User(idEmployee)));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return repository.findIdEntity(ClosingDayCfg.QUERY_FIND_ID_BY_EMPLOYEE_AND_OFFICE_EQUALS_CURRDATE, parameters);
+ } catch (Exception e) {
+ logger.error("findIdClosingDayByEmployee", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @param updatedBy
+ * @return
+ * @throws Exception
+ */
+ public boolean disableClosingDayById(String id, String updatedBy) throws Exception {
+ try {
+ ClosingDayRepository repository = new ClosingDayRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ID, id));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_ACTIVE_STATUS, ActiveStatus.DISABLED));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_BY, updatedBy));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_LAST_UPDATED_ON, new Date()));
+
+ return repository.updateClosingDay(ClosingDayCfg.QUERY_UPDATE_CLOSING_DAY_BY_STATUS, parameters);
+ } catch (Exception e) {
+ logger.error("disableClosingDayById", e);
+ throw e;
+ }
+ }
+
+ public Long countIdClosingDayByEmployee(String idEmployee, String idOffice) throws Exception {
+ try {
+ ClosingDayRepository repository = new ClosingDayRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_USER, new User(idEmployee)));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return repository.countIdClosingDayByEmployee(ClosingDayCfg.QUERY_FIND_ID_BY_EMPLOYEE_AND_OFFICE_EQUALS_CURRDATE, parameters);
+ } catch (Exception e) {
+ logger.error("findIdClosingDayByEmployee", e);
+ throw e;
+ }
+ }
+
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableGeneralBoxController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableGeneralBoxController.java
new file mode 100644
index 0000000..fa17a49
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableGeneralBoxController.java
@@ -0,0 +1,46 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.admin;
+
+import com.arrebol.apc.controller.mobile.repository.admin.StableGeneralBoxRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.admin.constance.StableGeneralBoxCfg;
+import com.arrebol.apc.model.core.Office;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class StableGeneralBoxController implements Serializable {
+
+ /**
+ *
+ * @param idOffice
+ * @return
+ * @throws Exception
+ */
+ public boolean existStableGeneralBoxByCreatedOn(String idOffice) throws Exception {
+ try {
+ StableGeneralBoxRepository repository = new StableGeneralBoxRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(StableGeneralBoxCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return new Long(1).compareTo(repository.countStableGeneralBoxByOfficeEqualsToCurrentDate(StableGeneralBoxCfg.QUERY_COUNT_STABLE_GENERAL_BOX_BY_OFFICE_EQUALS_TO_CURRENT_DATE, parameters)) == 0;
+ } catch (Exception e) {
+ logger.error("existStableSmallBoxByCreatedOn", e);
+ throw e;
+ }
+ }
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableSmallBoxController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableSmallBoxController.java
new file mode 100644
index 0000000..be3c449
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/admin/StableSmallBoxController.java
@@ -0,0 +1,95 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.admin;
+
+import com.arrebol.apc.controller.mobile.repository.admin.ClosingDayRepository;
+import com.arrebol.apc.controller.mobile.repository.admin.StableSmallBoxRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.admin.constance.StableSmallBoxCfg;
+import com.arrebol.apc.model.admin.constance.StableSmallBoxCfg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.enums.ActiveStatus;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class StableSmallBoxController implements Serializable {
+
+ /**
+ *
+ * @param id
+ * @param updatedBy
+ * @return
+ * @throws Exception
+ */
+ public boolean disableIdSmallBoxById(String id, String updatedBy) throws Exception {
+ try {
+ ClosingDayRepository repository = new ClosingDayRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_ID, id));
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_ACTIVE_STATUS, ActiveStatus.DISABLED));
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_LAST_UPDATED_BY, updatedBy));
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_LAST_UPDATED_ON, new Date()));
+
+ return repository.updateClosingDay(StableSmallBoxCfg.QUERY_UPDATE_STABLE_SMALL_BOX_BY_STATUS, parameters);
+ } catch (Exception e) {
+ logger.error("disableIdSmallBoxById", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param idOffice
+ * @return
+ * @throws Exception
+ */
+ public boolean existStableSmallBoxByCreatedOn(String idOffice) throws Exception {
+ try {
+ StableSmallBoxRepository repository = new StableSmallBoxRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return new Long(1).compareTo(repository.countStableSmallBoxByOfficeEqualsToCurrentDate(StableSmallBoxCfg.QUERY_COUNT_STABLE_SMALL_BOX_BY_OFFICE_EQUALS_TO_CURDATE, parameters)) == 0;
+ } catch (Exception e) {
+ logger.error("existStableSmallBoxByCreatedOn", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param idOffice
+ * @return
+ * @throws Exception
+ */
+ public String findIdStableSmallBoxByOfficeInCurrentDate(String idOffice) throws Exception {
+ try {
+ ClosingDayRepository repository = new ClosingDayRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(StableSmallBoxCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return repository.findIdEntity(StableSmallBoxCfg.QUERY_FIND_STABLE_SMALL_BOX_BY_OFFICE_EQUALS_TO_CURRENT_DATE, parameters);
+ } catch (Exception e) {
+ logger.error("findIdStableSmallBoxByOfficeInCurrentDate", e);
+ throw e;
+ }
+ }
+
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/bitacora/BitacoraController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/bitacora/BitacoraController.java
new file mode 100644
index 0000000..d1c0334
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/bitacora/BitacoraController.java
@@ -0,0 +1,59 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.bitacora;
+
+import com.arrebol.apc.controller.mobile.repository.bitacora.BitacoraRepository;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.system.logs.Bitacora;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.UUID;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class BitacoraController implements Serializable {
+
+ /**
+ *
+ * @param action
+ * @param userName
+ * @param comments
+ * @param createdBy
+ * @param office
+ * @param description
+ * @return
+ */
+ public boolean insertBitacoraRecord(String action, String userName, String comments, String createdBy, String office, String description) {
+ boolean success;
+ try {
+ BitacoraRepository repository = new BitacoraRepository();
+ Bitacora bitacora = new Bitacora();
+
+ bitacora.setId(UUID.randomUUID().toString());
+ bitacora.setNameUser(userName);
+ bitacora.setAction(action);
+ bitacora.setCommentsUser(comments);
+ bitacora.setCreatedBy(createdBy);
+ bitacora.setCreatedOn(new Date());
+ bitacora.setOffice(new Office(office));
+ bitacora.setDescription(description);
+
+ success = repository.saveBitacora(bitacora);
+ } catch (Exception e) {
+ success = false;
+ logger.error("insertBitacoraRecord", e);
+ }
+ return success;
+ }
+
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/cash/CashRegisterCurdateByUserController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/cash/CashRegisterCurdateByUserController.java
new file mode 100644
index 0000000..4747225
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/cash/CashRegisterCurdateByUserController.java
@@ -0,0 +1,107 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.cash;
+
+import com.arrebol.apc.controller.mobile.repository.views.CashRegisterCurdateByUserViewRepository;
+import com.arrebol.apc.controller.mobile.repository.views.TotalCashByCurdateViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.core.constance.CashRegisterCurdateByUserViewCfg;
+import com.arrebol.apc.model.views.CashRegisterCurdateByUserView;
+import com.arrebol.apc.model.views.TotalCashByCurdateView;
+import com.arrebol.apc.model.ws.parsed.AmountJaxb;
+import com.arrebol.apc.model.ws.parsed.CashRegisterJaxb;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class CashRegisterCurdateByUserController implements Serializable {
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public CashRegisterJaxb findAllCashRegisterCurdateByUserId(String userId) throws Exception {
+ logger.debug("findAllCashRegisterCurdateByUserId");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ CashRegisterCurdateByUserViewCfg.FIELD_USER_ID,
+ userId
+ )
+ );
+
+ Double totalCash = 0d;
+ List amounts = new ArrayList<>();
+
+ List results = cashRegisterCurdateByUserViewRepository.findAllCashRegisterCurdateByUserId(
+ CashRegisterCurdateByUserView.class,
+ CashRegisterCurdateByUserViewCfg.QUERY_FIND_CASH_REGISTER,
+ parameters);
+
+ for (CashRegisterCurdateByUserView result : results) {
+ totalCash += result.getPayment().doubleValue();
+
+ amounts.add(
+ new AmountJaxb(
+ result.getCustomerName(),
+ result.getPayment().doubleValue()
+ )
+ );
+ }
+
+ return new CashRegisterJaxb(totalCash, amounts);
+ } catch (Exception e) {
+ logger.error("findAllCashRegisterCurdateByUserId", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public TotalCashByCurdateView findDailyTotalsByUserId(String userId) throws Exception {
+ logger.debug("findById");
+ try {
+ TotalCashByCurdateView result = totalCashByCurdateViewRepository.findById(userId);
+
+ if (null == result) {
+ throw new NullPointerException("userId: " + userId + " NOT found");
+ } else {
+ return result;
+ }
+ } catch (Exception e) {
+ logger.error("findById", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -3434981661467291172L;
+ final Logger logger = LogManager.getLogger(CashRegisterCurdateByUserController.class);
+
+ private final CashRegisterCurdateByUserViewRepository cashRegisterCurdateByUserViewRepository;
+ private final TotalCashByCurdateViewRepository totalCashByCurdateViewRepository;
+
+ public CashRegisterCurdateByUserController() {
+ this.cashRegisterCurdateByUserViewRepository = new CashRegisterCurdateByUserViewRepository();
+ this.totalCashByCurdateViewRepository = new TotalCashByCurdateViewRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java
new file mode 100644
index 0000000..74734ae
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/customer/CustomerController.java
@@ -0,0 +1,63 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.customer;
+
+import com.arrebol.apc.controller.mobile.repository.views.LoanByUserViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.core.constance.LoanByUserViewCfg;
+import com.arrebol.apc.model.enums.PreferenceValue;
+import com.arrebol.apc.model.views.LoanByUserView;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class CustomerController implements Serializable {
+
+ /**
+ *
+ * @param orderList
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public List findAllLoansByUserId(String orderList, String userId) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+
+ boolean isByOrderInList = PreferenceValue.ORDER_IN_LIST.toString().equals(orderList);
+
+ parameters.add(new ModelParameter(LoanByUserViewCfg.FIELD_USER_ID, userId));
+
+ return loanByUserViewRepository
+ .findAllLoansByUserId(
+ isByOrderInList
+ ? LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_ORDER_LIST
+ : LoanByUserViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ID_BY_CUSTOMER_NAME,
+ parameters
+ );
+ } catch (Exception e) {
+ logger.error("findAllLoansByUserId", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -6689182942800786108L;
+ final Logger logger = LogManager.getLogger(CustomerController.class);
+
+ private final LoanByUserViewRepository loanByUserViewRepository;
+
+ public CustomerController() {
+ this.loanByUserViewRepository = new LoanByUserViewRepository();
+ }
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/exchange/ExchangeEnebledUsersController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/exchange/ExchangeEnebledUsersController.java
new file mode 100644
index 0000000..abdf1aa
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/exchange/ExchangeEnebledUsersController.java
@@ -0,0 +1,165 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.exchange;
+
+import com.arrebol.apc.controller.mobile.repository.admin.TransferRepository;
+import com.arrebol.apc.controller.mobile.repository.views.ExchangeEnebledUsersViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.admin.Transfer;
+import com.arrebol.apc.model.admin.constance.TransferCfg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.core.constance.ExchangeEnebledUsersViewCfg;
+import com.arrebol.apc.model.enums.ActionStatus;
+import com.arrebol.apc.model.enums.ActiveStatus;
+import com.arrebol.apc.model.views.ExchangeEnebledUsersView;
+import com.arrebol.apc.model.ws.parsed.Exchange;
+import com.arrebol.apc.model.ws.parsed.ExchangeJaxb;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class ExchangeEnebledUsersController implements Serializable {
+
+ /**
+ *
+ * @param userId
+ * @param officeId
+ * @return
+ * @throws Exception
+ */
+ public List findEnebledUsersToUserId(String userId, String officeId) throws Exception {
+ logger.debug("exchangeEnebledUsersViewRepository");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ ExchangeEnebledUsersViewCfg.PARAM_OFFICE_ID,
+ officeId
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ ExchangeEnebledUsersViewCfg.FIELD_VIEW_ID,
+ userId
+ )
+ );
+
+ return exchangeEnebledUsersViewRepository.findEnebledUsersToUserId(
+ ExchangeEnebledUsersViewCfg.QUERY_FIND_ENEBLED_USERS_TO_USER_ID,
+ parameters
+ );
+ } catch (Exception e) {
+ logger.error("findEnebledUsersToUserId", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param jaxb
+ * @return
+ * @throws Exception
+ */
+ public boolean newExchange(ExchangeJaxb jaxb) throws Exception {
+ logger.debug("newExchange");
+ try {
+ Transfer transfer = new Transfer(
+ new User(jaxb.getSenderId()),
+ new User(jaxb.getReceiverId()),
+ ActiveStatus.ENEBLED,
+ ActionStatus.PENDING,
+ jaxb.getAmount(),
+ new Office(jaxb.getOfficeId()),
+ jaxb.getSenderId());
+
+ return transferRepository.addTransfer(transfer);
+ } catch (Exception e) {
+ logger.error("newExchange", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param transerId
+ * @param userId
+ * @param isApproved
+ * @return
+ * @throws Exception
+ */
+ public boolean updateExchange(String transerId, String userId, boolean isApproved) throws Exception {
+ logger.debug("updateExchange");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(TransferCfg.FIELD_ACTION_STATUS, isApproved ? ActionStatus.APPROVED : ActionStatus.REJECTED));
+ parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_BY, userId));
+ parameters.add(new ModelParameter(TransferCfg.FIELD_LAST_UPDATED_ON, new Date()));
+ parameters.add(new ModelParameter(TransferCfg.FIELD_ID, transerId));
+
+ return transferRepository.updateTransfer(TransferCfg.QUERY_UPDATE_TRANSFER_BY_ACTION, parameters);
+ } catch (Exception e) {
+ logger.error("updateExchange", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public List exchangesByUsers(String userId) throws Exception {
+ logger.debug("exchangesByUsers");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ TransferCfg.FIELD_USER_TRANSMITTER,
+ new User(userId)
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ TransferCfg.FIELD_USER_RECEIVER,
+ new User(userId)
+ )
+ );
+
+ return transferRepository.findAllTransferByUserIdAndCurdate(TransferCfg.QUERY_FIND_ALL_TRANSFER_BY_USER_ID_AND_CURDATE, parameters);
+ } catch (Exception e) {
+ logger.error("exchangesByUsers", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = 2625775904919860613L;
+ final Logger logger = LogManager.getLogger(ExchangeEnebledUsersController.class);
+
+ private final ExchangeEnebledUsersViewRepository exchangeEnebledUsersViewRepository;
+ private final TransferRepository transferRepository;
+
+ public ExchangeEnebledUsersController() {
+ this.exchangeEnebledUsersViewRepository = new ExchangeEnebledUsersViewRepository();
+ this.transferRepository = new TransferRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/gasoline/GasolineController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/gasoline/GasolineController.java
new file mode 100644
index 0000000..282ac51
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/gasoline/GasolineController.java
@@ -0,0 +1,41 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.gasoline;
+
+import com.arrebol.apc.controller.mobile.repository.gasoline.GasolineRepository;
+import com.arrebol.apc.model.gasoline.Gasoline;
+import java.io.Serializable;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class GasolineController implements Serializable {
+
+ /**
+ *
+ * @param gasoline
+ * @return
+ * @throws Exception
+ */
+ public boolean saveNewGasolinePayment(Gasoline gasoline) throws Exception {
+ try {
+ GasolineRepository gasolineRepository = new GasolineRepository();
+
+ return gasolineRepository.saveNewGasolinePayment(gasoline);
+ } catch (Exception e) {
+ logger.error("addNewGasolineEntry", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -5280895557294295000L;
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java
new file mode 100644
index 0000000..3f874bc
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/loan/LoanController.java
@@ -0,0 +1,1398 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.loan;
+
+import com.arrebol.apc.controller.mobile.json.loan.AuthorizeTransferList;
+import com.arrebol.apc.controller.mobile.json.loan.AuthorizeTransferPaymentsDto;
+import com.arrebol.apc.controller.mobile.json.loan.DeleteLoanDetailsJaxb;
+import com.arrebol.apc.model.ws.parsed.LoanRequestedJaxb;
+import com.arrebol.apc.controller.mobile.json.loan.LoanTypeJaxb;
+import com.arrebol.apc.controller.mobile.json.loan.LoanTypeListJaxb;
+import com.arrebol.apc.controller.mobile.json.loan.UpdateLoanToDeliveryStatusDTO;
+import com.arrebol.apc.controller.mobile.json.loan.UpdateLoanToDeliveryStatusList;
+import com.arrebol.apc.controller.mobile.repository.loan.AddAmountRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanByRenovationRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanDetailsRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanFeeNotificationRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanToDeliveryByCertifierRepository;
+import com.arrebol.apc.controller.mobile.repository.loan.LoanTypeRepository;
+import com.arrebol.apc.controller.mobile.repository.user.UserRepository;
+import com.arrebol.apc.controller.mobile.repository.views.LoanApprovedDetailViewRepository;
+import com.arrebol.apc.controller.mobile.repository.views.LoanInPendingStatusToDeliveryViewRepository;
+import com.arrebol.apc.controller.mobile.repository.views.SearchPersonAvailableRepository;
+import com.arrebol.apc.controller.mobile.repository.views.TransferInPendingStatusViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.catalog.People;
+import com.arrebol.apc.model.catalog.RouteCtlg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.core.constance.AvailableCustomersViewCfg;
+import com.arrebol.apc.model.core.constance.AvailableEndorsementsViewCfg;
+import com.arrebol.apc.model.core.constance.LoanByUserCfg;
+import com.arrebol.apc.model.core.constance.LoanCfg;
+import com.arrebol.apc.model.core.constance.LoanDetailsCfg;
+import com.arrebol.apc.model.core.constance.LoanFeeNotificationCfg;
+import com.arrebol.apc.model.core.constance.LoanToDeliveryByCertifierViewCfg;
+import com.arrebol.apc.model.core.constance.LoanTypeCfg;
+import com.arrebol.apc.model.core.constance.UserCfg;
+import com.arrebol.apc.model.enums.ActiveStatus;
+import com.arrebol.apc.model.enums.ComissionType;
+import com.arrebol.apc.model.enums.LoanDetailsType;
+import com.arrebol.apc.model.enums.LoanStatus;
+import com.arrebol.apc.model.enums.OwnerLoan;
+import com.arrebol.apc.model.enums.PeopleType;
+import com.arrebol.apc.model.enums.TransferStatus;
+import com.arrebol.apc.model.loan.Delivery;
+import com.arrebol.apc.model.loan.Loan;
+import com.arrebol.apc.model.loan.LoanByRenovation;
+import com.arrebol.apc.model.loan.LoanByUser;
+import com.arrebol.apc.model.loan.LoanByUserId;
+import com.arrebol.apc.model.loan.LoanDetails;
+import com.arrebol.apc.model.loan.LoanFeeNotification;
+import com.arrebol.apc.model.loan.LoanType;
+import com.arrebol.apc.model.views.AvailableCustomersView;
+import com.arrebol.apc.model.views.AvailableEndorsementsView;
+import com.arrebol.apc.model.views.LoanInPendingStatusToDeliveryView;
+import com.arrebol.apc.model.views.LoanToDeliveryByCertifierView;
+import com.arrebol.apc.model.views.TransferInPendingStatusView;
+import com.arrebol.apc.model.views.constance.LoanInPendingStatusToDeliveryViewCfg;
+import com.arrebol.apc.model.views.constance.TransferInPendingStatusViewCfg;
+import com.arrebol.apc.model.ws.parsed.FeesToPayByLoanRequestJaxb;
+import com.arrebol.apc.model.ws.parsed.LoanDetailJaxb;
+import com.arrebol.apc.model.ws.parsed.NewAmountJaxb;
+import com.arrebol.apc.model.ws.parsed.NewTransferAccountJaxb;
+import com.arrebol.apc.model.ws.parsed.PersonJaxb;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.UUID;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class LoanController implements Serializable {
+
+ /**
+ *
+ * @param loanIdToUpdate
+ * @return
+ */
+ public boolean deleteLoanDetailsFeeByLoanCurdate(String loanIdToUpdate) {
+ logger.debug("deleteLoanDetailsFeeByLoanCurdate");
+
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate)));
+ return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters);
+ }
+
+ /**
+ *
+ * @param loanIdToUpdate
+ * @return
+ */
+ public boolean deleteLoanFeeNotificationByLoanCurdate(String loanIdToUpdate) {
+ logger.debug("deleteLoanFeeNotificationByLoanCurdate");
+
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanIdToUpdate)));
+
+ return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_FEE_NOTIFICATION_CURDATE_BY_LOAN, parameters);
+ }
+
+ /**
+ *
+ * @param loan
+ * @return
+ * @throws Exception
+ */
+ public boolean updateLoan(Loan loan) throws Exception {
+ logger.debug("updateLoan");
+ try {
+ return loanRepository.updateLoan(loan);
+ } catch (Exception e) {
+ logger.error("updateLoan", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param loanIdToUpdate
+ * @return
+ */
+ public boolean deleteLoanDetailsByLoanCurdate(Loan loanIdToUpdate) {
+ logger.debug("updateLoandByUserByUserId");
+
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, loanIdToUpdate));
+
+ return loanRepository.deleteLoanDetailsByLoanCurdate(LoanCfg.QUERY_DELETE_LOAN_DETAILS_CURDATE_BY_LOAN, parameters);
+ }
+
+ /**
+ *
+ * @param customerId
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public DeleteLoanDetailsJaxb enebleToDeleteTodayDetails(String customerId, String userId) throws Exception {
+ DeleteLoanDetailsJaxb result;
+ try {
+ List parameters = new ArrayList<>();
+ List statuses = new ArrayList<>();
+
+ parameters.add(new ModelParameter(UserCfg.FIELD_ID, userId));
+ UserRepository userRepository = new UserRepository();
+
+ if (userRepository.containtsUserManagementProperty(UserCfg.QUERY_IS_USER_MANAGMENT, parameters)) {
+ statuses.add(LoanStatus.APPROVED);
+ statuses.add(LoanStatus.PENDING_RENOVATION);
+
+ parameters.clear();
+ parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER, new People(customerId)));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses));
+
+ if (1 == loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_BY_CUSTOMER_IN_STATUSES, parameters)) {
+ String loanId = loanRepository.findLoanId(LoanCfg.QUERY_SELECT_LOAN_ID_BY_CUSTOMER_IN_STATUSES, parameters);
+
+ result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, loanId);
+ List types = new ArrayList<>();
+
+ parameters.clear();
+ parameters.add(new ModelParameter(LoanCfg.FIELD_ID, loanId));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, statuses));
+
+ result.setApprovedOrPendingRenovation(0 < loanRepository.countLoan(LoanCfg.QUERY_COUNT_LOAN_IN_STATUSES, parameters));
+
+ if (result.getApprovedOrPendingRenovation()) {
+ types.add(LoanDetailsType.PAYMENT);
+ types.add(LoanDetailsType.TRANSFER);
+
+ parameters.clear();
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId)));
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types));
+
+ result.setTodayPayment(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters));
+
+ types.clear();
+ types.add(LoanDetailsType.FEE);
+
+ parameters.clear();
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(loanId)));
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_LOAN_DETAILS_TYPE, types));
+
+ result.setTodayFee(0 < loanDetailsRepository.countLoandDetails(LoanDetailsCfg.QUERY_COUNT_LOAN_DETAILS_IN_CURRDATE, parameters));
+ }
+ } else {
+ result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, "");
+ }
+ } else {
+ result = new DeleteLoanDetailsJaxb(Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, "");
+ }
+
+ return result;
+ } catch (Exception e) {
+ logger.error("enebleToDeleteTodayDetails", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param idLoan
+ * @return
+ * @throws Exception
+ */
+ public List findFeesToPayByLoanId(String idLoan) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan)));
+ return loanDetailsRepository.findFeesToPayByLoanId(LoanDetailsCfg.QUERY_FIND_ALL_FEES_BY_LOAN_ID, parameters);
+ } catch (Exception e) {
+ logger.error("findFeesToPayByLoanId", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param feesToPayByLoanRequestJaxb
+ * @return
+ * @throws Exception
+ */
+ public boolean updatePaidFeesStatusInLoanDetailIds(FeesToPayByLoanRequestJaxb feesToPayByLoanRequestJaxb) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+
+ List ids = new ArrayList<>();
+
+ feesToPayByLoanRequestJaxb.getFeeToPayList().forEach(fee -> {
+ ids.add(fee.getId());
+ });
+
+ int cantidad = feesToPayByLoanRequestJaxb.getFeeToPayList().size();
+ String texto;
+ String precio;
+
+ Locale canada = new Locale("en", "CA");
+ NumberFormat dollarFormat = NumberFormat.getCurrencyInstance(canada);
+ BigDecimal feePayment;
+
+ if (1 == cantidad) {
+ precio = dollarFormat.format(50);
+ feePayment = new BigDecimal("50");
+
+ texto = " de la multa del " + feesToPayByLoanRequestJaxb.getFeeToPayList().get(0).getStrDateToPay();
+ } else {
+ feePayment = new BigDecimal(50 * cantidad);
+ precio = dollarFormat.format(50 * cantidad);
+ String fechas = "";
+
+ for (int i = 0; i < feesToPayByLoanRequestJaxb.getFeeToPayList().size(); i++) {
+ fechas = fechas + feesToPayByLoanRequestJaxb.getFeeToPayList().get(i).getStrDateToPay();
+ if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) {
+ fechas = fechas + ",";
+ }
+ }
+
+ if (feesToPayByLoanRequestJaxb.getFeeToPayList().size() > 1) {
+ fechas = fechas.substring(0, fechas.length() - 1);
+ }
+
+ texto = " de las multas " + fechas;
+ }
+
+ String comments = "Se pago " + precio + texto;
+
+ LoanDetails details = new LoanDetails(
+ UUID.randomUUID().toString(),
+ new Loan(feesToPayByLoanRequestJaxb.getIdLoan()),
+ new User(feesToPayByLoanRequestJaxb.getIdUser()),
+ PeopleType.CUSTOMER,
+ 0,
+ feePayment,
+ LoanDetailsType.PAYMENT,
+ comments,
+ feesToPayByLoanRequestJaxb.getIdUser(),
+ new Date());
+
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids));
+
+ return loanDetailsRepository.updatePaidFeesStatusInLoanDetailIds(LoanDetailsCfg.QUERY_UPDATE_PAID_FEES_STATUS_IN_LOAN_DETAILS_IDS, parameters, details);
+ } catch (Exception e) {
+ logger.error("updatePaidFeesStatusInLoanDetailIds", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param officeId
+ * @return
+ * @throws Exception
+ */
+ public LoanTypeListJaxb findAllLoanTypeByOffice(String officeId) throws Exception {
+ logger.debug("findAllLoanTypeByOffice");
+ LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb();
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanTypeCfg.FIELD_OFFICE, new Office(officeId)));
+
+ List results = loanTypeRepository.findAllLoanTypeByOffice(LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE, parameters);
+ List loanTypeJaxbs = new ArrayList<>();
+
+ results.forEach((result) -> {
+ loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName()));
+ });
+
+ loanTypeListJaxb.setLoans(loanTypeJaxbs);
+
+ return loanTypeListJaxb;
+ } catch (Exception e) {
+ logger.error("findAllLoanTypeByOffice", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param name
+ * @return
+ * @throws Exception
+ */
+ public List findAllAvailableCustomersByType(String name) throws Exception {
+ logger.debug("findAllAvailableCustomersByType");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(AvailableCustomersViewCfg.FIELD_AVAILABLE_PERSON, name));
+
+ return searchPersonAvailableRepository.findAvailablePersonLike(
+ AvailableCustomersView.class,
+ AvailableCustomersViewCfg.QUERY_FIND_AVAILABLE_CUSTOMERS,
+ parameters);
+ } catch (Exception e) {
+ logger.error("findAllAvailableCustomersByType", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param name
+ * @return
+ * @throws Exception
+ */
+ public List findAllAvailableEndorsementsByType(String name) throws Exception {
+ logger.debug("findAllAvailableEndorsementsByType");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(AvailableEndorsementsViewCfg.FIELD_AVAILABLE_PERSON, name));
+
+ return searchPersonAvailableRepository.findAvailablePersonLike(
+ AvailableEndorsementsView.class,
+ AvailableEndorsementsViewCfg.QUERY_FIND_AVAILABLE_ENDORSEMENTS,
+ parameters);
+ } catch (Exception e) {
+ logger.error("findAllAvailableEndorsementsByType", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param jaxb
+ * @return
+ * @throws Exception
+ */
+ synchronized public boolean createLoan(LoanRequestedJaxb jaxb) throws Exception {
+ logger.debug("createLoan");
+
+ try {
+
+ if (!jaxb.getCustomer().isCreatePerson()
+ && !verifyPersonAvailability(
+ AvailableCustomersView.class,
+ jaxb.getCustomer().getId()
+ )) {
+ throw new Exception(user_unavailable);
+ }
+
+ if (!jaxb.getEndorsement().isCreatePerson()
+ && !verifyPersonAvailability(
+ AvailableEndorsementsView.class,
+ jaxb.getEndorsement().getId()
+ )) {
+ throw new Exception(user_unavailable);
+ }
+
+//DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date date = new Date();//dateFormat.parse(jaxb.getStrDate());
+
+ LoanByUser loanByUser = new LoanByUser(
+ new LoanByUserId(null, jaxb.getUserId()),
+ LoanStatus.PENDING,
+ OwnerLoan.CURRENT_OWNER,
+ jaxb.getUserId());
+
+ LoanType loanType = loanTypeRepository.findLoanType(jaxb.getLoanTypeId());
+ RouteCtlg routeCtlg = new RouteCtlg(jaxb.getRouteId());
+
+ Loan loan = new Loan(
+ new LoanType(loanType.getId()),
+ null,
+ null,
+ routeCtlg,
+ LoanStatus.PENDING,
+ BigDecimal.ZERO,
+ loanType.getPaymentTotal(),
+ 0,
+ jaxb.getUserId(),
+ date,
+ jaxb.getCustomer().isCreatePerson() ? ActiveStatus.ENEBLED : ActiveStatus.DISABLED,
+ ActiveStatus.DISABLED // FROZEN funcationality
+ );
+ return loanRepository.createLoan(
+ loan,
+ loanByUser,
+ jaxb);
+ } catch (Exception e) {
+ logger.error("createLoan", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param newAmountJaxb
+ * @return
+ * @throws Exception
+ */
+ public boolean saveNewAmount(NewAmountJaxb newAmountJaxb) throws Exception {
+ logger.debug("saveNewAmount");
+
+ LoanFeeNotification notification = null;
+ try {
+ //DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date date = new Date();//dateFormat.parse(newAmountJaxb.getStrDate());
+ List parameters = new ArrayList<>();
+
+ if (newAmountJaxb.isFee()) {
+ parameters.add(
+ new ModelParameter(
+ LoanFeeNotificationCfg.FIELD_LOAN,
+ new Loan(newAmountJaxb.getLoanId())
+ )
+ );
+
+ Long total = loanFeeNotificationRepository.countNotificationByLoanId(
+ Long.class,
+ LoanFeeNotificationCfg.QUERY_COUNT_NOTIFICATION_BY_LOAN_ID,
+ parameters);
+
+ notification = new LoanFeeNotification(
+ new Loan(newAmountJaxb.getLoanId()),
+ new User(newAmountJaxb.getUserId()),
+ (total.intValue() + 1),
+ newAmountJaxb.getUserId(),
+ date
+ );
+ }
+
+ if (newAmountJaxb.isFee() && null == notification) {
+ throw new Exception("Could not create the notification for the loan " + newAmountJaxb.getLoanId());
+ }
+
+ Loan loan = loanRepository.findLoanById(newAmountJaxb.getLoanId());
+ int referenceNumber = loan.getLastReferenceNumber() + 1;
+
+ LoanDetails loanDetails = new LoanDetails(
+ new Loan(newAmountJaxb.getLoanId()),
+ new User(newAmountJaxb.getUserId()),
+ newAmountJaxb.isCustomer() ? PeopleType.CUSTOMER : PeopleType.ENDORSEMENT,
+ newAmountJaxb.getAmount(),
+ referenceNumber,
+ newAmountJaxb.isFee() ? LoanDetailsType.FEE : LoanDetailsType.PAYMENT,
+ newAmountJaxb.getUserId(),
+ date,
+ newAmountJaxb.getComments()
+ );
+
+ BigDecimal newAmountPaid, newAmountToPay;
+
+ if (newAmountJaxb.isFee()) {
+ newAmountPaid = loan.getAmountPaid();
+ newAmountToPay = loan.getAmountToPay().add(newAmountJaxb.getAmount());
+ } else {
+ newAmountPaid = loan.getAmountPaid().add(newAmountJaxb.getAmount());
+ newAmountToPay = loan.getAmountToPay();
+ }
+
+ parameters.clear();
+
+ String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID;
+
+ if (!newAmountJaxb.isFee() && 0 == loan.getAmountToPay().compareTo(newAmountPaid)) {
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH));
+
+ query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID;
+ }
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, newAmountToPay));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, newAmountJaxb.getUserId()));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_ID, newAmountJaxb.getLoanId()));
+
+ return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters);
+ } catch (Exception e) {
+ logger.error("saveNewAmount", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param transfer
+ * @return
+ * @throws Exception
+ */
+ public boolean saveNewTransferAmount(NewTransferAccountJaxb transfer) throws Exception {
+ logger.debug("saveNewTransferAmount");
+
+ LoanFeeNotification notification = null;
+ try {
+ Date date = new Date();
+ List parameters = new ArrayList<>();
+
+ Loan loan = loanRepository.findLoanById(transfer.getLoanId());
+ int referenceNumber = loan.getLastReferenceNumber() + 1;
+
+ BigDecimal amountWithoutIVA = transfer.getAmount().divide(new BigDecimal(1.16),RoundingMode.FLOOR);
+
+ amountWithoutIVA = amountWithoutIVA.setScale(2, RoundingMode.FLOOR);
+
+ StringBuilder comments = new StringBuilder(transfer.getComments());
+
+ comments.append(". Monto de transferencia con IVA: $");
+ comments.append(transfer.getAmount());
+ comments.append(", monto de transferencia sin IVA: $");
+ comments.append(amountWithoutIVA);
+
+ LoanDetails loanDetails = new LoanDetails(
+ new Loan(transfer.getLoanId()),
+ new User(transfer.getUserId()),
+ PeopleType.CUSTOMER,
+ amountWithoutIVA,
+ referenceNumber,
+ LoanDetailsType.TRANSFER,
+ transfer.getUserId(),
+ date,
+ transfer.getComments(),
+ null == transfer.getTransferReference() || transfer.getTransferReference().trim().equals("") ? "Asesor no guardo la referencia de la transferencia. Rechar directamente o solicitar con el administrador la aclaraciĆ³n." : transfer.getTransferReference(),
+ TransferStatus.PENDING
+ );
+
+ BigDecimal newAmountPaid = loan.getAmountPaid().add(amountWithoutIVA);
+
+ parameters.clear();
+
+ String query = LoanCfg.QUERY_UPDATE_LOAN_BY_ID;
+
+ if (0 == loan.getAmountToPay().compareTo(newAmountPaid)) {
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, LoanStatus.FINISH));
+
+ query = LoanCfg.QUERY_UPDATE_AND_FINISH_LOAN_BY_ID;
+ }
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, newAmountPaid));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_TO_PAY, loan.getAmountToPay()));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, referenceNumber));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, transfer.getUserId()));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date));
+ parameters.add(new ModelParameter(LoanCfg.FIELD_ID, transfer.getLoanId()));
+
+ return addAmountRepository.saveNewAmount(notification, loanDetails, query, parameters);
+ } catch (Exception e) {
+ logger.error("saveNewTransferAmount", e);
+ throw e;
+ }
+ }
+
+ /**
+ * This method is for get all loan types applying some business rules, like
+ * number of Fees and if you are ok in 100% you can get next loan.
+ *
+ * @param officeId
+ * @param loanId
+ * @return
+ * @throws Exception
+ */
+ public LoanTypeListJaxb findNewCreditLimit(String officeId, String loanId) throws Exception {
+ logger.debug("findNewCreditLimit");
+ LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb();
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ LoanTypeCfg.FIELD_OFFICE,
+ new Office(officeId)
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanTypeCfg.PARAM_LOAN,
+ new Loan(loanId)
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanTypeCfg.PARAM_LOAN_ID,
+ loanId
+ )
+ );
+
+ List results = loanTypeRepository.findIdAndPaymentLoans(LoanTypeCfg.QUERY_FIND_NEW_CREDIT_LINE_BY_LOAN_ID, parameters);
+ List loanTypeJaxbs = new ArrayList<>();
+
+ results.forEach((result) -> {
+ loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment()));
+ });
+
+ loanTypeListJaxb.setLoans(loanTypeJaxbs);
+
+ return loanTypeListJaxb;
+ } catch (Exception e) {
+ logger.error("findNewCreditLimit", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param officeId
+ * @return
+ * @throws Exception
+ */
+ public LoanTypeListJaxb findAllLoansTypeByOffice(String officeId) throws Exception {
+ logger.debug("findNewCreditLimit");
+ LoanTypeListJaxb loanTypeListJaxb = new LoanTypeListJaxb();
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ LoanTypeCfg.FIELD_OFFICE,
+ new Office(officeId)
+ )
+ );
+
+ List results = loanTypeRepository.findIdAndPaymentLoans(
+ LoanTypeCfg.QUERY_FIND_ALL_LOAN_TYPE_WITH_DESCRIPTION_BY_OFFICE,
+ parameters);
+
+ List loanTypeJaxbs = new ArrayList<>();
+
+ results.forEach((result) -> {
+ loanTypeJaxbs.add(new LoanTypeJaxb(result.getId(), result.getPayment(), result.getLoanTypeName()));
+ });
+
+ loanTypeListJaxb.setLoans(loanTypeJaxbs);
+
+ return loanTypeListJaxb;
+ } catch (Exception e) {
+ logger.error("findNewCreditLimit", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param loan
+ * @param credit
+ * @param user
+ * @param paymentAmount
+ * @param endorsement
+ * @return
+ * @throws Exception
+ */
+ public boolean renovation(String loan,
+ String credit,
+ String user,
+ BigDecimal paymentAmount,
+ PersonJaxb endorsement) throws Exception {
+ logger.debug("renovation");
+ try {
+ Date date = new Date();
+
+ Loan currentLoan = loanRepository.findLoanById(loan);
+ LoanType newCredit = loanTypeRepository.findLoanType(credit);
+ int lastReferenceNumber = currentLoan.getLastReferenceNumber() + 1;
+
+ LoanDetails loanDetails = new LoanDetails(
+ new Loan(loan),
+ new User(user),
+ PeopleType.CUSTOMER,
+ paymentAmount,
+ lastReferenceNumber,
+ LoanDetailsType.PAYMENT,
+ user,
+ date,
+ "Pago y solicitud de renovacion"
+ );
+
+ LoanByUser loanByUser = new LoanByUser(
+ new LoanByUserId(null, user),
+ LoanStatus.PENDING,
+ OwnerLoan.CURRENT_OWNER,
+ user);
+
+ Loan renovation = new Loan(
+ new LoanType(newCredit.getId()),
+ new People(currentLoan.getCustomer().getId()),
+ null,
+ new RouteCtlg(currentLoan.getRouteCtlg().getId()),
+ LoanStatus.PENDING,
+ BigDecimal.ZERO,
+ newCredit.getPaymentTotal(),
+ 0,
+ user,
+ date,
+ ActiveStatus.DISABLED,
+ ActiveStatus.DISABLED // FROZEN funcationality
+ );
+
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_AMOUNT_PAID,
+ currentLoan.getAmountPaid().add(paymentAmount)
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_LAST_REFERENCE_NUMBER,
+ lastReferenceNumber
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_LOAN_STATUS,
+ LoanStatus.PENDING_RENOVATION
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_LAST_UPDATED_BY,
+ user
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_LAST_UPDATED_ON,
+ date
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanCfg.FIELD_ID,
+ loan
+ )
+ );
+
+ People people = null;
+
+ if (null != endorsement) {
+ if (endorsement.isCreatePerson()) {
+ people = new People(
+ endorsement, false,
+ currentLoan.getRouteCtlg().getOffice().getId(),
+ user, currentLoan.getRouteCtlg().getId()
+ );
+ } else {
+ renovation.setEndorsement(new People(endorsement.getId()));
+ }
+ } else {
+ renovation.setEndorsement(new People(currentLoan.getEndorsement().getId()));
+ }
+
+ return loanRepository.renovationLoan(
+ loan,
+ renovation,
+ loanByUser,
+ LoanCfg.QUERY_UPDATE_LOAN_FROM_RENOVATION,
+ parameters,
+ loanDetails, people,
+ null == endorsement ? false : endorsement.isCreatePerson());
+ } catch (Exception e) {
+ logger.error("renovation", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param loan
+ * @param credit
+ * @param user
+ * @param paymentAmount
+ * @param currentOwner
+ * @param endorsement
+ * @return
+ * @throws Exception
+ */
+ public boolean renovationHasPaymentToday(String loan,
+ String credit,
+ String user,
+ BigDecimal paymentAmount,
+ String currentOwner,
+ PersonJaxb endorsement) throws Exception {
+ logger.debug("renovationHasPaymentToday");
+ try {
+ Date date = new Date();
+
+ Loan currentLoan = loanRepository.findLoanById(loan);
+ LoanType newCredit = loanTypeRepository.findLoanType(credit);
+
+ LoanByUser loanByUser = new LoanByUser(
+ new LoanByUserId(null, currentOwner),
+ LoanStatus.PENDING,
+ OwnerLoan.CURRENT_OWNER,
+ user);
+
+ Loan renovation = new Loan(
+ new LoanType(newCredit.getId()),
+ new People(currentLoan.getCustomer().getId()),
+ null,
+ new RouteCtlg(currentLoan.getRouteCtlg().getId()),
+ LoanStatus.PENDING,
+ BigDecimal.ZERO,
+ newCredit.getPaymentTotal(),
+ 0,
+ user,
+ date,
+ ActiveStatus.DISABLED,
+ ActiveStatus.DISABLED // FROZEN funcationality
+ );
+
+ People people = null;
+
+ if (null != endorsement) {
+ if (endorsement.isCreatePerson()) {
+ people = new People(
+ endorsement, false,
+ currentLoan.getRouteCtlg().getOffice().getId(),
+ user, currentLoan.getRouteCtlg().getId()
+ );
+ } else {
+ renovation.setEndorsement(new People(endorsement.getId()));
+ }
+ } else {
+ renovation.setEndorsement(new People(currentLoan.getEndorsement().getId()));
+ }
+
+ return loanRepository.renovationHasPaymentToday(
+ loan,
+ renovation,
+ loanByUser,
+ people,
+ null == endorsement ? false : endorsement.isCreatePerson());
+ } catch (Exception e) {
+ logger.error("renovationHasPaymentToday", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public List findLoansByCertifier(String userId) throws Exception {
+ logger.debug("findLoansByCertifier");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanToDeliveryByCertifierViewCfg.FIELD_USER_ID, userId));
+
+ return toDeliveryByCertifierRepository.findLoansByCertifier(
+ LoanToDeliveryByCertifierView.class,
+ LoanToDeliveryByCertifierViewCfg.QUERY_FIND_LOANS_BY_CERTIFIER,
+ parameters);
+ } catch (Exception e) {
+ logger.error("findLoansByCertifier", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @param user
+ * @param comments
+ * @param action true Approved otherwise Rejected.
+ * @param amount
+ * @param discount
+ * @return
+ * @throws Exception
+ */
+ public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount) throws Exception {
+ logger.debug("certifierAction");
+ boolean success;
+ try {
+ // revisar si es nuevo (1) o renovado (2).
+ // 1 = se cambia el estatus al valor de action
+ // 2, si action es true, hay que hacer update de 3 tablas
+ // A)loan renovado estutus = APPROVED
+ // B) Finish
+ // 1)old loan estatus = FINISH,
+ // 2)old loandbyuser estatus = FINISH
+ // C)loans by renovation estatus = APPROVED
+ // 2, si action es false, hay que hacer update de 3 tablas
+ // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT
+ // B)old loan estatus = APPROVED
+ // 1)old loan estatus = APPROVED
+ // 2)old loandbyuser estatus = APPROVED
+ // C)loans by renovation estatus = REJECT
+ LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id);
+
+ if (null == loanByRenovation) {
+ success = updateLoanByIdFromCertifiedView(
+ id,
+ user,
+ action,
+ comments,
+ amount,
+ ComissionType.INCLUDED);
+ } else {
+ LoanDetails loanDetails = null;
+ BigDecimal totalAmountPaid = null;
+ Integer newLastReferenceNumber = null;
+
+ // Means discount is bigger than 0
+ if (1 == discount.compareTo(new BigDecimal(0))) {
+ Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId());
+
+ totalAmountPaid = loan.getAmountPaid().add(discount);
+ newLastReferenceNumber = loan.getLastReferenceNumber() + 1;
+
+ loanDetails = new LoanDetails(
+ new Loan(loanByRenovation.getLoanOld().getId()),
+ new User(user),
+ PeopleType.CUSTOMER,
+ discount,
+ newLastReferenceNumber,
+ LoanDetailsType.RENOVATION_PAYMENT,
+ user,
+ new Date(),
+ "RetenciĆ³n de " + discount + " el la entrega del crĆ©dito renovado");
+ }
+
+ success = loanByRenovationRepository.updateLoanRenovationFromCerfierView(
+ loanByRenovation,
+ user,
+ comments,
+ action,
+ amount,
+ discount,
+ loanDetails,
+ totalAmountPaid,
+ newLastReferenceNumber,
+ ComissionType.INCLUDED);
+ }
+ return success;
+ } catch (Exception e) {
+ logger.error("certifierAction", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param id
+ * @param user
+ * @param comments
+ * @param action
+ * @param amount
+ * @param discount
+ * @param comissionType
+ * @return
+ * @throws Exception
+ */
+ public boolean certifierAction(String id, String user, String comments, boolean action, BigDecimal amount, BigDecimal discount, ComissionType comissionType) throws Exception {
+ logger.debug("certifierAction");
+ boolean success;
+ try {
+ // revisar si es nuevo (1) o renovado (2).
+ // 1 = se cambia el estatus al valor de action
+ // 2, si action es true, hay que hacer update de 3 tablas
+ // A)loan renovado estutus = APPROVED
+ // B) Finish
+ // 1)old loan estatus = FINISH,
+ // 2)old loandbyuser estatus = FINISH
+ // C)loans by renovation estatus = APPROVED
+ // 2, si action es false, hay que hacer update de 3 tablas
+ // A)loan renovado estutus = REJECT, and loandbyuser estatus = REJECT
+ // B)old loan estatus = APPROVED
+ // 1)old loan estatus = APPROVED
+ // 2)old loandbyuser estatus = APPROVED
+ // C)loans by renovation estatus = REJECT
+ LoanByRenovation loanByRenovation = loanByRenovationRepository.findLoanRenovationByNewLoanId(id);
+
+ if (null == loanByRenovation) {
+ success = updateLoanByIdFromCertifiedView(
+ id,
+ user,
+ action,
+ comments,
+ amount,
+ comissionType);
+ } else {
+ LoanDetails loanDetails = null;
+ BigDecimal totalAmountPaid = null;
+ Integer newLastReferenceNumber = null;
+
+ // Means discount is bigger than 0
+ if (1 == discount.compareTo(new BigDecimal(0))) {
+ Loan loan = loanRepository.findLoanById(loanByRenovation.getLoanOld().getId());
+
+ totalAmountPaid = loan.getAmountPaid().add(discount);
+ newLastReferenceNumber = loan.getLastReferenceNumber() + 1;
+
+ loanDetails = new LoanDetails(
+ new Loan(loanByRenovation.getLoanOld().getId()),
+ new User(user),
+ PeopleType.CUSTOMER,
+ discount,
+ newLastReferenceNumber,
+ LoanDetailsType.RENOVATION_PAYMENT,
+ user,
+ new Date(),
+ "RetenciĆ³n de " + discount + " el la entrega del crĆ©dito renovado");
+ }
+
+ success = loanByRenovationRepository.updateLoanRenovationFromCerfierView(
+ loanByRenovation,
+ user,
+ comments,
+ action,
+ amount,
+ discount,
+ loanDetails,
+ totalAmountPaid,
+ newLastReferenceNumber,
+ comissionType);
+ }
+ return success;
+ } catch (Exception e) {
+ logger.error("certifierAction", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param idLoan
+ * @return
+ * @throws Exception
+ */
+ public List approvedDetailsByIdLoan(String idLoan) throws Exception {
+ logger.debug("approvedDetailsByIdLoan");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID_LOAN, new Loan(idLoan)));
+
+ return loanApprovedDetailViewRepository.findLoanDetailsByLoan(
+ LoanDetailsCfg.QUERY_FIND_LOAN_DETAILS_BY_LOAN,
+ parameters
+ );
+ } catch (Exception e) {
+ logger.error("approvedDetailsByIdLoan", e);
+ throw e;
+ }
+ }
+
+ /**
+ * Searching all loan details by id.
+ *
+ * @param loanId
+ * @return
+ * @throws Exception
+ */
+ public List getLoanDetailsCurdatebyIdLoan(String loanId) throws Exception {
+ logger.debug("getLoanDetailsCurdatebyIdLoan");
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId)));
+
+ try {
+ return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_CURDATE_BY_LOAN, parameters);
+ } catch (Exception ex) {
+ logger.error("getLoanDetailsCurdatebyIdLoan", ex);
+ throw ex;
+ }
+ }
+
+ public List getLoanDetailsFeeCurdatebyIdLoan(String loanId) throws Exception {
+ logger.debug("getLoanDetailsFeeCurdatebyIdLoan");
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_DETAILS_LOAN, new Loan(loanId)));
+
+ try {
+ return loanDetailsRepository.findLoanDetailsByLoanId(LoanCfg.QUERY_FIND_LOAN_DETAILS_FEE_CURDATE_BY_LOAN, parameters);
+ } catch (Exception ex) {
+ logger.error("getLoanDetailsCurdatebyIdLoan", ex);
+ throw ex;
+ }
+ }
+
+ /**
+ *
+ * @param loanId
+ * @return
+ * @throws Exception
+ */
+ public Loan getLoanById(String loanId) throws Exception {
+ try {
+ return loanRepository.findLoanById(loanId);
+ } catch (Exception ex) {
+ throw ex;
+ }
+ }
+
+ /**
+ *
+ * @param idLoan
+ * @param idLoanType
+ * @return
+ * @throws Exception
+ */
+ public boolean updatePaymentTotalLoanById(String idLoan, String idLoanType) throws Exception {
+ try {
+ Loan loan = loanRepository.findLoanById(idLoan);
+ LoanType loanType = loanTypeRepository.findLoanType(idLoanType);
+
+ loan.setLoanType(loanType);
+ loan.setAmountToPay(loanType.getPaymentTotal());
+
+ return loanRepository.updateLoan(loan);
+ } catch (Exception ex) {
+ throw ex;
+ }
+ }
+
+ /**
+ *
+ * @return @throws Exception
+ */
+ public List findAllTransferToAuthorize() throws Exception {
+ try {
+ TransferInPendingStatusViewRepository repository = new TransferInPendingStatusViewRepository();
+ List transferInPendingStatusViews = repository.findAllTransferFromHQL(TransferInPendingStatusViewCfg.QUERY_FIND_ALL_TRANSFER_IN_PENDING_STATUS, null);
+ List results = new ArrayList<>();
+
+ transferInPendingStatusViews.forEach((row) -> {
+ results.add(new AuthorizeTransferPaymentsDto(row.getIdLoanDetail(),
+ row.getStrCreatedOn(),
+ row.getCustomerName(),
+ row.getEndorsementName(),
+ row.getUserName(),
+ row.getPaymentAmount(),
+ row.getLoanComments()));
+ });
+
+ return results;
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param authorizeTransferList
+ * @param transferStatus
+ * @return
+ * @throws Exception
+ */
+ public boolean updateTransferList(AuthorizeTransferList authorizeTransferList, TransferStatus transferStatus) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+ List ids = new ArrayList<>();
+
+ authorizeTransferList.getTransferListToUpdateStatus().forEach((row) -> {
+ ids.add(row.getIdLoan());
+ });
+
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_TRANSFER_STATUS, transferStatus));
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_COMMENS, authorizeTransferList.getComments()));
+ parameters.add(new ModelParameter(LoanDetailsCfg.FIELD_ID, ids));
+
+ return loanDetailsRepository.updateLoanDetails(LoanDetailsCfg.UPDATE_TRANSFER_STATUS_WHERE_ID_IN, parameters);
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @return @throws Exception
+ */
+ public List findAllLoanInPendingStatusToDeliveryView() throws Exception {
+ try {
+ LoanInPendingStatusToDeliveryViewRepository repository = new LoanInPendingStatusToDeliveryViewRepository();
+ List dataRows = repository.findAllLoanInPendingStatusToDeliveryViewFromHQL(LoanInPendingStatusToDeliveryViewCfg.QUERY_FIND_ALL_LOAN_IN_PENDING_STATUS_TO_DELIVERY_VIEW, null);
+ List results = new ArrayList<>();
+
+ dataRows.forEach((row) -> {
+ results.add(new UpdateLoanToDeliveryStatusDTO(row.getIdLoan(),
+ row.getStrCreatedOn(),
+ row.getCustomerName(),
+ row.getEndorsementName(),
+ row.getUserName(),
+ row.getPayment()));
+ });
+
+ return results;
+ } catch (Exception e) {
+ logger.error("findAllLoanInPendingStatusToDeliveryView", e);
+ throw e;
+ }
+ }
+
+ public boolean updateLoanPendingStatusToDelivery(UpdateLoanToDeliveryStatusList updateLoanToDeliveryStatusList, LoanStatus loanStatus) throws Exception {
+ try {
+ List loanParams = new ArrayList<>();
+ List loanByUserParams = new ArrayList<>();
+ List ids = new ArrayList<>();
+ List loans = new ArrayList<>();
+
+ updateLoanToDeliveryStatusList.getLoanToDeliveryList().forEach((row) -> {
+ ids.add(row.getIdLoan());
+ loans.add(new Loan(row.getIdLoan()));
+ });
+
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, loanStatus));
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_AMOUNT_PAID, new BigDecimal(0)));
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_REFERENCE_NUMBER, 0));
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, updateLoanToDeliveryStatusList.getIdUpdateUser()));
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, new Date()));
+ loanParams.add(new ModelParameter(LoanCfg.FIELD_ID, ids));
+
+ loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN_BY_USER_STATUS, loanStatus));
+ loanByUserParams.add(new ModelParameter(LoanByUserCfg.FIELD_LOAN, loans));
+
+ return loanRepository.loanPendingStatusToDelivery(LoanCfg.QUERY_UPDATE_LOAN_STATUS_WHERE_ID_IN, LoanByUserCfg.QUERY_UPDATE_LOAN_BY_USER_STATUS_WHERE_LOAN_IN, loanParams, loanByUserParams);
+ } catch (Exception e) {
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param loanId
+ * @param userId
+ * @param action
+ * @param comments
+ * @param amount
+ * @param comissionType
+ * @return
+ * @throws Exception
+ */
+ private boolean updateLoanByIdFromCertifiedView(String loanId, String userId, boolean action, String comments, BigDecimal amount, ComissionType comissionType) throws Exception {
+ logger.debug("updateLoanByIdFromCertifiedView");
+ try {
+ List parameters = new ArrayList<>();
+ Date date = new Date();
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_LOAN_STATUS, action ? LoanStatus.APPROVED : LoanStatus.REJECTED)
+ );
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_COMMENTS, comments)
+ );
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_CREATED_ON, date)
+ );
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_BY, userId)
+ );
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_LAST_UPDATED_ON, date)
+ );
+
+ parameters.add(
+ new ModelParameter(LoanCfg.FIELD_ID, loanId)
+ );
+
+ Delivery delivery = null;
+
+ if (action) {
+ delivery = new Delivery(
+ new User(userId),
+ new Loan(loanId),
+ amount,
+ userId,
+ date,
+ comissionType);
+ }
+
+ return loanRepository.updateLoan(
+ loanId,
+ LoanCfg.QUERY_UPDATE_LOAN_WITH_CREATED_ON_BY_ID_FROM_CERTIFIER_VIEW,
+ parameters,
+ action ? LoanStatus.APPROVED : LoanStatus.REJECTED,
+ delivery);
+ } catch (Exception e) {
+ logger.error("updateLoanByIdFromCertifiedView", e);
+ throw e;
+ }
+ }
+
+ /**
+ * Vefify that person is available to create a new Loan.
+ *
+ * @param clazz AvailableCustomersView or AvailableEndorsementsView.
+ * @param idPerson Identification NUmber
+ * @return true if is available otherwise false.
+ * @throws Exception
+ */
+ private boolean verifyPersonAvailability(Class clazz, String idPerson) throws Exception {
+ logger.debug("verifyPersonAvailability");
+ try {
+ if (null == idPerson || "".equals(idPerson.trim())) {
+ throw new NullPointerException(clazz + " id is null");
+ }
+
+ return null != searchPersonAvailableRepository.findAvailablePersonByPersonId(clazz, idPerson);
+ } catch (Exception e) {
+ logger.error("verifyPersonAvailability", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -3608679734068691688L;
+ final Logger logger = LogManager.getLogger(LoanController.class
+ );
+
+ private final LoanTypeRepository loanTypeRepository;
+ private final LoanRepository loanRepository;
+ private final LoanFeeNotificationRepository loanFeeNotificationRepository;
+ private final AddAmountRepository addAmountRepository;
+ private final LoanToDeliveryByCertifierRepository toDeliveryByCertifierRepository;
+ private final LoanByRenovationRepository loanByRenovationRepository;
+ private final SearchPersonAvailableRepository searchPersonAvailableRepository;
+ private final LoanApprovedDetailViewRepository loanApprovedDetailViewRepository;
+ private final LoanDetailsRepository loanDetailsRepository;
+
+ private final String user_unavailable = "User unavailable to this operation";
+
+ public LoanController() {
+ this.loanTypeRepository = new LoanTypeRepository();
+ this.loanRepository = new LoanRepository();
+ this.loanFeeNotificationRepository = new LoanFeeNotificationRepository();
+ this.addAmountRepository = new AddAmountRepository();
+ this.toDeliveryByCertifierRepository = new LoanToDeliveryByCertifierRepository();
+ this.loanByRenovationRepository = new LoanByRenovationRepository();
+ this.searchPersonAvailableRepository = new SearchPersonAvailableRepository();
+ this.loanApprovedDetailViewRepository = new LoanApprovedDetailViewRepository();
+ this.loanDetailsRepository = new LoanDetailsRepository();
+ }
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java
new file mode 100644
index 0000000..e83c1fb
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/login/LoginWSController.java
@@ -0,0 +1,80 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.login;
+
+import com.arrebol.apc.controller.mobile.moxy.login.UserMxy;
+import com.arrebol.apc.controller.mobile.moxy.login.UserPreferenceMxy;
+import com.arrebol.apc.controller.mobile.repository.jaas.AuthenticationRepository;
+import com.arrebol.apc.model.mobile.access.MobileUser;
+import com.arrebol.apc.model.mobile.preference.UserMobilePreference;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class LoginWSController implements Serializable {
+
+ public UserMxy login(String userName, String password) throws Exception {
+ logger.debug("login");
+
+ UserMxy userMxy;
+ List preferenceLst;
+ try {
+ MobileUser mobileUser = getAuthenticationRepository().findUser(userName, password);
+
+ if (null == mobileUser) {
+ throw new Exception("Access denied");
+ } else {
+ userMxy = new UserMxy(
+ mobileUser.getId(),
+ mobileUser.getUserName(),
+ mobileUser.getAvatar(),
+ mobileUser.getOfficeId(),
+ mobileUser.getRouteId(),
+ mobileUser.getCertifier(),
+ mobileUser.getManagement().toString()
+ );
+ }
+
+ List userMobilePreferences = getAuthenticationRepository().findAllMobilePreferenceByUser(userMxy.getId());
+
+ if (!userMobilePreferences.isEmpty()) {
+ preferenceLst = new ArrayList<>();
+
+ userMobilePreferences.forEach((preference) -> {
+ preferenceLst.add(new UserPreferenceMxy(preference.getPreferenceName(), preference.getPreferenceValue()));
+ });
+
+ userMxy.setPreferences(preferenceLst);
+ }
+ } catch (Exception e) {
+ logger.error("login", e);
+ throw e;
+ }
+ return userMxy;
+ }
+
+ public LoginWSController() {
+ this.authenticationRepository = new AuthenticationRepository();
+ }
+
+ public AuthenticationRepository getAuthenticationRepository() {
+ return authenticationRepository;
+ }
+
+ private static final long serialVersionUID = 2795964728722199660L;
+ final Logger logger = LogManager.getLogger(LoginWSController.class);
+
+ private final AuthenticationRepository authenticationRepository;
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/otherexpense/OtherExpenseController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/otherexpense/OtherExpenseController.java
new file mode 100644
index 0000000..3df43be
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/otherexpense/OtherExpenseController.java
@@ -0,0 +1,58 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.otherexpense;
+
+import com.arrebol.apc.controller.mobile.repository.admin.OtherExpenseRepository;
+import com.arrebol.apc.model.admin.OtherExpense;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class OtherExpenseController implements Serializable {
+
+ /**
+ *
+ * @param officeId
+ * @param userId
+ * @param expense
+ * @param description
+ * @return
+ * @throws Exception
+ */
+ public boolean addOtherExpense(
+ String officeId,
+ String userId,
+ Double expense,
+ String description) throws Exception {
+ logger.debug("addOtherExpense");
+ try {
+ OtherExpense otherExpense = new OtherExpense(officeId, userId, new BigDecimal(expense), description);
+
+ return otherExpenseRepository.saveOtherExpense(otherExpense);
+ } catch (Exception e) {
+ logger.error("addOtherExpense", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -1748077572747436181L;
+
+ final Logger logger = LogManager.getLogger(OtherExpenseController.class);
+
+ private final OtherExpenseRepository otherExpenseRepository;
+
+ public OtherExpenseController() {
+ this.otherExpenseRepository = new OtherExpenseRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/person/PersonController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/person/PersonController.java
new file mode 100644
index 0000000..874e3f3
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/person/PersonController.java
@@ -0,0 +1,54 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.person;
+
+import com.arrebol.apc.controller.mobile.repository.people.PeopleRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.catalog.constance.PeopleCfg;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class PersonController implements Serializable {
+
+ /**
+ *
+ * @param loanId
+ * @param lastUpdatedBy
+ * @param phoneNumber
+ * @param isCustomer
+ * @return
+ */
+ public boolean changeContactNumber(String loanId, String lastUpdatedBy, String phoneNumber, boolean isCustomer) {
+ boolean success = false;
+ try {
+ PeopleRepository repository = new PeopleRepository();
+ String personId = repository.findPeopleIdByIdLoad(loanId, isCustomer);
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(PeopleCfg.FIELD_PHONE_HOME, phoneNumber));
+ parameters.add(new ModelParameter(PeopleCfg.FIELD_LAST_UPDATED_BY, lastUpdatedBy));
+ parameters.add(new ModelParameter(PeopleCfg.FIELD_LAST_UPDATED_ON, new Date()));
+ parameters.add(new ModelParameter(PeopleCfg.FIELD_ID, personId));
+
+ return repository.changeContactNumber(PeopleCfg.QUERY_UPDATE_PHONE_HOME_BY_PEOPLE_ID, parameters);
+ } catch (Exception e) {
+ logger.error("changeContactNumber", e);
+ }
+ return success;
+ }
+
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/preference/SystemPreferenceController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/preference/SystemPreferenceController.java
new file mode 100644
index 0000000..5c0d4af
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/preference/SystemPreferenceController.java
@@ -0,0 +1,243 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.preference;
+
+import com.arrebol.apc.controller.mobile.moxy.views.LoanByUserOrderPreferenceViewJaxb;
+import com.arrebol.apc.controller.mobile.moxy.views.LoanByUserOrderPreferenceViewListJaxb;
+import com.arrebol.apc.controller.mobile.repository.preference.UserMobilePreferenceRepository;
+import com.arrebol.apc.controller.mobile.repository.views.LoanByUserOrderPreferenceViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.admin.constance.ClosingDayCfg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.core.constance.LoanByUserCfg;
+import com.arrebol.apc.model.core.constance.LoanByUserOrderPreferenceViewCfg;
+import com.arrebol.apc.model.core.constance.UserMobilePreferenceCfg;
+import com.arrebol.apc.model.enums.PreferenceName;
+import com.arrebol.apc.model.enums.PreferenceValue;
+import com.arrebol.apc.model.loan.LoanByUserId;
+import com.arrebol.apc.model.mobile.preference.UserMobilePreference;
+import com.arrebol.apc.model.views.LoanByUserOrderPreferenceView;
+import com.arrebol.apc.model.ws.parsed.ConfigurationJaxb;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class SystemPreferenceController implements Serializable {
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public List findAllLoanByUserOrderPreference(String userId) throws Exception {
+ logger.debug("findAllLoanByUserOrderPreference");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanByUserOrderPreferenceViewCfg.FIELD_ORDER_USER_ID, userId));
+
+ return loanByUserOrderPreferenceViewRepository
+ .findAllLoanByUserOrderPreference(
+ LoanByUserOrderPreferenceViewCfg.QUERY_FIND_ALL_LOAN_BY_USER_ORDER_PREFERENCE,
+ parameters
+ );
+ } catch (Exception e) {
+ logger.error("findAllLoanByUserOrderPreference", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param updateOrderListPreference
+ * @return
+ * @throws Exception
+ */
+ public boolean updateOrderInList(LoanByUserOrderPreferenceViewListJaxb updateOrderListPreference) throws Exception {
+ logger.debug("updateOrderInList");
+
+ boolean success = false;
+ try {
+ if (updateLoanByUser(updateOrderListPreference)) {
+ success = updateUserMobilePreference(
+ new User(updateOrderListPreference.getLoanByUserOrderPreferences().get(0).getUserId()),
+ PreferenceName.ORDER_LIST.toString(),
+ PreferenceValue.ORDER_IN_LIST.toString()
+ );
+ }
+ return success;
+ } catch (Exception e) {
+ logger.error("updateOrderInList", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param UserId
+ * @param preferenceName
+ * @param preferenceValue
+ * @return
+ * @throws Exception
+ */
+ public boolean updateUserMobilePreference(String UserId, String preferenceName, String preferenceValue) throws Exception {
+ logger.debug("updateUserMobilePreference");
+
+ boolean success = false;
+ try {
+ success = updateUserMobilePreference(
+ new User(UserId),
+ preferenceName,
+ preferenceValue
+ );
+
+ } catch (Exception e) {
+ logger.error("updateUserMobilePreference", e);
+ throw e;
+ }
+ return success;
+ }
+
+ /**
+ *
+ * @param updateOrderListPreference
+ * @return
+ * @throws Exception
+ */
+ private boolean updateLoanByUser(LoanByUserOrderPreferenceViewListJaxb updateOrderListPreference) throws Exception {
+ logger.debug("updateLoanByUser");
+ try {
+ for (int i = 0; i < updateOrderListPreference.getLoanByUserOrderPreferences().size(); i++) {
+ LoanByUserOrderPreferenceViewJaxb preference = updateOrderListPreference.getLoanByUserOrderPreferences().get(i);
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ LoanByUserCfg.FIELD_ORDER_IN_LIST,
+ preference.getOrderInList()
+ )
+ );
+
+ parameters.add(
+ new ModelParameter(
+ LoanByUserCfg.FIELD_ID,
+ new LoanByUserId(
+ preference.getId(),
+ preference.getUserId()
+ )
+ )
+ );
+
+ loanByUserOrderPreferenceViewRepository.updateQuery(
+ LoanByUserCfg.QUERY_UPDATE_ORDER_IN_LIST,
+ parameters
+ );
+ }
+ return true;
+ } catch (Exception e) {
+ logger.error("updateLoanByUser", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param user
+ * @param preferenceName
+ * @param preferenceValue
+ * @return
+ * @throws Exception
+ */
+ private boolean updateUserMobilePreference(User user, String preferenceName, String preferenceValue) throws Exception {
+ logger.debug("updateUserMobilePreference");
+
+ boolean success = false;
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_USER, user));
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_PREFERENCE_NAME, preferenceName));
+
+ UserMobilePreference userMobilePreference = userMobilePreferenceRepository.findUserMobilePreference(
+ UserMobilePreference.class,
+ UserMobilePreferenceCfg.QUERY_FIND_MOBILE_PREFERENCE_BY_USER_AND_PREFERENCE_NAME,
+ parameters);
+
+ if (null != userMobilePreference) {
+ parameters.clear();
+
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_PREFERENCE_VALUE, preferenceValue));
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_LAST_UPDATED_BY, user.getId()));
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_LAST_UPDATED_ON, new Date()));
+ parameters.add(new ModelParameter(UserMobilePreferenceCfg.FIELD_ID, userMobilePreference.getId()));
+
+ success = userMobilePreferenceRepository.updateQueryUserMobilePreference(
+ UserMobilePreferenceCfg.QUERY_UPDATE_PREFERENCE_VALUE,
+ parameters
+ );
+ } else {
+ userMobilePreference = new UserMobilePreference(
+ user,
+ preferenceName,
+ preferenceValue,
+ user.getId());
+ success = userMobilePreferenceRepository.insertUserMobilePreference(userMobilePreference);
+ }
+ } catch (Exception e) {
+ logger.error("updateUserMobilePreference", e);
+ throw e;
+ }
+ return success;
+ }
+
+ /**
+ *
+ * @param userId
+ * @param officeId
+ * @return
+ * @throws Exception
+ */
+ public ConfigurationJaxb findConfigurationButton(String userId, String officeId) throws Exception {
+ logger.debug("findConfigurationButton");
+ ConfigurationJaxb configuration;
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_USER, new User(userId)));
+ parameters.add(new ModelParameter(ClosingDayCfg.FIELD_OFFICE, new Office(officeId)));
+
+ Long result = userMobilePreferenceRepository.count(ClosingDayCfg.QUERY_COUNT_CLOSING_DATE_BY_USER_AND_OFFICE, parameters);
+ configuration = new ConfigurationJaxb(result.compareTo(new Long(0)) == 0);
+ } catch (Exception e) {
+ logger.error("findConfigurationButton", e);
+ configuration = new ConfigurationJaxb(false);
+ }
+ return configuration;
+ }
+
+ private static final long serialVersionUID = 6329489276545356862L;
+ final Logger logger = LogManager.getLogger(SystemPreferenceController.class);
+
+ private final LoanByUserOrderPreferenceViewRepository loanByUserOrderPreferenceViewRepository;
+ private final UserMobilePreferenceRepository userMobilePreferenceRepository;
+
+ public SystemPreferenceController() {
+ this.loanByUserOrderPreferenceViewRepository = new LoanByUserOrderPreferenceViewRepository();
+ this.userMobilePreferenceRepository = new UserMobilePreferenceRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/reports/ReportsController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/reports/ReportsController.java
new file mode 100644
index 0000000..7d0f190
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/reports/ReportsController.java
@@ -0,0 +1,54 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.reports;
+
+import com.arrebol.apc.controller.mobile.repository.reports.ReportsRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.reports.UserWeekReport;
+import com.arrebol.apc.model.reports.constance.UserWeekReportCfg;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class ReportsController implements Serializable {
+
+ /**
+ *
+ * @param id
+ * @return
+ * @throws Exception
+ */
+ public UserWeekReport findUserWeekReportDetailsByUser(String id) throws Exception {
+ try {
+ ReportsRepository reportsRepository = new ReportsRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(UserWeekReportCfg.FIELD_ID, id)
+ );
+
+ return reportsRepository.findUserWeekReportDetailsByUser(UserWeekReport.class, UserWeekReportCfg.QUERY_FIND_USER_WEEK_REPORT_BY_USER, parameters);
+ } catch (Exception e) {
+ logger.error("findUserWeekReportDetailsByUser", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -5280895557294295916L;
+ final Logger logger = LogManager.getLogger(getClass());
+
+ public ReportsController() {
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/route/RouteController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/route/RouteController.java
new file mode 100644
index 0000000..780db71
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/route/RouteController.java
@@ -0,0 +1,44 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.route;
+
+import com.arrebol.apc.controller.mobile.moxy.views.ContainerRoutes;
+import com.arrebol.apc.controller.mobile.repository.route.RouteRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.catalog.constance.RouteCfg;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.enums.ActiveStatus;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class RouteController implements Serializable {
+
+ public ContainerRoutes findAllRoutesAvailables(String officeId) throws Exception {
+ try {
+ RouteRepository repository = new RouteRepository();
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(RouteCfg.FIELD_OFFICE, new Office(officeId)));
+ parameters.add(new ModelParameter(RouteCfg.FIELD_ACTIVE_STATUS, ActiveStatus.ENEBLED));
+
+ return repository.findAllRoutesAvailables(RouteCfg.QUERY_FIND_ALL_AVAILABLES_ROUTES, parameters);
+ } catch (Exception e) {
+ logger.error("findAllRoutesAvailables", e);
+ throw e;
+ }
+ }
+
+ final Logger logger = LogManager.getLogger(getClass());
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/search/PersonSearchController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/search/PersonSearchController.java
new file mode 100644
index 0000000..0e66d5d
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/search/PersonSearchController.java
@@ -0,0 +1,175 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.search;
+
+import com.arrebol.apc.controller.mobile.repository.views.PersonSearchHistoricalDetailsViewRepository;
+import com.arrebol.apc.controller.mobile.repository.views.PersonSearchViewRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.catalog.People;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.core.constance.LoanByUserCfg;
+import com.arrebol.apc.model.core.constance.LoanCfg;
+import com.arrebol.apc.model.core.constance.PersonSearchHistoricalDetailsViewCfg;
+import com.arrebol.apc.model.core.constance.PersonSearchViewCfg;
+import com.arrebol.apc.model.core.constance.UserCfg;
+import com.arrebol.apc.model.views.LoanByUserView;
+import com.arrebol.apc.model.views.PersonSearchDetailView;
+import com.arrebol.apc.model.views.PersonSearchHistoricalDetailsView;
+import com.arrebol.apc.model.views.PersonSearchView;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class PersonSearchController implements Serializable {
+
+ /**
+ *
+ * @param nameToSearch
+ * @return
+ * @throws Exception
+ */
+ public PersonSearchView fullNameEqualsToPersonSearch(String nameToSearch) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ PersonSearchViewCfg.FIELD_PERSON_SEARCH,
+ nameToSearch
+ )
+ );
+
+ PersonSearchView result = (PersonSearchView) personSearchViewRepository.findResultXML(
+ PersonSearchView.class,
+ PersonSearchViewCfg.QUERY_FULL_NAME_EQUALS_TO_PERSON_SEARCH,
+ parameters
+ );
+
+ if (null == result) {
+ result = new PersonSearchView("N/A", "N/A");
+ }
+ return result;
+ } catch (Exception e) {
+ logger.error("findAllCoincidences", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param search
+ * @return If any return list of coincidences otherwise return empty list.
+ * @throws Exception
+ */
+ public List findAllCoincidences(String search) throws Exception {
+ logger.debug("findAllCoincidences");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ PersonSearchViewCfg.FIELD_PERSON_SEARCH,
+ search
+ )
+ );
+
+ return personSearchViewRepository.findResultList(
+ PersonSearchView.class,
+ PersonSearchViewCfg.QUERY_LIKE_BY_PERSON_SEARCH,
+ parameters
+ );
+ } catch (Exception e) {
+ logger.error("findAllCoincidences", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param personSearchId
+ * @return
+ * @throws Exception
+ */
+ public PersonSearchDetailView findPersonSearchDetail(String personSearchId) throws Exception {
+ logger.debug("findPersonSearchDetail");
+ try {
+ return personSearchViewRepository.findResult(PersonSearchDetailView.class, personSearchId);
+ } catch (Exception e) {
+ logger.error("findPersonSearchDetail", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param personSearchId
+ * @return
+ * @throws Exception
+ */
+ public List findPersonHistoricalDetailsByPersonId(String personSearchId) throws Exception {
+ logger.debug("findPersonHistoricalDetailsByPersonId");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(PersonSearchHistoricalDetailsViewCfg.FIELD_PERSON_SEARCH_ID, personSearchId));
+
+ return personSearchHistoricalDetailsViewRepository.findAllByPersonId(
+ PersonSearchHistoricalDetailsView.class,
+ PersonSearchHistoricalDetailsViewCfg.QUERY_FIND_PERSON_SEARCH_HISTORICAL_DETAILS_BY_PERSON_ID,
+ parameters);
+ } catch (Exception e) {
+ logger.error("findPersonHistoricalDetailsByPersonId", e);
+ throw e;
+ }
+ }
+
+ //Necesito utilizar tuple
+ /**
+ *
+ * @param idUser
+ * @param personSearch
+ * @return
+ * @throws Exception
+ */
+ public LoanByUserView searchPaymentDetails(String idUser, String personSearch) throws Exception {
+ logger.debug("searchPaymentDetails");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(LoanCfg.FIELD_CUSTOMER, new People(personSearch)));
+ parameters.add(new ModelParameter(LoanByUserCfg.FIELD_USER, new User(idUser)));
+ parameters.add(new ModelParameter(UserCfg.FIELD_ID, idUser));
+
+ return (LoanByUserView) personSearchViewRepository.findResultTupleXML(
+ LoanCfg.QUERY_SEARCH_PAYMENT_DETAILS,
+ parameters);
+
+ } catch (Exception e) {
+ logger.error("searchPaymentDetails", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -3224360462532091921L;
+ final Logger logger = LogManager.getLogger(PersonSearchController.class);
+
+ final private PersonSearchViewRepository personSearchViewRepository;
+ final private PersonSearchHistoricalDetailsViewRepository personSearchHistoricalDetailsViewRepository;
+
+ public PersonSearchController() {
+ this.personSearchViewRepository = new PersonSearchViewRepository();
+ this.personSearchHistoricalDetailsViewRepository = new PersonSearchHistoricalDetailsViewRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/tracking/PaymentTrackingController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/tracking/PaymentTrackingController.java
new file mode 100644
index 0000000..79783c3
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/tracking/PaymentTrackingController.java
@@ -0,0 +1,69 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.tracking;
+
+import com.arrebol.apc.controller.mobile.moxy.views.PaymentTrackingViewJaxb;
+import com.arrebol.apc.controller.mobile.repository.tracking.PaymentTrackingRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.views.AdvanceUserDailyView;
+import com.arrebol.apc.model.views.constance.AdvanceUserDailyViewCfg;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class PaymentTrackingController implements Serializable {
+
+ public PaymentTrackingViewJaxb paymentTrakingByUserDetails(String idUser, String idOffice) {
+ PaymentTrackingViewJaxb paymentTracking = new PaymentTrackingViewJaxb();
+ logger.debug("paymentTrakingByUserDetails");
+ try {
+
+ List parameters = new ArrayList<>();
+
+ parameters.add(
+ new ModelParameter(
+ AdvanceUserDailyViewCfg.FIELD_VIEW_USER,
+ new User(idUser)
+ )
+ );
+ parameters.add(
+ new ModelParameter(
+ AdvanceUserDailyViewCfg.FIELD_VIEW_OFFICE,
+ new Office(idOffice)
+ )
+ );
+
+ PaymentTrackingRepository repository = new PaymentTrackingRepository();
+
+ AdvanceUserDailyView result = repository.paymentTrakingByUserDetails(
+ AdvanceUserDailyView.class,
+ AdvanceUserDailyViewCfg.QUERY_PAYMENT_TRACKING_BY_IDS,
+ parameters);
+
+ if (null != result) {
+ paymentTracking.setTotalExpected(result.getTotalExpected());
+ paymentTracking.setTotalNow(result.getTotalNow());
+ }
+ } catch (Exception e) {
+ logger.error("paymentTrakingByUserDetails");
+ }
+
+ return paymentTracking;
+ }
+
+ private static final long serialVersionUID = -3224360462532091920L;
+ final Logger logger = LogManager.getLogger(PaymentTrackingController.class);
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/user/UserController.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/user/UserController.java
new file mode 100644
index 0000000..2cd14fd
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/controller/user/UserController.java
@@ -0,0 +1,95 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.controller.user;
+
+import com.arrebol.apc.controller.mobile.repository.user.UserRepository;
+import com.arrebol.apc.model.ModelParameter;
+import com.arrebol.apc.model.core.Office;
+import com.arrebol.apc.model.core.User;
+import com.arrebol.apc.model.core.constance.UserCfg;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class UserController implements Serializable {
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public boolean isUserEnebled(String userId) throws Exception {
+ logger.info("isUserEnebled");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(UserCfg.FIELD_ID, userId));
+
+ return userId.equals(userRepository.findUserStatusById(UserCfg.QUERY_VERIFY_USER_STATUS_BY_ID, parameters));
+ } catch (Exception e) {
+ logger.error("isUserEnebled", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param userId
+ * @return
+ * @throws Exception
+ */
+ public boolean containtsUserManagementProperty(String userId) throws Exception {
+ logger.info("containtsUserManagementProperty");
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(UserCfg.FIELD_ID, userId));
+
+ return userRepository.containtsUserManagementProperty(UserCfg.QUERY_IS_USER_MANAGMENT, parameters);
+ } catch (Exception e) {
+ logger.error("containtsUserManagementProperty", e);
+ throw e;
+ }
+ }
+
+ /**
+ *
+ * @param idOffice
+ * @return
+ * @throws Exception
+ */
+ public List listOfUsersByOffice(String idOffice) throws Exception {
+ try {
+ List parameters = new ArrayList<>();
+
+ parameters.add(new ModelParameter(UserCfg.FIELD_OFFICE, new Office(idOffice)));
+
+ return userRepository.listOfUsersByOffice(UserCfg.QUERY_LIST_OF_USERS_BY_OFFICE, parameters);
+ } catch (Exception e) {
+ logger.error("listOfUsersByOffice", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -2705701746315543593L;
+ final Logger logger = LogManager.getLogger(getClass());
+
+ private final UserRepository userRepository;
+
+ public UserController() {
+ this.userRepository = new UserRepository();
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferList.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferList.java
new file mode 100644
index 0000000..db61a0a
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferList.java
@@ -0,0 +1,96 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import java.util.List;
+import java.util.Objects;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "authorizeTransferList")
+public class AuthorizeTransferList {
+
+ private String idUpdateUser;
+ private String comments;
+ private List transferListToUpdateStatus;
+
+ /**
+ *
+ */
+ public AuthorizeTransferList() {
+ }
+
+ /**
+ *
+ * @param idUpdateUser
+ * @param comments
+ * @param transferListToUpdateStatus
+ */
+ public AuthorizeTransferList(String idUpdateUser, String comments, List transferListToUpdateStatus) {
+ this.idUpdateUser = idUpdateUser;
+ this.comments = comments;
+ this.transferListToUpdateStatus = transferListToUpdateStatus;
+ }
+
+ @XmlElement(name = "idUpdateUser")
+ public String getIdUpdateUser() {
+ return idUpdateUser;
+ }
+
+ public void setIdUpdateUser(String idUpdateUser) {
+ this.idUpdateUser = idUpdateUser;
+ }
+
+ @XmlElement(name = "comments")
+ public String getComments() {
+ return comments;
+ }
+
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+
+ @XmlElement(name = "transferListToUpdateStatus")
+ public List getTransferListToUpdateStatus() {
+ return transferListToUpdateStatus;
+ }
+
+ public void setTransferListToUpdateStatus(List transferListToUpdateStatus) {
+ this.transferListToUpdateStatus = transferListToUpdateStatus;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 31 * hash + Objects.hashCode(this.idUpdateUser);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final AuthorizeTransferList other = (AuthorizeTransferList) obj;
+ if (!Objects.equals(this.idUpdateUser, other.idUpdateUser)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferPaymentsDto.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferPaymentsDto.java
new file mode 100644
index 0000000..6656274
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/AuthorizeTransferPaymentsDto.java
@@ -0,0 +1,117 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "authorizeTransferPaymentsDto")
+public class AuthorizeTransferPaymentsDto {
+
+ private String idLoan;
+ private String strDate;
+ private String customerName;
+ private String endorsementName;
+ private String userName;
+ private Double amount;
+ private String comments;
+
+ /**
+ *
+ */
+ public AuthorizeTransferPaymentsDto() {
+ }
+
+ /**
+ *
+ * @param idLoan
+ * @param strDate
+ * @param customerName
+ * @param endorsementName
+ * @param userName
+ * @param amount
+ * @param comments
+ */
+ public AuthorizeTransferPaymentsDto(String idLoan, String strDate, String customerName, String endorsementName, String userName, Double amount, String comments) {
+ this.idLoan = idLoan;
+ this.strDate = strDate;
+ this.customerName = customerName;
+ this.endorsementName = endorsementName;
+ this.userName = userName;
+ this.amount = amount;
+ this.comments = comments;
+ }
+
+ @XmlElement(name = "idLoan")
+ public String getIdLoan() {
+ return idLoan;
+ }
+
+ public void setIdLoan(String idLoan) {
+ this.idLoan = idLoan;
+ }
+
+ @XmlElement(name = "strDate")
+ public String getStrDate() {
+ return strDate;
+ }
+
+ public void setStrDate(String strDate) {
+ this.strDate = strDate;
+ }
+
+ @XmlElement(name = "customerName")
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ @XmlElement(name = "endorsementName")
+ public String getEndorsementName() {
+ return endorsementName;
+ }
+
+ public void setEndorsementName(String endorsementName) {
+ this.endorsementName = endorsementName;
+ }
+
+ @XmlElement(name = "userName")
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @XmlElement(name = "amount")
+ public Double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(Double amount) {
+ this.amount = amount;
+ }
+
+ @XmlElement(name = "comments")
+ public String getComments() {
+ return comments;
+ }
+
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/DeleteLoanDetailsJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/DeleteLoanDetailsJaxb.java
new file mode 100644
index 0000000..03f6fda
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/DeleteLoanDetailsJaxb.java
@@ -0,0 +1,117 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "deleteLoanDetailsJaxb")
+public class DeleteLoanDetailsJaxb {
+
+ private Boolean approvedOrPendingRenovation;
+ private Boolean todayPayment;
+ private Boolean todayFee;
+ private String loanId;
+
+ public DeleteLoanDetailsJaxb() {
+ }
+
+ /**
+ *
+ * @param approvedOrPendingRenovation
+ * @param todayPayment
+ * @param todayFee
+ */
+ public DeleteLoanDetailsJaxb(Boolean approvedOrPendingRenovation, Boolean todayPayment, Boolean todayFee) {
+ this.approvedOrPendingRenovation = approvedOrPendingRenovation;
+ this.todayPayment = todayPayment;
+ this.todayFee = todayFee;
+ }
+
+ /**
+ *
+ * @param approvedOrPendingRenovation
+ * @param todayPayment
+ * @param todayFee
+ * @param loanId
+ */
+ public DeleteLoanDetailsJaxb(Boolean approvedOrPendingRenovation, Boolean todayPayment, Boolean todayFee, String loanId) {
+ this.approvedOrPendingRenovation = approvedOrPendingRenovation;
+ this.todayPayment = todayPayment;
+ this.todayFee = todayFee;
+ this.loanId = loanId;
+ }
+
+ /**
+ *
+ * @param todayPayment
+ * @param todayFee
+ */
+ public DeleteLoanDetailsJaxb(Boolean todayPayment, Boolean todayFee) {
+ this.todayPayment = todayPayment;
+ this.todayFee = todayFee;
+ }
+
+ /**
+ *
+ * @param todayPayment
+ * @param todayFee
+ * @param loanId
+ */
+ public DeleteLoanDetailsJaxb(Boolean todayPayment, Boolean todayFee, String loanId) {
+ this.todayPayment = todayPayment;
+ this.todayFee = todayFee;
+ this.loanId = loanId;
+ }
+
+ @XmlElement(name = "approvedOrPendingRenovation")
+ public Boolean getApprovedOrPendingRenovation() {
+ return approvedOrPendingRenovation;
+ }
+
+ public void setApprovedOrPendingRenovation(Boolean approvedOrPendingRenovation) {
+ this.approvedOrPendingRenovation = approvedOrPendingRenovation;
+ }
+
+ @XmlElement(name = "todayPayment")
+ public Boolean getTodayPayment() {
+ return todayPayment;
+ }
+
+ public void setTodayPayment(Boolean todayPayment) {
+ this.todayPayment = todayPayment;
+ }
+
+ @XmlElement(name = "todayFee")
+ public Boolean getTodayFee() {
+ return todayFee;
+ }
+
+ public void setTodayFee(Boolean todayFee) {
+ this.todayFee = todayFee;
+ }
+
+ @XmlElement(name = "loanId")
+ public String getLoanId() {
+ return loanId;
+ }
+
+ public void setLoanId(String loanId) {
+ this.loanId = loanId;
+ }
+
+ @Override
+ public String toString() {
+ return "DeleteLoanDetailsJaxb{" + "approvedOrPendingRenovation=" + approvedOrPendingRenovation + ", todayPayment=" + todayPayment + ", todayFee=" + todayFee + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/GenericAPCResponserJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/GenericAPCResponserJaxb.java
new file mode 100644
index 0000000..2b4f184
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/GenericAPCResponserJaxb.java
@@ -0,0 +1,97 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "apcResponse")
+public class GenericAPCResponserJaxb {
+
+ private Boolean successful;
+ private String message;
+ private String idClosingDay;
+ private String idSmallBox;
+ private String idGeneralBox;
+ private Boolean enabledSubmit;
+
+ /**
+ *
+ */
+ public GenericAPCResponserJaxb() {
+ }
+
+ /**
+ *
+ * @param successful
+ * @param message
+ */
+ public GenericAPCResponserJaxb(Boolean successful, String message) {
+ this.successful = successful;
+ this.message = message;
+ }
+
+ @XmlElement(name = "successful")
+ public Boolean getSuccessful() {
+ return null == successful ? Boolean.FALSE : successful;
+ }
+
+ public void setSuccessful(Boolean successful) {
+ this.successful = successful;
+ }
+
+ @XmlElement(name = "message")
+ public String getMessage() {
+ return null == message ? "" : message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @XmlElement(name = "idClosingDay")
+ public String getIdClosingDay() {
+ return idClosingDay;
+ }
+
+ public void setIdClosingDay(String idClosingDay) {
+ this.idClosingDay = idClosingDay;
+ }
+
+ @XmlElement(name = "idSmallBox")
+ public String getIdSmallBox() {
+ return idSmallBox;
+ }
+
+ public void setIdSmallBox(String idSmallBox) {
+ this.idSmallBox = idSmallBox;
+ }
+
+ @XmlElement(name = "idGeneralBox")
+ public String getIdGeneralBox() {
+ return idGeneralBox;
+ }
+
+ public void setIdGeneralBox(String idGeneralBox) {
+ this.idGeneralBox = idGeneralBox;
+ }
+
+ @XmlElement(name = "enabledSubmit")
+ public Boolean getEnabledSubmit() {
+ return null == enabledSubmit ? Boolean.FALSE : enabledSubmit;
+ }
+
+ public void setEnabledSubmit(Boolean enabledSubmit) {
+ this.enabledSubmit = enabledSubmit;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeJaxb.java
new file mode 100644
index 0000000..1f0977f
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeJaxb.java
@@ -0,0 +1,73 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import java.math.BigDecimal;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "loan")
+public class LoanTypeJaxb {
+
+ private String id;
+ private BigDecimal payment;
+ private String description;
+
+ public LoanTypeJaxb() {
+ }
+
+ public LoanTypeJaxb(String id, BigDecimal payment) {
+ this.id = id;
+ this.payment = payment;
+ }
+
+ public LoanTypeJaxb(String id, BigDecimal payment, String description) {
+ this.id = id;
+ this.payment = payment;
+ this.description = description;
+ }
+
+ @XmlElement(name = "id")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @XmlElement(name = "payment")
+ public BigDecimal getPayment() {
+ return payment;
+ }
+
+ public void setPayment(BigDecimal payment) {
+ this.payment = payment;
+ }
+
+ @XmlElement(name = "description")
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+
+ @Override
+ public String toString() {
+ return "LoanTypeJaxb{" + "payment=" + payment + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeListJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeListJaxb.java
new file mode 100644
index 0000000..f775c4b
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/LoanTypeListJaxb.java
@@ -0,0 +1,48 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "availableLoans")
+public class LoanTypeListJaxb {
+
+ private List loans;
+
+ public LoanTypeListJaxb() {
+ }
+
+ /**
+ *
+ * @param loans
+ */
+ public LoanTypeListJaxb(List loans) {
+ this.loans = loans;
+ }
+
+ @XmlElement(name = "loans")
+ public List getLoans() {
+ return loans;
+ }
+
+ public void setLoans(List loans) {
+ this.loans = loans;
+ }
+
+ @Override
+ public String toString() {
+ return "LoanTypeListJaxb{" + "loans=" + loans + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/TransferListToUpdateStatus.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/TransferListToUpdateStatus.java
new file mode 100644
index 0000000..075e456
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/TransferListToUpdateStatus.java
@@ -0,0 +1,71 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import java.util.Objects;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "transferListToUpdateStatus")
+public class TransferListToUpdateStatus {
+
+ private String idLoan;
+
+ /**
+ *
+ */
+ public TransferListToUpdateStatus() {
+ }
+
+ /**
+ *
+ * @param idLoan
+ */
+ public TransferListToUpdateStatus(String idLoan) {
+ this.idLoan = idLoan;
+ }
+
+ @XmlElement(name = "idLoan")
+ public String getIdLoan() {
+ return idLoan;
+ }
+
+ public void setIdLoan(String idLoan) {
+ this.idLoan = idLoan;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 79 * hash + Objects.hashCode(this.idLoan);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final TransferListToUpdateStatus other = (TransferListToUpdateStatus) obj;
+ if (!Objects.equals(this.idLoan, other.idLoan)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusDTO.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusDTO.java
new file mode 100644
index 0000000..461fe6c
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusDTO.java
@@ -0,0 +1,102 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "updateLoanToDeliveryStatusDTO")
+public class UpdateLoanToDeliveryStatusDTO {
+
+ private String idLoan;
+ private String strDate;
+ private String customerName;
+ private String endorsementName;
+ private String userName;
+ private Double amount;
+
+ public UpdateLoanToDeliveryStatusDTO() {
+ }
+
+ /**
+ *
+ * @param idLoan
+ * @param strDate
+ * @param customerName
+ * @param endorsementName
+ * @param userName
+ * @param amount
+ */
+ public UpdateLoanToDeliveryStatusDTO(String idLoan, String strDate, String customerName, String endorsementName, String userName, Double amount) {
+ this.idLoan = idLoan;
+ this.strDate = strDate;
+ this.customerName = customerName;
+ this.endorsementName = endorsementName;
+ this.userName = userName;
+ this.amount = amount;
+ }
+
+ @XmlElement(name = "idLoan")
+ public String getIdLoan() {
+ return idLoan;
+ }
+
+ public void setIdLoan(String idLoan) {
+ this.idLoan = idLoan;
+ }
+
+ @XmlElement(name = "strDate")
+ public String getStrDate() {
+ return strDate;
+ }
+
+ public void setStrDate(String strDate) {
+ this.strDate = strDate;
+ }
+
+ @XmlElement(name = "customerName")
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ @XmlElement(name = "endorsementName")
+ public String getEndorsementName() {
+ return endorsementName;
+ }
+
+ public void setEndorsementName(String endorsementName) {
+ this.endorsementName = endorsementName;
+ }
+
+ @XmlElement(name = "userName")
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @XmlElement(name = "amount")
+ public Double getAmount() {
+ return amount;
+ }
+
+ public void setAmount(Double amount) {
+ this.amount = amount;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusList.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusList.java
new file mode 100644
index 0000000..584a1ca
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/json/loan/UpdateLoanToDeliveryStatusList.java
@@ -0,0 +1,67 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.json.loan;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "updateLoanToDeliveryStatusList")
+public class UpdateLoanToDeliveryStatusList {
+
+ private String idUpdateUser;
+ private String comments;
+ private List loanToDeliveryList;
+
+ public UpdateLoanToDeliveryStatusList() {
+ }
+
+ /**
+ *
+ * @param idUpdateUser
+ * @param comments
+ * @param loanToDeliveryList
+ */
+ public UpdateLoanToDeliveryStatusList(String idUpdateUser, String comments, List loanToDeliveryList) {
+ this.idUpdateUser = idUpdateUser;
+ this.comments = comments;
+ this.loanToDeliveryList = loanToDeliveryList;
+ }
+
+ @XmlElement(name = "idUpdateUser")
+ public String getIdUpdateUser() {
+ return idUpdateUser;
+ }
+
+ public void setIdUpdateUser(String idUpdateUser) {
+ this.idUpdateUser = idUpdateUser;
+ }
+
+ @XmlElement(name = "comments")
+ public String getComments() {
+ return comments;
+ }
+
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+
+ @XmlElement(name = "loanToDeliveryList")
+ public List getLoanToDeliveryList() {
+ return loanToDeliveryList;
+ }
+
+ public void setLoanToDeliveryList(List loanToDeliveryList) {
+ this.loanToDeliveryList = loanToDeliveryList;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/PersonMxy.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/PersonMxy.java
new file mode 100644
index 0000000..e9e3afe
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/PersonMxy.java
@@ -0,0 +1,122 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public abstract class PersonMxy {
+
+ protected String id;
+ protected String firstName;
+ protected String secondName;
+ protected String lastName;
+ protected String middleName;
+ protected String addressHome;
+ protected String addressWork;
+ protected String phoneHome;
+ protected String phoneWork;
+ protected String thumbnail;
+
+ public PersonMxy() {
+ }
+
+ public PersonMxy(String id, String firstName, String lastName, String thumbnail) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.thumbnail = thumbnail;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getSecondName() {
+ return secondName;
+ }
+
+ public void setSecondName(String secondName) {
+ this.secondName = secondName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getAddressHome() {
+ return addressHome;
+ }
+
+ public void setAddressHome(String addressHome) {
+ this.addressHome = addressHome;
+ }
+
+ public String getAddressWork() {
+ return addressWork;
+ }
+
+ public void setAddressWork(String addressWork) {
+ this.addressWork = addressWork;
+ }
+
+ public String getPhoneHome() {
+ return phoneHome;
+ }
+
+ public void setPhoneHome(String phoneHome) {
+ this.phoneHome = phoneHome;
+ }
+
+ public String getPhoneWork() {
+ return phoneWork;
+ }
+
+ public void setPhoneWork(String phoneWork) {
+ this.phoneWork = phoneWork;
+ }
+
+ public String getThumbnail() {
+ return thumbnail;
+ }
+
+ public void setThumbnail(String thumbnail) {
+ this.thumbnail = thumbnail;
+ }
+
+ @Override
+ public String toString() {
+ return "PersonMxy{" + "firstName=" + firstName + ", lastName=" + lastName + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java
new file mode 100644
index 0000000..f230c8c
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserMxy.java
@@ -0,0 +1,121 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.login;
+
+import com.arrebol.apc.controller.mobile.moxy.PersonMxy;
+import java.util.List;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class UserMxy extends PersonMxy {
+
+ private String userName;
+ private String officeId;
+ private String routeId;
+ private String certifier;
+ private String management;
+
+ private List preferences;
+
+ public UserMxy() {
+ }
+
+ /**
+ *
+ * @param id
+ * @param userName
+ * @param thumbnail
+ * @param officeId
+ * @param routeId
+ * @param certifier
+ */
+ public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier) {
+ this.id = id;
+ this.userName = userName;
+ this.thumbnail = thumbnail;
+ this.officeId = officeId;
+ this.routeId = routeId;
+ this.certifier = certifier;
+ }
+
+ /**
+ *
+ * @param id
+ * @param userName
+ * @param thumbnail
+ * @param officeId
+ * @param routeId
+ * @param certifier
+ * @param management
+ */
+ public UserMxy(String id, String userName, String thumbnail, String officeId, String routeId, String certifier, String management) {
+ this.id = id;
+ this.userName = userName;
+ this.thumbnail = thumbnail;
+ this.officeId = officeId;
+ this.routeId = routeId;
+ this.certifier = certifier;
+ this.management = management;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getOfficeId() {
+ return officeId;
+ }
+
+ public void setOfficeId(String officeId) {
+ this.officeId = officeId;
+ }
+
+ public void setPreferences(List preferences) {
+ this.preferences = preferences;
+ }
+
+ public List getPreferences() {
+ return preferences;
+ }
+
+ public String getRouteId() {
+ return routeId;
+ }
+
+ public void setRouteId(String routeId) {
+ this.routeId = routeId;
+ }
+
+ public String getCertifier() {
+ return certifier;
+ }
+
+ public void setCertifier(String certifier) {
+ this.certifier = certifier;
+ }
+
+ public String getManagement() {
+ return management;
+ }
+
+ public void setManagement(String management) {
+ this.management = management;
+ }
+
+ @Override
+ public String toString() {
+ return "UserMxy{" + "userName=" + userName + ", preferences=" + preferences + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserPreferenceMxy.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserPreferenceMxy.java
new file mode 100644
index 0000000..dff1fee
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/login/UserPreferenceMxy.java
@@ -0,0 +1,53 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.login;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class UserPreferenceMxy {
+
+ private String preferenceName;
+ private String preferenceValue;
+
+ public UserPreferenceMxy() {
+ }
+
+ /**
+ *
+ * @param preferenceName
+ * @param preferenceValue
+ */
+ public UserPreferenceMxy(String preferenceName, String preferenceValue) {
+ this.preferenceName = preferenceName;
+ this.preferenceValue = preferenceValue;
+ }
+
+ public String getPreferenceName() {
+ return preferenceName;
+ }
+
+ public void setPreferenceName(String preferenceName) {
+ this.preferenceName = preferenceName;
+ }
+
+ public String getPreferenceValue() {
+ return preferenceValue;
+ }
+
+ public void setPreferenceValue(String preferenceValue) {
+ this.preferenceValue = preferenceValue;
+ }
+
+ @Override
+ public String toString() {
+ return "UserPreferenceMxy{" + "preferenceName=" + preferenceName + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/ContainerRoutes.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/ContainerRoutes.java
new file mode 100644
index 0000000..1282ac4
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/ContainerRoutes.java
@@ -0,0 +1,43 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.views;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "containerRoutes")
+public class ContainerRoutes {
+
+ private List routes;
+
+ public ContainerRoutes() {
+ }
+
+ /**
+ *
+ * @param routes
+ */
+ public ContainerRoutes(List routes) {
+ this.routes = routes;
+ }
+
+ @XmlElement(name = "routes")
+ public List getRoutes() {
+ return routes;
+ }
+
+ public void setRoutes(List routes) {
+ this.routes = routes;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewJaxb.java
new file mode 100644
index 0000000..e96591d
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewJaxb.java
@@ -0,0 +1,116 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.views;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "loanByUserOrderPreference")
+public class LoanByUserOrderPreferenceViewJaxb {
+
+ private String id;
+
+ private String userId;
+
+ private String customerName;
+
+ private String customerAddressHome;
+
+ private String customerAddressBusiness;
+
+ private Integer orderInList;
+
+ public LoanByUserOrderPreferenceViewJaxb() {
+ }
+
+ /**
+ *
+ * @param id
+ * @param userId
+ * @param orderInList
+ */
+ public LoanByUserOrderPreferenceViewJaxb(String id, String userId, Integer orderInList) {
+ this.id = id;
+ this.userId = userId;
+ this.orderInList = orderInList;
+ }
+
+ /**
+ *
+ * @param customerName
+ * @param orderInList
+ */
+ public LoanByUserOrderPreferenceViewJaxb(String customerName, Integer orderInList) {
+ this.customerName = customerName;
+ this.orderInList = orderInList;
+ }
+
+ @XmlAttribute(name = "id")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @XmlAttribute(name = "userId")
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ @XmlAttribute(name = "customerName")
+ public String getCustomerName() {
+ return customerName;
+ }
+
+ public void setCustomerName(String customerName) {
+ this.customerName = customerName;
+ }
+
+ @XmlAttribute(name = "customerAddressHome")
+ public String getCustomerAddressHome() {
+ return customerAddressHome;
+ }
+
+ public void setCustomerAddressHome(String customerAddressHome) {
+ this.customerAddressHome = customerAddressHome;
+ }
+
+ @XmlAttribute(name = "customerAddressBusiness")
+ public String getCustomerAddressBusiness() {
+ return customerAddressBusiness;
+ }
+
+ public void setCustomerAddressBusiness(String customerAddressBusiness) {
+ this.customerAddressBusiness = customerAddressBusiness;
+ }
+
+ @XmlAttribute(name = "orderInList")
+ public Integer getOrderInList() {
+ return orderInList;
+ }
+
+ public void setOrderInList(Integer orderInList) {
+ this.orderInList = orderInList;
+ }
+
+ @Override
+ public String toString() {
+ return "LoanByUserOrderPreferenceViewJaxb{" + "customerName=" + customerName + ", orderInList=" + orderInList + '}';
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewListJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewListJaxb.java
new file mode 100644
index 0000000..db05f0e
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/LoanByUserOrderPreferenceViewListJaxb.java
@@ -0,0 +1,39 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.views;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "systemPreferences")
+public class LoanByUserOrderPreferenceViewListJaxb {
+
+ List loanByUserOrderPreferences;
+
+ public LoanByUserOrderPreferenceViewListJaxb() {
+ }
+
+ public LoanByUserOrderPreferenceViewListJaxb(List loanByUserOrderPreferences) {
+ this.loanByUserOrderPreferences = loanByUserOrderPreferences;
+ }
+
+ @XmlElement(name = "loanByUserOrderPreferences")
+ public List getLoanByUserOrderPreferences() {
+ return loanByUserOrderPreferences;
+ }
+
+ public void setLoanByUserOrderPreferences(List loanByUserOrderPreferences) {
+ this.loanByUserOrderPreferences = loanByUserOrderPreferences;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/PaymentTrackingViewJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/PaymentTrackingViewJaxb.java
new file mode 100644
index 0000000..36eacce
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/PaymentTrackingViewJaxb.java
@@ -0,0 +1,60 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.views;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "paymentTracking")
+public class PaymentTrackingViewJaxb {
+
+ private String id;
+
+ private Integer totalExpected;
+
+ private Integer totalNow;
+
+ @XmlElement(name = "id")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @XmlElement(name = "totalExpected")
+ public Integer getTotalExpected() {
+ if (null == totalExpected) {
+ totalExpected = 0;
+ }
+ return totalExpected;
+ }
+
+ public void setTotalExpected(Integer totalExpected) {
+ this.totalExpected = totalExpected;
+ }
+
+ @XmlElement(name = "totalNow")
+ public Integer getTotalNow() {
+ if (null == totalNow) {
+ totalNow = 0;
+ }
+
+ return totalNow;
+ }
+
+ public void setTotalNow(Integer totalNow) {
+ this.totalNow = totalNow;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/RouteJaxb.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/RouteJaxb.java
new file mode 100644
index 0000000..14c6b0d
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/moxy/views/RouteJaxb.java
@@ -0,0 +1,49 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.moxy.views;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+@XmlRootElement(name = "route")
+public class RouteJaxb {
+
+ private String id;
+ private String name;
+
+ public RouteJaxb() {
+ }
+
+ public RouteJaxb(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ @XmlElement(name = "id")
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @XmlElement(name = "name")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/ArrebolTestRepository.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/ArrebolTestRepository.java
new file mode 100644
index 0000000..b7d4d0d
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/ArrebolTestRepository.java
@@ -0,0 +1,39 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.repository;
+
+import com.arrebol.apc.test.ArrebolTest;
+import java.io.Serializable;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public class ArrebolTestRepository extends GenericRepository implements Serializable {
+
+ /**
+ *
+ * @param arrebolTest
+ * @return
+ * @throws Exception
+ */
+ public boolean saveArrebolTest(ArrebolTest arrebolTest) throws Exception {
+ logger.info("saveArrebolTest");
+ try {
+ return save(arrebolTest);
+ } catch (Exception e) {
+ logger.error("saveArrebolTest", e);
+ throw e;
+ }
+ }
+
+ private static final long serialVersionUID = -6564619785642944612L;
+ final Logger logger = LogManager.getLogger(ArrebolTestRepository.class);
+}
diff --git a/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/GenericRepository.java b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/GenericRepository.java
new file mode 100644
index 0000000..30d1351
--- /dev/null
+++ b/ace-controller-mobile/src/main/java/com/arrebol/apc/controller/mobile/repository/GenericRepository.java
@@ -0,0 +1,671 @@
+/*
+ * Arrebol Consultancy copyright.
+ *
+ * This code belongs to Arrebol Consultancy
+ * its use, redistribution or modification are prohibited
+ * without written authorization from Arrebol Consultancy.
+ */
+package com.arrebol.apc.controller.mobile.repository;
+
+import com.arrebol.apc.controller.mobile.util.HibernateUtil;
+import com.arrebol.apc.model.ModelParameter;
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.Tuple;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.query.Query;
+
+/**
+ *
+ * @author Carlos Janitzio Zavala Lopez
+ */
+public abstract class GenericRepository {
+
+ private Session sessionOld;
+ private Transaction transactionOld;
+
+ /**
+ * Save an APC entity.
+ *
+ * @param entity APC entity in DB.
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected boolean save(Object entity) throws Exception {
+ logger.debug("Save");
+ boolean success = false;
+
+ Session session = null;
+ Transaction transaction = null;
+ try {
+ session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ session.save(entity);
+
+ transaction.commit();
+ logger.debug("Entity saved: " + entity);
+
+ success = true;
+ } catch (HibernateException e) {
+ logger.error("Save Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method save() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+ /* finally {
+ if (null != session) {
+ session.close();
+ }
+ }*/
+
+ return success;
+ }
+
+ /**
+ *
+ * @param entities
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected boolean saveMany(List entities) throws Exception {
+ logger.debug("saveMany");
+ boolean success = false;
+
+ Session session = null;
+ Transaction transaction = null;
+ try {
+ session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ for (Object entity : entities) {
+ session.save(entity);
+ }
+
+ transaction.commit();
+
+ logger.debug("Entities saveMany: ");
+
+ success = true;
+ } catch (HibernateException e) {
+ logger.error("saveMany Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method saveMany() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+ /* finally {
+ if (null != session) {
+ session.close();
+ }
+ }*/
+
+ return success;
+ }
+
+ /**
+ * Update an APC entity.
+ *
+ * @param entity APC entity in DB.
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected boolean update(Object entity) throws Exception {
+ logger.debug("update");
+
+ boolean success = false;
+ Transaction transaction = null;
+
+ try {
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ session.update(entity);
+
+ transaction.commit();
+
+ logger.debug("Entity updated: " + entity);
+
+ success = true;
+ } catch (HibernateException e) {
+ logger.error("update Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("update save() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+
+ return success;
+ }
+
+ /**
+ *
+ * @param xmlQuery
+ * @param parameters
+ * @return
+ * @throws Exception
+ */
+ protected boolean updateCreateNamedQuery(String xmlQuery, List parameters) throws Exception {
+ logger.debug("updateCreateNamedQuery");
+ boolean success = false;
+
+ Transaction transaction = null;
+ try {
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ if (null != parameters && !parameters.isEmpty()) {
+ Query query = session.createNamedQuery(xmlQuery);
+
+ parameters.forEach((param) -> {
+ query.setParameter(param.getParameter(), param.getValue());
+ });
+
+ query.executeUpdate();
+ logger.debug("Query update executed");
+ }
+
+ transaction.commit();
+
+ logger.debug("Entity updateCreateNamedQuery");
+
+ success = true;
+ } catch (HibernateException e) {
+ logger.error("updateCreateNamedQuery Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method updateCreateNamedQuery() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+ return success;
+ }
+
+ /**
+ * Delete an APC entity.
+ *
+ * @param entity APC entity in DB.
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected boolean delete(Object entity) throws Exception {
+ logger.debug("delete");
+ boolean success = false;
+
+ Session session = null;
+ Transaction transaction = null;
+ try {
+ session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ session.delete(entity);
+
+ transaction.commit();
+
+ logger.debug("Entity deleted: " + entity);
+
+ success = true;
+ } catch (HibernateException e) {
+ logger.error("delete Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method delete() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+ /* finally {
+ if (null != session) {
+ session.close();
+ }
+ }*/
+
+ return success;
+ }
+
+ /**
+ * Find a APC entity.
+ *
+ * @param clazz APC entity class name to find in DB.
+ * @param id
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected Object findAPCEntity(Class clazz, String id) throws Exception {
+ logger.debug("findAPCEntity");
+
+ Object apcEntity = null;
+ Transaction transaction = null;
+ try {
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ apcEntity = session.get(clazz, id);
+
+ transaction.commit();
+
+ logger.debug("APC entity found: " + apcEntity);
+ } catch (HibernateException e) {
+ logger.error("findAPCEntity Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method findAPCEntity() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+
+ return apcEntity;
+ }
+
+ /**
+ * Execute a query from XML mapping file.
+ *
+ * @param clazz
+ * @param xmlQuery
+ * @param parameters
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected Object createNamedQueryUniqueResult(Class clazz, String xmlQuery, List parameters) throws Exception {
+ logger.debug("createNamedQueryUniqueResult");
+
+ Object entity = null;
+ Transaction transaction = null;
+ try {
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ transaction = session.beginTransaction();
+
+ if (null != parameters && !parameters.isEmpty()) {
+ Query query = session.createNamedQuery(xmlQuery, clazz);
+
+ parameters.forEach((param) -> {
+ query.setParameter(param.getParameter(), param.getValue());
+ });
+
+ entity = query.uniqueResult();
+ }
+
+ transaction.commit();
+ logger.debug("APC entity from xml query: " + entity);
+ } catch (HibernateException e) {
+ logger.error("createNamedQueryUniqueResult Hibernate", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ } catch (Exception e) {
+ logger.error("Method createNamedQueryUniqueResult() ", e);
+
+ if (null != transaction) {
+ transaction.rollback();
+ }
+ throw e;
+ }
+
+ return entity;
+ }
+
+ /**
+ *
+ * @param clazz
+ * @param xmlQuery
+ * @param parameters
+ * @return
+ * @throws java.lang.Exception
+ */
+ protected List createNamedQueryResultList(Class clazz, String xmlQuery, List parameters) throws Exception {
+ logger.debug("createNamedQueryResultList");
+
+ List