@Override public void store(Destination domainObject) { try (Transaction tx = graphDatabaseService.beginTx()) { Node airport = indexRepository.get(domainObject.getAirport(), NodeType.AIRPORT); Node flight = indexRepository.get(domainObject.getFlightNumber(), NodeType.FLIGHT); if (airport == null || flight == null) { logger.warn( "Relationship cannot be established between " + NodeType.FLIGHT.getClassName() + " : " + domainObject.getFlightNumber() + " and " + NodeType.AIRPORT.getClassName() + " : " + domainObject.getAirport()); return; } createSingleRelationship( flight, airport, NodeType.FLIGHT, NodeType.AIRPORT, NodeRelationshipType.DESTINATION, getPropertyMap(domainObject)); tx.success(); logger.info( "Relation created of type : " + NodeRelationshipType.DESTINATION.name() + " from flight : " + domainObject.getFlightNumber() + " to airport : " + domainObject.getAirport()); } }
@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)); }