Skip to content
Merged
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 @@ -84,4 +84,9 @@ public ApiResponse getButtonsByBibId(@RequestParam(value="catalogName",defaultVa
public ApiResponse getButtonConfiguration() {
return new ApiResponse(SUCCESS,"Current Button Configuration",getItForMeService.getRegisteredButtons());
}

@RequestMapping("/text-call-number")
public ApiResponse textCall(@RequestParam(value="catalogName",defaultValue="evans") String catalogName, @RequestParam("bibId") String bibId, @RequestParam("holdingId") String holdingId) {
return new ApiResponse(SUCCESS, getItForMeService.getTextCallNumberButton(catalogName, bibId, holdingId));
}
}
16 changes: 13 additions & 3 deletions src/main/java/edu/tamu/app/model/CatalogHolding.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public class CatalogHolding {
private String edition;
private String oclc;
private String recordId;
private String callNumber;
private boolean largeVolume = false;

private Map<String, Map<String, String>> catalogItems = new HashMap<String, Map<String, String>>();

public CatalogHolding(String marcRecordLeader, String mfhd, String issn, String isbn, String title, String author,
String publisher, String place, String year, String genre, String edition, String fallBackLocationCode, String oclc, String recordId,
String publisher, String place, String year, String genre, String edition, String fallBackLocationCode, String oclc, String recordId, String callNumber,
Map<String, Map<String, String>> catalogItems) {
this.setMarcRecordLeader(marcRecordLeader);
this.setMfhd(mfhd);
Expand All @@ -50,12 +51,13 @@ public CatalogHolding(String marcRecordLeader, String mfhd, String issn, String
this.setFallbackLocationCode(fallBackLocationCode);
this.setOclc(oclc);
this.setRecordId(recordId);
this.setCallNumber(callNumber);
}

public CatalogHolding(String marcRecordLeader, String mfhd, String issn, String isbn, String title, String author,
String publisher, String place, String year, String genre, String edition, String fallBackLocationCode, String oclc, String recordId,
String publisher, String place, String year, String genre, String edition, String fallBackLocationCode, String oclc, String recordId, String callNumber,
boolean largeVolume, Map<String, Map<String, String>> catalogItems) {
this(marcRecordLeader, mfhd, issn, isbn, title, author, publisher, place, year, genre, edition, fallBackLocationCode, oclc, recordId, catalogItems);
this(marcRecordLeader, mfhd, issn, isbn, title, author, publisher, place, year, genre, edition, fallBackLocationCode, oclc, recordId, callNumber, catalogItems);
this.setLargeVolume(largeVolume);
}

Expand Down Expand Up @@ -171,6 +173,14 @@ public void setRecordId(String recordId) {
this.recordId = recordId;
}

public String getCallNumber() {
return callNumber;
}

public void setCallNumber(String callNumber) {
this.callNumber = callNumber;
}

public Map<String, Map<String, String>> getCatalogItems() {
return catalogItems;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/edu/tamu/app/service/CatalogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface CatalogService {

List<CatalogHolding> getHoldingsByBibId(String bibId);

CatalogHolding getHolding(String bibId, String holdingId);

String getName();

void setName(String name);
Expand Down Expand Up @@ -42,5 +44,4 @@ public interface CatalogService {
String getSidPrefix();

void setSidPrefix(String sidPrefix);

}
54 changes: 54 additions & 0 deletions src/main/java/edu/tamu/app/service/GetItForMeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;

Expand Down Expand Up @@ -89,6 +91,10 @@ public List<CatalogHolding> getHoldingsByBibId(String catalogName, String bibId)
return getCatalogServiceByName(catalogName).getHoldingsByBibId(bibId);
}

public CatalogHolding getHolding(String catalogName, String bibId, String holdingId) {
return getCatalogServiceByName(catalogName).getHolding(bibId, holdingId);
}

protected CatalogService getCatalogServiceByName(String catalogName) {
return catalogServiceFactory.getOrCreateCatalogService(catalogName);
}
Expand Down Expand Up @@ -360,11 +366,59 @@ public Map<String,ButtonPresentation> getButtonDataByBibId(String catalogName, S
}
}
});

return presentableHoldings;
}
return null;
}

public Map<String,String> getTextCallNumberButton(String catalogName, String bibId, String holdingId) {
Map<String,String> textCallNumberButtonContent = new HashMap<String,String>();
String locationCode = "";
String locationName = "";
String itemStatus = "";

CatalogHolding holding = this.getHolding(catalogName, bibId, holdingId);

Iterator<Map.Entry<String, Map<String,String>>> itemsIterator = holding.getCatalogItems().entrySet().iterator();
while(itemsIterator.hasNext()) {
Map.Entry<String,Map<String,String>> entry = itemsIterator.next();
Map<String,String> itemData = entry.getValue();
itemStatus = itemData.get("itemStatus");
if (catalogName.equals("evans") && holding.getFallbackLocationCode().isEmpty() && holding.getFallbackLocationCode().equals("stk") && (holding.getCallNumber().contains("THESIS") || holding.getCallNumber().contains("RECORD") || holding.getCallNumber().contains("DISSERTATION"))) {
locationCode = "tdr";
locationName = holding.getFallbackLocationCode();
break;
} else if (itemData.containsKey("tempLocationCode")) {
locationCode = itemData.get("tempLocationCode");
locationName = itemData.get("tempLocation");
break;
} else if (itemData.containsKey("permLocationCode")) {
locationCode = itemData.get("permLocationCode");
locationName = itemData.get("permLocation");
} else {
locationCode = holding.getFallbackLocationCode();
//we don't have access to a friendly location name at the holding level, so reuse location code
locationName = holding.getFallbackLocationCode();
}

}

textCallNumberButtonContent.put("title", holding.getTitle());
textCallNumberButtonContent.put("call", holding.getCallNumber());
textCallNumberButtonContent.put("loc", locationName);
if (holding.getCatalogItems().size() == 1) {
textCallNumberButtonContent.put("status", itemStatus);
}

logger.debug("*** Text A Call Number Button for holding: "+holdingId+" ***");
textCallNumberButtonContent.forEach((k,v) -> {
logger.debug(k+": "+v);
});
return textCallNumberButtonContent;
}


private Map<String,String> buildHoldingParameters(Map<String,String> parameters, CatalogHolding holding) {
// these template parameter keys are a special case, and come from the parent
// holding, rather than the item data itself
Expand Down
Loading