Mercurial > hg > drupalISMI
diff importFromOpenMind/importer/model2neo4j.py @ 33:7e2e344c3b87
make name of type attribute configurable. default '_type' for nodes.
author | casties |
---|---|
date | Tue, 02 Feb 2016 14:41:08 +0100 |
parents | 48bbba800c03 |
children | 74dfaed3600b |
line wrap: on
line diff
--- a/importFromOpenMind/importer/model2neo4j.py Fri Jan 22 20:41:25 2016 +0100 +++ b/importFromOpenMind/importer/model2neo4j.py Tue Feb 02 14:41:08 2016 +0100 @@ -13,6 +13,10 @@ # neo4j base URL neo4jBaseURL = "http://localhost:7474/db/data/" +# name of type attribute +node_type_attribute = '_type' +rel_type_attribute = 'type' + ## setup @@ -27,7 +31,7 @@ cnt = 0 for node_id in nx.nodes_iter(nx_graph): attrs = nx_graph.node[node_id] - ntype = attrs['type'] + ntype = attrs[node_type_attribute] ismi_id = attrs['ismi_id'] # create node with attributes n4j_node = n4j_graph.nodes.create(**attrs) @@ -50,7 +54,7 @@ (nx_src, nx_tar) = nx_edge # get attributes of edge attrs = nx_graph.edge[nx_src][nx_tar][0] - ntype = attrs['type'] + etype = attrs[rel_type_attribute] # get ismi_id of source and target nodes src_id = nx_graph.node[nx_src]['ismi_id'] tar_id = nx_graph.node[nx_tar]['ismi_id'] @@ -66,7 +70,7 @@ break # create Neo4J relation - n4j_rel = n4j_graph.relationships.create(src, ntype, tar) + n4j_rel = n4j_graph.relationships.create(src, etype, tar) # add attributes n4j_rel.properties = attrs