Skip to content

Commit

Permalink
Merge pull request #1260 from openlibraryenvironment/OLE-9424
Browse files Browse the repository at this point in the history
OLE-9424 : Alter Due Date does not capture the date iit happened or the operator ID
  • Loading branch information
NSSuresh11 authored Mar 8, 2019
2 parents ed72139 + 0c3b3c5 commit 00e1f81
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,56 @@
</delete>
</rollback>
</changeSet>

<changeSet context="bootstrap" author="ole" id="OLE_DUE_DATE_HISTORY_T">
<createTable catalogName="ole"
schemaName="ole"
tableName="OLE_DUE_DATE_HISTORY_T ">
<column name="DUE_DATE_ID" type="VARCHAR(40)"/>
<column name="LOAN_ID" type="VARCHAR(40)"/>
<column name="PTRN_BARCODE" type="VARCHAR(100)"/>
<column name="ITEM_BARCODE" type="VARCHAR(100)"/>
<column name="CURR_DUE_DT_TIME" type="TIMESTAMP"/>
<column name="PAST_DUE_DT_TIME" type="TIMESTAMP"/>
<column name="OPTR_ID" type="VARCHAR(40)"/>
<column name="UPDATED_DT_TIME" type="TIMESTAMP"/>
</createTable>
</changeSet>

<changeSet context="bootstrap" author="ole" id="OLE_DUE_DATE_HISTORY_TP1">
<addPrimaryKey catalogName="ole"
columnNames="DUE_DATE_ID"
constraintName="OLE_DUE_DATE_HISTORY_TP1"
schemaName="ole"
tableName="OLE_DUE_DATE_HISTORY_T"/>

</changeSet>

<changeSet context="bootstrap" author="ole" id="OLE_DUE_DATE_HISTORY_S" dbms="mysql">
<createTable catalogName="ole"
schemaName="ole"
tableName="OLE_DUE_DATE_HISTORY_S">
<column name="ID" type="BIGINT(19)"/>
</createTable>
</changeSet>

<changeSet context="bootstrap" author="ole" id="OLE_DUE_DATE_HISTORY_S_PK" dbms="mysql">
<addPrimaryKey catalogName="ole"
columnNames="ID"
constraintName="OLE_DUE_DATE_HISTORY_S_PK"
schemaName="ole"
tableName="OLE_DUE_DATE_HISTORY_S"/>

</changeSet>

<changeSet context="bootstrap" author="ole" id="OLE_DUE_DATE_HISTORY_S_AUTOINCREMENT" dbms="mysql">
<addAutoIncrement catalogName="ole"
columnDataType="BIGINT(19)"
columnName="ID"
incrementBy="1"
schemaName="ole"
startWith="1"
tableName="OLE_DUE_DATE_HISTORY_S"/>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -519,6 +521,7 @@ private AlterDueDateAndRenewResponse updateDueDate(Map<String, String[]> itemBar
}
}
List<OleLoanDocument> loanDocumentsToBeUpdatedInDb = filterListForInvalidDueDateItems(itemBarcodeMap, getSelectedLoanDocumentList(circForm));
List<OleDueDateDocument> oleDueDateDocumentsToBeUpdatedInDb = new ArrayList<>();
CircUtilController circUtilController = new CircUtilController();

Map<String, Map> docstoreResultMap = alterDueDateInDocstore(circForm, itemBarcodeMap, selectedLoanDocumentList);
Expand All @@ -542,7 +545,18 @@ private AlterDueDateAndRenewResponse updateDueDate(Map<String, String[]> 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);
}
Expand All @@ -553,6 +567,7 @@ private AlterDueDateAndRenewResponse updateDueDate(Map<String, String[]> itemBar
}
}
saveLoanDocumentsToDb(loanDocumentsToBeUpdatedInDb);
saveDueDateDocumentsToDb(oleDueDateDocumentsToBeUpdatedInDb);
//alterDueDateForLoanInDB(loanDocumentsToBeUpdatedInDb);
//TODO: Handle rollback in doscstore if db update fails.
AlterDueDateAndRenewResponse alterDueDateAndRenewResponse = new AlterDueDateAndRenewResponse();
Expand All @@ -567,6 +582,11 @@ private void saveLoanDocumentsToDb(List<OleLoanDocument> loanDocumentsToBeUpdate
oleBusinessObjectService.save(loanDocumentsToBeUpdatedInDb);
}

private void saveDueDateDocumentsToDb(List<OleDueDateDocument> oleDueDateDocumentsToBeUpdatedInDb) {
BusinessObjectService oleBusinessObjectService = (BusinessObjectService) SpringContext.getService("oleBusinessObjectService");
oleBusinessObjectService.save(oleDueDateDocumentsToBeUpdatedInDb);
}

private Date getDateFromString(String dateString) throws ParseException {
return getDateTimeService().convertToDate(dateString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,17 @@
<field-descriptor name="versionNumber" column="VER_NBR" jdbc-type="BIGINT" locking="true" />
</class-descriptor>

<class-descriptor class="org.kuali.ole.deliver.bo.OleDueDateDocument" table="OLE_DUE_DATE_HISTORY_T">
<field-descriptor name="dueDateId" column="DUE_DATE_ID" jdbc-type="VARCHAR" primarykey="true" index="true" autoincrement="true" sequence-name="OLE_DUE_DATE_HISTORY_S"></field-descriptor>
<field-descriptor name="loanId" column="LOAN_ID" jdbc-type="VARCHAR" />
<field-descriptor name="patronBarcode" column="PTRN_BARCODE" jdbc-type="VARCHAR" />
<field-descriptor name="itemBarcode" column="ITEM_BARCODE" jdbc-type="VARCHAR" />
<field-descriptor name="loanDueDate" column="CURR_DUE_DT_TIME" jdbc-type="TIMESTAMP"></field-descriptor>
<field-descriptor name="pastDueDate" column="PAST_DUE_DT_TIME" jdbc-type="TIMESTAMP"></field-descriptor>
<field-descriptor name="updatedDateTime" column="UPDATED_DT_TIME" jdbc-type="TIMESTAMP"></field-descriptor>
<field-descriptor name="loanOperatorId" column="OPTR_ID" jdbc-type="VARCHAR"></field-descriptor>
</class-descriptor>

</descriptor-repository>


Expand Down

0 comments on commit 00e1f81

Please sign in to comment.