001package systems.dmx.storage.neo4j;
002
003import systems.dmx.core.storage.spi.DMXTransaction;
004
005import org.neo4j.graphdb.GraphDatabaseService;
006import org.neo4j.graphdb.Transaction;
007
008
009
010/**
011 * Adapts a Neo4j transaction to a DMX transaction.
012 */
013class Neo4jTransactionAdapter implements DMXTransaction {
014
015    // ---------------------------------------------------------------------------------------------- Instance Variables
016
017    private Transaction tx;
018
019    // ---------------------------------------------------------------------------------------------------- Constructors
020
021    Neo4jTransactionAdapter(GraphDatabaseService neo4j) {
022        tx = neo4j.beginTx();
023    }
024
025    // -------------------------------------------------------------------------------------------------- Public Methods
026
027    @Override
028    public void success() {
029        tx.success();
030    }
031
032    @Override
033    public void failure() {
034        tx.failure();
035    }
036
037    @Override
038    public void finish() {
039        tx.finish();
040    }
041}