def parseStakeholdersResponse(self, jsonBody): stakeholders = [] data = json.loads(str(jsonBody)) for stakeholder in data['data']: s = Stakeholder(id=stakeholder['id'], version=stakeholder['version']) for taggroup in stakeholder['taggroups']: tg = TagGroup(id=taggroup['id']) mainTag = taggroup['main_tag'] tg.setMainTag(Tag(id=mainTag['id'], key=mainTag['key'], value=mainTag['value'])) for tag in taggroup['tags']: t = Tag(id=tag['id'], key=tag['key'], value=tag['value']) tg.addTag(t) s.addTagGroup(tg) stakeholders.append(s) return stakeholders
def addStakeholders(self): self.connect(self.stakeholderProtocol, SIGNAL("created( bool, int, QString"), self.addStakeholdersFinished) # Dummy stakeholder s = Stakeholder() tag = Tag(key="Name", value="Adrian Weber Investment") tagGroup = TagGroup() tagGroup.setMainTag(tag) tagGroup.addTag(tag) tagGroup.addTag(Tag(key="Country", value="Swaziland")) s.addTagGroup(tagGroup) msg, rawBody = self.stakeholderProtocol.add(s) self.log(msg) self.log(rawBody)