I have a Callable class that is defined to add a new node and a set of
properties etc - and I am running it on a singleThread using
Executors.newSingleThreadExecutor(). When I execute the task and get
the tasks result - it seems to return the Node - but all the properties
have been stripped....
Trace:
[2011-08-18 15:39:13,094] [pool-12-thread-1] [INFO ] STDOUT: New Node id
is:7
*[2011-08-18 15:39:13,095] [pool-12-thread-1] [INFO ] STDOUT: Property
Values: [buyer]
[2011-08-18 15:39:13,095] [WorkManager(2)-6] [INFO ] STDOUT: Received
values: []
*[2011-08-18 15:39:16,111] [pool-12-thread-1] [INFO ] STDOUT: New Node
id is:8
*[2011-08-18 15:39:16,113] [pool-12-thread-1] [INFO ] STDOUT: Property
Values: [D:/*..]
[2011-08-18 15:39:16,114] [WorkManager(2)-3] [INFO ] STDOUT: Received
values: []
Code below:
public Node addInternalNode(String keyName, String keyValue,
RelationshipType referenceType, Node referenceNode, HashMap<String,
Object> values, String tabletype){
if (keyName!=null && keyValue != null){
AddInternalNode callable = new AddInternalNode();
callable.set(keyName, keyValue, referenceType,
referenceNode, values, tabletype);
FutureTask<Object> task = new FutureTask<Object>(callable);
threadPool.execute(task);
try {
org.neo4j.graphdb.Node intNode =
(org.neo4j.graphdb.Node) task.get();
* System.out.println("Received values: " +
intNode.getPropertyValues());
* } catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
private final class AddInternalNode implements Callable<Object> {
private String keyName;
private String keyValue;
private RelationshipType referenceType;
private Node referenceNode;
private String tableName;
private HashMap<String, Object> values;
public void set(String keyName, String keyValue,
RelationshipType referenceType, Node referenceNode, HashMap<String,
Object> values, String tableName){
this.keyName=keyName;
this.keyValue=keyValue;
this.referenceType=referenceType;
this.referenceNode=referenceNode;
this.values = values;
this.tableName=tableName;
}
@Override
public Object call() throws Exception {
org.neo4j.graphdb.Node id=null;
id = index.forNodes(keyName).get(keyName,
keyValue).getSingle();
IndexHits<org.neo4j.graphdb.Node> hits =
index.forNodes(keyName).get(keyName,keyValue);
if (hits.hasNext())
id = hits.next();
if ( id == null )
{
Transaction tx = graphDb.beginTx();
try{
id = graphDb.createNode();
System.out.println("New Node id is:" + id.getId());
id.setProperty(keyName, keyValue);
index.forNodes(keyName).add(id, keyName, keyValue);
if (tableName!=null)
id.setProperty("Table", tableName);
//if the values exist then add them as properties
if (values!=null){
for(String key : values.keySet()){
id.setProperty(key, values.get(key));
}
}
} catch(Exception e){
e.printStackTrace();
} finally {
tx.success();
tx.finish();
}
} else System.out.println("Existing Node id is:" +
id.getId());
* System.out.println("Property Values: "+id.getPropertyValues());
* return id;
}
}
--
*Robert Haynes* e: [email protected] w: www.lexcient.com m: +61 413 350774
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user