Skip to content

Commit

Permalink
PR-1927 Add item location to RequestItem call (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanisSaldabols authored Sep 10, 2024
1 parent b10a141 commit cce5ed0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib-ncip-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.olf.rs</groupId>
<artifactId>lib-ncip-cli</artifactId>
<version>0.24.0</version>
<version>0.24.1</version>
<name>lib-ncip-cli</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion lib-ncip-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.olf.rs</groupId>
<artifactId>lib-ncip-client</artifactId>
<version>0.24.0</version>
<version>0.24.1</version>
<name>NCIP Client</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class RequestItem extends NCIPService implements NCIPCircTransaction {
Expand All @@ -29,6 +31,7 @@ public class RequestItem extends NCIPService implements NCIPCircTransaction {
private String requestTypeString;
private String requestScopeTypeString = null;
private String pickupLocationString = null;
private String itemLocationCode = null;

public RequestItem setRegistryId(String id) {
this.registryId = id;
Expand Down Expand Up @@ -90,6 +93,11 @@ public RequestItem setPickupLocation(String pickupLocationString) {
return this;
}

public RequestItem setItemLocationCode(String itemLocationCode) {
this.itemLocationCode = itemLocationCode;
return this;
}

@Override
public NCIPInitiationData generateNCIP2Object() {
RequestItemInitiationData requestItemInitiationData = new RequestItemInitiationData();
Expand Down Expand Up @@ -147,6 +155,19 @@ public NCIPInitiationData generateNCIP2Object() {
requestItemInitiationData.setPickupLocation(pickupLocation);
}

if (itemLocationCode != null) {
LocationNameInstance locationNameInstance = new LocationNameInstance();
locationNameInstance.setLocationNameLevel(BigDecimal.ONE);
locationNameInstance.setLocationNameValue(itemLocationCode);
LocationName locationName = new LocationName();
locationName.setLocationNameInstances(Collections.singletonList(locationNameInstance));
Location location = new Location();
location.setLocationName(locationName);
ItemOptionalFields itemOptionalFields = new ItemOptionalFields();
itemOptionalFields.setLocations(Collections.singletonList(location));
requestItemInitiationData.setItemOptionalFields(itemOptionalFields);
}

requestItemInitiationData.setUserId(userid);
requestItemInitiationData.setRequestId(requestId);
requestItemInitiationData.setInitiationHeader(initiationHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ public void testGenerateNcip2Object() {
requestItem.setBibliographicRecordId("pn234092945");
requestItem.setBibliographicRecordIdCode("LCOC");
requestItem.setRequestType("Loan");
requestItem.setItemLocationCode("NC");
RequestItemInitiationData initData
= (RequestItemInitiationData) requestItem.generateNCIP2Object();
InitiationHeader initiationHeader = initData.getInitiationHeader();
assertEquals("CBA", initiationHeader.getToAgencyId().getAgencyId().getValue());
assertEquals("NC", initData.getItemOptionalFields().getLocation(0).getLocationName()
.getLocationNameInstance(0).getLocationNameValue());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.olf.rs</groupId>
<version>0.24.0</version>
<version>0.24.1</version>
<artifactId>lib-ncip-client-proj</artifactId>
<packaging>pom</packaging>
<name>lib-ncip-client-proj</name>
Expand Down

0 comments on commit cce5ed0

Please sign in to comment.