/***************************************************************************
                   Job Data Base Class  ( JobData.cpp )
                -----------------------------------------

	begin      : 2013/02/27
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
					- 2013/02/27 - 1st dadamin
	email      : dev1@solbox.com
	version    : 3.2.0

	CopyRight(C) 2005 Solbox Inc. All Rights reserved.
	Redistribution and use in source and binary forms, with or with out
	modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#include "rc_mngd.h"
#include "JobData.h"
#include "Logger.h"
#include "Job.h"
#include "ServiceOpen.h"
#include "ServiceChange.h"
#include "VolumeInfo.h"
#include "AnonymousDir.h"
#include "FileControl.h"


// Abstract Factory returning a Job
CJob * CJobFactory::CreateJob(CJobDataMap &jobMap)
{
	CJob * r = NULL;

	_LOG( LDBG, "Job Factory [%s]",jobMap[KEY_JOB_TYPE].c_str());

	if( jobMap[KEY_JOB_TYPE].compare(JOB_SERVICE_OPEN) == 0 )
	{
		r = new CServiceOpen;
	}
	else if( jobMap[KEY_JOB_TYPE].compare(JOB_SERVICE_CHANGE) == 0 )
	{
		r = new CServiceChange;
	}
	else if( jobMap[KEY_JOB_TYPE].compare(JOB_VOLUME_INFO) == 0 )
	{
		r = new CVolumeInfo;
	}
	else if( jobMap[KEY_JOB_TYPE].compare(JOB_ANONY_DIR) == 0 )
	{
		r = new CAnonymousDir;
	}
	else if( jobMap[KEY_JOB_TYPE].compare(JOB_FILE_CTL) == 0 )
	{
		r = new CFileControl;
	}
	else 
	{
		r = NULL;
		LOG(LERR, "Job type is unknown.");
	}

	return r;
}

