From 0c3b3c562a0975285528b0875056f4f714b36245 Mon Sep 17 00:00:00 2001 From: NSSuresh11 Date: Fri, 8 Mar 2019 17:09:08 +0530 Subject: [PATCH] OLE-9424 : Alter Due Date does not capture the date iit happened or the operator ID --- .../ole/3.0.16/db.changelog-20190305.xml | 52 +++++ .../org/kuali/ole/sql/mysql/3.0.16.sql | 40 +++- .../ole/deliver/bo/OleDueDateDocument.java | 186 ++++++++++++++++++ .../deliver/controller/CircController.java | 20 ++ .../org/kuali/ole/deliver/ojb-deliver.xml | 11 ++ 5 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 ole-app/olefs/src/main/java/org/kuali/ole/deliver/bo/OleDueDateDocument.java diff --git a/ole-app/ole-db/ole-liquibase/ole-liquibase-upgrade/src/main/resources/org/kuali/ole/3.0.16/db.changelog-20190305.xml b/ole-app/ole-db/ole-liquibase/ole-liquibase-upgrade/src/main/resources/org/kuali/ole/3.0.16/db.changelog-20190305.xml index b6d5fd7a05..16985800ae 100644 --- a/ole-app/ole-db/ole-liquibase/ole-liquibase-upgrade/src/main/resources/org/kuali/ole/3.0.16/db.changelog-20190305.xml +++ b/ole-app/ole-db/ole-liquibase/ole-liquibase-upgrade/src/main/resources/org/kuali/ole/3.0.16/db.changelog-20190305.xml @@ -15,4 +15,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ole-app/ole-db/ole-sql/ole-liquibase-upgrade-sql/src/main/resources/org/kuali/ole/sql/mysql/3.0.16.sql b/ole-app/ole-db/ole-sql/ole-liquibase-upgrade-sql/src/main/resources/org/kuali/ole/sql/mysql/3.0.16.sql index b004f20faa..57f3377d35 100644 --- a/ole-app/ole-db/ole-sql/ole-liquibase-upgrade-sql/src/main/resources/org/kuali/ole/sql/mysql/3.0.16.sql +++ b/ole-app/ole-db/ole-sql/ole-liquibase-upgrade-sql/src/main/resources/org/kuali/ole/sql/mysql/3.0.16.sql @@ -12,7 +12,45 @@ SET sql_mode='NO_BACKSLASH_ESCAPES' INSERT INTO KRIM_PERM_T (PERM_ID, OBJ_ID, VER_NBR, PERM_TMPL_ID, NMSPC_CD, NM, DESC_TXT, ACTV_IND) VALUES ('OLELOAN1013', 'OLELOAN1013', '1', '56', 'OLE-DLVR', 'Override Renew', 'Allows users to override and Renew an Item.', 'Y') / -INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_KRIM_PERM_T_mysql', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 1, '7:debc1265d1f9c60a28ad8938a56c8d6c', 'sql, loadData', '', 'EXECUTED', '3.2.0') +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_KRIM_PERM_T_mysql', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 1, '7:f5f74a44985d771a8827504582d99ece', 'sql, loadData', '', 'EXECUTED', '3.2.0') +/ + +-- Changeset org/kuali/ole/3.0.16/db.changelog-20190305.xml::OLE_DUE_DATE_HISTORY_T::ole +CREATE TABLE ole.OLE_DUE_DATE_HISTORY_T (DUE_DATE_ID VARCHAR(40) NULL, LOAN_ID VARCHAR(40) NULL, PTRN_BARCODE VARCHAR(100) NULL, ITEM_BARCODE VARCHAR(100) NULL, CURR_DUE_DT_TIME TIMESTAMP NULL, PAST_DUE_DT_TIME TIMESTAMP NULL, OPTR_ID VARCHAR(40) NULL, UPDATED_DT_TIME TIMESTAMP NULL) +/ + +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_DUE_DATE_HISTORY_T', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 2, '7:d956eb47ece794808e92c32e76d5d89b', 'createTable', '', 'EXECUTED', '3.2.0') +/ + +-- Changeset org/kuali/ole/3.0.16/db.changelog-20190305.xml::OLE_DUE_DATE_HISTORY_TP1::ole +ALTER TABLE ole.OLE_DUE_DATE_HISTORY_T ADD PRIMARY KEY (DUE_DATE_ID) +/ + +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_DUE_DATE_HISTORY_TP1', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 3, '7:69222127bd45e97e6c42a0966aa032c0', 'addPrimaryKey', '', 'EXECUTED', '3.2.0') +/ + +-- Changeset org/kuali/ole/3.0.16/db.changelog-20190305.xml::OLE_DUE_DATE_HISTORY_S::ole +CREATE TABLE ole.OLE_DUE_DATE_HISTORY_S (ID BIGINT(19) NULL) +/ + +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_DUE_DATE_HISTORY_S', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 4, '7:77667c87caab84198ee97cff0582dc30', 'createTable', '', 'EXECUTED', '3.2.0') +/ + +-- Changeset org/kuali/ole/3.0.16/db.changelog-20190305.xml::OLE_DUE_DATE_HISTORY_S_PK::ole +ALTER TABLE ole.OLE_DUE_DATE_HISTORY_S ADD PRIMARY KEY (ID) +/ + +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_DUE_DATE_HISTORY_S_PK', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 5, '7:2a4c0f8365563d97dfdeb1420a7e962e', 'addPrimaryKey', '', 'EXECUTED', '3.2.0') +/ + +-- Changeset org/kuali/ole/3.0.16/db.changelog-20190305.xml::OLE_DUE_DATE_HISTORY_S_AUTOINCREMENT::ole +ALTER TABLE ole.OLE_DUE_DATE_HISTORY_S MODIFY ID BIGINT(19) AUTO_INCREMENT +/ + +ALTER TABLE ole.OLE_DUE_DATE_HISTORY_S AUTO_INCREMENT=1 +/ + +INSERT INTO DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, LIQUIBASE) VALUES ('OLE_DUE_DATE_HISTORY_S_AUTOINCREMENT', 'ole', 'org/kuali/ole/3.0.16/db.changelog-20190305.xml', NOW(), 6, '7:b85638b3a8a8071255ea7f628fec9708', 'addAutoIncrement', '', 'EXECUTED', '3.2.0') / -- Release Database Lock diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/deliver/bo/OleDueDateDocument.java b/ole-app/olefs/src/main/java/org/kuali/ole/deliver/bo/OleDueDateDocument.java new file mode 100644 index 0000000000..c7cbb61f09 --- /dev/null +++ b/ole-app/olefs/src/main/java/org/kuali/ole/deliver/bo/OleDueDateDocument.java @@ -0,0 +1,186 @@ +package org.kuali.ole.deliver.bo; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.kuali.ole.OLEConstants; +import org.kuali.ole.OLEPropertyConstants; +import org.kuali.ole.deliver.service.CircDeskLocationResolver; +import org.kuali.ole.deliver.service.OleLoanDocumentDaoOjb; +import org.kuali.ole.deliver.util.ItemFineRate; +import org.kuali.ole.deliver.util.LoanDateTimeUtil; +import org.kuali.ole.describe.bo.OleInstanceItemType; +import org.kuali.ole.describe.bo.OleLocation; +import org.kuali.ole.docstore.common.document.content.instance.Item; +import org.kuali.ole.service.OleCirculationPolicyServiceImpl; +import org.kuali.ole.sys.context.SpringContext; +import org.kuali.rice.core.api.config.property.ConfigContext; +import org.kuali.rice.kim.impl.identity.entity.EntityBo; +import org.kuali.rice.krad.bo.PersistableBusinessObject; +import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; +import org.kuali.rice.krad.service.KRADServiceLocator; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.*; + +/** + * The OleLoanDocument is a BO class that defines the loan document fields with getters and setters which + * is used for interacting the loan data with the persistence layer in OLE. + */ +public class OleDueDateDocument extends PersistableBusinessObjectBase { + private String baseUrl = ConfigContext.getCurrentContextConfig().getProperty(OLEPropertyConstants.OLE_URL_BASE); + private String dueDateId; + private String loanId; + private String patronBarcode; + private String itemBarcode; + private Timestamp loanDueDate; + private String loanOperatorId; + private Date pastDueDate; + private Timestamp updatedDateTime; + + /** + * Gets the patronBarcode attribute. + * + * @return Returns the patronBarcode + */ + public String getPatronBarcode() { + return patronBarcode; + } + + /** + * Sets the patronBarcode attribute value. + * + * @param patronBarcode The patronBarcode to set. + */ + public void setPatronBarcode(String patronBarcode) { + this.patronBarcode = patronBarcode; + } + + /** + * Gets the loanId attribute. + * + * @return Returns the loanId + */ + public String getLoanId() { + return loanId; + } + + /** + * Sets the loanId attribute value. + * + * @param loanId The loanId to set. + */ + public void setLoanId(String loanId) { + this.loanId = loanId; + } + + /** + * Gets the dueDateId attribute. + * + * @return Returns the dueDateId + */ + public String getDueDateId() { + return dueDateId; + } + + /** + * Sets the dueDateId attribute value. + * + * @param dueDateId The loanId to set. + */ + public void setDueDateId(String dueDateId) { + this.dueDateId = dueDateId; + } + + /** + * Gets the itemBarcode attribute. + * + * @return Returns the itemBarcode + */ + public String getItemBarcode() { + return itemBarcode; + } + + /** + * Sets the itemBarcode attribute value. + * + * @param itemBarcode The itemBarcode to set. + */ + public void setItemBarcode(String itemBarcode) { + this.itemBarcode = itemBarcode; + } + + /** + * Gets the loanOperatorId attribute. + * + * @return Returns the loanOperatorId + */ + public String getLoanOperatorIdd() { + return loanOperatorId; + } + + /** + * Sets the loanOperatorId attribute value. + * + * @param loanOperatorId The loanOperatorId to set. + */ + public void setLoanOperatorId(String loanOperatorId) { + this.loanOperatorId = loanOperatorId; + } + + + /** + * Gets the loanDueDate attribute. + * + * @return Returns the loanDueDate + */ + public Timestamp getLoanDueDate() { + return loanDueDate; + } + + /** + * Sets the loanDueDate attribute value. + * + * @param loanDueDate The loanDueDate to set. + */ + public void setLoanDueDate(Timestamp loanDueDate) { + this.loanDueDate = loanDueDate; + } + + /** + * Gets the pastDueDate attribute. + * + * @return Returns the pastDueDate + */ + public Date getPastDueDate() { + return pastDueDate; + } + + /** + * Sets the pastDueDate attribute value. + * + * @param pastDueDate The pastDueDate to set. + */ + public void setPastDueDate(Date pastDueDate) { + this.pastDueDate = pastDueDate; + } + + /** + * Gets the updatedDateTime attribute. + * + * @return Returns the updatedDateTime + */ + public Timestamp getUpdatedDateTime() { + return updatedDateTime; + } + + /** + * Sets the updatedDateTime attribute value. + * + * @param updatedDateTime The updatedDateTime to set. + */ + public void setUpdatedDateTime(Timestamp updatedDateTime) { + this.updatedDateTime = updatedDateTime; + } + +} diff --git a/ole-app/olefs/src/main/java/org/kuali/ole/deliver/controller/CircController.java b/ole-app/olefs/src/main/java/org/kuali/ole/deliver/controller/CircController.java index 1ca80b1663..652c3a15c7 100644 --- a/ole-app/olefs/src/main/java/org/kuali/ole/deliver/controller/CircController.java +++ b/ole-app/olefs/src/main/java/org/kuali/ole/deliver/controller/CircController.java @@ -10,6 +10,7 @@ import org.kuali.ole.OLEParameterConstants; import org.kuali.ole.deliver.OleLoanDocumentsFromSolrBuilder; import org.kuali.ole.deliver.bo.OLEDeliverNotice; +import org.kuali.ole.deliver.bo.OleDueDateDocument; import org.kuali.ole.deliver.bo.OleLoanDocument; import org.kuali.ole.deliver.bo.FeeType; import org.kuali.ole.deliver.calendar.service.DateUtil; @@ -32,6 +33,7 @@ import org.kuali.rice.core.api.config.property.ConfigContext; import org.kuali.rice.core.api.datetime.DateTimeService; import org.kuali.rice.krad.service.BusinessObjectService; +import org.kuali.rice.krad.util.GlobalVariables; import org.kuali.rice.krad.web.form.UifFormBase; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; @@ -519,6 +521,7 @@ private AlterDueDateAndRenewResponse updateDueDate(Map itemBar } } List loanDocumentsToBeUpdatedInDb = filterListForInvalidDueDateItems(itemBarcodeMap, getSelectedLoanDocumentList(circForm)); + List oleDueDateDocumentsToBeUpdatedInDb = new ArrayList<>(); CircUtilController circUtilController = new CircUtilController(); Map docstoreResultMap = alterDueDateInDocstore(circForm, itemBarcodeMap, selectedLoanDocumentList); @@ -542,7 +545,18 @@ private AlterDueDateAndRenewResponse updateDueDate(Map itemBar } newDueDate = getCheckoutUIController(circForm.getFormKey()).processDateAndTimeForAlterDueDate(getDateFromString(dateString), dueDateAndTime[1]); } + loanDocument.setPastDueDate(loanDocument.getLoanDueDate()); loanDocument.setLoanDueDate(newDueDate); + OleDueDateDocument oleDueDateDocument = new OleDueDateDocument(); + oleDueDateDocument.setLoanId(loanDocument.getLoanId()); + oleDueDateDocument.setPatronBarcode(loanDocument.getOlePatron().getBarcode()); + oleDueDateDocument.setItemBarcode(loanDocument.getItemId()); + oleDueDateDocument.setLoanDueDate(newDueDate); + oleDueDateDocument.setPastDueDate(loanDocument.getPastDueDate()); + oleDueDateDocument.setUpdatedDateTime(getDateTimeService().getCurrentTimestamp()); + oleDueDateDocument.setLoanOperatorId(GlobalVariables.getUserSession().getPrincipalId()); + oleDueDateDocumentsToBeUpdatedInDb.add(oleDueDateDocument); + circUtilController.updateNoticesForLoanDocument(loanDocument); validItemIdsMap.put(loanDocument.getItemId(), dueDateAndTime); } @@ -553,6 +567,7 @@ private AlterDueDateAndRenewResponse updateDueDate(Map itemBar } } saveLoanDocumentsToDb(loanDocumentsToBeUpdatedInDb); + saveDueDateDocumentsToDb(oleDueDateDocumentsToBeUpdatedInDb); //alterDueDateForLoanInDB(loanDocumentsToBeUpdatedInDb); //TODO: Handle rollback in doscstore if db update fails. AlterDueDateAndRenewResponse alterDueDateAndRenewResponse = new AlterDueDateAndRenewResponse(); @@ -567,6 +582,11 @@ private void saveLoanDocumentsToDb(List loanDocumentsToBeUpdate oleBusinessObjectService.save(loanDocumentsToBeUpdatedInDb); } + private void saveDueDateDocumentsToDb(List oleDueDateDocumentsToBeUpdatedInDb) { + BusinessObjectService oleBusinessObjectService = (BusinessObjectService) SpringContext.getService("oleBusinessObjectService"); + oleBusinessObjectService.save(oleDueDateDocumentsToBeUpdatedInDb); + } + private Date getDateFromString(String dateString) throws ParseException { return getDateTimeService().convertToDate(dateString); } diff --git a/ole-app/olefs/src/main/resources/org/kuali/ole/deliver/ojb-deliver.xml b/ole-app/olefs/src/main/resources/org/kuali/ole/deliver/ojb-deliver.xml index 14486c1b9f..41dae81da2 100644 --- a/ole-app/olefs/src/main/resources/org/kuali/ole/deliver/ojb-deliver.xml +++ b/ole-app/olefs/src/main/resources/org/kuali/ole/deliver/ojb-deliver.xml @@ -2016,6 +2016,17 @@ + + + + + + + + + + +