Skip to content

Commit

Permalink
Merge pull request #12 from TAMULib/sprint5-staging
Browse files Browse the repository at this point in the history
Sprint5 staging
  • Loading branch information
kaladay committed Jan 15, 2021
2 parents af1a5ca + 645c8dd commit d1a869a
Show file tree
Hide file tree
Showing 25 changed files with 194 additions and 4,697 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
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>edu.tamu</groupId>
<artifactId>catalog-service</artifactId>
<artifactId>gifmbutton-service</artifactId>
<version>2.2.0</version>
<name>Catalog-Service</name>
<description>A service for interfacing with Library Catalogs</description>
<name>GIFM Button-Service</name>
<description>A service providing item retrieval links for catalog holdings</description>

<parent>
<groupId>edu.tamu.weaver</groupId>
Expand Down
79 changes: 39 additions & 40 deletions ...p/controller/CatalogAccessController.java → .../app/controller/GetItForMeController.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static edu.tamu.weaver.response.ApiStatus.ERROR;
import static edu.tamu.weaver.response.ApiStatus.SUCCESS;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -14,79 +13,79 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.JsonProcessingException;

import edu.tamu.app.model.ButtonPresentation;
import edu.tamu.app.service.GetItForMeService;
import edu.tamu.weaver.response.ApiResponse;

@RestController
@RequestMapping("/catalog-access")
public class CatalogAccessController {
public class GetItForMeController {
@Autowired
GetItForMeService getItForMeService;

/**
* Provides the raw CatalogHolding data
*
* @param catalogName
* @param bibId
* @return
* @throws JsonProcessingException
* @throws IOException
*/

@RequestMapping("/get-holdings")
public ApiResponse getHoldings(@RequestParam(value="catalogName",defaultValue="evans") String catalogName, @RequestParam("bibId") String bibId) throws JsonProcessingException, IOException {
return new ApiResponse(SUCCESS,getItForMeService.getHoldingsByBibId(catalogName,bibId));
}

/**
* Provides fully formatted HTML buttons, keyed by item MFHD
* @param catalogName
* @param bibId
* @param String catalogName (optional)
* @param String bibId
* @return
*/
@RequestMapping("/get-html-buttons")
public ApiResponse getHtmlButtonsByBibId(@RequestParam(value="catalogName",defaultValue="evans") String catalogName, @RequestParam("bibId") String bibId) {
Map<String, ButtonPresentation> presentableHoldings = getItForMeService.getButtonDataByBibId(catalogName, bibId);
if (presentableHoldings != null) {
Map<String,List<String>> buttonContents = new HashMap<String,List<String>>();
for (Map.Entry<String, ButtonPresentation> entry : presentableHoldings.entrySet()) {
if (entry.getValue() != null) {
buttonContents.put(entry.getKey(), entry.getValue().buildPresentation());
} else {
buttonContents.put(entry.getKey(), new ArrayList<String>());
}
}
return new ApiResponse(SUCCESS,buttonContents);
}
return new ApiResponse(ERROR,"Catalog or Holding not found");
Map<String, ButtonPresentation> presentableHoldings = getItForMeService.getButtonDataByBibId(catalogName, bibId);
if (presentableHoldings != null) {
Map<String,List<String>> buttonContents = new HashMap<String,List<String>>();
for (Map.Entry<String, ButtonPresentation> entry : presentableHoldings.entrySet()) {
if (entry.getValue() != null) {
buttonContents.put(entry.getKey(), entry.getValue().buildPresentation());
} else {
buttonContents.put(entry.getKey(), new ArrayList<String>());
}
}
return new ApiResponse(SUCCESS,buttonContents);
} else {
return new ApiResponse(ERROR,"Error processing Catalog or Holding");
}
}

/**
* Provides the raw button data in JSON format, keyed by MFHD.
* @param catalogName
* @param bibId
* @param String catalogName (optional)
* @param String bibId
* @return
*/

@RequestMapping("/get-buttons")
public ApiResponse getButtonsByBibId(@RequestParam(value="catalogName",defaultValue="evans") String catalogName, @RequestParam("bibId") String bibId) {
Map<String,ButtonPresentation> buttonData = getItForMeService.getButtonDataByBibId(catalogName, bibId);
if (buttonData != null) {
return new ApiResponse(SUCCESS,buttonData);
return new ApiResponse(SUCCESS,buttonData);
} else {
return new ApiResponse(ERROR,"Error processing Catalog or Holding");
}
return new ApiResponse(ERROR,"Catalog or Holding not found");
}

/**
* Provides the current buttons configuration in JSON format
* @return
*/
@RequestMapping("/get-button-config")
public ApiResponse getButtonConfiguration() {
return new ApiResponse(SUCCESS,"Current Button Configuration",getItForMeService.getRegisteredButtons());
}

/**
* Provides the text a call number button data in JSON format
* @param String catalogName (optional)
* @param String bibId
* @param String holdingId
* @return
*/
@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));
Map<String,String> buttonData = getItForMeService.getTextCallNumberButton(catalogName, bibId, holdingId);
if (buttonData != null) {
return new ApiResponse(SUCCESS, getItForMeService.getTextCallNumberButton(catalogName, bibId, holdingId));
} else {
return new ApiResponse(ERROR,"Error processing Catalog or Holding");
}
}
}

0 comments on commit d1a869a

Please sign in to comment.