package qa.qcri.aidr.trainer.pybossa.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import qa.qcri.aidr.common.logging.ErrorLog;
import qa.qcri.aidr.trainer.pybossa.service.ClientAppCreateWorker;
import qa.qcri.aidr.trainer.pybossa.service.ClientAppRunWorker;
import qa.qcri.aidr.trainer.pybossa.service.MicroMapperWorker;
import qa.qcri.aidr.trainer.pybossa.service.Worker;



/**
 * A synchronous worker
 */
@Component("syncWorker")
public class SyncWorker implements Worker {

	protected static Logger logger = Logger.getLogger(SyncWorker.class);
	private static ErrorLog elog = new ErrorLog();
	
    @Autowired
    ClientAppCreateWorker pybossaWorker;

    @Autowired
    private ClientAppRunWorker clientAppRunWorker;

    @Autowired
    private MicroMapperWorker microMapperWorker;

	public void work() {
		String threadName = Thread.currentThread().getName();
		//logger.debug("   " + threadName + " has began working.(SyncWorker - run ClientApps)");
        logger.info("Scheduler is starting");
        try {

            pybossaWorker.doCreateApp();
            clientAppRunWorker.processTaskPublish();
            clientAppRunWorker.processTaskRunImport();

            microMapperWorker.processTaskPublish();
            microMapperWorker.processTaskImport();
            microMapperWorker.processTaskExport();

            Thread.sleep(180000); // simulates work

        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (Exception e) {
            logger.error(elog.toStringException(e));
        }
        //logger.debug("   " + threadName + " has completed work.(SyncWorker - run ClientApps)");
        logger.info("Scheduler is going sleep");
    }
	
}

@@ -192,52 +192,8 @@
 t;%0A%0A
-import qa.qcri.aidr.common.logging.ErrorLog;
 %0Aimp
@@ -614,55 +614,8 @@
 s);%0A
-%09private static ErrorLog elog = new ErrorLog();
 %0A%09%0A 
@@ -884,98 +884,8 @@
 ();%0A
-%09%09//logger.debug(%22   %22 + threadName + %22 has began working.(SyncWorker - run ClientApps)%22);
 %0A   
@@ -1096,111 +1096,8 @@
 );%0A%0A
-            microMapperWorker.processTaskPublish();%0A            microMapperWorker.processTaskImport();%0A
     
@@ -1173,10 +1173,10 @@
 eep(
-18
+60
 0000
@@ -1358,142 +1358,34 @@
 or(e
-log.toStringException(e));%0A        %7D%0A        //logger.debug(%22   %22 + threadName + %22 has completed work.(SyncWorker - run ClientApps)%22);
+.getMessage());%0A        %7D%0A
 %0A   

add back code