@Transactional(readOnly = true)
  @Override
  public List<DropDownObject> getBatteryList() {

    List<DropDownObject> dropDownObjectList = new ArrayList<DropDownObject>();

    List<Battery> batteryList = batteryRepository.getBatteryList();

    for (Battery battery : batteryList) {
      dropDownObjectList.add(
          new DropDownObject(battery.getBatteryId().toString(), battery.getName()));
    }

    return dropDownObjectList;
  }
  public BatteryInfo convertToBatteryItem(Battery battery) {

    if (battery == null) {
      return null;
    }

    BatteryInfo batteryInfo = new BatteryInfo();
    batteryInfo.setBatteryId(battery.getBatteryId());
    batteryInfo.setName(battery.getName());
    batteryInfo.setDisabled(battery.isDisabled());
    batteryInfo.setDescription(battery.getDescription());
    batteryInfo.setDateCreated(battery.getDateCreated());

    return batteryInfo;
  }
  @Override
  public void update(BatteryInfo batteryInfo) {
    Set<Survey> existingSurveys = new HashSet<Survey>();
    for (SurveyInfo surveyInfo : batteryInfo.getSurveys()) {
      existingSurveys.add(surveyService.findOne(surveyInfo.getSurveyId()));
    }

    Battery battery = batteryRepository.findOne(batteryInfo.getBatteryId());
    battery.setName(batteryInfo.getName());
    battery.setDescription(batteryInfo.getDescription());
    battery.setDisabled(batteryInfo.isDisabled());
    battery.setSurveys(existingSurveys);

    batteryRepository.update(battery);
  }
  @Transactional(readOnly = true)
  @Override
  public Set<BatteryDto> getBatteryDtoSet() {

    Set<BatteryDto> batteryDtoList = Sets.newTreeSet();

    List<Battery> batteryList = batteryRepository.getBatteryList();

    for (Battery battery : batteryList) {
      BatteryDto batterycDto = new BatteryDto();
      batterycDto.setBatteryId(battery.getBatteryId());
      batterycDto.setBatteryName(battery.getName());
      batteryDtoList.add(batterycDto);
    }
    return batteryDtoList;
  }
  @Override
  public BatteryInfo create(BatteryInfo batteryInfo) {
    Battery battery = new Battery();

    battery.setName(batteryInfo.getName());
    battery.setDescription(batteryInfo.getDescription());
    battery.setDisabled(batteryInfo.isDisabled());

    if (batteryInfo.getSurveys() != null && batteryInfo.getSurveys().size() > 0) {
      List<Survey> surveyList = new ArrayList<Survey>();

      for (SurveyInfo surveyInfo : batteryInfo.getSurveys()) {
        // if (surveyInfo.getIsIncludedInBattery()) {
        surveyList.add(surveyService.findOne(surveyInfo.getSurveyId()));
        // }
      }

      if (surveyList.size() > 0) {
        battery.setSurveys(new HashSet<Survey>(surveyList));
      }
    }

    batteryRepository.create(battery);

    batteryInfo.setBatteryId(battery.getBatteryId());

    return batteryInfo;
  }