@Override @WebMethod public ResponseDTO findAll(@WebParam NodeType nodeType, @WebParam SortOrder sortOrder) { Validator.checkRequiredArgument(nodeType); List<Domain> domainList = null; try (Transaction tx = graphDatabaseService.beginTx()) { ResourceIterator<Node> resourceIterator = indexRepository.getNodes(nodeType); if (resourceIterator != null && resourceIterator.hasNext()) { domainList = Lists.newArrayList(); while (resourceIterator.hasNext()) { domainList.add(domainFactory.create(resourceIterator.next(), nodeType)); } } tx.success(); tx.close(); } return new ResponseDTO(new Assembler().toDtos(domainList, nodeType)); }
@Override @WebMethod public ResponseDTO findCauseOfDepartureDelaysAtEachAirport() { Map<String, Map<String, Integer>> airportDelayCauseMap = Maps.newHashMap(); try (Transaction tx = graphDatabaseService.beginTx()) { ResourceIterator<Node> resourceIterator = indexRepository.getNodes(NodeType.AIRPORT); if (resourceIterator != null) { while (resourceIterator.hasNext()) { Node node = resourceIterator.next(); airportDelayCauseMap.put( node.getProperty(NodeType.AIRPORT.getIdType()).toString(), airportTraversal.findCauseOfDepartureDelaysAtEachAirport(node)); } } tx.success(); tx.close(); } return new ResponseDTO(new Assembler().toCauseDtos(airportDelayCauseMap)); }
@Override @WebMethod public ResponseDTO findDelayedFlights(Integer delayTime) { Map<String, List<DelayDTO>> delayDtoMap = Maps.newHashMap(); try (Transaction tx = graphDatabaseService.beginTx()) { ResourceIterator<Node> resourceIterator = indexRepository.getNodes(NodeType.AIRPORT); if (resourceIterator != null) { while (resourceIterator.hasNext()) { Node node = resourceIterator.next(); delayDtoMap.put( node.getProperty(NodeType.AIRPORT.getIdType()).toString(), airportTraversal.findDelayedFlights(node, delayTime)); } } tx.success(); tx.close(); } return new ResponseDTO(new Assembler().toDelayDtos(delayDtoMap)); }