in app/java/src/main/java/com/google/cloudclientapi/CensusController.java [38:70]
public String index(
@RequestParam(name = "fur", required = false, defaultValue = "Gray") String fur,
@RequestParam(name = "age", required = false, defaultValue = "Adult") String age,
@RequestParam(name = "location", required = false, defaultValue = "Above Ground")
String location,
Model model) {
logger.info("Request received for fur: {}, age: {}, location: {}", fur, age, location);
if (EnvironmentVars.get("PROCESSED_DATA_BUCKET") == null
|| EnvironmentVars.get("PROCESSED_DATA_BUCKET").isEmpty()) {
throw new UnspecifiedProcessedDataBucketException();
}
// Default values (which would be rendered as "No data available.").
model.addAttribute("squirrel_count", 0);
model.addAttribute("data_points", Arrays.asList(0, 0, 0, 0, 0));
SquirrelSegment squirrelSegment = retrieveData(fur, age, location);
if (squirrelSegment == null) {
return "index";
}
model.addAttribute("squirrel_count", squirrelSegment._counter);
List<Integer> dataPoints =
Arrays.asList(
squirrelSegment.Chasing,
squirrelSegment.Climbing,
squirrelSegment.Eating,
squirrelSegment.Foraging,
squirrelSegment.Running);
model.addAttribute("data_points", dataPoints);
return "index";
}