28 lines
774 B
Java
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);
|
|
}
|
|
|
|
}
|