from LastUsedFactory import LastUsedFactory from Department import Department from Employee import Employee from Store import store class EmployeeFactory(object): def new(self, empId, firstName="", lastName="", email=""): emp = Employee() emp.setEmpId(empId) if firstName: emp.setFirstName(firstName) if lastName: emp.setLastName(lastName) if email: emp.setEmail(email) emp.setStatus("Active") return emp def getEmployees(self): return store.fetchObjectsOfClass(Employee, clauses="WHERE firstName IS NOT NULL AND lastName IS NOT NULL ORDER BY shiftObjId,lastName ASC, firstName ASC") def getActiveEmployees(self): return store.fetchObjectsOfClass(Employee, clauses="WHERE firstName IS NOT NULL AND lastName IS NOT NULL AND status='Active' ORDER BY shiftObjId, lastName, firstName") def getDepartmentsOfEmployeeBySerialNum(self,serialNum): return store.fetchObjectsOfClass(Department, clauses="WHERE employeeObjId=%s" % serialNum) def getEmployeesOfDepartmentCode(self,code): return store.fetchObjectsOfClass(Department, clauses="WHERE code='%s' AND employeeObjId IS NOT NULL" % code) def getLoggedInEmployees(self): return filter(lambda e: e.activeLaborHed(), self.getEmployees()) def getEmployeeByEmpId(self, empId): objects = store.fetchObjectsOfClass(Employee, clauses="WHERE empId='%s'" % (empId)) if not objects: return None else: return objects[0] def getEmployeeBySerialNum(self, serialNum): return store.fetchObject(Employee, serialNum) def searchEmployee(self, clauses): return store.fetchObjectsOfClass(Employee, clauses)