@RequestMapping(value = "/{id}", method = RequestMethod.GET, params = "format=jit")
@ResponseBody
public JitNode getDetailsAsJit(@PathVariable Long id) {
Region region = regionService.findOne(id);
JitNode regionNode = new JitNode();
regionNode.setId(region.getId().toString());
regionNode.setName(region.getName());
Set<DataCenter> dataCenters = region.getDataCenters();
Set<JitNode> dataCenterNodes = new HashSet<JitNode>();
for (DataCenter dataCenter : dataCenters) {
JitNode dataCenterNode = new JitNode();
dataCenterNode.setId(dataCenter.getId().toString());
dataCenterNode.setName(dataCenter.getName());
dataCenterNodes.add(dataCenterNode);
Set<JitNode> farmNodes = new HashSet<JitNode>();
for (int i = 0; i < 8; i++) {
JitNode farmNode = new JitNode();
farmNode.setId(dataCenter.getId() + "_" + i);
farmNode.setName("Farm " + (i + 1));
farmNodes.add(farmNode);
}
dataCenterNode.setChildren(farmNodes);
}
regionNode.setChildren(dataCenterNodes);