Search in sources :

Example 1 with Flight

use of org.neo4j.ogm.domain.gh851.Flight in project neo4j-ogm by neo4j.

the class QueryCapabilityTest method createFlights.

private void createFlights() {
    // Create a few airports
    Airport lhr = new Airport("LHR", "London Heathrow");
    Airport lax = new Airport("LAX", "Los Angeles");
    Airport cdg = new Airport("CDG", "Paris Charles de Gaulle");
    // Create some flights
    session.save(new Flight("FL 001", lhr, lax));
    session.save(new Flight("FL 002", lhr, cdg));
    session.save(new Flight("FL 003", lax, lhr));
}
Also used : Flight(org.neo4j.ogm.domain.gh851.Flight) Airport(org.neo4j.ogm.domain.gh851.Airport)

Example 2 with Flight

use of org.neo4j.ogm.domain.gh851.Flight in project neo4j-ogm by neo4j.

the class QueryCapabilityTest method nestedFiltersOnSameEntitiesButDifferentRelationsShouldWork.

// GH-851
@Test
public void nestedFiltersOnSameEntitiesButDifferentRelationsShouldWork() {
    Filters filters = new Filters();
    Filter filter = new Filter("code", ComparisonOperator.EQUALS, "LHR");
    filter.setOwnerEntityType(Flight.class);
    filter.setNestedPropertyType(Airport.class);
    filter.setNestedPropertyName("departure");
    filter.setRelationshipType("DEPARTS");
    filter.setRelationshipDirection(Relationship.OUTGOING);
    filters.and(filter);
    filter = new Filter("code", ComparisonOperator.EQUALS, "LAX");
    filter.setOwnerEntityType(Flight.class);
    filter.setNestedPropertyType(Airport.class);
    filter.setNestedPropertyName("arrival");
    filter.setRelationshipType("ARRIVES");
    filter.setRelationshipDirection(Relationship.OUTGOING);
    filters.and(filter);
    Collection<Flight> flights = session.loadAll(Flight.class, filters);
    assertThat(flights).hasSize(1).first().extracting(Flight::getName).isEqualTo("FL 001");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Flight(org.neo4j.ogm.domain.gh851.Flight) Test(org.junit.Test)

Example 3 with Flight

use of org.neo4j.ogm.domain.gh851.Flight in project neo4j-ogm by neo4j.

the class QueryCapabilityTest method deepNestedFiltersOnSameEntitiesButDifferentRelationsShouldWork.

// GH-851
@Test
public void deepNestedFiltersOnSameEntitiesButDifferentRelationsShouldWork() {
    Filters filters = new Filters();
    Filter filter = new Filter("code", ComparisonOperator.EQUALS, "LHR");
    filter.setOwnerEntityType(Flight.class);
    filter.setNestedPath(new Filter.NestedPathSegment("departure", Airport.class));
    filters.and(filter);
    filter = new Filter("code", ComparisonOperator.EQUALS, "LAX");
    filter.setOwnerEntityType(Flight.class);
    filter.setNestedPath(new Filter.NestedPathSegment("arrival", Airport.class));
    filters.and(filter);
    Collection<Flight> flights = session.loadAll(Flight.class, filters);
    assertThat(flights).hasSize(1).first().extracting(Flight::getName).isEqualTo("FL 001");
}
Also used : Filters(org.neo4j.ogm.cypher.Filters) Filter(org.neo4j.ogm.cypher.Filter) Flight(org.neo4j.ogm.domain.gh851.Flight) Airport(org.neo4j.ogm.domain.gh851.Airport) Test(org.junit.Test)

Aggregations

Flight (org.neo4j.ogm.domain.gh851.Flight)3 Test (org.junit.Test)2 Filter (org.neo4j.ogm.cypher.Filter)2 Filters (org.neo4j.ogm.cypher.Filters)2 Airport (org.neo4j.ogm.domain.gh851.Airport)2