def case_from_json(data): c = Case() c.setCaseId(data['case_id']) c.setTypeId(data['properties']['case_type']) c.setName(data['properties']['case_name']) c.setClosed(data['closed']) if data['properties']['date_opened']: c.setDateOpened(to_jdate( datetime.strptime( data['properties']['date_opened'], '%Y-%m-%dT%H:%M:%S'))) # 'Z' in fmt string omitted due to jython bug owner_id = data['properties']['owner_id'] or data['user_id'] or "" c.setUserId(owner_id) # according to clayton "there is no user_id, only owner_id" for k, v in data['properties'].iteritems(): if v is not None and k not in ['case_name', 'case_type', 'date_opened']: c.setProperty(k, v) for k, v in data['indices'].iteritems(): c.setIndex(k, v['case_type'], v['case_id']) for k, v in data['attachments'].iteritems(): c.updateAttachment(k, v['url']) return c
def case_from_json(data): c = Case() c.setCaseId(data['case_id']) c.setTypeId(data['properties']['case_type']) c.setName(data['properties']['case_name']) c.setClosed(data['closed']) if data['properties']['date_opened']: c.setDateOpened(to_jdate(datetime.strptime(data['properties']['date_opened'], '%Y-%m-%dT%H:%M:%S'))) # 'Z' in fmt string omitted due to jython bug c.setUserId(data['user_id'] or "") for k, v in data['properties'].iteritems(): if v is not None and k not in ['case_name', 'case_type', 'date_opened']: c.setProperty(k, v) for k, v in data['indices'].iteritems(): c.setIndex(k, v['case_type'], v['case_id']) return c
def case_from_json(data): c = Case() c.setCaseId(data['case_id']) c.setTypeId(data['properties']['case_type']) c.setName(data['properties']['case_name']) c.setClosed(data['closed']) if data['properties']['date_opened']: c.setDateOpened( to_jdate( datetime.strptime(data['properties']['date_opened'], '%Y-%m-%dT%H:%M:%S')) ) # 'Z' in fmt string omitted due to jython bug c.setUserId(data['user_id'] or "") for k, v in data['properties'].iteritems(): if v is not None and k not in [ 'case_name', 'case_type', 'date_opened' ]: c.setProperty(k, v) for k, v in data['indices'].iteritems(): c.setIndex(k, v['case_type'], v['case_id']) return c
def case_from_json(data): c = Case() c.setCaseId(data['case_id']) c.setTypeId(data['properties']['case_type']) c.setName(data['properties']['case_name']) c.setClosed(data['closed']) if data['properties']['date_opened']: c.setDateOpened( to_jdate( datetime.strptime(data['properties']['date_opened'], '%Y-%m-%dT%H:%M:%S')) ) # 'Z' in fmt string omitted due to jython bug owner_id = data['properties']['owner_id'] or data['user_id'] or "" c.setUserId( owner_id) # according to clayton "there is no user_id, only owner_id" for k, v in data['properties'].iteritems(): if v is not None and k not in [ 'case_name', 'case_type', 'date_opened' ]: c.setProperty(k, v) for k, v in data['indices'].iteritems(): c.setIndex(k, v['case_type'], v['case_id']) for k, v in data['attachments'].iteritems(): c.updateAttachment(k, v['url']) return c