package com.camunda.demo.customeronboarding;

import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.camunda.consulting.simulator.PayloadGenerator;
import com.camunda.consulting.simulator.SimulatorPlugin;
import com.camunda.demo.customeronboarding.DemoData.ContentGenerator;
import com.camunda.demo.customeronboarding.model.NewApplication;
import com.camunda.demo.sso.AutoLoginAuthenticationFilter;

@Configuration
public class StartConfiguration {
  
  @Bean(name="corporationMapper")
  public ExecutionListener getMapper () {
    return (execution) -> {
      NewApplication application = (NewApplication) execution.getVariable("application");
      execution.setVariable("corporation", application.getCorporation());
    };
  }
  
  @Bean
  public SimulatorPlugin simulatorPlugin() {
        return new SimulatorPlugin();
  }
  
  @Bean
  public PayloadGenerator generator() {
        return new ContentGenerator();
  }
  
  @Bean
  public FilterRegistrationBean<AutoLoginAuthenticationFilter> loggingFilter(){
      FilterRegistrationBean<AutoLoginAuthenticationFilter> registrationBean = new FilterRegistrationBean<>();
           
      registrationBean.setFilter(new AutoLoginAuthenticationFilter());
      registrationBean.addUrlPatterns("/*");
           
      return registrationBean;    
  }

}

@@ -96,24 +96,163 @@
 nListener;%0D%0A
+import org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0Aimport org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;%0D%0A
 import org.s
@@ -791,16 +791,109 @@
 ation %7B%0D
+%0A%0D%0A  private final static Logger LOGGER = LoggerFactory.getLogger(StartConfiguration.class);%0D
 %0A  %0D%0A  @
@@ -1194,50 +1194,213 @@
 %0D%0A  
-public SimulatorPlugin simulatorPlugin() %7B
+@ConditionalOnProperty(%0D%0A%09  value=%22shouldsimulate%22,%0D%0A%09  havingValue = %22true%22,%0D%0A%09  matchIfMissing = false)%0D%0A  public SimulatorPlugin simulatorPlugin() %7B%0D%0A%09  LOGGER.info(%22------LOAD SIMULATOR PLUGIN------%22);
 %0D%0A  
@@ -1433,34 +1433,32 @@
 Plugin();%0D%0A  %7D%0D%0A
-  
 %0D%0A  @Bean%0D%0A  pub
@@ -1458,45 +1458,209 @@
 %0D%0A  
-public PayloadGenerator generator() %7B
+@ConditionalOnProperty(%0D%0A%09  value=%22shouldsimulate%22,%0D%0A%09  havingValue = %22true%22,%0D%0A%09  matchIfMissing = false)%0D%0A  public PayloadGenerator generator() %7B%0D%0A%09  LOGGER.info(%22------LOAD PAYLOAD GENERATOR------%22);
 %0D%0A  
@@ -1694,34 +1694,32 @@
 erator();%0D%0A  %7D%0D%0A
-  
 %0D%0A  @Bean%0D%0A  pub

use conditional beans