
DELETE FROM CT_MRDS.A_FILE_MANAGER_CONFIG;
DELETE FROM CT_MRDS.A_SOURCE_FILE_RECEIVED;
DELETE FROM CT_MRDS.A_COLUMN_DATE_FORMAT;
DELETE FROM CT_MRDS.A_SOURCE_FILE_CONFIG;
DELETE FROM CT_MRDS.A_SOURCE;


INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('default', 'EnvironmentID','dev');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'Region',            'eu-frankfurt-1');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'NameSpace',         'frcnomajoc7v');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'InboxBucketName',   'mrds_inbox_tst');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'DataBucketName',    'mrds_data_tst');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'HistoryBucketName', 'mrds_history_tst');
--INSERT INTO A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'UriName',           'https://objectstorage.'||vpRegion||'.oraclecloud.com/n/'||vpNameSpace||'/b/'||vpDataBucketName||'/o/');
--INSERT INTO A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'DataBucketUri',     'https://objectstorage.'||vpRegion||'.oraclecloud.com/n/'||vpNameSpace||'/b/'||vpDataBucketName||'/o/');
--INSERT INTO A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'InboxBucketUri',    'http://dev.example.com/inboxBucket');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'CredentialName',    'OCI$RESOURCE_PRINCIPAL');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'LoggingEnabled',    'ON');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'MinLogLevel',       'DEBUG');
INSERT INTO CT_MRDS.A_FILE_MANAGER_CONFIG (environment_id, config_variable, config_variable_value) VALUES ('dev', 'DefaultDateFormat', 'DD/MM/YYYY HH24:MI:SS');
commit;

-- ISD
call CT_MRDS.FILE_MANAGER.ADD_SOURCE(pSourceKey => 'ISD', pSourceNAme => 'Integrated Surface Data');

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'ISD'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'IDS_DATA'
        ,pSourceFileDesc        => 'Yearly figures by station'
        ,pSourceFileNamePattern => '*.csv'
        ,pTableId               => 'IDS_DATA'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.IDS_DATA'
        );

-- LM
call CT_MRDS.FILE_MANAGER.ADD_SOURCE(pSourceKey => 'LM', pSourceNAme => 'LM');

-- STANDING_FACILITIES
call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
        pSourceKey              => 'LM'
        ,pSourceFileType        => 'CONTAINER'
        ,pSourceFileId          => 'STANDING_FACILITIES'
        ,pSourceFileDesc        => 'LM Standing facilities'
        ,pSourceFileNamePattern => '*.xml'
        ,pTableId               => null
        ,pTemplateTableName     => null
        ,pContainerFileKey      => null
        );
                
call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'LM'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'STANDING_FACILITIES'
        ,pSourceFileDesc        => 'LM Standing facilities header'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'STANDING_FACILITIES_HEADER'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.LM_STANDING_FACILITIES_HEADER'
        );

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'LM'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'STANDING_FACILITIES'
        ,pSourceFileDesc        => 'LM Standing facilities'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'STANDING_FACILITIES'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.LM_STANDING_FACILITIES'
        );

--
-- C2D
-- 

call CT_MRDS.FILE_MANAGER.ADD_SOURCE(pSourceKey => 'C2D', pSourceNAme => 'C2D');

-- UC_ACC
call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'UC_NMA_ACC'
        ,pSourceFileDesc        => 'UC NonMarketableAssets ACC'
        ,pSourceFileNamePattern => '*.csv'
        ,pTableId               => 'UC_NMA_ACC'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.C2D_UC_NMA_ACC'
        );


-- UC_DISSEM
call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'CONTAINER'
        ,pSourceFileId          => 'UC_DISSEM'
        ,pSourceFileDesc        => 'UC Dissemination'
        ,pSourceFileNamePattern => '*.xml'
        ,pTableId               => null
        ,pTemplateTableName     => null
        ,pContainerFileKey      => null
        );

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'UC_DISSEM'
        ,pSourceFileDesc        => 'UC Dissemination Metadata'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'A_UC_DISSEM_METADATA_LOADS'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.C2D_A_UC_DISSEM_METADATA_LOADS'
        );
        
call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'A_UC_DISSEM_METADATA_LOADS'
		,pColumnName   => 'SNAPSHOT_DATE'
		,pDateFormat   => 'YYYY-MM-DD'
		);

call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'A_UC_DISSEM_METADATA_LOADS'
		,pColumnName   => 'FILE_CREATION_DATE'
		,pDateFormat   => 'YYYY-MM-DD"T"HH24:MI:SS'
		);

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'UC_DISSEM'
        ,pSourceFileDesc        => 'UC MarketableAssets Dissemination'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'UC_MA_DISSEM'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.C2D_UC_MA_DISSEM'
        );
        
call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'UC_MA_DISSEM'
		,pColumnName   => 'SNAPSHOT_DATE'
		,pDateFormat   => 'YYYY-MM-DD'
		);

call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'UC_MA_DISSEM'
		,pColumnName   => 'FILE_CREATION_DATE'
		,pDateFormat   => 'YYYY-MM-DD"T"HH24:MI:SS'
		);

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'UC_DISSEM'
        ,pSourceFileDesc        => 'UC MarketableAssets Dissemination'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'UC_NMA_DISSEM'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.C2D_UC_NMA_DISSEM'
        );
        
call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'UC_NMA_DISSEM'
		,pColumnName   => 'SNAPSHOT_DATE'
		,pDateFormat   => 'YYYY-MM-DD'
		);

call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'UC_NMA_DISSEM'
		,pColumnName   => 'FILE_CREATION_DATE'
		,pDateFormat   => 'YYYY-MM-DD"T"HH24:MI:SS'
		);

call CT_MRDS.FILE_MANAGER.ADD_COLUMN_DATE_FORMAT(
		 pSourceFileId => 'UC_DISSEM'
		,pTableId      => 'UC_NMA_DISSEM'
		,pColumnName   => 'MATURITY_DATE'
		,pDateFormat   => 'YYYY-MM-DD'
		);

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'C2D'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'UC_DISSEM'
        ,pSourceFileDesc        => 'UC Additional Credit Claims'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'UC_ACC'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.C2D_UC_NMA_ACC'
        );
--
-- MDP
-- 
call CT_MRDS.FILE_MANAGER.ADD_SOURCE(pSourceKey => 'MDP', pSourceNAme => 'MDP');

call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'MDP'
        ,pSourceFileType        => 'INPUT'
        ,pSourceFileId          => 'BBG_EQUITY_OT'
        ,pSourceFileDesc        => 'Bloomberg Debt'
        ,pSourceFileNamePattern => '.*.csv'
        ,pTableId               => 'BBG_EQUITY_OT'
        ,pTemplateTableName     => 'CT_ET_TEMPLATES.ODS_MDP_BBG_EQUITY_OT'
        ,pContainerFileKey      => null
        );

-- LOAD_CONFIG     MDP
call CT_MRDS.FILE_MANAGER.ADD_SOURCE_FILE_CONFIG(
         pSourceKey             => 'MDP'
        ,pSourceFileType        => 'LOAD_CONFIG'
        ,pSourceFileId          => null
        ,pSourceFileDesc        => 'Reuters list ODS Cloud'
        ,pSourceFileNamePattern => '.*.txt'
        ,pTableId               => null
        ,pTemplateTableName     => null
        ,pContainerFileKey      => null
        );
