@Transactional
  @Auditable(actionType = AuditActionType.DELETE)
  public void deleteProject(Integer projectId) throws ParentChildConstraintException {
    Project project;

    project = projectDAO.findById(projectId);

    deleteEmptyAssignments(project);
    LOGGER.debug("Deleting project " + project);
    projectDAO.delete(project);
  }
  private List<Project> fetchProjects(UserCriteria userCriteria) {
    List<Project> projects;
    if (userCriteria.isOnlyActiveProjects()) {
      LOGGER.debug("Fetching only active projects");

      projects = projectDAO.findAllActive();
    } else {
      LOGGER.debug("Fetching all projects");

      projects = projectDAO.findAll();
    }
    return projects;
  }
  public Project getProject(Integer projectId) throws ObjectNotFoundException {
    Project project = projectDAO.findById(projectId);

    if (project == null) {
      throw new ObjectNotFoundException("Project not found for id " + projectId);
    }

    return project;
  }
  @Transactional
  @Override
  public Project updateProject(Project project) {
    projectDAO.persist(project);

    validatePMRoles(project);
    assignUsersToDefaultProject(project);

    return project;
  }
  /**
   * Get available projects depended on the userCriteria
   *
   * @param userCriteria
   * @return
   */
  private List<Project> getAvailableProjects(UserCriteria userCriteria) {
    List<Project> projects;

    if (userCriteria.isEmptyCustomers()) {
      projects = fetchProjects(userCriteria);
    } else {
      projects =
          projectDAO.findProjectForCustomers(
              userCriteria.getCustomers(), userCriteria.isOnlyActiveProjects());
    }

    projects = checkForOnlyBillableProjects(userCriteria, projects);

    return projects;
  }
 @Override
 public List<Project> getActiveProjects() {
   return projectDAO.findAllActive();
 }
 @Override
 public List<Project> getProjects() {
   return projectDAO.findAll();
 }
 public List<Project> getProjectManagerProjects(User user) {
   return projectDAO.findActiveProjectsWhereUserIsPM(user);
 }