Example #1
0
 public string Get()
 {
     if (Neo4JContext.RunQuery("MATCH (a { name: 'TEST' }) RETURN a").ToString() == "Neo4j.Driver.Internal.Result.StatementResult")
     {
         return("TEST_OK");
     }
     return("TEST_ERR");
 }
Example #2
0
        public IFlight GetById(ulong Id)
        {
            Flight flight = new Flight();
            var    v      = Neo4JContext.RunQuery("Match (fa:airport)-[]->(fad:airportDay)-[]->(fl:flight)-[]->(tad:airportDay)<-[]-(ta:airport) " +
                                                  "where id(fl)=" + Id + " return fa, fad, fl, id(fl) as id, tad, ta");

            foreach (var record in v)
            {
                flight = FillFlightData(record);
            }

            return(flight);
        }
Example #3
0
        public IEnumerable <IFlight> GetAll()
        {
            var flightList = new List <Flight>();

            var v = Neo4JContext.RunQuery("Match (fa:airport)-[]->(fad:airportDay)-[]->(fl:flight)-[]->(tad:airportDay)<-[]-(ta:airport) " +
                                          "return fa, fad, fl, id(fl) as id, tad, ta");

            foreach (var record in v)
            {
                flightList.Add(FillFlightData(record));
            }

            return(flightList);
        }
Example #4
0
        public List <Country> GetAll()
        {
            var countryList = new List <Country>();

            var queryResult = Neo4JContext.RunQuery("MATCH (o) WHERE o:country RETURN o;");

            foreach (var record in queryResult)
            {
                INode country = record["o"].As <INode>();

                countryList.Add(GetCountryFromResult(country));
            }

            return(countryList);
        }
Example #5
0
        public List <Airport> GetAll()
        {
            var airportList = new List <Airport>();

            var queryResult = Neo4JContext.RunQuery("MATCH (o) WHERE o:airport RETURN o;");

            foreach (var record in queryResult)
            {
                INode airport = record["o"].As <INode>();

                airportList.Add(GetAirportFromResult(airport));
            }

            return(airportList);
        }
Example #6
0
        public DataFactoryDelegation(ISerializer serializer, ILogger logger, IImageConverter imageConverter)
        {
            _serializer     = serializer;
            _logger         = logger;
            _imageConverter = imageConverter;

            if (Neo4JContext.RunTestQuery())
            {
                _dataFactory = new Neo4JDataFactory(_serializer, _logger, _imageConverter);
            }
            else
            {
                _dataFactory = new FileSystemDataFactory(_serializer, _logger, _imageConverter);
            }
        }
Example #7
0
        public List <IFlight> GetDirectFlightsByTripParams(ITripParams tripParams)
        {
            var flightList = new List <IFlight>();

            var v = Neo4JContext.RunQuery("Match (fa:airport)-[]->(fad:airportDay)-[]->(fl:flight)-[]->(tad:airportDay)<-[]-(ta:airport) " +
                                          "where fa.name = '" + tripParams.origin + "' and ta.name = '" + tripParams.destination + "' " +
                                          "and fad.name = '" + tripParams.origin + ":" + tripParams.depDate + "' " +
                                          "return fa, fad, fl, id(fl) as id, tad, ta;");

            foreach (var record in v)
            {
                flightList.Add(FillFlightData(record));
            }

            return(flightList);
        }
Example #8
0
        public List <IRoute> GetRouteWith1Stop(ITripParams tripParams)
        {
            var routes = new List <IRoute>();

            var v = Neo4JContext.RunQuery("MATCH (depAirport:airport{name: '" + tripParams.origin + "'})-[d1:hasDay]->" +
                                          "(depDay:airportDay{name: '" + tripParams.origin + ":" + tripParams.depDate + "'})-[r1]->(flight1:flight)" +
                                          "-[r2]->(tranDay1:airportDay)-[r3]->(flight2:flight)-[r4]->(arrDay:airportDay)<-[d3:hasDay]-(arrAirport:airport{name: '" + tripParams.destination + "'}), " +
                                          "(tranDay1)-[d2:hasDay]-(tranAirport:airport) " +
                                          "WITH depAirport, depDay, tranAirport, arrAirport, arrDay, flight1, flight2, tranDay1, " +
                                          "r1, r2, r3, r4, d1, d2, d3, duration.inseconds(flight1.arrives, flight2.departs).minutes AS conTime, flight1.price + flight2.price AS totPrice " +
                                          "WHERE flight1.arrives < flight2.departs AND conTime >= 50 AND conTime <= 720 " +
                                          "RETURN depAirport, depDay, tranAirport, arrAirport, arrDay, flight1, flight2, tranDay1, id(flight1) as id1, id(flight2) as id2, r1, r2, r3, r4, d1, d2, d3, conTime, totPrice " +
                                          "ORDER BY totPrice;");

            foreach (var record in v)
            {
                routes.Add(FillRouteData(record));
            }
            return(routes);
        }