Search in sources :

Example 6 with Location

use of org.neo4j.ogm.domain.restaurant.Location in project neo4j-ogm by neo4j.

the class RestaurantIntegrationTest method shouldSaveBranchWitlCompositeLocationConverter.

@Test
public void shouldSaveBranchWitlCompositeLocationConverter() throws Exception {
    Franchise franchise = new Franchise();
    Restaurant restaurant = new Restaurant();
    Branch branch = new Branch(new Location(37.61649, -122.38681), franchise, restaurant);
    session.save(branch);
    session.clear();
    Branch loaded = session.load(Branch.class, branch.getId());
    assertThat(loaded.getLocation().getLatitude()).isCloseTo(37.61649, within(0.00001));
    assertThat(loaded.getLocation().getLongitude()).isCloseTo(-122.38681, within(0.00001));
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Branch(org.neo4j.ogm.domain.restaurant.Branch) Franchise(org.neo4j.ogm.domain.restaurant.Franchise) Location(org.neo4j.ogm.domain.restaurant.Location) Test(org.junit.Test)

Example 7 with Location

use of org.neo4j.ogm.domain.restaurant.Location in project neo4j-ogm by neo4j.

the class CompilerTest method createSingleStatementForLabelsInDifferentOrder.

@Test
public void createSingleStatementForLabelsInDifferentOrder() throws Exception {
    Franchise franchise = new Franchise();
    Restaurant r1 = new Restaurant();
    r1.setName("La Strada Tooting");
    r1.labels = Arrays.asList("Delicious", "Foreign");
    Restaurant r2 = new Restaurant();
    r2.setName("La Strada Brno");
    r2.labels = Arrays.asList("Foreign", "Delicious");
    franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r1));
    franchise.addBranch(new Branch(new Location(0.0, 0.0), franchise, r2));
    Compiler compiler = mapAndCompile(franchise, -1);
    assertThat(compiler.createNodesStatements()).extracting(Statement::getStatement).containsOnly("UNWIND $rows as row CREATE (n:`Franchise`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, $type as type", // the point is only one query for this combination of labels
    "UNWIND $rows as row CREATE (n:`Delicious`:`Foreign`:`Restaurant`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, $type as type");
}
Also used : Restaurant(org.neo4j.ogm.domain.restaurant.Restaurant) Branch(org.neo4j.ogm.domain.restaurant.Branch) Franchise(org.neo4j.ogm.domain.restaurant.Franchise) Location(org.neo4j.ogm.domain.restaurant.Location) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Location (org.neo4j.ogm.domain.restaurant.Location)7 Restaurant (org.neo4j.ogm.domain.restaurant.Restaurant)7 Branch (org.neo4j.ogm.domain.restaurant.Branch)3 Franchise (org.neo4j.ogm.domain.restaurant.Franchise)3 Filter (org.neo4j.ogm.cypher.Filter)2 HashMap (java.util.HashMap)1 DistanceComparison (org.neo4j.ogm.cypher.function.DistanceComparison)1 DistanceFromPoint (org.neo4j.ogm.cypher.function.DistanceFromPoint)1