@Component
public class ScheduledTasks {
- @Getter
- private ImportSummary importSummary;
-
- public ScheduledTasks() {
- log.info("ScheduledTasks created");
- }
-
@Autowired
private ServiceProperties serviceProperties;
@Autowired
private ScheduledSunriseChacker scheduledSunriseChacker;
+ @Getter
+ private ImportSummary importSummary;
+
+ @Getter
+ private String status;
+
@PostConstruct
public void scheduleTasks() {
//new CronTrigger("0 0 4 1/1 * ? *")
public void handleEvent(ImportStartedEvent evt) {
log.info("ImportStartedEvent handle");
importSummary = null;
+ status = String.format("Import from %s started", evt.getFileName());
}
@Async
public void handleEvent(ImportCompletedEvent evt) {
log.info("ImportCompletedEvent handle");
importSummary = evt.getSummary();
+ status = "Import completed";
}
}
private final ImportSummary summary;
- public ImportCompletedEvent(ImportSummary summary, Object source) {
+ public ImportCompletedEvent(Object source, ImportSummary summary) {
super(source);
this.summary = summary;
}
@Setter
public class ImportStartedEvent extends ApplicationEvent {
- public ImportStartedEvent(Object source) {
+ private String fileName;
+
+ public ImportStartedEvent(Object source, String fileName) {
super(source);
+ this.fileName = fileName;
}
}
@Override
public void run() {
- applicationEventPublisher.publishEvent(new ImportStartedEvent(this));
ImportSummary summary = null;
try {
- log.info("ScheduledImport started");
Optional<UploadFile> opUploadFile = uploadFileRepository.findFirstByOrderByCreatedDesc();
if (opUploadFile.isPresent()) {
+ log.info("ScheduledImport started from {}", opUploadFile.get().getName());
+ applicationEventPublisher.publishEvent(new ImportStartedEvent(this, opUploadFile.get().getName()));
summary = vodXlsProcessor.process(opUploadFile.get().getName(), opUploadFile.get().getFile());
}
} catch (Exception e) {
log.error("ScheduledImport error!", e);
} finally {
- applicationEventPublisher.publishEvent(new ImportCompletedEvent(summary, this));
+ applicationEventPublisher.publishEvent(new ImportCompletedEvent(this, summary));
log.info("ScheduledImport finished");
}
import hu.user.mcvodsync.db.repository.AssetSyncRepository;
import hu.user.mcvodsync.db.repository.PlaylistSyncRepository;
import hu.user.mcvodsync.db.repository.UploadFileRepository;
+import hu.user.mcvodsync.service.config.ScheduledTasks;
import hu.user.mcvodsync.ui.Constants;
import hu.user.mcvodsync.ui.auth.CurrentProfile;
import hu.user.mcvodsync.ui.session.SessionSettings;
@WireVariable
private UploadFileRepository uploadFileRepository;
+ @WireVariable
+ private ScheduledTasks scheduledTasks;
+
private String page;
@Init
log.info("Init {}", path);
}
+ @Command
+ public void onTimer() {
+ BindUtils.postNotifyChange(scheduledTasks, "status");
+ }
+
@Command
public void route(String path) {
if (Constants.NAV_ROOT.equals(path))
}
</script>
<window vflex="true" viewModel="@id('vm') @init('hu.user.mcvodsync.ui.view.IndexViewModel')">
+ <timer delay="2000" onTimer="@command('onTimer')" repeats="true"/>
<caption sclass="header" id="appHeader">
<div style="display: block">
<div style="display: inline; float: left">
<include src="@load(vm.page)" hflex="true" vflex="true"/>
</center>
<south height="50px">
- <hlayout>
- <div width="50px" height="50px" style="background: blue"></div>
- </hlayout>
+ <hbox pack="end" align="center" hflex="true" vflex="true">
+ <label style="font-size: 1.5em; padding-right: 20px; color: navy"
+ value="@load(vm.scheduledTasks.status)"/>
+ </hbox>
</south>
</borderlayout>
</window>