Skip to content

Commit

Permalink
added manual interaction completed event trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
alex9849 committed Nov 25, 2023
1 parent 71a2f23 commit 5173b40
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public enum EventTrigger {
COCKTAIL_PRODUCTION_STARTED, COCKTAIL_PRODUCTION_MANUAL_INTERACTION_REQUESTED,
COCKTAIL_PRODUCTION_MANUAL_INTERACTION_COMPLETED,
COCKTAIL_PRODUCTION_FINISHED, COCKTAIL_PRODUCTION_CANCELED,
APPLICATION_STARTUP;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@Transactional
public class CocktailOrderService {
private CocktailFactory cocktailFactory;
private CocktailProgress prevCocktailProgress;

private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

Expand Down Expand Up @@ -84,6 +85,7 @@ private void onCocktailProgressSubscriptionChange(CocktailProgress progress) {
if(progress.getState() == CocktailProgress.State.CANCELLED || progress.getState() == CocktailProgress.State.FINISHED) {
this.scheduler.schedule(() -> {
this.cocktailFactory = null;
this.prevCocktailProgress = null;
this.webSocketService.broadcastCurrentCocktailProgress(null);
this.pumpUpService.reschedulePumpBack();
}, 5000, TimeUnit.MILLISECONDS);
Expand All @@ -107,6 +109,15 @@ private void onCocktailProgressSubscriptionChange(CocktailProgress progress) {
eventService.triggerActions(EventTrigger.COCKTAIL_PRODUCTION_FINISHED);
break;
}
if(prevCocktailProgress != null) {
if(prevCocktailProgress.getState() == CocktailProgress.State.MANUAL_ACTION_REQUIRED
|| prevCocktailProgress.getState() == CocktailProgress.State.MANUAL_INGREDIENT_ADD) {
if(progress.getState() == CocktailProgress.State.RUNNING) {
eventService.triggerActions(EventTrigger.COCKTAIL_PRODUCTION_MANUAL_INTERACTION_COMPLETED);
}
}
}
prevCocktailProgress = progress;
}

public FeasibilityFactory checkFeasibility(Recipe recipe, CocktailOrderConfiguration orderConfig) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/de/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ export default {
event_action_trigger_display_names: {
cocktail_prod_started: 'Cocktail-Produktion gestartet',
cocktail_prod_manual_interaction_requested: 'Manuelle Interaktion bei Cocktail-Produktion angefordert',
cocktail_prod_manual_interaction_completed: 'Manuelle Interaktion bei Cocktail-Produktion abgeschlossen',
cocktail_prod_finished: 'Cocktail-Produktion beendet',
cocktail_prod_canceled: 'Cocktail-Produktion abgebrochen',
application_started: 'Anwendung gestartet'
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/en_US/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ export default {
event_action_trigger_display_names: {
cocktail_prod_started: 'Cocktail production started',
cocktail_prod_manual_interaction_requested: 'Cocktail production manual interaction requested',
cocktail_prod_manual_interaction_completed: 'Cocktail production manual interaction completed',
cocktail_prod_finished: 'Cocktail production finished',
cocktail_prod_canceled: 'Cocktail production canceled',
application_started: 'Application started'
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/mixins/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export const eventActionTriggerDisplayNames = {
}, {
label: this.$t('constants.event_action_trigger_display_names.cocktail_prod_manual_interaction_requested'),
value: 'COCKTAIL_PRODUCTION_MANUAL_INTERACTION_REQUESTED'
}, {
label: this.$t('constants.event_action_trigger_display_names.cocktail_prod_manual_interaction_completed'),
value: 'COCKTAIL_PRODUCTION_MANUAL_INTERACTION_COMPLETED'
}, {
label: this.$t('constants.event_action_trigger_display_names.cocktail_prod_finished'),
value: 'COCKTAIL_PRODUCTION_FINISHED'
Expand Down

0 comments on commit 5173b40

Please sign in to comment.