Package org.springframework.data.neo4j.model

Examples of org.springframework.data.neo4j.model.Person


                addSerialFriend(serialTesters.nicki.getId(), serialTesters.michael);

                // 1A. Make sure that before we deal with any serialization, we are still operating
                //    with the expected ManagedFieldAccessorSet class
                final Person person = personRepository.findOne(serialTesters.nicki.getId());
                assertEquals(ManagedFieldAccessorSet.class, person.getSerialFriends().getClass());
                assertEquals(1, person.getSerialFriends().size());

                // 1B. Make sure that before we deal with any serialization, we are still operating
                //    with the expected ManagedPrefixedDynamicProperties class
                assertEquals(ManagedPrefixedDynamicProperties.class, person.getPersonalProperties().getClass());
                assertEquals(2, person.getPersonalProperties().asMap().size());
                assertThat(asCollection(person.getPersonalProperties().getPropertyKeys()), hasItems("addressLine1", "addressLine2"));

                // 2. Do Serialization and return serialized object
                byte[] bos = serializeIt(person);
                return deserializeIt(bos);
            }
View Full Code Here


    private void addSerialFriend(final Long sourcePersonId, final Person target) {
        neo4jTemplate.exec(new GraphCallback.WithoutResult(){
            @Override
            public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
                final Person person1 = personRepository.findOne(sourcePersonId);
                person1.addSerialFriend(target);
                personRepository.save(person1);
            }
        });
    }
View Full Code Here

    RepositoryClient client = container.getInstance(RepositoryClient.class);
    CdiPersonRepository repository = client.repository;

    assertThat(repository, is(notNullValue()));

    Person person = null;
    Person result = null;

    try (Transaction tx = database.beginTx()) {
      repository.deleteAll();

      person = new Person("Simon", 28);
      result = repository.save(person);
      tx.success();
    }

        try (Transaction tx = database.beginTx()) {
            assertThat(result, is(notNullValue()));
            Long resultId = result.getId();
            Person lookedUpPerson = repository.findOne(person.getId());
            assertThat(lookedUpPerson.getId(), is(resultId));
            tx.success();
        }
  }
View Full Code Here

            if (i % 1000 == 0) {
                long now = System.currentTimeMillis();
                System.out.println(i+". entries " + (now-time));
                time=now;
            }
            Person person = new Person("John " + i, 40 + i);
            person.setLocation((i % 180) - 90,(i % 180) - 90);
            personRepository.save(person);
        }
    }
View Full Code Here

    RepositoryClient client = container.getInstance(RepositoryClient.class);
    CdiPersonRepository2 repository = client.repository2;

    assertThat(repository, is(notNullValue()));

    Person person = null;
    Person result = null;

    try (Transaction tx = database.beginTx()) {
      repository.deleteAll();

      person = new Person("Simon", 28);
      result = repository.save(person);
      tx.success();
    }

        try (Transaction tx = database.beginTx()) {
            assertThat(result, is(notNullValue()));
            Long resultId = result.getId();
            Person lookedUpPerson = repository.findOne(person.getId());
            assertThat(lookedUpPerson.getId(), is(resultId));
            tx.success();
        }
  }
View Full Code Here

    RepositoryClient client = container.getInstance(RepositoryClient.class);
    CdiPersonRepository3 repository = client.repository3;

    assertThat(repository, is(notNullValue()));

    Person person = null;
    Person result = null;

    try (Transaction tx = database.beginTx()) {
      repository.deleteAll();

      person = new Person("Simon", 28);
      result = repository.save(person);
      tx.success();
    }

        try (Transaction tx = database.beginTx()) {
            assertThat(result, is(notNullValue()));
            Long resultId = result.getId();
            Person lookedUpPerson = repository.findOne(person.getId());
            assertThat(lookedUpPerson.getId(), is(resultId));
            tx.success();
        }

  }
View Full Code Here

        MappingInfrastructureFactoryBean factoryBean = new MappingInfrastructureFactoryBean(db, null);
        factoryBean.setTypeRepresentationStrategy(TypeRepresentationStrategyFactory.Strategy.SubRef);
        factoryBean.afterPropertiesSet();
        Neo4jTemplate template = new Neo4jTemplate(factoryBean.getObject());
        Transaction tx = db.beginTx();
        Person person = template.save(new Person());
        person.setName("Bar");
        template.save(person);
        tx.failure();
        tx.close();
    }
View Full Code Here

    @Transactional
    @Test(expected = InvalidEntityTypeException.class// DATAGRAPH-298
    public void testInvalidEntityLoadAttemptThroughAbstractRepoThrowsAppropriateException() {

        Person person = personRepository.save(new Person("someone",30));

        // We are trying to load a Person Node Entity, using a completely different
        // and abstract defined Node entity - this should fail
        AbstractNodeEntity shouldNotWork = abstractNodeEntityRepository.findOne(person.getId());

    }
View Full Code Here

    public MatrixTeam() {
    }

    public MatrixTeam createMatrixTeam(GraphRepository<Person> repo, GraphRepository<Group> groupRepo, GraphRepository<Friendship> friendshipRepository) {
        cypher = new Person("Cypher", 30);
        neo = new Person("Neo", 36);
        neo.setPersonality(Personality.EXTROVERT);
        neo.setLocation(16, 56);

        trinity = new Person("Trinity", 25);
        trinity.setBoss(cypher);
        trinity.setLocation( 16.5, 56.5 );
        matrixGroup = new Group();
        matrixGroup.setName("Matrix");
        matrixGroup.addPerson(neo);
View Full Code Here

    @Test
    public void testCreateEntityFromStoredType() throws Exception {
        final Node personNode = template.createNode();
        personNode.setProperty("name","Michael");
        final Person person = entityPersister.createEntityFromState(personNode, Person.class, template.getMappingPolicy(Person.class), template);
        assertEquals("Michael",person.getName());
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.model.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.