IHMConfigClass.php 6.71 KB
<?php

/**
 * @class IHMConfigClass
 * @brief Class that's contain all specific configuration of the IHM client
 * @details
 */
class IHMConfigClass
{
	private static $genericDataDir = "generic_data/";

	private static $functionsDir   = "Functions/";
	
	private static $constantsFile  = "constants.xml";

	private static $functionsFile  = "functions.xml";
	
	private static $paramTemplateDir = "LocalData/ParamTemplate/";

	private static $paramTemplateFile = "ParamTemplateList.xml";
	
	private static $paramTemplateGenerateDir = "generateTemplateParams";
	
	private static $dataDir        = "data/";

	private static $compilationDir = "compilation/";

	private static $storedRequestDir = "REQ/";

	private static $requestDir     = "RES/";

	private static $sharedDir      = "shared_data/";
	
	private static $sharedTreeFile = "SharedObjectTree.xml";

	private static $ttDir          = "TT/";

	private static $wsDir          = "WS/";
	
	private static $downloadTmp    = "DOWNLOAD.TEMP/";

	private static $jobsDir        = "JOBS/";
	
	private static $localBaseDir   = "DATA/";

	private static $aliasesFile    = "Alias.xml";

	private static $wsInfoFile       = "WS_info.json";

	private static $processMgrFile = "processManager.xml";

	private static $migrationBackupDir = "MIGRATION_BACKUP/";

	private static $jobsMgrFile = "jobs.xml";
	
	private static $userParamMgrFile = "WsParams.xml";

	private static $userRequestMgrFile  = "Request.xml";

	private static $localTreeFile = "LocalParams.xml";

	private static $userName;
	
	private static $userHost;
	
	public static $remoteDataDir = "RemoteData/";
				
	public static function setUserName($userName)
	{
		self::$userName = $userName;
	}

	public static function getUserName()
	{
		return self::$userName;
	}
	
	public static function setUserHost($userHost)
	{
		self::$userHost = $userHost;
	}

	public static function getUserHost()
	{
		return self::$userHost;
	}
	
	public static function getDataDir()
	{
		return IHM_SRC_DIR."/".self::$dataDir.'/';
	}
	
	public static function getRelativeResultPath()
	{
		$userPath = self::$dataDir."/".self::$userName.'/'.self::$requestDir;
 
		return $userPath;
	}
	
	public static function getUserPath()
	{
		$userPath = self::getDataDir().self::$userName.'/';

		if (!is_dir($userPath))
			mkdir($userPath);
			
		return $userPath;
	}

	public static function getUserWSInfoFilePath()
	{
		return self::getUserPath().self::$wsInfoFile;
	}

	public static function getProcessManagerFilePath()
	{
		return self::getDataDir().self::$processMgrFile;
	}

	public static function getMigrationBackupPath($version)
	{
		$backupPath = self::getDataDir().self::$migrationBackupDir;
		if (!is_dir($backupPath))
			mkdir($backupPath);
		$backupPath .= ("".$version."/");
		if (!is_dir($backupPath))
			mkdir($backupPath);
		$backupPath .= (self::$userName.'/');
		if (!is_dir($backupPath))
			mkdir($backupPath);
		return $backupPath;
	}
	
	public static function getGenericDataPath()
	{
		return IHM_SRC_DIR."/".self::$genericDataDir."/";
	}
	
	public static function getConstantsFilePath()
	{
		return self::getGenericDataPath().self::$functionsDir.self::$constantsFile;
	}

	public static function getFunctionsFilePath()
	{
		return self::getGenericDataPath().self::$functionsDir.self::$functionsFile;
	}
	
	public static function getParamTemplateFilePath($fileName)
	{
		return self::getGenericDataPath().self::$paramTemplateDir.$fileName.".xml";
	}
	
	public static function getTemplateParamGeneratePath()
	{
		return self::getUserPath().self::$paramTemplateGenerateDir;
	}
	
	public static function getDownloadTmpPath()
	{
		return self::getUserPath().self::$downloadTmp;
	}
	
	public static function getParamTemplateListFilePath()
	{
		return self::getGenericDataPath().self::$paramTemplateDir.self::$paramTemplateFile;
	}
	
	public static function getUserParamManagerFilePath()
	{
		return self::getUserWSPath().self::$userParamMgrFile;
	}

	public static function getUserRequestManagerFilePath()
	{
		return self::getUserWSPath().self::$userRequestMgrFile;
	}
	
	public static function getUserDerivedParamFilePath($paramId)
	{
		return self::getUserWSPath().$paramId.".xml";
	}
	
	public static function getUserUploadedParamFilePath($paramId)
	{
		return self::getUserWSPath().$paramId.".xml";
	}

	public static function getLocalParamDBPath()
	{
		return PARAMS_LOCALDB_DIR;
	}
	
	public static function getLocalParamInfoPath()
	{
		return PARAMS_LOCALINFO_DIR;
	}

	public static function getSharedPath()
	{
		return IHM_SRC_DIR.'/'.self::$sharedDir;
	}
	
	public static function getSharedTreeFilePath()
	{
		return self::getSharedPath().self::$sharedTreeFile;
	}

	public static function getUserTTPath()
	{
		return self::getUserPath().self::$ttDir;
	}

	public static function getUserWSPath()
	{
		return self::getUserPath().self::$wsDir;
	}

	public static function getUserJobsPath()
	{
		$jobsPath = self::getUserPath().self::$jobsDir;

		if (!is_dir($jobsPath))
			mkdir($jobsPath,0755);

		return $jobsPath;
	}

	public static function getUserJobsFile()
	{
		return self::getUserJobsPath().self::$jobsMgrFile;
	}


	public static function getUserAliasesFilePath()
	{
		return self::getUserWSPath().self::$aliasesFile;
	}

	public static function getUserLocalTreePath()
	{
		return self::getUserWSPath().self::$localTreeFile;
	}

	public static function getCompilationPath()
	{
		$compilationPath = self::getUserPath().self::$compilationDir;

		if (!is_dir($compilationPath))
		{
			if (mkdir($compilationPath))
			{
				mkdir($compilationPath."src/");
				mkdir($compilationPath."lib/");
			}
		}
			
		return $compilationPath;
	}

	public static function getLocalBasePath()
	{
		$localBasePath = self::getUserPath().self::$localBaseDir;
		
		if (!is_dir($localBasePath))
			mkdir($localBasePath);
			
		return $localBasePath;
	}
	
	public static function getRemoteParamsFile()
	{
		$remoteBasePath = self::getUserPath().self::$wsDir;
				 			
		return $remoteBasePath.'RemoteParams.xml';
	}
			
	public static function getRequestPath()
	{
		$requestPath = self::getUserPath().self::$requestDir;

		if (!is_dir($requestPath))
			mkdir($requestPath);
			
		return $requestPath;
	}

	public static function getStoredRequestPath()
	{
		$storedRequestPath = self::getUserPath().self::$storedRequestDir;

		if (!is_dir($storedRequestPath))
			mkdir($storedRequestPath);

		return $storedRequestPath;
	}
	
	public static function getRemoteDataPath()
	{
		$remoteDataPath = self::getGenericDataPath().self::$remoteDataDir;
		
		return $remoteDataPath;
	}
	
}

?>