-- REMEMBER TO TO REGISTER THE FOLLOWING VOCABULARY (the TOAS):
-- f9b99dfb-ddd3-4fe1-8ee5-5c7acc5fc901_Vm9jYWJ1bGFyeURTUmVzb3VyY2VzL1ZvY2FidWxhcnlEU1Jlc291cmNlVHlwZQ==
--  and then launch the consistency workflow to update class/scheme into the database

INSERT INTO datasources (
	id,
	officialname,
	englishname,
	websiteurl,
	logourl,
	contactemail,
	namespaceprefix,
	collectedfrom,
	datasourceclass,
	_dnet_resource_identifier_
) VALUES (
	'openaire____::corda_h2020',
	'CORDA - COmmon Research DAta Warehouse - Horizon 2020',
	'CORDA - COmmon Research DAta Warehouse - Horizon 2020',
	'http://ec.europa.eu/programmes/horizon2020/',
	'http://ec.europa.eu/programmes/horizon2020/sites/horizon2020/themes/h2020/images/bannerEmptyH2020.jpg',
	'ec-fp7-it-helpdesk@ec.europa.eu',
	'corda__h2020',
	'infrastruct_::openaire',
	'entityregistry',
	'openaire____::corda_h2020'
);

INSERT INTO api (
	id,
	protocolclass,
	datasource,
	_dnet_resource_identifier_,
	typologyclass,
	compatibilityclass
) VALUES (
	'openaire____::corda_h2020::0',
	'filesystem',
	'openaire____::corda_h2020',
	'openaire____::corda_h2020::0',
	'entityregistry',
	'native'
);

INSERT INTO apicollections (
	param,
	original,
	api,
	_dnet_resource_identifier_
) VALUES (
	'extensions',
	'xml',
	'openaire____::corda_h2020::0',
	'openaire____::corda_h2020::0@@extensions'
);

INSERT INTO apicollections (
	param,
	original,
	api,
	_dnet_resource_identifier_
) VALUES (
	'baseUrl',
	'file:///var/lib/dnet/corda_h2020',
	'openaire____::corda_h2020::0',
	'openaire____::corda_h2020::0@@baseUrl'
);

INSERT INTO apicollections (
	param,
	original,
	api,
	_dnet_resource_identifier_,
	accessparam
) VALUES (
	'metadata_identifier_path',
	'//project/@id',
	'openaire____::corda_h2020::0',
	'openaire____::corda_h2020::0@@metadata_identifier_path',
	FALSE
);

--
INSERT INTO datasources (
	id,
	officialname,
	englishname,
	websiteurl,
	logourl,
	contactemail,
	namespaceprefix,
	collectedfrom,
	datasourceclass,
	_dnet_resource_identifier_
) VALUES (
	'openaire____::corda_h2020_fundings',
	'CORDA - COmmon Research DAta Warehouse - Horizon 2020 - Fundings',
	'CORDA - COmmon Research DAta Warehouse - Horizon 2020 - Fundings',
	'http://ec.europa.eu/programmes/horizon2020/',
	'http://ec.europa.eu/programmes/horizon2020/sites/horizon2020/themes/h2020/images/bannerEmptyH2020.jpg',
	'ec-fp7-it-helpdesk@ec.europa.eu',
	'ec__________',
	'infrastruct_::openaire',
	'entityregistry',
	'openaire____::corda_h2020'
);

INSERT INTO api (
	id,
	protocolclass,
	datasource,
	_dnet_resource_identifier_,
	typologyclass,
	compatibilityclass
) VALUES (
	'openaire____::corda_h2020_fundings::0',
	'filesystem',
	'openaire____::corda_h2020_fundings',
	'openaire____::corda_h2020_fundings::0',
	'entityregistry',
	'native'
);

INSERT INTO apicollections (
	param,
	original,
	api,
	_dnet_resource_identifier_
) VALUES (
	'extensions',
	'xml',
	'openaire____::corda_h2020_fundings::0',
	'openaire____::corda_h2020_fundings::0@@extensions'
);

INSERT INTO apicollections (
	param,
	original,
	api,
	_dnet_resource_identifier_
) VALUES (
	'baseUrl',
	'file:///var/lib/dnet/corda_h2020_fundings',
	'openaire____::corda_h2020_fundings::0',
	'openaire____::corda_h2020_fundings::0@@baseUrl'
);

INSERT INTO fundingpaths (
_dnet_resource_identifier_,
id,
path,
jurisdiction,
description,
funder
) VALUES (
'ec__________::EC::H2020',
'ec__________::EC::H2020',
'<fundingtree><funder><id>ec__________::EC</id><shortname>EC</shortname><name>European Commission</name><jurisdiction>EU</jurisdiction></funder><funding_level_0><id>ec__________::EC::H2020</id><description>Horizon 2020 Framework Programme</description><name>H2020</name><parent/><class>ec:frameworkprogram</class></funding_level_0></fundingtree>',
'EU',
'Horizon 2020 Framework Programme',
'ec__________::EC'
);


-- remove the wrong fundingpaths brought in by HE projects wrongly harvested via H2020 API

delete from fundingpaths where id like 'ec__________::EC::H2020::HORIZON%';
