class CycleService {

  @Transactional
  public void deleteCycle(Long cycleId, User user) throws Exception {
    Cycle cycle = cycleRepository.findByIdOrThrow(cycleId);
    if (cycle.getCycleState() != CycleState.ACTIVE) {
      cycle
          .getCompanies()
          .forEach(company -> companyService.deleteCompany(company.getId(), false, user));
      this.logger.info("Deleted (non active) cycle with id " + cycle.getId());
    } else {
      throw new Exception("An active Cycle can not be deleted");
    }
  }

  @Autowired public  CycleService(
      CyclePreparationCloningService cyclePreparationCloningService,
      CycleRepository cycleRepository,
      CompanyHistoryRepository companyHistoryRepository,
      CompanyService companyService);

}