|
|
|
|
@ -32,26 +32,36 @@ public class SamplingRateService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Optional<SamplingRate> getSamplingRateById(Integer id) {
|
|
|
|
|
if (id == null) {
|
|
|
|
|
throw new IllegalArgumentException("ID cannot be null");
|
|
|
|
|
}
|
|
|
|
|
logger.info("Getting sampling rate by id:{}", id);
|
|
|
|
|
return repository.findById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Optional<SamplingRate> updateSamplingRate(Integer id, String value) {
|
|
|
|
|
logger.info("Updating sampling rate:{}", value);
|
|
|
|
|
if (value == null || value.trim().isEmpty()) {
|
|
|
|
|
throw new IllegalArgumentException("Sampling-Rate value cannot be null or empty");}
|
|
|
|
|
Optional<SamplingRate> existingSamplingRate = repository.findById(id);
|
|
|
|
|
if(existingSamplingRate.isEmpty()) {
|
|
|
|
|
logger.warn("Sampling rate not found with id:{}", id);
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
}
|
|
|
|
|
SamplingRate samplingRate = existingSamplingRate.get();
|
|
|
|
|
samplingRate.setValue(value);
|
|
|
|
|
SamplingRate updatedSamplingRate = repository.update(samplingRate);
|
|
|
|
|
return Optional.of(updatedSamplingRate);
|
|
|
|
|
if (id == null) {
|
|
|
|
|
throw new IllegalArgumentException("ID cannot be null");
|
|
|
|
|
}
|
|
|
|
|
logger.info("Updating sampling rate:{}", value);
|
|
|
|
|
if (value == null || value.trim().isEmpty()) {
|
|
|
|
|
throw new IllegalArgumentException("Sampling-Rate value cannot be null or empty");
|
|
|
|
|
}
|
|
|
|
|
Optional<SamplingRate> existingSamplingRate = repository.findById(id);
|
|
|
|
|
if(existingSamplingRate.isEmpty()) {
|
|
|
|
|
logger.warn("Sampling rate not found with id:{}", id);
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
}
|
|
|
|
|
SamplingRate samplingRate = existingSamplingRate.get();
|
|
|
|
|
samplingRate.setValue(value);
|
|
|
|
|
SamplingRate updatedSamplingRate = repository.update(samplingRate);
|
|
|
|
|
return Optional.of(updatedSamplingRate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean deleteSamplingRate(Integer id) {
|
|
|
|
|
if (id == null) {
|
|
|
|
|
throw new IllegalArgumentException("Sampling rate id cannot be null");
|
|
|
|
|
}
|
|
|
|
|
logger.info("Deleting sampling rate:{}", id);
|
|
|
|
|
return repository.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|