Project

General

Profile

1
<RESOURCE_PROFILE>
2
    <HEADER>
3
        <RESOURCE_IDENTIFIER value="c0fb3b80-8466-466c-89b1-a5d1e3d60910_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
6
        <RESOURCE_URI value=""/>
7
        <DATE_OF_CREATION value="2017-04-11T13:46:22+00:00"/>
8
    </HEADER>
9
    <BODY>
10
        <CONFIGURATION>
11
            <IMPORTED/>
12
            <SCRIPT>
13
                <TITLE>dc_cleaning_OPENAIREplus_dc_relation</TITLE>
14
                <CODE>declare_script "dc_cleaning_OpenAIREplus_dc_relation";
15
declare_ns oaf = "http://namespace.openaire.eu/oaf";
16
declare_ns dri = "http://www.driver-repository.eu/namespace/dri";
17
declare_ns dr = "http://www.driver-repository.eu/namespace/dr";
18
declare_ns dc = "http://purl.org/dc/elements/1.1/";
19
declare_ns prov = "http://www.openarchives.org/OAI/2.0/provenance";
20
//preprocess p1 = dblookup("select id, officialname, accessinfopackage from datasources where accessinfopackage is not null");
21
$var0 = "''";
22
$varFP7 = "'corda_______::'";
23
$varH2020 = "'corda__h2020::'";
24
$varFCT="'fct_________::'";
25
$varWT = "'wt__________::'";
26
$varDummy = "''";
27
static $varDatasourceid = getValue(PROFILEFIELD, [xpath:"concat('collection(&amp;apos;/db/DRIVER/RepositoryServiceResources&amp;apos;)//RESOURCE_PROFILE[.//EXTRA_FIELDS/FIELD[key=&amp;quot;NamespacePrefix&amp;quot;][value=&amp;quot;', //oaf:datasourceprefix, '&amp;quot;]]')", xpath:"//EXTRA_FIELDS/FIELD[key='OpenAireDataSourceId']/value"]);
28
static $varRepoid = xpath:"//dri:repositoryId";
29
static $varOfficialname = getValue(PROFILEFIELD, [xpath:"concat('collection(&amp;apos;/db/DRIVER/RepositoryServiceResources&amp;apos;)//RESOURCE_PROFILE[.//EXTRA_FIELDS/FIELD[key=&amp;quot;NamespacePrefix&amp;quot;][value=&amp;quot;', //oaf:datasourceprefix, '&amp;quot;]]')", xpath:"//CONFIGURATION/OFFICIAL_NAME"]);
30
dri:objIdentifier = xpath:"//dri:objIdentifier";
31
dri:repositoryId = $varRepoid;
32
dri:recordIdentifier = xpath:"//dri:recordIdentifier";
33
//
34
//apply xpath:"//dc:creator" if xpath:"string-length(.) &gt; 0" dc:creator = xpath:"normalize-space(.)"; else $varDummy = "''";
35
//to invert names in FigShare, FigShare is separately dealth with 
36
apply xpath:"//dc:creator[//oaf:datasourceprefix != 'od______2073']" if xpath:"string-length(.) &gt; 0" dc:creator = xpath:"normalize-space(.)"; else $varDummy = "''";
37
//Convert seemingly does only likes names starting with letters (what about letters other than a-zA-Z?) &lt;&gt; cannot be dealt with in contains
38
apply xpath:"//dc:creator[//oaf:datasourceprefix = 'od______2073']" if xpath:"not(contains('0123456789()[]_',substring(normalize-space(.),1,1)))" dc:creator = Convert(xpath:".", Person); else $varDummy = "''";
39
//
40
if xpath:"//dc:title[string-length(.)&gt; 0]" $varDummy = "''"; else dc:coverage = skipRecord();
41
dc:title = xpath:"//dc:title[string-length(.) &gt; 0]/normalize-space(.)";
42
apply xpath:"//dc:subject" if xpath:"string-length(.) &gt; 0" dc:subject = xpath:"normalize-space(.)"; else $varDummy = "''";
43
apply xpath:"//dc:publisher" if xpath:"string-length(.) &gt; 0" dc:publisher = xpath:"normalize-space(.)"; else $varDummy = "''";
44
apply xpath:"//dc:source" if xpath:"string-length(.) &gt; 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
45
apply xpath:"//dc:identifier" if xpath:"ends-with(normalize-space(.), '.pdf')" oaf:fulltext = xpath:"normalize-space(.)"; else $varDummy = "''";
46
dc:contributor = xpath:"//dc:contributor";
47
dc:description = xpath:"//dc:description";
48
dc:format = xpath:"//dc:format";
49
$varHttpTest = "''";
50
if xpath:"//dc:relation[starts-with(., 'http')]" $varHttpTest = "true"; else dc:relation = skipRecord();
51
apply xpath:"//dc:relation" if xpath:"starts-with(normalize-space(.), 'http')" dc:identifier = xpath:"normalize-space(.)"; else $varDummy = "''";
52
apply xpath:"//dc:identifier" if xpath:"string-length(.) &gt; 0" dr:CobjIdentifier = xpath:"normalize-space(.)"; else $varDummy = "''";
53
dr:dateOfCollection = xpath:"//dri:dateOfCollection";
54
static dr:dateOfTransformation = xpath:"current-dateTime()";
55
dc:type = xpath:"//dc:type";
56
dc:rights = xpath:"//dc:rights";
57
if xpath:"count(//dc:language) &gt; 0" dc:language = Convert(xpath:"//dc:language", Languages); else dc:language = "eng";
58
//if xpath:"//dc:rights[text()='info:eu-repo/semantics/openAccess']" dc:publisher = xpath:"//dc:publisher"; else dc:publisher = skipRecord();
59
dc:date = xpath:"//dc:date";
60
$varDate = Convert(xpath:"descendant-or-self::dc:date", DateISO8601, "yyyy-MM-dd", "min()");
61
if xpath:"starts-with($varDate, '00') or starts-with($varDate, '10')" oaf:dateAccepted = $varDummy; else oaf:dateAccepted = $varDate;
62
apply xpath:"//dc:date" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/date')" oaf:embargoenddate = RegExpr(xpath:"normalize-space(.)", $var0, "s/^(.*info:eu-repo\/date\/embargoEnd\/)//gmi"); else $var0 = "''";
63
// FP7
64
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/fp7/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
65
// ERC (provided by OAPEN)
66
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european research council.*/-/)(\d\d\d\d\d\d)(.*)', 'i')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european research council.*/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
67
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european union.* seventh framework programme.*/-/)(\d\d\d\d\d\d)(.*)', 'i')]/concat($varFP7, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/european union.* seventh framework programme.*/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
68
// H2020
69
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i')]/concat($varH2020, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement[/]+ec/h2020/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
70
// FCT
71
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(info:eu-repo/grantagreement/fct)/(.+)/(\d+)(.*)', 'i')]/concat($varFCT, replace(normalize-space(.), '(info:eu-repo/grantagreement/fct)/(.+)/(\d+)(.*)', '$3', 'i'))";
72
// WT
73
oaf:projectid = xpath:"//dc:relation[matches(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', 'i')]/concat($varWT, replace(normalize-space(.), '(.*)(info:eu-repo/grantagreement/wellcome trust/-/)(\d\d\d\d\d\d)(.*)', '$3', 'i'))";
74
dc:relation = xpath:"//dc:relation";
75
//comment-js-09-10-2012 apply xpath:"//dc:rights" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/semantics')" dc:rights = empty; else dc:rights = xpath:"normalize-space(.)";
76
//
77
//
78
oaf:collectedDatasourceid = xpath:"$varDatasourceid";
79
//
80
dr:CobjCategory = Convert(xpath:"//dc:type", TextTypologies);
81
apply xpath:"//dc:rights" if xpath:"starts-with(normalize-space(.), 'info:eu-repo/semantics')" oaf:accessrights = Convert(xpath:"normalize-space(.)", AccessRights); else dc:rights = xpath:".";
82
if xpath:"//dc:rights[starts-with(normalize-space(.), 'info:eu-repo/semantics')]" $var0 = "''"; else oaf:accessrights = "OPEN";
83
//if xpath:"count(//dc:rights) = 0" oaf:accessrights = "OPEN"; else $var0 = "''";
84
// oaf:accessrights = Convert(xpath:"normalize-space(//dc:rights)", AccessRights);
85
//
86
static oaf:collectedFrom = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
87
static oaf:hostedBy = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
88
//
89
$varId = identifierExtract('["//dc:identifier", "//dc:relation"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/&lt;&gt;]*/[^\s"&lt;&gt;]+[^\s"/&lt;&gt;\.])');
90
oaf:identifier = set(xpath:"$varId//value", @identifierType = "doi";);
91
oaf:datasourceprefix = xpath:"//oaf:datasourceprefix";
92
end</CODE>
93
            </SCRIPT>
94
        </CONFIGURATION>
95
        <STATUS/>
96
        <SECURITY_PARAMETERS/>
97
    </BODY>
98
</RESOURCE_PROFILE>
(49-49/56)