package com.commercetools;

import com.commercetools.pspadapter.payone.*;
import com.commercetools.pspadapter.payone.config.PropertyProvider;
import com.commercetools.pspadapter.payone.config.ServiceConfig;
import org.quartz.CronScheduleBuilder;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.MalformedURLException;

import static java.lang.String.format;

public class Main {

    private static final Logger LOG = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) throws SchedulerException, MalformedURLException {

        final PropertyProvider propertyProvider = new PropertyProvider();
        final ServiceConfig serviceConfig = new ServiceConfig(propertyProvider);

        final IntegrationService integrationService = ServiceFactory.createIntegrationService(propertyProvider, serviceConfig);
        integrationService.start();

        ScheduledJobFactory scheduledJobFactory = new ScheduledJobFactory();

        scheduledJobFactory.setAllScheduledItemsStartedListener(() ->
                LOG.info(format("%n%1$s%nPayone Integration Service is STARTED%n%1$s",
                "============================================================"))
        );

        scheduledJobFactory.createScheduledJob(
                CronScheduleBuilder.cronSchedule(serviceConfig.getScheduledJobCronForShortTimeFramePoll()),
                ScheduledJobShortTimeframe.class,
                integrationService);

        scheduledJobFactory.createScheduledJob(
                CronScheduleBuilder.cronSchedule(serviceConfig.getScheduledJobCronForLongTimeFramePoll()),
                ScheduledJobLongTimeframe.class,
                integrationService);
    }
}

@@ -375,16 +375,117 @@
 ption;%0A%0A
+import static com.commercetools.pspadapter.payone.config.PropertyProvider.PAYONE_INTEGRATOR_VERSION;%0A
 import s
@@ -1261,15 +1261,38 @@
 ED%25n
-%251$s%22,%0A
+Version: %252$s%25n%251$s%22,%0A        
     
@@ -1365,16 +1365,121 @@
 =======%22
+,%0A                        propertyProvider.getProperty(PAYONE_INTEGRATOR_VERSION).orElse(%22DEBUG-VERSION%22)
 ))%0A     

print build version on application start