def __CreateOrUpdateVerifiableOrg(self, claim: ClaimParser, verifiableOrg: VerifiableOrg): organizationId = claim.getField("legal_entity_id") name = claim.getField("legal_name") effectiveDate = self.__ToDate(claim.getField("effective_date")) endDate = endDate = self.__ToDate(claim.getField("end_date")) orgType = self.__get_VerifiableOrgType(claim) jurisdiction = self.__get_Jurisdiction(claim) if not verifiableOrg: self.__logger.debug("Registering {0} ...".format(name)) verifiableOrg = VerifiableOrg(orgId=organizationId, orgTypeId=orgType, jurisdictionId=jurisdiction, legalName=name, effectiveDate=effectiveDate, endDate=endDate) verifiableOrg.save() else: self.__logger.debug("Updating records for {0} ... ".format(name)) verifiableOrg.orgId = organizationId verifiableOrg.orgTypeId = orgType verifiableOrg.jurisdictionId = jurisdiction verifiableOrg.legalName = name verifiableOrg.effectiveDate = effectiveDate verifiableOrg.endDate = endDate verifiableOrg.save() return verifiableOrg
def __CreateOrUpdateVerifiableOrg(self, claim): organizationId = claim["busId"] name = claim["LegalName"] verifiableOrg = VerifiableOrg.objects.filter(orgId=organizationId) if not verifiableOrg: self.__logger.debug("Organization, {0}, with business id {1} does not exist. Creating ... ".format(name, organizationId)) verifiableOrg = VerifiableOrg( orgId = claim["busId"], orgTypeId = self.__get_VerifiableOrgType(claim), jurisdictionId = self.__get_Jurisdiction(claim), legalName = claim["LegalName"], effectiveDate = claim["effectiveDate"] ) verifiableOrg.save() else: self.__logger.debug("Organization, {0}, with business id {1} exists. Updating ... ".format(name, organizationId)) verifiableOrg = verifiableOrg[0] verifiableOrg.orgId = claim["busId"] verifiableOrg.orgTypeId = self.__get_VerifiableOrgType(claim) verifiableOrg.jurisdictionId = self.__get_Jurisdiction(claim) verifiableOrg.legalName = claim["LegalName"] verifiableOrg.effectiveDate = claim["effectiveDate"] verifiableOrg.save() return verifiableOrg