Schedule notification after execution + Code Clean
This commit is contained in:
parent
7bd2e2f93d
commit
233aa2a821
@ -5,9 +5,9 @@ import {ScheduleEditorComponent} from "./pages/schedule/editor/schedule-editor.c
|
||||
import {DeviceListComponent} from "./pages/device/list/device-list.component";
|
||||
import {DeviceEditorComponent} from "./pages/device/editor/device-editor.component";
|
||||
import {PropertyListComponent} from "./pages/property/list/property-list.component";
|
||||
import {ChannelListComponent} from "./pages/channel-list/channel-list.component";
|
||||
import {BulkListComponent} from "./pages/bulk/bulk-list/bulk-list.component";
|
||||
import {BulkComponent} from "./pages/bulk/bulk/bulk.component";
|
||||
import {ChannelListComponent} from "./pages/channel/list/channel-list.component";
|
||||
import {BulkListComponent} from "./pages/bulk/list/bulk-list.component";
|
||||
import {BulkEditorComponent} from "./pages/bulk/editor/bulk-editor.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: 'Device', component: DeviceEditorComponent},
|
||||
@ -22,7 +22,7 @@ const routes: Routes = [
|
||||
{path: 'Schedule', component: ScheduleEditorComponent},
|
||||
{path: 'ScheduleList', component: ScheduleListComponent},
|
||||
|
||||
{path: 'Bulk', component: BulkComponent},
|
||||
{path: 'Bulk', component: BulkEditorComponent},
|
||||
{path: 'BulkList', component: BulkListComponent},
|
||||
|
||||
{path: '**', redirectTo: '/ScheduleList'},
|
||||
|
||||
@ -5,7 +5,7 @@ import {AppRoutingModule} from './app-routing.module';
|
||||
import {AppComponent} from './app.component';
|
||||
import {HttpClientModule} from "@angular/common/http";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {EditFieldComponent} from './shared/edit-field/edit-field.component';
|
||||
import {TextComponent} from './shared/text/text.component';
|
||||
import {ScheduleListComponent} from './pages/schedule/list/schedule-list.component';
|
||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||
import {NumberComponent} from './shared/number/number.component';
|
||||
@ -14,14 +14,14 @@ import {SearchComponent} from './shared/search/search.component';
|
||||
import {DeviceListComponent} from './pages/device/list/device-list.component';
|
||||
import {DeviceEditorComponent} from './pages/device/editor/device-editor.component';
|
||||
import {PropertyListComponent} from './pages/property/list/property-list.component';
|
||||
import {ChannelListComponent} from './pages/channel-list/channel-list.component';
|
||||
import {BulkListComponent} from './pages/bulk/bulk-list/bulk-list.component';
|
||||
import {BulkComponent} from './pages/bulk/bulk/bulk.component';
|
||||
import {ChannelListComponent} from './pages/channel/list/channel-list.component';
|
||||
import {BulkListComponent} from './pages/bulk/list/bulk-list.component';
|
||||
import {BulkEditorComponent} from './pages/bulk/editor/bulk-editor.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
EditFieldComponent,
|
||||
TextComponent,
|
||||
ScheduleEditorComponent,
|
||||
ScheduleListComponent,
|
||||
NumberComponent,
|
||||
@ -32,7 +32,7 @@ import {BulkComponent} from './pages/bulk/bulk/bulk.component';
|
||||
ChannelListComponent,
|
||||
DeviceListComponent,
|
||||
BulkListComponent,
|
||||
BulkComponent,
|
||||
BulkEditorComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<ng-container *ngIf="bulk">
|
||||
<h1>
|
||||
<app-edit-field [initial]="bulk.name" (valueChange)="set(bulk, 'name', $event)"></app-edit-field>
|
||||
<app-text [initial]="bulk.name" (valueChange)="set(bulk, 'name', $event)"></app-text>
|
||||
</h1>
|
||||
<table>
|
||||
<tr>
|
||||
@ -7,11 +7,11 @@ import {BulkEntry} from "../../../api/bulk/BulkEntry";
|
||||
import {faTimesCircle} from "@fortawesome/free-regular-svg-icons";
|
||||
|
||||
@Component({
|
||||
selector: 'app-bulk',
|
||||
templateUrl: './bulk.component.html',
|
||||
styleUrls: ['./bulk.component.less']
|
||||
selector: 'app-bulk-editor',
|
||||
templateUrl: './bulk-editor.component.html',
|
||||
styleUrls: ['./bulk-editor.component.less']
|
||||
})
|
||||
export class BulkComponent implements OnInit {
|
||||
export class BulkEditorComponent implements OnInit {
|
||||
|
||||
readonly faTimes = faTimesCircle;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ChannelService} from "../../api/channel/channel.service";
|
||||
import {Channel, KnxGroup, Logic} from "../../api/channel/Channel";
|
||||
import {Update} from "../../api/Update";
|
||||
import {ChannelService} from "../../../api/channel/channel.service";
|
||||
import {Channel, KnxGroup, Logic} from "../../../api/channel/Channel";
|
||||
import {Update} from "../../../api/Update";
|
||||
|
||||
@Component({
|
||||
selector: 'app-channel-list',
|
||||
@ -7,7 +7,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<app-edit-field [initial]="deviceSwitch.title" (valueChange)="set('title', $event)"></app-edit-field>
|
||||
<app-text [initial]="deviceSwitch.title" (valueChange)="set('title', $event)"></app-text>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -24,7 +24,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<app-edit-field [initial]="deviceStateScene.title" (valueChange)="set('title', $event)"></app-edit-field>
|
||||
<app-text [initial]="deviceStateScene.title" (valueChange)="set('title', $event)"></app-text>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -47,7 +47,7 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td>
|
||||
<app-edit-field [initial]="deviceShutter.title" (valueChange)="set('title', $event)"></app-edit-field>
|
||||
<app-text [initial]="deviceShutter.title" (valueChange)="set('title', $event)"></app-text>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<app-edit-field [initial]="property.title" (valueChange)="edit(property, 'title', $event)"></app-edit-field>
|
||||
<app-text [initial]="property.title" (valueChange)="edit(property, 'title', $event)"></app-text>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<tr class="header">
|
||||
<ng-container *ngTemplateOutlet="boolean;context:{schedule: schedule, value: schedule.enabled, key:'enabled'}"></ng-container>
|
||||
<td colspan="24">
|
||||
<app-edit-field [initial]="schedule.title" (valueChange)="set(null, 'title', $event)"></app-edit-field>
|
||||
<app-text [initial]="schedule.title" (valueChange)="set(null, 'title', $event)"></app-text>
|
||||
</td>
|
||||
</tr>
|
||||
<tr [class.disabled]="!schedule.enabled">
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-field',
|
||||
templateUrl: './edit-field.component.html',
|
||||
styleUrls: ['./edit-field.component.less']
|
||||
selector: 'app-text',
|
||||
templateUrl: './text.component.html',
|
||||
styleUrls: ['./text.component.less']
|
||||
})
|
||||
export class EditFieldComponent implements OnInit {
|
||||
export class TextComponent implements OnInit {
|
||||
|
||||
@ViewChild('input')
|
||||
input?: ElementRef;
|
||||
@ -1,10 +1,7 @@
|
||||
package de.ph87.homeautomation.schedule;
|
||||
|
||||
import de.ph87.homeautomation.schedule.entry.ScheduleEntry;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashSet;
|
||||
@ -14,6 +11,7 @@ import java.util.Set;
|
||||
@Setter
|
||||
@ToString
|
||||
@Entity
|
||||
@NoArgsConstructor
|
||||
public class Schedule {
|
||||
|
||||
@Id
|
||||
@ -30,4 +28,8 @@ public class Schedule {
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "schedule")
|
||||
private Set<ScheduleEntry> entries = new HashSet<>();
|
||||
|
||||
public Schedule(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,6 +33,8 @@ public class ScheduleCalculator {
|
||||
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
private final ScheduleMapper scheduleMapper;
|
||||
|
||||
@EventListener(ApplicationStartedEvent.class)
|
||||
public void calculateAllNext() {
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
@ -40,7 +42,7 @@ public class ScheduleCalculator {
|
||||
}
|
||||
|
||||
public void calculateSchedule(final Schedule schedule, final ZonedDateTime now) {
|
||||
schedule.getEntries().forEach(scheduleEntry -> calculateEntry(schedule, scheduleEntry, now));
|
||||
schedule.getEntries().forEach(entry -> calculateEntry(schedule, entry, now));
|
||||
final Optional<ScheduleEntry> nextEntry = schedule.getEntries().stream()
|
||||
.filter(entry -> entry.getNextFuzzyTimestamp() != null && entry.getNextFuzzyTimestamp().isAfter(now))
|
||||
.min(Comparator.comparing(ScheduleEntry::getNextFuzzyTimestamp));
|
||||
@ -50,6 +52,7 @@ public class ScheduleCalculator {
|
||||
log.info("Next schedule for \"{}\": {}", schedule.getTitle(), nextEntry.get().getNextFuzzyTimestamp());
|
||||
}
|
||||
applicationEventPublisher.publishEvent(new ScheduleThreadWakeUpEvent());
|
||||
scheduleMapper.publish(schedule, true);
|
||||
}
|
||||
|
||||
private void calculateEntry(final Schedule schedule, final ScheduleEntry entry, final ZonedDateTime now) {
|
||||
|
||||
@ -15,40 +15,40 @@ import java.util.Comparator;
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class ScheduleExecutionService {
|
||||
public class ScheduleExecutor {
|
||||
|
||||
private final ScheduleReader scheduleReader;
|
||||
|
||||
private final ScheduleCalculator scheduleCalculator;
|
||||
|
||||
private final PropertyWriteService propertyWriteService;
|
||||
private final PropertyWriteService propertyWriter;
|
||||
|
||||
private final BulkExecutor bulkExecutor;
|
||||
|
||||
private final ScheduleWriter scheduleWriter;
|
||||
|
||||
public void executeAllLastDue() {
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
scheduleReader.findAll().forEach(schedule -> executeLastDue(schedule, now));
|
||||
scheduleReader.findAll().forEach(this::executeLastDue);
|
||||
}
|
||||
|
||||
private void executeLastDue(final Schedule schedule, final ZonedDateTime now) {
|
||||
private void executeLastDue(final Schedule schedule) {
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
schedule.getEntries().stream()
|
||||
.filter(entry -> entry.getNextFuzzyTimestamp() != null && !entry.getNextFuzzyTimestamp().isAfter(now))
|
||||
.max(Comparator.comparing(ScheduleEntry::getNextFuzzyTimestamp))
|
||||
.ifPresent(entry -> executeEntry(schedule, entry, now));
|
||||
.ifPresent(entry -> executeEntry(schedule, entry));
|
||||
}
|
||||
|
||||
private void executeEntry(final Schedule schedule, final ScheduleEntry entry, final ZonedDateTime now) {
|
||||
private void executeEntry(final Schedule schedule, final ScheduleEntry entry) {
|
||||
log.info("Executing Schedule \"{}\" Entry {}", schedule.getTitle(), entry);
|
||||
entry.setLastClearTimestamp(entry.getNextClearTimestamp());
|
||||
scheduleCalculator.calculateSchedule(schedule, now);
|
||||
if (entry.getProperty() != null) {
|
||||
log.debug("Schedule setting property: {} = {}", entry.getProperty().getTitle(), entry.getValue());
|
||||
propertyWriteService.writeToChannel(entry.getProperty(), entry.getValue());
|
||||
propertyWriter.writeToChannel(entry.getProperty(), entry.getValue());
|
||||
}
|
||||
if (entry.getBulk() != null) {
|
||||
log.debug("Schedule executing Bulk: {}", entry.getBulk());
|
||||
bulkExecutor.execute(entry.getBulk());
|
||||
}
|
||||
entry.setLastClearTimestamp(entry.getNextClearTimestamp());
|
||||
scheduleWriter.notifyChanged(schedule);
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@ import java.time.ZonedDateTime;
|
||||
@RequiredArgsConstructor
|
||||
public class ScheduleThreadService extends AbstractThreadService {
|
||||
|
||||
private final ScheduleExecutionService scheduleExecutionService;
|
||||
private final ScheduleExecutor scheduleExecutor;
|
||||
|
||||
private final ScheduleEntryReader scheduleEntryReader;
|
||||
|
||||
@ -25,13 +25,13 @@ public class ScheduleThreadService extends AbstractThreadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception {
|
||||
protected void doStart() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long doStep() throws InterruptedException {
|
||||
scheduleExecutionService.executeAllLastDue();
|
||||
protected long doStep() {
|
||||
scheduleExecutor.executeAllLastDue();
|
||||
return scheduleEntryReader.getNextTimestamp().map(nextTimestamp -> Duration.between(ZonedDateTime.now(), nextTimestamp).toMillis()).orElse(0L);
|
||||
}
|
||||
|
||||
|
||||
@ -25,9 +25,9 @@ public class ScheduleWriter {
|
||||
private final ScheduleRepository scheduleRepository;
|
||||
|
||||
public ScheduleDto create() {
|
||||
final Schedule entry = new Schedule();
|
||||
entry.setTitle(generateUnusedName());
|
||||
return scheduleMapper.publish(scheduleRepository.save(entry), true);
|
||||
final Schedule schedule = scheduleRepository.save(new Schedule(generateUnusedName()));
|
||||
notifyChanged(schedule);
|
||||
return scheduleMapper.toDto(schedule);
|
||||
}
|
||||
|
||||
private String generateUnusedName() {
|
||||
@ -42,14 +42,17 @@ public class ScheduleWriter {
|
||||
public <T> ScheduleDto set(final long id, final BiConsumer<Schedule, T> setter, final T value) {
|
||||
final Schedule schedule = scheduleReader.getById(id);
|
||||
setter.accept(schedule, value);
|
||||
scheduleCalculator.calculateSchedule(schedule, ZonedDateTime.now());
|
||||
return scheduleMapper.publish(schedule, true);
|
||||
notifyChanged(schedule);
|
||||
return scheduleMapper.toDto(schedule);
|
||||
}
|
||||
|
||||
public void delete(final long id) {
|
||||
final Schedule schedule = scheduleReader.getById(id);
|
||||
scheduleRepository.delete(schedule);
|
||||
scheduleMapper.publish(schedule, false);
|
||||
}
|
||||
|
||||
public void notifyChanged(final Schedule schedule) {
|
||||
scheduleCalculator.calculateSchedule(schedule, ZonedDateTime.now());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,17 +3,14 @@ package de.ph87.homeautomation.schedule.entry;
|
||||
import de.ph87.homeautomation.bulk.BulkReader;
|
||||
import de.ph87.homeautomation.property.PropertyReader;
|
||||
import de.ph87.homeautomation.schedule.Schedule;
|
||||
import de.ph87.homeautomation.schedule.ScheduleCalculator;
|
||||
import de.ph87.homeautomation.schedule.ScheduleMapper;
|
||||
import de.ph87.homeautomation.schedule.ScheduleReader;
|
||||
import de.ph87.homeautomation.schedule.ScheduleWriter;
|
||||
import de.ph87.homeautomation.web.BadRequestException;
|
||||
import de.ph87.homeautomation.web.WebSocketService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -31,36 +28,33 @@ public class ScheduleEntryWriter {
|
||||
|
||||
private final ScheduleReader scheduleReader;
|
||||
|
||||
private final ScheduleCalculator scheduleCalculationService;
|
||||
|
||||
private final ScheduleEntryMapper scheduleEntryMapper;
|
||||
|
||||
private final ScheduleEntryRepository scheduleEntryRepository;
|
||||
|
||||
private final WebSocketService webSocketService;
|
||||
|
||||
private final ScheduleMapper scheduleMapper;
|
||||
|
||||
private final PropertyReader propertyReader;
|
||||
|
||||
private final BulkReader bulkReader;
|
||||
|
||||
private final ScheduleWriter scheduleWriter;
|
||||
|
||||
public ScheduleEntryDto create(final long scheduleId) {
|
||||
final Schedule schedule = scheduleReader.getById(scheduleId);
|
||||
final ScheduleEntry entry = scheduleEntryRepository.save(new ScheduleEntry(schedule));
|
||||
schedule.getEntries().add(entry);
|
||||
return publish(entry, true, true);
|
||||
scheduleWriter.notifyChanged(schedule);
|
||||
return scheduleEntryMapper.toDto(entry);
|
||||
}
|
||||
|
||||
private <T> ScheduleEntryDto setValue(final long id, final BiConsumer<ScheduleEntry, T> setter, final T value) {
|
||||
private <T> ScheduleEntryDto modifyValue(final long id, final BiConsumer<ScheduleEntry, T> setter, final T value) {
|
||||
return modify(id, entry -> setter.accept(entry, value));
|
||||
}
|
||||
|
||||
private ScheduleEntryDto modify(final long id, final Consumer<ScheduleEntry> setter) {
|
||||
final ScheduleEntry entry = scheduleEntryReader.getById(id);
|
||||
setter.accept(entry);
|
||||
scheduleCalculationService.calculateSchedule(entry.getSchedule(), ZonedDateTime.now());
|
||||
return publish(entry, true, true);
|
||||
scheduleWriter.notifyChanged(entry.getSchedule());
|
||||
return scheduleEntryMapper.toDto(entry);
|
||||
}
|
||||
|
||||
public void delete(final long id) {
|
||||
@ -68,7 +62,7 @@ public class ScheduleEntryWriter {
|
||||
setPosition(entry, entry.getSchedule().getEntries().size() - 1);
|
||||
entry.getSchedule().getEntries().remove(entry);
|
||||
scheduleEntryRepository.delete(entry);
|
||||
publish(entry, false, true);
|
||||
scheduleWriter.notifyChanged(entry.getSchedule());
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setPosition(final long id, final int newPosition) {
|
||||
@ -81,71 +75,71 @@ public class ScheduleEntryWriter {
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setEnabled(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setEnabled, value);
|
||||
return modifyValue(id, ScheduleEntry::setEnabled, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setMonday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setMonday, value);
|
||||
return modifyValue(id, ScheduleEntry::setMonday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setTuesday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setTuesday, value);
|
||||
return modifyValue(id, ScheduleEntry::setTuesday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setWednesday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setWednesday, value);
|
||||
return modifyValue(id, ScheduleEntry::setWednesday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setThursday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setThursday, value);
|
||||
return modifyValue(id, ScheduleEntry::setThursday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setFriday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setFriday, value);
|
||||
return modifyValue(id, ScheduleEntry::setFriday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setSaturday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setSaturday, value);
|
||||
return modifyValue(id, ScheduleEntry::setSaturday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setSunday(final long id, final boolean value) {
|
||||
return setValue(id, ScheduleEntry::setSunday, value);
|
||||
return modifyValue(id, ScheduleEntry::setSunday, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setType(final long id, final ScheduleEntryType value) {
|
||||
return setValue(id, ScheduleEntry::setType, value);
|
||||
return modifyValue(id, ScheduleEntry::setType, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setZenith(final long id, final double value) {
|
||||
return setValue(id, ScheduleEntry::setZenith, value);
|
||||
return modifyValue(id, ScheduleEntry::setZenith, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setHour(final long id, final int value) {
|
||||
return setValue(id, ScheduleEntry::setHour, value);
|
||||
return modifyValue(id, ScheduleEntry::setHour, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setMinute(final long id, final int value) {
|
||||
return setValue(id, ScheduleEntry::setMinute, value);
|
||||
return modifyValue(id, ScheduleEntry::setMinute, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setSecond(final long id, final int value) {
|
||||
return setValue(id, ScheduleEntry::setSecond, value);
|
||||
return modifyValue(id, ScheduleEntry::setSecond, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setFuzzySeconds(final long id, final int value) {
|
||||
return setValue(id, ScheduleEntry::setFuzzySeconds, value);
|
||||
return modifyValue(id, ScheduleEntry::setFuzzySeconds, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setValue(final long id, final double value) {
|
||||
return setValue(id, ScheduleEntry::setValue, value);
|
||||
return modifyValue(id, ScheduleEntry::setValue, value);
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setProperty(final long id, final Long propertyId) {
|
||||
return setValue(id, ScheduleEntry::setProperty, propertyId == null ? null : propertyReader.getById(propertyId));
|
||||
return modifyValue(id, ScheduleEntry::setProperty, propertyId == null ? null : propertyReader.getById(propertyId));
|
||||
}
|
||||
|
||||
public ScheduleEntryDto setBulk(final long id, final Long bulkId) {
|
||||
return setValue(id, ScheduleEntry::setBulk, bulkId == null ? null : bulkReader.getById(bulkId));
|
||||
return modifyValue(id, ScheduleEntry::setBulk, bulkId == null ? null : bulkReader.getById(bulkId));
|
||||
}
|
||||
|
||||
private void setPosition(final ScheduleEntry entry, final int newPosition) {
|
||||
@ -158,19 +152,9 @@ public class ScheduleEntryWriter {
|
||||
for (final ScheduleEntry e : entry.getSchedule().getEntries()) {
|
||||
if (e.getPosition() >= min && e.getPosition() <= max) {
|
||||
e.setPosition(e.getPosition() + diff);
|
||||
publish(e, true, false);
|
||||
}
|
||||
}
|
||||
entry.setPosition(newPosition);
|
||||
}
|
||||
|
||||
private ScheduleEntryDto publish(final ScheduleEntry entry, final boolean existing, final boolean publishSchedule) {
|
||||
final ScheduleEntryDto dto = scheduleEntryMapper.toDto(entry);
|
||||
webSocketService.send(ScheduleEntryDto.class, dto, existing);
|
||||
if (publishSchedule) {
|
||||
scheduleMapper.publish(entry.getSchedule(), true);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user