Homeautomation/src/main/java/de/ph87/homeautomation/bulk/BulkExecutor.java
Patrick Haßel 0b146b5972 #3 FIX Property- & Device updates
+ Devices in Property::usages
+ code clean
2022-10-26 21:04:18 +02:00

28 lines
774 B
Java

package de.ph87.homeautomation.bulk;
import de.ph87.homeautomation.property.PropertyWriter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Service
@Transactional
@RequiredArgsConstructor
public class BulkExecutor {
private final PropertyWriter propertyWriter;
public void execute(final Bulk bulk) {
if (!bulk.isEnabled()) {
log.info("Bulk disabled, not executing it: {}", bulk);
return;
}
log.info("Executing Bulk: {}", bulk);
bulk.getEntries().forEach(entry -> propertyWriter.writeToChannel(entry.getProperty(), entry.getValue()));
log.debug("Finished executing Bulk: {}", bulk);
}
}