@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;
  }
  @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);
  }