Package org.neo4j.graphdb

Examples of org.neo4j.graphdb.Transaction


    }

    @Before
    public void setUp() throws Throwable {
        serverGraphDatabase.cleanContent();
        final Transaction tx = serverGraphDatabase.beginTx();
        remoteNode = serverGraphDatabase.createNode();
        remoteNode.setProperty(NAME, VALUE);
        tx.success();tx.close();

        consoleService = new ConsoleService();
        service = new Neo4jService();
    }
View Full Code Here


    }

    private CypherResult doExecuteQuery(String query, Map<String, Object> params, boolean canProfile) {
        params = params == null ? Collections.<String,Object>emptyMap() : params;
        long time=System.currentTimeMillis();
        Transaction tx = gdb.beginTx();
        javax.transaction.Transaction resumeTx;
        try {
            resumeTx = suspendTx(query);
            ExecutionResult result = canProfile ? executionEngine.profile(query,params) : executionEngine.execute(query,params);
            final Collection<Map<String, Object>> data = IteratorUtil.asCollection(result);
            time = System.currentTimeMillis() - time;
            resumeTransaction(resumeTx);
            CypherResult cypherResult = new CypherResult(result.columns(), data, result.getQueryStatistics(), time, canProfile ? result.executionPlanDescription() : null, prettify(query));
            tx.success();
            return cypherResult;
        } finally {
            tx.close();
            awaitIndexOnline(query);
        }
    }
View Full Code Here

    private final Set<String> autoIndexedProperties = new HashSet<>();
    private final AutoIndexer<Node> nodeAutoIndexer;
    private final RelationshipAutoIndexer relationshipAutoIndexer;

    public Index(GraphDatabaseService gdb) {
        Transaction tx = gdb.beginTx();
        // force initialize the indexes
        gdb.index().forNodes("node_auto_index");
        gdb.index().forNodes("relationship_auto_index");
        nodeAutoIndexer = gdb.index().getNodeAutoIndexer();
        relationshipAutoIndexer = gdb.index().getRelationshipAutoIndexer();
        enableAutoIndex(nodeAutoIndexer);
        enableAutoIndex(relationshipAutoIndexer);
        autoIndexedProperties.addAll(nodeAutoIndexer.getAutoIndexedProperties());
        autoIndexedProperties.addAll(relationshipAutoIndexer.getAutoIndexedProperties());
        tx.success();tx.close();
    }
View Full Code Here

        return (String) this.node.getProperty(AssetDB.NAME);
    }

    @Override
    public void setName(String name) {
        Transaction tx = db.beginTx();
        try {
            node.setProperty(AssetDB.NAME,name);
            tx.success();
        } finally {
            tx.finish();
        }
    }
View Full Code Here

    public List<FlatColor> getColors() {
        return swatches;
    }

    public void save() {
        Transaction tx = this.db.beginTx();
        try {
            StringBuffer sb = new StringBuffer();
            for(FlatColor color : swatches) {
                sb.append(Integer.toHexString(color.getRGBA()));
                sb.append(",");
            }
            this.node.setProperty("colors",sb.toString());
            tx.success();
        } finally {
            tx.finish();
        }
    }
View Full Code Here

        if(!node.hasProperty("editable")) return false;
        return ((Boolean)node.getProperty("editable")).booleanValue();
    }

    public void setEditable(boolean editable) {
        Transaction tx = db.beginTx();
        try {
            node.setProperty("editable",Boolean.valueOf(editable));
            tx.success();
        } finally {
            tx.finish();
        }
    }
View Full Code Here

   * to avoid the creation of multiple nodes representing the same sequence.
   *
   * @param neo4jDb the db where the schema will be updated
   */
  public void createUniqueConstraint(Set<String> generatorsKey) {
    Transaction tx = null;
    try {
      tx = neo4jDb.beginTx();
      for ( String generatorKey : generatorsKey ) {
        Label label = DynamicLabel.label( generatorKey );
        if ( isMissingUniqueConstraint( neo4jDb, label, SEQUENCE_NAME_PROPERTY ) ) {
          neo4jDb.schema().constraintFor( label ).assertPropertyIsUnique( SEQUENCE_NAME_PROPERTY ).create();
        }
      }
      tx.success();
    }
    finally {
      tx.close();
    }
  }
View Full Code Here

    // This should never happen
    throw log.cannotGenerateSequence( sequenceName( rowKey ) );
  }

  private int sequence(RowKey rowKey, int increment, final int initialValue) {
    Transaction tx = neo4jDb.beginTx();
    Lock lock = null;
    try {
      Node sequence = getOrCreateSequence( rowKey, initialValue );
      lock = tx.acquireWriteLock( sequence );
      int nextValue = updateSequenceValue( sequenceName( rowKey ), sequence, increment );
      tx.success();
      lock.release();
      return nextValue;
    }
    finally {
      tx.close();
    }
  }
View Full Code Here

    addUniqueConstraints( identifierGenerators );
    addSequences( identifierGenerators );
  }

  private void addUniqueConstraints(Set<IdentifierGenerator> identifierGenerators) {
    Transaction tx = null;
    try {
      tx = neo4jDb.beginTx();
      for ( IdentifierGenerator identifierGenerator : identifierGenerators ) {
        addUniqueConstraint( identifierGenerator );
      }
      tx.success();
    }
    finally {
      tx.close();
    }
  }
View Full Code Here

    }
    return true;
  }

  private void addSequences(Set<IdentifierGenerator> identifierGenerators) {
    Transaction tx = null;
    try {
      tx = neo4jDb.beginTx();
      for ( IdentifierGenerator generator : identifierGenerators ) {
        addSequence( generator );
      }
      tx.success();
    }
    finally {
      tx.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.Transaction

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.