diff options
author | shefali shetty <sshefali44@gmail.com> | 2012-06-01 11:13:10 +0530 |
---|---|---|
committer | shefali shetty <sshefali44@gmail.com> | 2012-06-01 11:13:10 +0530 |
commit | 82e6b6a0535a9ffb202ed8c6bb786bdf41a7bb80 (patch) | |
tree | d7a6c2288cf71cd3fe3d49d24997ea65ac2b0710 /gstudio/models.py | |
parent | 185094d8fb4f73ea8986559ad5bc6908f3535802 (diff) | |
download | gnowsys-82e6b6a0535a9ffb202ed8c6bb786bdf41a7bb80.tar.gz |
unused arrays removed
Diffstat (limited to 'gstudio/models.py')
-rw-r--r-- | gstudio/models.py | 72 |
1 files changed, 27 insertions, 45 deletions
diff --git a/gstudio/models.py b/gstudio/models.py index 2c9d51f..167ed8c 100644 --- a/gstudio/models.py +++ b/gstudio/models.py @@ -861,81 +861,63 @@ class Nodetype(Node): def get_graph_json(self): - # predicate_id={"plural":"a1","altnames":"a2","contains_members":"a3","contains_subtypes":"a4","prior_nodes":"a5", "posterior_nodes":"a6"} - g_json = {} + g_json = {} g_json["node_metadata"]= [] g_json["relations"]=[] - g_json["relset"]=[] - + global counter global attr_counter nbh = self.get_nbh predicate_id = {} - + for key in nbh.keys(): val = str(counter) + "a" predicate_id[key] = val - counter = counter + 1 - #print predicate_id - - + counter = counter + 1 - this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true"} + this_node = {"_id":str(self.id),"title":self.title,"screen_name":self.title, "url":self.get_absolute_url(),"expanded":"true","refType":self.reftype} g_json["node_metadata"].append(this_node) - g_json["relset"].append(self.id) + for key in predicate_id.keys(): if nbh[key]: try: - #g_json[str(key)]=[] - #g_json["relations"].append(key) - g_json["node_metadata"].append({"_id":str(predicate_id[key]),"screen_name":key}) - - #g_json[str(key)].append({"from":self.id , "to":predicate_id[key],"value":1, "level":1 }) - g_json["relations"].append({"from":self.id ,"type":str(key),"value":1,"to":predicate_id[key] }) if not isinstance(nbh[key],basestring): - for item in nbh[key]: - if item.reftype!="Relation": - # create nodes + + for item in nbh[key]: + if item.reftype=="Relationtype": + if item.left_subjecttype.id==self.id: + flag=1 + elif item.right_subjecttype.id==self.id: + flag=0 + # create nodes - g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false"}) - g_json["relset"].append(item.id) + g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false","refType":item.reftype,"inverse":item.inverse,"flag":flag}) - # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) - #create links - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) - - else: - - if item.left_subject.id==self.id: - item1=item.right_subject - elif item.right_subject.id==self.id: - item1=item.left_subject - - g_json["node_metadata"].append({"_id":str(item1.id),"screen_name":item1.title,"title":self.title, "url":item1.get_absolute_url(),"expanded":"false"}) - - # g_json[str(key)].append({"from":predicate_id[key] , "to":item.id ,"value":1 }) + g_json["node_metadata"].append({"_id":str(item.id),"screen_name":item.title,"title":self.title, "url":item.get_absolute_url(),"expanded":"false","refType":item.reftype}) #create links - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item1.id }) - + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key), "value":1,"to":item.id }) + + else: - #value={nbh["plural"]:"a4",nbh["altnames"]:"a5"} - #this_node[str(key)]=nbh[key] key, nbh[key] - #for item in value.keys(): + g_json["node_metadata"].append({"_id":(str(attr_counter)+"a"),"screen_name":nbh[key]}) - #g_json[str(key)].append({"from":predicate_id[key] , "to":attr_counter ,"value":1, "level":2 }) - g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a")}) + g_json["relations"].append({"from":predicate_id[key] ,"type":str(key) ,"value":1,"to":(str(attr_counter)+"a")}) attr_counter-=1 except: pass - #print g_json + - return json.dumps(g_json) + return json.dumps(g_json) + + + + @property def get_possible_attributes(self): """ |