Package healthwatcher.business.employee

Source Code of healthwatcher.business.employee.EmployeeRecord

package healthwatcher.business.employee;

import lib.concurrency.ConcurrencyManager;
import lib.exceptions.ExceptionMessages;
import lib.exceptions.ObjectAlreadyInsertedException;
import lib.exceptions.ObjectNotFoundException;
import lib.exceptions.ObjectNotValidException;
import lib.exceptions.RepositoryException;
import healthwatcher.data.IEmployeeRepository;
import healthwatcher.model.employee.Employee;

public class EmployeeRecord {

  private IEmployeeRepository employeeRepository;

  private ConcurrencyManager manager = new ConcurrencyManager();

  public EmployeeRecord(IEmployeeRepository rep) {
    this.employeeRepository = rep;
  }

  public Employee search(String login) throws ObjectNotFoundException, RepositoryException {
    return employeeRepository.search(login);
  }

  public void insert(Employee employee) throws ObjectNotValidException,
      ObjectAlreadyInsertedException, ObjectNotValidException, RepositoryException {
    //#if relacional
    manager.beginExecution(employee.getLogin());
    //#endif
    if (employeeRepository.exists(employee.getLogin())) {
      throw new ObjectAlreadyInsertedException(ExceptionMessages.EXC_JA_EXISTE);
    } else {
      employeeRepository.insert(employee);
    }
    //#if relacional
    manager.endExecution(employee.getLogin());
    //#endif
  }

  public void update(Employee employee) throws ObjectNotValidException, ObjectNotFoundException,
      ObjectNotValidException, RepositoryException {
    employeeRepository.update(employee);
  }
}
TOP

Related Classes of healthwatcher.business.employee.EmployeeRecord

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.