Mercurial > hg > NetworkVis
comparison ismi-python-neo4jrestclient/ismi-vis.py @ 21:d964d9a23837
now with clickable author names in detail panel.
author | casties |
---|---|
date | Fri, 09 Oct 2015 15:01:20 +0200 |
parents | d8bbf6d5920b |
children | 80010fb9dbce |
comparison
equal
deleted
inserted
replaced
20:d8bbf6d5920b | 21:d964d9a23837 |
---|---|
186 " optional match (t)-[:was_created_by]->(a:PERSON)" | 186 " optional match (t)-[:was_created_by]->(a:PERSON)" |
187 " optional match (s:TEXT)<-[:is_commentary_on]-(t)" | 187 " optional match (s:TEXT)<-[:is_commentary_on]-(t)" |
188 " optional match (s)-[:was_created_by]->(sa:PERSON)" | 188 " optional match (s)-[:was_created_by]->(sa:PERSON)" |
189 " optional match (t)<-[:is_commentary_on]-(c:TEXT)" | 189 " optional match (t)<-[:is_commentary_on]-(c:TEXT)" |
190 " optional match (c)-[:was_created_by]->(ca:PERSON)" | 190 " optional match (c)-[:was_created_by]->(ca:PERSON)" |
191 " return t,a.label,s.label,s.ismi_id,sa.label,c.label,c.ismi_id,ca.label") | 191 " return t,a.label,a.ismi_id,s.label,s.ismi_id,sa.label,c.label,c.ismi_id,ca.label") |
192 print("query:%s"%query) | 192 print("query:%s"%query) |
193 results = gdb.query(query, returns=(Node,str,str,str,str,str,str,str), | 193 results = gdb.query(query, returns=(Node,str,str,str,str,str,str,str,str), |
194 params={"text_id": int(text_id)}) | 194 params={"text_id": int(text_id)}) |
195 | 195 |
196 print("result:%s"%results) | 196 print("result:%s"%results) |
197 text = None | 197 text = None |
198 author = None | 198 author = None |
199 scs = {} | 199 scs = {} |
200 cs = {} | 200 cs = {} |
201 for [t,a_label,s_label,s_id,sa_label,c_label,c_id,ca_label] in results: | 201 for [t,a_label,a_id,s_label,s_id,sa_label,c_label,c_id,ca_label] in results: |
202 text = t | 202 text = t |
203 author = a_label | 203 author = a_label |
204 author_id = a_id | |
204 if s_id is not None and s_id != "None": | 205 if s_id is not None and s_id != "None": |
205 scs[int(s_id)] = {"title": s_label, "author":sa_label} | 206 scs[int(s_id)] = {"title": s_label, "author":sa_label} |
206 | 207 |
207 if c_id is not None and c_id != "None": | 208 if c_id is not None and c_id != "None": |
208 cs[int(c_id)] = {"title": c_label, "author":ca_label} | 209 cs[int(c_id)] = {"title": c_label, "author":ca_label} |
209 | 210 |
210 print("text:%s scs:%s cs:%s"%(text, scs, cs)) | 211 print("text:%s scs:%s cs:%s"%(text, scs, cs)) |
211 return Response(dumps({"title": text['label'], "attrs": text.properties, | 212 return Response(dumps({"title": text['label'], "attrs": text.properties, |
212 "author": author, | 213 "author": {"label": author, "ismi_id": author_id}, |
213 "commenting": scs, "commentaries": cs}), | 214 "commenting": scs, "commentaries": cs}), |
214 mimetype="application/json") | 215 mimetype="application/json") |
215 | 216 |
216 | 217 |
217 if __name__ == '__main__': | 218 if __name__ == '__main__': |