Skip to content

Commit

Permalink
Merge pull request #1190 from GIRISANKAR/develop
Browse files Browse the repository at this point in the history
OLE-9348    & OLE-9349
  • Loading branch information
GIRISANKAR authored Feb 26, 2018
2 parents 7880b56 + 6652700 commit 87a2e39
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ole-app/olefs/src/main/java/org/kuali/ole/OLEConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,11 @@ public static final class OLEBatchProcess {
public static final String DESTINATION_FIELD_DONOR_PUBLIC_DISPLAY = "Donor Public Display";
public static final String DESTINATION_FIELD_DONOR_NOTE = "Donor Note";
public static final String DESTINATION_FIELD_DONOR_CODE = "Donor Code";
public static final String DESTINATION_FIELD_DATE_CREATED = "Date Created";
public static final String DESTINATION_FIELD_DATE_UPDATED = "Date Updated";
public static final String PUBLIC_NOTE = "Public Note";
public static final String SOURCE_FIELD_DATE_CREATED = "Date Created";
public static final String SOURCE_FIELD_DATE_UPDATED = "Date Updated";
public static final String LCC = "LCC";
public static final String LOCAL_IDENTIFIER = "Local Identifier";
public static final String DESTINATION_FIELD_HOLDING_CALL_NUMBER_TYPE = "Call Number Type";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.kuali.ole.oleng.helper.ExportEholdingsMappingHelper;
import org.kuali.ole.oleng.helper.ExportHoldingsMappingHelper;
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
import org.kuali.rice.core.api.util.RiceConstants;
import org.marc4j.marc.Record;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
Expand All @@ -25,6 +26,7 @@
import org.springframework.transaction.support.TransactionTemplate;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -201,6 +203,8 @@ private List<HoldingsTree> fetchHoldingsTreeForBib(int bibId) throws Exception {
Set<String> perpetualSet = null;
Set<String> extentOfOwnershipNoteSet = null;
Set<String> linkSet = null;
SimpleDateFormat univDateFormat = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE+" "+"HH:mm:ss");
SimpleDateFormat dbDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

while (resultSet.next()) {
String holdingsType = resultSet.getString("HOLDINGS_TYPE");
Expand Down Expand Up @@ -294,12 +298,20 @@ private List<HoldingsTree> fetchHoldingsTreeForBib(int bibId) throws Exception {
holdings.setId("who-" + id);
holdings.setContentObject(oleHoldings);
holdings.setCreatedBy(resultSet.getString("CREATED_BY"));
holdings.setCreatedOn(resultSet.getString("DATE_CREATED"));

String dateCreated = resultSet.getString("DATE_CREATED");
String dateUpdated = resultSet.getString("DATE_UPDATED");

if(dateCreated != null){
holdings.setCreatedOn(univDateFormat.format(dbDateFormat.parse(dateCreated)));
}
if (resultSet.getString("STAFF_ONLY") != null) {
holdings.setStaffOnly((resultSet.getString("STAFF_ONLY").equalsIgnoreCase("Y") ? Boolean.TRUE : Boolean.FALSE));
}
holdings.setUpdatedBy(resultSet.getString("UPDATED_BY"));
holdings.setUpdatedOn(resultSet.getString("DATE_UPDATED"));
if(dateUpdated != null){
holdings.setUpdatedOn(univDateFormat.format(dbDateFormat.parse(dateUpdated)));
}
holdings.setLastUpdated(resultSet.getString("DATE_UPDATED"));

uriSet = new HashSet<>();
Expand Down Expand Up @@ -402,6 +414,8 @@ public List<org.kuali.ole.docstore.common.document.Item> fetchItemForHoldings(in
Set<String> itemNoteSet = null;
Set<String> statisticalSearchSet = null;
org.kuali.ole.docstore.common.document.content.instance.Item itemObj = null;
SimpleDateFormat univDateFormat = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE+" "+"HH:mm:ss");
SimpleDateFormat dbDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

while (resultSet.next()) {
String id = resultSet.getString("ITEM_ID");
Expand Down Expand Up @@ -510,14 +524,24 @@ public List<org.kuali.ole.docstore.common.document.Item> fetchItemForHoldings(in
itemObj.setTemporaryItemType(tempItemType);
item.setContentObject(itemObj);
item.setCreatedBy(resultSet.getString("CREATED_BY"));
item.setCreatedOn(resultSet.getString("DATE_CREATED"));

String dateCreated = resultSet.getString("DATE_CREATED");
String dateUpdated = resultSet.getString("DATE_UPDATED");

if(dateCreated != null){
item.setCreatedOn(univDateFormat.format(dbDateFormat.parse(dateCreated)));
}
if (resultSet.getString("STAFF_ONLY") != null) {
item.setStaffOnly((resultSet.getString("STAFF_ONLY").equalsIgnoreCase("Y") ? Boolean.TRUE : Boolean.FALSE));
}
item.setUpdatedBy(resultSet.getString("UPDATED_BY"));
item.setUpdatedOn(resultSet.getString("DATE_UPDATED"));
if(dateUpdated != null){
item.setUpdatedOn(univDateFormat.format(dbDateFormat.parse(dateUpdated)));
}
item.setLastUpdated(resultSet.getString("DATE_UPDATED"));

itemObj.setDateCreated(item.getCreatedOn());
itemObj.setDateUpdated(item.getUpdatedOn());
}
if (itemNoteSet.add(resultSet.getString("ITEM_NOTE_ID"))) {
Note note = new Note();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ protected void generateSubFieldsForHolding(Holdings holdingsDocument, Map<String
} else {
generateDateCreated(holdingsDocument, getCode(entry.getKey()), dataField);
}
} else if (entry.getValue().equalsIgnoreCase(OLEConstants.OLEBatchProcess.SOURCE_FIELD_DATE_UPDATED)) {
dataField = checkDataField(dataFieldList, StringUtils.trim(entry.getKey()).substring(0, 3));
if (dataField == null) {
dataField = getDataField(entry);
generateDateUpdated(holdingsDocument, getCode(entry.getKey()), dataField);
if (!dataField.getSubfields().isEmpty()) dataFieldList.add(dataField);
} else {
generateDateUpdated(holdingsDocument, getCode(entry.getKey()), dataField);
}
}
}
} catch (Exception ex) {
Expand Down Expand Up @@ -497,6 +506,24 @@ protected List<DataField> generateSubFieldsForItem(Holdings holdingsDocument, It
} else {
generateVendorLineItemIdentifier(item, getCode(entry.getKey()), dataField);
}
} else if (entry.getValue().equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_DATE_CREATED)) {
dataField = checkDataField(dataFieldItemList, StringUtils.trim(entry.getKey()).substring(0, 3));
if (dataField == null) {
dataField = getDataField(entry);
generateDateCreated(item, getCode(entry.getKey()), dataField);
if (!dataField.getSubfields().isEmpty()) dataFieldItemList.add(dataField);
} else {
generateDateCreated(item, getCode(entry.getKey()), dataField);
}
} else if (entry.getValue().equalsIgnoreCase(OLEConstants.OLEBatchProcess.DESTINATION_FIELD_DATE_UPDATED)) {
dataField = checkDataField(dataFieldItemList, StringUtils.trim(entry.getKey()).substring(0, 3));
if (dataField == null) {
dataField = getDataField(entry);
generateDateUpdated(item, getCode(entry.getKey()), dataField);
if (!dataField.getSubfields().isEmpty()) dataFieldItemList.add(dataField);
} else {
generateDateUpdated(item, getCode(entry.getKey()), dataField);
}
}
}
if (!CollectionUtils.isEmpty(dataFieldsItemNoteMap)) {
Expand Down Expand Up @@ -1122,6 +1149,27 @@ private void generateDateCreated(Holdings holdings, char code, DataField dataFie
}
}

