Examples of Neo4jTemplate


Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    FileUtils.deleteRecursively(new File(DB_PATH));
    return new EmbeddedGraphDatabase(DB_PATH);
  }

  @Bean public Neo4jTemplate neo4jTemplate() throws IOException {
    return new Neo4jTemplate(graphDatabaseService());
  }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    @Before
    public void setUp() throws Exception {
        // todo cleanup !!
        mappingContext = new Neo4jMappingContext();
        Infrastructure infrastructure = createInfrastructure(mappingContext);
        template = new Neo4jTemplate(infrastructure);
        conversionService = template.getConversionService();


        tx = template.getGraphDatabase().beginTx();
        group = new Group();
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    private Config assertInjected(String testCase) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:org/springframework/data/neo4j/config/DataGraphNamespaceHandlerTests" + testCase + "-context.xml");
        try {
        Config config = ctx.getBean("config", Config.class);
        Neo4jTemplate template = config.neo4jTemplate;
        Assert.assertNotNull("template", template);
        GraphDatabaseAPI graphDatabaseService = (GraphDatabaseAPI) template.getGraphDatabaseService();
        String fileSeparator = "target" + System.getProperty("file.separator") + "config-test";
        Assert.assertTrue("store-dir", graphDatabaseService.getStoreDir().endsWith(fileSeparator));
        Assert.assertNotNull("graphDatabaseService",config.graphDatabaseService);
        Assert.assertNotNull("transactionManager",config.transactionManager);
//        config.graphDatabaseService.shutdown();
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

public class ReadWriteTests {
    public static void main(String[] args) throws IOException {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:ReadWriteTests-context.xml");
        boolean delete = false;
        try {
            Neo4jTemplate template = ctx.getBean(Neo4jTemplate.class);
            Car car = findOne(template);
            if (car != null) {
                delete = true;
                assertEquals(Volvo.class, car.getClass());
            } else {
                Transaction tx = template.getGraphDatabase().beginTx();
                Volvo volvo = template.save(new Volvo());
                assertEquals(1, volvo.id.intValue());
                tx.success();
                tx.close();
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    final static String CLASS_NAME = Person.class.getSimpleName();

    @Before
    public void setUp() {
        Neo4jMappingContext context = new Neo4jMappingContext();
        Neo4jTemplate template = Mockito.mock(Neo4jTemplate.class);
        finishMock(template);
        this.query = new CypherQueryBuilder(context, Person.class, template);
        this.trsSpecificExpectedQuery = null;
    }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

   */
  @Override
  protected T create(CreationalContext<T> creationalContext, Class<T> repositoryType, Object customImplementation) {

    Neo4jMappingContext neo4jMapCtx = new Neo4jMappingContext();
    Neo4jTemplate neo4jTemplate = new Neo4jTemplate(getDependencyInstance(graphDatabase, GraphDatabase.class));

    GraphRepositoryFactory factory = new GraphRepositoryFactory(neo4jTemplate, neo4jMapCtx);
    return factory.getRepository(repositoryType, customImplementation);
  }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
        ReferenceNodes.obtainReferenceNode(db,"root");
        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

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    public void setUp() throws Exception
    {
        graphDatabaseService = createGraphDatabaseService();
        graphDatabase = createGraphDatabase();
        transactionManager = createTransactionManager();
        template = new Neo4jTemplate(graphDatabase, transactionManager);
        createData();
        transaction = graphDatabase.beginTx();
    }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

    public void setUp() throws Exception
    {
        graphDatabaseService = createGraphDatabaseService();
        graphDatabase = createGraphDatabase();
        transactionManager = createTransactionManager();
        template = new Neo4jTemplate(graphDatabase, transactionManager);
        createData();
    }
View Full Code Here

Examples of org.springframework.data.neo4j.support.Neo4jTemplate

        return new DelegatingGraphDatabase(graphDatabaseService);
    }

    @Test
    public void testBeginTxWithoutConfiguredTxManager() throws Exception {
        Neo4jTemplate template = new Neo4jTemplate(graphDatabase);
        Transaction tx = template.getGraphDatabase().beginTx();
        Node node = template.createNode();
        node.setProperty("name","foo");
        tx.success();
        tx.close();

        tx = template.getGraphDatabase().beginTx();
        try {
            assertNotNull(node.getProperty("name"));
        } finally {
            tx.success();tx.close();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.