Skip to content

Commit

Permalink
OLE-8900 : Fixed the issue with holdings / eholdings / item overlays …
Browse files Browse the repository at this point in the history
…by Ids.
  • Loading branch information
sheiksalahudeen committed Jul 5, 2016
1 parent 7eb3417 commit d4880ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord
// Prepare data mapping before MARC Transformation
Map<String, List<JSONObject>> dataMappingsMapPreTransformation = prepareDataMapping(marcRecord, batchProcessProfile, OleNGConstants.PRE_MARC_TRANSFORMATION);

JSONObject holdingsData = getMatchPointProcessor().prepareMatchPointsForHoldings(marcRecord, batchProcessProfile);
JSONObject eholdingsData = getMatchPointProcessor().prepareMatchPointsForEHoldings(marcRecord, batchProcessProfile);
JSONObject itemData = getMatchPointProcessor().prepareMatchPointsForItem(marcRecord, batchProcessProfile);

//Transformations pertaining to MARC record (001,003,035$a etc..)
handleBatchProfileTransformations(marcRecord, batchProcessProfile);
Expand All @@ -214,19 +217,16 @@ private JSONObject prepareRequest(Integer index, String bibId, Record marcRecord
List<JSONObject> bibDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.BIB_DATAMAPPINGS);
bibData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(bibDataMappingsPreTrans, bibDataMappingsPostTrans));

JSONObject holdingsData = getMatchPointProcessor().prepareMatchPointsForHoldings(marcRecord, batchProcessProfile);
List<JSONObject> holdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.HOLDINGS_DATAMAPPINGS);
List<JSONObject> holdingsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.HOLDINGS_DATAMAPPINGS);
holdingsData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(holdingsDataMappingsPreTrans, holdingsDataMappingsPostTrans));
bibData.put(OleNGConstants.HOLDINGS, holdingsData);

JSONObject eholdingsData = getMatchPointProcessor().prepareMatchPointsForEHoldings(marcRecord, batchProcessProfile);
List<JSONObject> eholdingsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.EHOLDINGS_DATAMAPPINGS);
List<JSONObject> eholdingsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.EHOLDINGS_DATAMAPPINGS);
eholdingsData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(eholdingsDataMappingsPreTrans, eholdingsDataMappingsPostTrans));
bibData.put(OleNGConstants.EHOLDINGS, eholdingsData);

