def Insert(self,people): dao = PersonDao() newIds = [] newPhones = [] newEmails = [] for p in people: newId = dao.insert(p.first_name,p.last_name,p.job_title, p.salutation) newIds.append(newId) newPhones.append((newId,Phone(-1,"",PhoneType.Office))) newPhones.append((newId,Phone(-1,"",PhoneType.Fax))) newPhones.append((newId,Phone(-1,"",PhoneType.Mobile))) newPhones.append((newId,Phone(-1,"",PhoneType.Personal))) newEmails.append((newId,Email(-1,"",EmailType.Office))) newEmails.append((newId,Email(-1,"",EmailType.Personal))) if len(p.roles) > 0: r = [t for t in p.roles] dao.updateRoles(newId,r) self.insertPhones(newPhones) self.insertEmails(newEmails) newPeople = self.Get(newIds) return newPeople
def Update(self,people): dao = PersonDao() newIds = [] logging.info("Updating Person 1") for p in people: logging.info("Updating Person 2") newIds.append(dao.update(p.id,p.first_name,p.last_name,p.job_title, p.salutation)) if len(p.roles) > 0: r = [t for t in p.roles] dao.updateRoles(p.id,r) PhoneFactory().update(p.phones) EmailFactory().update(p.emails) return self.Get([p.id for p in people])
def count_people(self): dao = PersonDao() return dao.count_all()
def get_all(self): dao = PersonDao() #rows = dao.GetAllIds() ids = [r[0] for r in dao.get_all_ids()] return self.Get(ids)