package com.solambda.swiffer.examples.templates;

import java.time.Duration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.solambda.swiffer.api.Decisions;
import com.solambda.swiffer.api.Input;
import com.solambda.swiffer.api.OnActivityCompleted;
import com.solambda.swiffer.api.OnSignalReceived;
import com.solambda.swiffer.api.OnTimerFired;
import com.solambda.swiffer.api.OnWorkflowStarted;
import com.solambda.swiffer.api.Output;
import com.solambda.swiffer.examples.ActivityDefinitions.ParseInteger;
import com.solambda.swiffer.examples.WorkflowDefinitions;
import com.solambda.swiffer.examples.WorkflowDefinitions.SimpleExampleWorkflowDefinition;

@SimpleExampleWorkflowDefinition
public class SimpleTemplate {

	private static final String TIMER_ID = "timer1";
	private static final Logger LOGGER = LoggerFactory.getLogger(SimpleTemplate.class);

	@OnWorkflowStarted
	public void onStart(final String stringToParse, final Decisions decideTo) {
		decideTo.startTimer(TIMER_ID, Duration.ofSeconds(3), stringToParse);
	}

	@OnActivityCompleted(ParseInteger.class)
	public void onParseInteger(@Output Integer output, @Input final String input, final Decisions decideTo) {
		LOGGER.info("Task correctly executed with result {}", output);
	}

	@OnTimerFired(TIMER_ID)
	public void timerFired(final String control, final Decisions decideTo) {
		LOGGER.info("Timer fired with control {}", control);
		decideTo.scheduleActivityTask(ParseInteger.class, control);
	}

	@OnSignalReceived(WorkflowDefinitions.SIGNAL_NAME)
	public void signalReceived(final String input, final Decisions decideTo) {
		LOGGER.info("Signal received with input  {}", input);
		decideTo.completeWorkflow(input);
	}

}

@@ -69,16 +69,48 @@
 uration;
+%0Aimport java.time.LocalDateTime;
 %0A%0Aimport
@@ -292,24 +292,74 @@
 yCompleted;%0A
+import com.solambda.swiffer.api.OnMarkerRecorded;%0A
 import com.s
@@ -529,24 +529,96 @@
 api.Output;%0A
+import com.solambda.swiffer.api.internal.decisions.DecisionTaskContext;%0A
 import com.s
@@ -939,16 +939,83 @@
 imer1%22;%0A
+    private static final String MARKER_NAME = %22timer-time-marker%22;%0A
 %09private
@@ -1376,32 +1376,61 @@
 al String input,
+ DecisionTaskContext context,
  final Decisions
@@ -1507,17 +1507,135 @@
 utput);%0A
-%09
+        LOGGER.info(%22Get recorded marker details %7B%7D%22, context.getMarkerDetails(MARKER_NAME, LocalDateTime.class));%0A    
 %7D%0A%0A%09@OnT
@@ -1783,16 +1783,135 @@
 ntrol);%0A
+        LocalDateTime dateTime = LocalDateTime.now();%0A        LOGGER.info(%22Record Marker with details %7B%7D%22, dateTime);%0A%0A
 %09%09decide
@@ -1962,16 +1962,69 @@
 control)
+%0A                .recordMarker(MARKER_NAME, dateTime)
 ;%0A%09%7D%0A%0A%09@
@@ -2245,10 +2245,172 @@
 t);%0A%09%7D%0A%0A
+%09@OnMarkerRecorded(MARKER_NAME)%0A    public void onMarkerRecorded(@Input LocalDateTime input) %7B%0A        LOGGER.info(%22Marker Recorded with input %7B%7D%22, input);%0A    %7D%0A
 %7D%0A

Fix #8 Extend Example with marker usage