コード例 #1
0
  @Transactional(readOnly = true)
  @Override
  public BatteryInfo getBattery(int batteryId) {
    BatteryInfo batteryInfo = null;
    Battery battery = batteryRepository.findOne(batteryId);

    if (battery != null) {
      batteryInfo = EditorsBatteryViewTransformer.transformBattery(battery);
    }

    return batteryInfo;
  }
コード例 #2
0
  @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);
  }