/**
* generates the subfields for the Date Updated for the given holdings
*
* @param holdings
* @param code
* @param dataField
*/
private void generateDateUpdated(Holdings holdings, char code, DataField dataField) throws Exception {
Subfield subField = new SubfieldImpl();
subField.setCode(code);
try {
if (null != holdings && null != holdings.getUpdatedOn()) {
subField.setData(holdings.getUpdatedOn());
dataField.addSubfield(subField);
}
} catch (Exception ex) {
logError(holdings, ex, "generateDateUpdated()");
}
}


/**
* generates the subfield for the item public note
*
Expand Down Expand Up @@ -1258,6 +1306,46 @@ private void generateVendorLineItemIdentifier(Item item, char code, DataField da
}
}


/**
* generates subfield for Date Created for the given item
* @param item
* @param code
* @param dataField
*/
private void generateDateCreated(Item item, char code, DataField dataField) {
try {
if (item != null && StringUtils.isNotEmpty(item.getDateCreated())) {
Subfield subField = new SubfieldImpl();
subField.setCode(code);
subField.setData(item.getDateCreated());
dataField.addSubfield(subField);
}
} catch (Exception ex) {
logError(item, ex, "generateVendorLineItemIdentifier()");
}
}


/**
* generates subfield for Date Updated for the given item
* @param item
* @param code
* @param dataField
*/
private void generateDateUpdated(Item item, char code, DataField dataField) {
try {
if (item != null && StringUtils.isNotEmpty(item.getDateUpdated())) {
Subfield subField = new SubfieldImpl();
subField.setCode(code);
subField.setData(item.getDateUpdated());
dataField.addSubfield(subField);
}
} catch (Exception ex) {
logError(item, ex, "generateVendorLineItemIdentifier()");
}
}

