Exemple #1
0
    def update(self):
        self.normalize()
        if self.badSetup:
            log(self.ID, "Employee is invalid")
            return
        if not self.exists:
            log(self.ID, "Employee does not exist yet, did you mean to create?")
            return
        _first_name = "first_name='{}'".format(self.first_name)
        _last_name = "last_name='{}'".format(self.last_name)
        _ssn = "ssn='{}'".format(self.ssn)
        _job_title = "job_title='{}'".format(self.job_title)
        _salary_type = "salary_type='{}'".format(self.salary_type)
        _insurancePlan = "insurancePlan='{}'".format(self.insurancePlan)
        _email = "email='{}'".format(self.email)
        _country = "country='{}'".format(self.country)
        _state = "state='{}'".format(self.state)
        _street_name = "street_name='{}'".format(self.street_name)
        _postal_code = "postal_code='{}'".format(self.postal_code)
        _F01k_deduction = "F01k_deduction='{}'".format(self.F01k_deduction)
        _rate = "rate='{}'".format(self.rate)
        _hours = "hours='{}'".format(self.hours)
        DB.execute(
            Query.UPDATE_SINGLE(
                Entity.EMPLOYEE,
                self.e_id,
                _first_name,
                _last_name,
                _ssn,
                _job_title,
                _salary_type,
                _insurancePlan,
                _email,
                _country,
                _state,
                _street_name,
                _postal_code,
                _F01k_deduction,
                _rate,
                _hours,
            )
        )

        # TODO: Only modify tables that actually changed

        DB.execute(Query.DELETE(Relation.HAS, "e_id='{}'".format(self.e_id)))

        DB.execute(Query.DELETE(Multivalue.EMPLOYEE_PHONE, "e_id='{}'".format(self.e_id)))

        DB.execute(Query.DELETE(Multivalue.EMPLOYEE_BENEFIT_SELECTION, "e_id='{}'".format(self.e_id)))

        for d in self.Dependents:
            DB.execute(Query.CREATE(Relation.HAS, self.e_id, d))

        for p in self.PhoneNumbers:
            DB.execute(Query.CREATE(Multivalue.EMPLOYEE_PHONE, self.e_id, p))

        for b in self.Benefits:
            DB.execute(Query.CREATE(Multivalue.EMPLOYEE_BENEFIT_SELECTION, self.e_id, b))
Exemple #2
0
 def update(self):
     self.normalize()
     if self.badSetup:
         log(self.ID, "Dependent is invalid")
         return
     if not self.exists:
         log(self.ID,
             "Dependent does not exist yet, did you mean to create?")
         return
     _first_name = "first_name='{}'".format(self.first_name)
     _last_name = "last_name='{}'".format(self.last_name)
     _ssn = "ssn='{}'".format(self.ssn)
     _benefitSelection = "benefitSelection='{}'".format(
         self.benefitSelection)
     DB.execute(
         Query.UPDATE_SINGLE(Entity.DEPENDENT, self.d_id, _first_name,
                             _last_name, _ssn, _benefitSelection))