コード例 #1
0
 public void removeOwner(Long id, String username) {
   User user = userService.findOne(username);
   Device device = findOneForCurrentUser(id);
   Set<User> owners = device.getOwners();
   owners.remove(user);
   deviceRepository.save(device);
 }
コード例 #2
0
 public Device addOwner(Long id, String username) {
   User user = userService.findOne(username);
   Device device = findOneForCurrentUser(id);
   Set<User> owners = device.getOwners();
   owners.add(user);
   deviceRepository.save(device);
   return device;
 }
コード例 #3
0
 public Alert addAlert(Long id, AlertDTO alertDTO) {
   Device device = findOneForCurrentUser(id);
   Alert alert =
       new Alert(
           device,
           alertDTO.getDescription(),
           alertDTO.getAfter(),
           alertDTO.getBefore(),
           alertDTO.getFields());
   List<Alert> alerts = device.getAlerts();
   alerts.add(alert);
   deviceRepository.save(device);
   return alert;
 }
コード例 #4
0
  public Track addTrack(TrackDTO trackDTO) {
    Device device = findOne(trackDTO.getDeviceId());

    Track track =
        new Track(
            device,
            trackDTO.getFields(),
            trackDTO.getLocation(),
            trackDTO.getReceivedAt(),
            trackDTO.getRecordedAt());

    device.getTracks().add(track);

    deviceRepository.save(device);

    return track;
  }