/**
* Logs error for exception happening for holdings or item mapping
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ var dataMappingObject = {
{id: 'locationLevel2', name: 'Location Level2'},
{id: 'locationLevel3', name: 'Location Level3'},
{id: 'locationLevel4', name: 'Location Level4'},
{id: 'locationLevel5', name: 'Location Level5'}
{id: 'locationLevel5', name: 'Location Level5'},
{id: 'datecreated', name: 'Date Created'},
{id: 'dateupdated', name: 'Date Updated'}
],
destinationFieldsForBibMarcItems : [
{id: 'Local Identifier', name: 'Local Identifier'},
Expand Down Expand Up @@ -79,7 +81,9 @@ var dataMappingObject = {
{id: 'vendorLineItemId', name: 'Vendor Line Item Identifier'},
{id: 'staffOnly', name: 'Staff Only'},
{id: 'numberOfPieces', name: 'Number of Pieces'},
{id: 'statisticalCode', name:'Statistical Code'}
{id: 'statisticalCode', name:'Statistical Code'},
{id: 'datecreated', name: 'Date Created'},
{id: 'dateupdated', name: 'Date Updated'}
],
destinationFieldsForBibMarcEHoldings : [
{id: 'Local Identifier', name: 'Local Identifier'},
Expand Down Expand Up @@ -139,7 +143,9 @@ var dataMappingObject = {
{id: 'materialsSpecified', name: 'Materials Specified'},
{id: 'firstIndicator', name: 'First Indicator'},
{id: 'secondIndicator', name: 'Second Indicator'},
{id: 'non-publicNote', name: 'Non-public Note'}
{id: 'non-publicNote', name: 'Non-public Note'},
{id: 'datecreated', name: 'Date Created'},
{id: 'dateupdated', name: 'Date Updated'}
],
destinationFieldsForConstantsBib : [
{id: 'bibStatus', name: 'Bib Status'},
Expand Down Expand Up @@ -863,4 +869,4 @@ var fieldOperation = {
ignoreGPF: false,
isAddLine: false,
collapsed: true
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@
"itemClaimsReturnedRecords",
"itemDamagedRecords",
"missingPieceItemRecordList",
"originalDueDate"
"originalDueDate",
"dateUpdated",
"dateCreated"

})
@XStreamAlias("item")
@XmlRootElement(name = "item")
Expand Down Expand Up @@ -223,6 +226,10 @@ public class Item {
protected int numberOfRenew;
@XmlElement(required = true)
protected String checkOutDateTime;
@XmlElement(required = false)
protected String dateCreated;
@XmlElement(required = false)
protected String dateUpdated;
@XmlAttribute
@XStreamAsAttribute
protected String analytic;
Expand Down Expand Up @@ -1277,4 +1284,20 @@ public String getOriginalDueDate() {
public void setOriginalDueDate(String originalDueDate) {
this.originalDueDate = originalDueDate;
}

public String getDateCreated() {
return dateCreated;
}

public void setDateCreated(String dateCreated) {
this.dateCreated = dateCreated;
}

public String getDateUpdated() {
return dateUpdated;
}

public void setDateUpdated(String dateUpdated) {
this.dateUpdated = dateUpdated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -1139,6 +1140,7 @@ public void bulkUpdateItem(Item item, List<String> itemIds, String canUpdateStaf
if (itemContent.getItemStatus() != null) {
if (StringUtils.isNotBlank(itemContent.getItemStatus().getCodeValue()) || StringUtils.isNotBlank(itemContent.getItemStatus().getFullValue())) {
existingItemContent.setItemStatus(itemContent.getItemStatus());
existingItemContent.setItemStatusEffectiveDate(new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new Date()));
}
}
if (canUpdateStaffOnlyFlag.equalsIgnoreCase("true")) {
Expand Down

0 comments on commit 87a2e39

Please sign in to comment.