use of org.neo4j.android.common.ParcelableNode in project neo4j-mobile-android by neo4j-contrib.
the class NodePropertiesActivity method createProperty.
private void createProperty(String key, String value) {
try {
GraphDatabase database = dbManager.getCurrentNeo4jDatabase();
database.beginTx();
try {
ParcelableNode node = database.getNodeById(nodeId);
if (!node.hasProperty(key)) {
node.setProperty(key, value);
database.updateNode(node);
database.txSuccess();
} else {
showPropertyAlreadyExistsError(key, value);
}
} finally {
database.txFinish();
}
} catch (Exception e) {
Ln.e(e, "failed to create new property with key '" + key + "' and value '" + value + "' on node with id '" + nodeId + "'.");
showErrorDialog();
}
updateNodePropertiesList();
}
use of org.neo4j.android.common.ParcelableNode in project neo4j-mobile-android by neo4j-contrib.
the class GraphDatabase method getNodeById.
public ParcelableNode getNodeById(long id) throws RemoteException, Neo4jServiceException {
ParcelableError err = new ParcelableError();
ParcelableNode result = mProxy.getNodeById(id, err);
Util.throwServiceExceptionIfError(err);
return result;
}
use of org.neo4j.android.common.ParcelableNode in project neo4j-mobile-android by neo4j-contrib.
the class DbWrapper method updateNode.
@Override
public void updateNode(ParcelableNode node, ParcelableError err) throws RemoteException {
try {
checkCallerHasWritePermission();
resumeTrx();
try {
Node target = mDb.getNodeById(node.getId());
if (target != null) {
// remove existing properties
for (String key : target.getPropertyKeys()) {
target.removeProperty(key);
}
// set new properties
for (String key : node.getPropertyKeys()) {
target.setProperty(key, node.getProperty(key));
}
} else {
String message = "node not found. node '" + node + "'";
Log.e(TAG, message);
err.setError(Errors.TRANSACTION, message);
}
} finally {
suspendCurrentTrx("updateNode");
}
} catch (Exception e) {
Log.e(TAG, "Failed to update node", e);
err.setError(Errors.TRANSACTION, e.getMessage());
}
}
Aggregations