JSONObject itemData = getMatchPointProcessor().prepareMatchPointsForItem(marcRecord, batchProcessProfile);
List<JSONObject> itemsDataMappingsPreTrans = dataMappingsMapPreTransformation.get(OleNGConstants.ITEM_DATAMAPPINGS);
List<JSONObject> itemsDataMappingsPostTrans = dataMappingsMapPostTransformations.get(OleNGConstants.ITEM_DATAMAPPINGS);
itemData.put(OleNGConstants.DATAMAPPING, buildOneObjectForList(itemsDataMappingsPreTrans, itemsDataMappingsPostTrans));
Expand Down Expand Up @@ -286,8 +286,8 @@ public List<JSONObject> buildOneObjectForList(List<JSONObject> dataMappingsPreTr
List<JSONObject> finalObjects = new ArrayList<>();

for (int index = 0; index < dataMappingsPreTrans.size(); index++) {
JSONObject preTransformObject = dataMappingsPreTrans.get(index);
JSONObject postTransformObject = dataMappingsPostTrans.get(index);
JSONObject preTransformObject = dataMappingsPreTrans.size() > index ? dataMappingsPreTrans.get(index) : new JSONObject();
JSONObject postTransformObject = dataMappingsPostTrans.size() > index ? dataMappingsPostTrans.get(index) : new JSONObject();
finalObjects.add(buildOneObject(preTransformObject, postTransformObject));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void buildItemResponse(HoldingsResponse holdingsResponse, Exchange exchan
if (CollectionUtils.isNotEmpty(createItemRecordAndDataMappings)) {
for (ItemRecordAndDataMapping itemRecordAndDataMapping : createItemRecordAndDataMappings) {
ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord();
if (holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) {
if (null != itemRecord && StringUtils.isNotBlank(itemRecord.getItemId()) && holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) {
ItemResponse itemResponse = new ItemResponse();
itemResponse.setItemId(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML+ "-" + itemRecord.getItemId());
itemResponse.setOperation(OleNGConstants.CREATED);
Expand All @@ -348,7 +348,7 @@ public void buildItemResponse(HoldingsResponse holdingsResponse, Exchange exchan
ItemRecord itemRecord = itemRecordAndDataMapping.getItemRecord();
if (holdingsRecord.getHoldingsId().equals(itemRecord.getHoldingsId())) {
ItemResponse itemResponse = new ItemResponse();
itemResponse.setItemId(itemRecord.getItemId());
itemResponse.setItemId(DocumentUniqueIDPrefix.PREFIX_WORK_ITEM_OLEML+ "-" + itemRecord.getItemId());
itemResponse.setOperation(status);
itemResponses.add(itemResponse);
}
Expand Down Expand Up @@ -1105,49 +1105,6 @@ private BibRecord prepareBib(JSONObject bibJSONDataObject) {
return bibRecord;
}

private List<HoldingsResponse> holdingsResponse(Exchange exchange, List holdingRecords, String operation) {
List<HoldingsResponse> holdingsResponses = new ArrayList<HoldingsResponse>();
if (CollectionUtils.isNotEmpty(holdingRecords)) {
for (Iterator iterator = holdingRecords.iterator(); iterator.hasNext(); ) {
HoldingsResponse holdingsResponse = new HoldingsResponse();
HoldingsRecord holdingsRecord = (HoldingsRecord) iterator.next();
holdingsResponse.setOperation(operation);
holdingsResponse.setHoldingsId(holdingsRecord.getUniqueIdPrefix() + "-" + holdingsRecord.getHoldingsId());
holdingsResponse.setItemResponses(prepareItemsResponse(holdingsRecord, exchange));
holdingsResponses.add(holdingsResponse);
}
}
return holdingsResponses;
}

private List<ItemResponse> prepareItemsResponse(HoldingsRecord holdingsRecord, Exchange exchange) {
List<ItemResponse> itemResponses = new ArrayList<ItemResponse>();

List itemRecordsToCreate = (List) exchange.get(OleNGConstants.ITEMS_CREATED);
itemResponses.addAll(itemResponse(holdingsRecord, itemRecordsToCreate, OleNGConstants.CREATED));

List itemRecordsToUpdate = (List) exchange.get(OleNGConstants.ITEMS_UPDATED);
itemResponses.addAll(itemResponse(holdingsRecord, itemRecordsToUpdate, OleNGConstants.UPDATED));

return itemResponses;
}

private List<ItemResponse> itemResponse(HoldingsRecord holdingsRecord, List itemRecords, String operation) {
List<ItemResponse> itemResponses = new ArrayList<ItemResponse>();
if (CollectionUtils.isNotEmpty(itemRecords)) {
for (Iterator iterator = itemRecords.iterator(); iterator.hasNext(); ) {
ItemRecord itemRecord = (ItemRecord) iterator.next();
if (itemRecord.getHoldingsId().equalsIgnoreCase(holdingsRecord.getHoldingsId())) {
ItemResponse itemResponse = new ItemResponse();
itemResponse.setOperation(operation);
itemResponse.setItemId(itemRecord.getUniqueIdPrefix() + "-" + itemRecord.getItemId());
itemResponses.add(itemResponse);
}
}
}
return itemResponses;
}

private JSONObject findDataMappingByValue(JSONArray dataMappings, String type, String value) {
if (null != dataMappings) {
for (int index = 0; index < dataMappings.length(); index++) {
Expand Down

0 comments on commit d4880ab

Please sign in to comment.