Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code to insert caret-C and strip non-numeric chars from front of … #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ public class SymphonyHostLMSService extends BaseHostLMSService {
return 'marcxml';
}

//Override to search on attribute 1016, and prepend '^C' to search string
//Override to search on attribute 1016 and tweak identifier for search string
@Override
public List<ItemLocation> z3950ItemsByIdentifier(PatronRequest pr, ISettings settings) {

List<ItemLocation> result = [];

String search_id = pr.supplierUniqueRecordId;
search_id = modifyIdentifier(search_id);
String prefix_query_string = "@attr 1=1016 ${search_id}";
def z_response = z3950Service.query(settings, prefix_query_string, 1, getHoldingsQueryRecsyn());
log.debug("Got Z3950 response: ${z_response}");
Expand All @@ -50,6 +51,18 @@ public class SymphonyHostLMSService extends BaseHostLMSService {
return result;
}

//Strip any non-numeric characters from the front of the string and prepend ^C
protected String modifyIdentifier(String id) {
def pattern = /([a-zA-Z]+)?(.*)/;
def matcher = id =~ pattern;
matcher.find();
if (matcher.matches() && matcher.group(2)?.length() > 0) {
return '^C' + matcher.group(2);
}
log.debug("Unable to determine characters to strip from identifier");
return '^C' + id;
}

// Given the record syntax above, process response records as Opac recsyn. If you change the recsyn string above
// you need to change the handler here. SIRSI for example needs to return us marcxml with a different location for the holdings
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,24 @@ class SymphonyHostLMSServiceSpec extends Specification implements ServiceUnitTes
result.size() == 1;
resultJson == '{"temporaryShelvingLocation":null,"itemId":null,"temporaryLocation":null,"shelvingLocation":"STACKS","callNumber":"HV6534 .V55 J36 2017","reason":null,"shelvingPreference":null,"preference":null,"location":"SAL3","itemLoanPolicy":"STKS-MONO"}';
}

def 'modifyIdentifier'() {
setup:
def identifier = 'a983475243';
def identifier2 = '983475243';
def identifier3 = 'abcdefgHIJKL';

when: 'We modify the identifier'
def result = service.modifyIdentifier(identifier);
def result2 = service.modifyIdentifier(identifier2);
def result3 = service.modifyIdentifier(identifier3);

then:
'^C983475243' == result;
'^C983475243' == result2;
'^CabcdefgHIJKL' == result3;


}
}