Skip to content
Snippets Groups Projects
Commit 002677ab authored by cramakri's avatar cramakri
Browse files

Renamed json_encoded_list to json_encoded_value

SVN: 27266
parent 612f7f1d
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ from com.fasterxml.jackson.databind import ObjectMapper ...@@ -6,7 +6,7 @@ from com.fasterxml.jackson.databind import ObjectMapper
# BEGIN Infrastructure # BEGIN Infrastructure
# #
def json_encoded_list(coll): def json_encoded_value(coll):
"""Utility function for converting a list into a json-encoded list""" """Utility function for converting a list into a json-encoded list"""
return ObjectMapper().writeValueAsString(coll) return ObjectMapper().writeValueAsString(coll)
...@@ -87,7 +87,7 @@ class RequestHandler: ...@@ -87,7 +87,7 @@ class RequestHandler:
for entry in entities: for entry in entities:
self.add_row(entry) self.add_row(entry)
def json_encoded_list(self, coll): def json_encoded_value(self, coll):
return ObjectMapper().writeValueAsString(coll) return ObjectMapper().writeValueAsString(coll)
def process_request(self): def process_request(self):
...@@ -122,7 +122,7 @@ def material_to_dict(material): ...@@ -122,7 +122,7 @@ def material_to_dict(material):
refcon = {} refcon = {}
refcon['entityKind'] = 'MATERIAL' refcon['entityKind'] = 'MATERIAL'
refcon['entityType'] = material.getMaterialType() refcon['entityType'] = material.getMaterialType()
material_dict['REFCON'] = json_encoded_list(refcon) material_dict['REFCON'] = json_encoded_value(refcon)
material_dict['CATEGORY'] = material.getMaterialType() material_dict['CATEGORY'] = material.getMaterialType()
if material.getMaterialType() == '5HT_COMPOUND': if material.getMaterialType() == '5HT_COMPOUND':
material_dict['SUMMARY'] = material.getPropertyValue("FORMULA") material_dict['SUMMARY'] = material.getPropertyValue("FORMULA")
...@@ -131,11 +131,11 @@ def material_to_dict(material): ...@@ -131,11 +131,11 @@ def material_to_dict(material):
material_dict['SUMMARY'] = material.getPropertyValue("DESC") material_dict['SUMMARY'] = material.getPropertyValue("DESC")
material_dict['IMAGE_URL'] = "" material_dict['IMAGE_URL'] = ""
material_dict['CHILDREN'] = json_encoded_list([]) material_dict['CHILDREN'] = json_encoded_value([])
prop_names = ["NAME", "PROT_NAME", "GENE_NAME", "LENGTH", "CHEMBL", "DESC", "FORMULA", "WEIGHT", "SMILES"] prop_names = ["NAME", "PROT_NAME", "GENE_NAME", "LENGTH", "CHEMBL", "DESC", "FORMULA", "WEIGHT", "SMILES"]
properties = dict((name, material.getPropertyValue(name)) for name in prop_names if material.getPropertyValue(name) is not None) properties = dict((name, material.getPropertyValue(name)) for name in prop_names if material.getPropertyValue(name) is not None)
material_dict['PROPERTIES'] = json_encoded_list(properties) material_dict['PROPERTIES'] = json_encoded_value(properties)
return material_dict return material_dict
def sample_to_dict(five_ht_sample, material_by_perm_id): def sample_to_dict(five_ht_sample, material_by_perm_id):
...@@ -147,17 +147,17 @@ def sample_to_dict(five_ht_sample, material_by_perm_id): ...@@ -147,17 +147,17 @@ def sample_to_dict(five_ht_sample, material_by_perm_id):
refcon = {} refcon = {}
refcon['entityKind'] = 'SAMPLE' refcon['entityKind'] = 'SAMPLE'
refcon['entityType'] = five_ht_sample.getSampleType() refcon['entityType'] = five_ht_sample.getSampleType()
sample_dict['REFCON'] = json_encoded_list(refcon) sample_dict['REFCON'] = json_encoded_value(refcon)
sample_dict['CATEGORY'] = five_ht_sample.getSampleType() sample_dict['CATEGORY'] = five_ht_sample.getSampleType()
compound = material_by_perm_id[five_ht_sample.getPropertyValue("COMPOUND")] compound = material_by_perm_id[five_ht_sample.getPropertyValue("COMPOUND")]
sample_dict['IMAGE_URL'] = image_url_for_compound(compound) sample_dict['IMAGE_URL'] = image_url_for_compound(compound)
children = [five_ht_sample.getPropertyValue("TARGET"), five_ht_sample.getPropertyValue("COMPOUND")] children = [five_ht_sample.getPropertyValue("TARGET"), five_ht_sample.getPropertyValue("COMPOUND")]
sample_dict['CHILDREN'] = json_encoded_list(children) sample_dict['CHILDREN'] = json_encoded_value(children)
prop_names = ["DESC"] prop_names = ["DESC"]
properties = dict((name, five_ht_sample.getPropertyValue(name)) for name in prop_names if five_ht_sample.getPropertyValue(name) is not None) properties = dict((name, five_ht_sample.getPropertyValue(name)) for name in prop_names if five_ht_sample.getPropertyValue(name) is not None)
sample_dict['PROPERTIES'] = json_encoded_list(properties) sample_dict['PROPERTIES'] = json_encoded_value(properties)
# Need to handle the material links as entity links: "TARGET", "COMPOUND" # Need to handle the material links as entity links: "TARGET", "COMPOUND"
return sample_dict return sample_dict
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment