My new code snippet is the following:
Map<String, Object> nodeProps = db.getNodeProperties(subjectNode);
if (nodeProps.get(predicateName) != null) {
try { // Property values might be an array
Object[] values = (Object[]) nodeProps.get(predicateName);
ArrayList<Object> valuesList = new ArrayList<>(Arrays.asList(values));
valuesList.add(value);
nodeProps.put(predicateName, valuesList.toArray(new
Object[valuesList.size()]));
} catch (ClassCastException cce) { // or just a value
Object v = nodeProps.get(predicateName);
Object[] valuesList = new Object[]{v, value};
nodeProps.put(predicateName, valuesList.toString());
}
} else {
nodeProps.put(predicateName, value);
}
db.setNodeProperties(subjectNode, nodeProps);
But in the graph I get: synonym [Ljava.lang.Object;@788ab663
I get an exception if I use:
nodeProps.put(predicateName, valuesList.toString());
Which is the right way to put the Object array in nodeProprs.put?
Τη Κυριακή, 8 Φεβρουαρίου 2015 - 10:28:10 μ.μ. UTC+2, ο χρήστης Aris
Fergadis έγραψε:
>
> I am using neo4j community 2.1.6 edition and I have already posted a
> question
> <http://stackoverflow.com/questions/28397457/neo4j-batchinserter-using-setnodeproperties-to-set-an-array-with-values>
>
> in stackoverflow.
>
> My task is to import an ontology to Neo. So I read triples and insert
> nodes, properties and relations. Many of my triples define multiple values
> for the same property of a node. I want to set those values as an array in
> the property. Unfortunately, the method
>
> *setNodeProperties
> <http://neo4j.com/api_docs/2.0.0/org/neo4j/unsafe/batchinsert/BatchInserter.html#setNodeProperties%28long,%20java.util.Map%29>*(long
> node,
> Map
> <http://docs.oracle.com/javase/7/docs/api/java/util/Map.html?is-external=true>
> <String
> <http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true>
> ,Object
> <http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true>
> > properties)seems to doesn't fit my needs.
>
> Is there any way to achieve my goal?
>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.