Skip to content

Commit

Permalink
OLE-8938 : Fixed issue with overlay if bib status equals does not pro…
Browse files Browse the repository at this point in the history
…tect attached eholdings
  • Loading branch information
sheiksalahudeen committed Jul 5, 2016
1 parent f19bf8b commit 69f8c95
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public static final class BatchProcess {
public static final String MATCHPOINT_FOR_DATAMAPPING = "matchpointForDataMapping";
public static final String ADDED_OPS = "addedOps";
public static final String ADDITIONAL_OVERLAY_OPS = "additionalOverlayOps";
public static final String DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS = "discardedBibForAdditionalOverlayOps";
public static final String DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS = "discardedHoldingsForAdditionalOverlayOps";
public static final String ACTION_OPS = "actionOps";
public static final String FIELD_OPS = "fieldOps";
public static final String BIB_DATAMAPPINGS = "bibDataMappings";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class HoldingsRecord extends PersistableBusinessObjectBase
private List<BibRecord> bibRecords;
private List<OLEHoldingsDonorRecord> donorList;
private List<HoldingsUriRecord> accessUriRecords;
private String operationType;

public List<HoldingsUriRecord> getAccessUriRecords() {
return accessUriRecords;
Expand Down Expand Up @@ -584,4 +585,12 @@ public List<OLEHoldingsDonorRecord> getDonorList() {
public void setDonorList(List<OLEHoldingsDonorRecord> donorList) {
this.donorList = donorList;
}

public String getOperationType() {
return operationType;
}

public void setOperationType(String operationType) {
this.operationType = operationType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public class ItemRecord extends PersistableBusinessObjectBase
@AuditField
private Timestamp originalDueDate;
private HoldingsRecord holdingsRecord;
private String operationType;

public List<MissingPieceItemRecord> getMissingPieceItemRecordList() {
return missingPieceItemRecordList;
Expand Down Expand Up @@ -630,4 +631,12 @@ public HoldingsRecord getHoldingsRecord() {
public void setHoldingsRecord(HoldingsRecord holdingsRecord) {
this.holdingsRecord = holdingsRecord;
}

public String getOperationType() {
return operationType;
}

public void setOperationType(String operationType) {
this.operationType = operationType;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.kuali.ole.dsng.rest.handler;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
Expand Down Expand Up @@ -102,4 +103,9 @@ public List<String> parseCommaSeperatedValues(String value){
}
return values;
}


public boolean isDiscardedByAdditionalOverlayOps(Set<String> discardedIdsForAdditionalOverlayOps, String id) {
return CollectionUtils.isNotEmpty(discardedIdsForAdditionalOverlayOps) ? discardedIdsForAdditionalOverlayOps.contains(id) : false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.marc4j.marc.VariableField;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;

/**
* Created by pvsubrah on 12/23/15.
Expand Down Expand Up @@ -78,6 +76,13 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
bibRecord.setOperationType(OleNGConstants.UPDATED);

saveBibInfoRecord(bibRecord,false);
} else {
Set<String> discardedBibIdsForAdditionalOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS);
if(null == discardedBibIdsForAdditionalOps) {
discardedBibIdsForAdditionalOps = new HashSet<String>();
}
discardedBibIdsForAdditionalOps.add(bibRecord.getBibId());
exchange.add(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS, discardedBibIdsForAdditionalOps);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.kuali.ole.dsng.rest.handler.Handler;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;

/**
* Created by pvsubrah on 1/22/16.
Expand All @@ -35,6 +33,7 @@ public Boolean isInterested(String operation) {
@Override
public void process(JSONObject requestJsonObject, Exchange exchange) {
List<HoldingsRecordAndDataMapping> holdingsRecordAndDataMappings = (List<HoldingsRecordAndDataMapping>) exchange.get(OleNGConstants.HOLDINGS_FOR_CREATE);
Set<String> discardedBibForAdditionalOverlayOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS);
List<HoldingsRecord> holdingsRecords = new ArrayList<HoldingsRecord>();
if (CollectionUtils.isNotEmpty(holdingsRecordAndDataMappings)) {
for (Iterator<HoldingsRecordAndDataMapping> iterator = holdingsRecordAndDataMappings.iterator(); iterator.hasNext(); ) {
Expand All @@ -43,16 +42,18 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord();
String bibId = holdingsRecord.getBibRecords().get(0).getBibId();
if (StringUtils.isNotBlank(bibId)) {
JSONObject dataMapping = holdingsRecordAndDataMapping.getDataMapping();
holdingsRecord.setBibId(bibId);
exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord);
JSONObject holdingsJSONObject = requestJsonObject.getJSONObject(OleNGConstants.HOLDINGS);
if (null != dataMapping) {
exchange.add(OleNGConstants.DATAMAPPING, dataMapping);
processDataMappings(holdingsJSONObject, exchange);
if (!isDiscardedByAdditionalOverlayOps(discardedBibForAdditionalOverlayOps, bibId)) {
JSONObject dataMapping = holdingsRecordAndDataMapping.getDataMapping();
holdingsRecord.setBibId(bibId);
exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord);
JSONObject holdingsJSONObject = requestJsonObject.getJSONObject(OleNGConstants.HOLDINGS);
if (null != dataMapping) {
exchange.add(OleNGConstants.DATAMAPPING, dataMapping);
processDataMappings(holdingsJSONObject, exchange);
}
setCommonValuesToHoldingsRecord(requestJsonObject, holdingsRecord);
holdingsRecords.add(holdingsRecord);
}
setCommonValuesToHoldingsRecord(requestJsonObject, holdingsRecord);
holdingsRecords.add(holdingsRecord);
}
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -64,6 +65,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
exchange.remove(OleNGConstants.DATAMAPPING);
try {
getOleDsNGMemorizeService().getHoldingDAO().saveAll(holdingsRecords);
for (Iterator<HoldingsRecord> iterator = holdingsRecords.iterator(); iterator.hasNext(); ) {
HoldingsRecord holdingsRecord = iterator.next();
holdingsRecord.setOperationType(OleNGConstants.CREATED);
}
} catch (Exception e) {
e.printStackTrace();
addFailureReportToExchange(requestJsonObject, exchange,OleNGConstants.NO_OF_FAILURE_HOLDINGS, e, holdingsRecords.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public Boolean isInterested(String operation) {
public void process(JSONObject requestJsonObject, Exchange exchange) {

List<HoldingsRecordAndDataMapping> holdingsRecordAndDataMappings = (List<HoldingsRecordAndDataMapping>) exchange.get(OleNGConstants.HOLDINGS_FOR_UPDATE);
Set<String> discardedBibForAdditionalOverlayOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_BIB_FOR_ADDITIONAL_OVERLAY_OPS);
List<HoldingsRecord> holdingsRecords = new ArrayList<HoldingsRecord>();
if (CollectionUtils.isNotEmpty(holdingsRecordAndDataMappings)) {
String updatedBy = getStringValueFromJsonObject(requestJsonObject, OleNGConstants.UPDATED_BY);
Expand All @@ -67,17 +68,27 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
try {
HoldingsRecordAndDataMapping holdingsRecordAndDataMapping = iterator.next();
HoldingsRecord holdingsRecord = holdingsRecordAndDataMapping.getHoldingsRecord();
holdingsRecord.setUpdatedDate(updatedDate);
holdingsRecord.setUpdatedBy(updatedBy);
if(holdingsRecord.getStaffOnlyFlag()==null){
holdingsRecord.setStaffOnlyFlag(false);
}
exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord);
JSONObject dataMappingByValue = holdingsRecordAndDataMapping.getDataMapping();
if (null != dataMappingByValue) {
processOverlay(exchange, holdingsRecord, dataMappingByValue);
holdingsRecords.add(holdingsRecord);
String bibId = holdingsRecord.getBibId();
if (!isDiscardedByAdditionalOverlayOps(discardedBibForAdditionalOverlayOps, bibId)) {
holdingsRecord.setUpdatedDate(updatedDate);
holdingsRecord.setUpdatedBy(updatedBy);
if(holdingsRecord.getStaffOnlyFlag()==null){
holdingsRecord.setStaffOnlyFlag(false);
}
exchange.add(OleNGConstants.HOLDINGS_RECORD, holdingsRecord);
JSONObject dataMappingByValue = holdingsRecordAndDataMapping.getDataMapping();
if (null != dataMappingByValue) {
processOverlay(exchange, holdingsRecord, dataMappingByValue);
}
HoldingsUtil.getInstance().processIfDeleteAllExistOpsFound(holdingsRecord, requestJsonObject);
holdingsRecords.add(holdingsRecord);
}else {
Set<String> discardedHoldingsIdsForAdditionalOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS);
if(null == discardedHoldingsIdsForAdditionalOps) {
discardedHoldingsIdsForAdditionalOps = new HashSet<String>();
}
discardedHoldingsIdsForAdditionalOps.add(holdingsRecord.getHoldingsId());
exchange.add(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS, discardedHoldingsIdsForAdditionalOps);
}
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -87,6 +98,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
exchange.remove(OleNGConstants.HOLDINGS_RECORD);
try {
getOleDsNGMemorizeService().getHoldingDAO().saveAll(holdingsRecords);
for (Iterator<HoldingsRecord> iterator = holdingsRecords.iterator(); iterator.hasNext(); ) {
HoldingsRecord holdingsRecord = iterator.next();
holdingsRecord.setOperationType(OleNGConstants.UPDATED);
}
} catch (Exception e) {
e.printStackTrace();
addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_HOLDINGS, e , 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/**
* Created by SheikS on 12/26/2015.
Expand All @@ -35,6 +36,7 @@ public Boolean isInterested(String operation) {
@Override
public void process(JSONObject requestJsonObject, Exchange exchange) {
List<ItemRecordAndDataMapping> itemRecordAndDataMappings = (List<ItemRecordAndDataMapping>) exchange.get(OleNGConstants.ITEMS_FOR_CREATE);
Set<String> discardedHoldingsForAdditionalOverlayOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS);
List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();

if (CollectionUtils.isNotEmpty(itemRecordAndDataMappings)) {
Expand All @@ -45,13 +47,15 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord();
String holdingsId = itemRecord.getHoldingsRecord().getHoldingsId();
if (StringUtils.isNotBlank(holdingsId)) {
JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping();
exchange.add(OleNGConstants.DATAMAPPING,dataMapping);
itemRecord.setHoldingsId(holdingsId);
exchange.add(OleNGConstants.ITEM_RECORD, itemRecord);
processDataMappings(itemJSONObject, exchange);
setCommonValuesToItemRecord(requestJsonObject, itemRecord);
itemRecords.add(itemRecord);
if (!isDiscardedByAdditionalOverlayOps(discardedHoldingsForAdditionalOverlayOps, holdingsId)) {
JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping();
exchange.add(OleNGConstants.DATAMAPPING,dataMapping);
itemRecord.setHoldingsId(holdingsId);
exchange.add(OleNGConstants.ITEM_RECORD, itemRecord);
processDataMappings(itemJSONObject, exchange);
setCommonValuesToItemRecord(requestJsonObject, itemRecord);
itemRecords.add(itemRecord);
}
}
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -63,6 +67,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
exchange.remove(OleNGConstants.DATAMAPPING);
try {
getOleDsNGMemorizeService().getItemDAO().saveAll(itemRecords);
for (Iterator<ItemRecord> iterator = itemRecords.iterator(); iterator.hasNext(); ) {
ItemRecord itemRecord = iterator.next();
itemRecord.setOperationType(OleNGConstants.CREATED);
}
} catch (Exception e) {
e.printStackTrace();
addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e , itemRecords.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@

import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Created by SheikS on 12/26/2015.
Expand All @@ -41,6 +38,7 @@ public Boolean isInterested(String operation) {
@Override
public void process(JSONObject requestJsonObject, Exchange exchange) {
List<ItemRecordAndDataMapping> itemRecordAndDataMappings = (List<ItemRecordAndDataMapping>) exchange.get(OleNGConstants.ITEMS_FOR_UPDATE);
Set<String> discardedHoldingsForAdditionalOverlayOps = (Set<String>) exchange.get(OleNGConstants.DISCARDED_HOLDINGS_FOR_ADDITIONAL_OVERLAY_OPS);
List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
if (CollectionUtils.isNotEmpty(itemRecordAndDataMappings)) {

Expand All @@ -52,14 +50,17 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
try {
ItemRecordAndDataMapping itemRecordAndDataMapping = iterator.next();
ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord();
JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping();
itemRecord.setUpdatedBy(updatedBy);
itemRecord.setUpdatedDate(updatedDate);
exchange.add(OleNGConstants.ITEM_RECORD, itemRecord);
if (null != dataMapping) {
processOverlay(exchange, dataMapping, itemRecord);
String holdingsId = itemRecord.getHoldingsId();
if (!isDiscardedByAdditionalOverlayOps(discardedHoldingsForAdditionalOverlayOps, holdingsId)) {
JSONObject dataMapping = itemRecordAndDataMapping.getDataMapping();
itemRecord.setUpdatedBy(updatedBy);
itemRecord.setUpdatedDate(updatedDate);
exchange.add(OleNGConstants.ITEM_RECORD, itemRecord);
if (null != dataMapping) {
processOverlay(exchange, dataMapping, itemRecord);
}
itemRecords.add(itemRecord);
}
itemRecords.add(itemRecord);
} catch (Exception e) {
e.printStackTrace();
addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e, 1);
Expand All @@ -69,6 +70,10 @@ public void process(JSONObject requestJsonObject, Exchange exchange) {
exchange.remove(OleNGConstants.ITEM_RECORD);
try {
getOleDsNGMemorizeService().getItemDAO().saveAll(itemRecords);
for (Iterator<ItemRecord> iterator = itemRecords.iterator(); iterator.hasNext(); ) {
ItemRecord itemRecord = iterator.next();
itemRecord.setOperationType(OleNGConstants.UPDATED);
}
} catch (Exception e) {
e.printStackTrace();
addFailureReportToExchange(requestJsonObject, exchange, OleNGConstants.NO_OF_FAILURE_ITEM, e , itemRecords.size());
Expand Down
Loading

0 comments on commit 69f8c95

Please sign in to comment.