Revision 52896
Added by Konstantina Galouni about 5 years ago
modules/uoa-claims/branches/refactorConnections/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U -T 4C source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/uoa-claims/trunk", |
|
5 |
"deploy_repository": "dnet45-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "kiatrop@di.uoa.gr, argirok@di.uoa.gr, kgalouni@di.uoa.gr", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", |
|
9 |
"name": "uoa-claims" |
|
10 |
} |
|
11 |
|
modules/uoa-claims/branches/refactorConnections/src/test/java/eu/dnetlib/data/claims/migration/parser/ExternalParserTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration.parser; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.Result; |
|
4 |
import eu.dnetlib.data.claimsDemo.ClaimUtils; |
|
5 |
import org.apache.log4j.BasicConfigurator; |
|
6 |
import org.junit.Assert; |
|
7 |
import org.junit.Before; |
|
8 |
import org.junit.Test; |
|
9 |
|
|
10 |
/** |
|
11 |
* Created by kiatrop on 23/2/2016. |
|
12 |
*/ |
|
13 |
public class ExternalParserTest { |
|
14 |
|
|
15 |
|
|
16 |
@Before |
|
17 |
public void init() throws Exception { |
|
18 |
BasicConfigurator.configure(); |
|
19 |
} |
|
20 |
private String crossrefJson = "{\"status\":\"ok\",\"message-type\":\"work-list\",\"message-version\":\"1.0.0\",\"message\":" + |
|
21 |
"{\"query\":{\"search-terms\":null,\"start-index\":0},\"items-per-page\":20,\"items\":[{\"indexed\":" + |
|
22 |
"{\"date-parts\":[[2015,12,28]], \"date-time\":\"2015-12-28T17:45:59Z\",\"timestamp\":1451324759779}," + |
|
23 |
"\"reference-count\":0,\"publisher\":\"Society for Neuroscience\", \"issue\":\"17\"," + |
|
24 |
"\"published-print\":{\"date-parts\":[[2012,4,25]]},\"DOI\":\"10.1523\\/jneurosci.2900-11.2012\"," + |
|
25 |
"\"type\":\"journal-article\",\"created\": {\"date-parts\":[[2012,4,25]]," + |
|
26 |
"\"date-time\":\"2012-04-25T16:38:54Z\",\"timestamp\":1335371934000},\"page\":\"5728-5736\"," + |
|
27 |
"\"source\":\"CrossRef\",\"title\":[\"Imaging Microglial\\/Macrophage Activation in Spinal Cords of " + |
|
28 |
"Experimental Autoimmune Encephalomyelitis Rats by Positron Emission Tomography Using the Mitochondrial " + |
|
29 |
"18 kDa Translocator Protein Radioligand [18F]DPA-714\"]," + |
|
30 |
"\"prefix\":\"http:\\/\\/id.crossref.org\\/prefix\\/10.1523\",\"volume\":\"32\",\"author\":" + |
|
31 |
"[{\"affiliation\":[],\"family\":\"Abourbeh\",\"given\":\"G.\"},{\"affiliation\":[],\"family\":\"Theze\"," + |
|
32 |
"\"given\":\"B.\"},{\"affiliation\":[],\"family\":\"Maroy\",\"given\":\"R.\"},{\"affiliation\":[],\"family\":" + |
|
33 |
"\"Dubois\",\"given\":\"A.\"},{\"affiliation\":[],\"family\":\"Brulon\",\"given\":\"V.\"}," + |
|
34 |
"{\"affiliation\":[],\"family\":\"Fontyn\",\"given\":\"Y.\"},{\"affiliation\":[],\"family\":\"Dolle\"," + |
|
35 |
"\"given\":\"F.\"},{\"affiliation\":[],\"family\":\"Tavitian\",\"given\":\"B.\"},{\"affiliation\":[]," + |
|
36 |
"\"family\":\"Boisgard\",\"given\":\"R.\"}],\"member\":\"http:\\/\\/id.crossref.org\\/member\\/393\"," + |
|
37 |
"\"published-online\":{\"date-parts\":[[2012,4,25]]},\"container-title\":[\"Journal of Neuroscience\"]," + |
|
38 |
"\"deposited\":{\"date-parts\":[[2014,2,27]],\"date-time\":\"2014-02-27T06:42:02Z\",\"timestamp\":1393483322000}," + |
|
39 |
"\"score\":1.0,\"subtitle\":[],\"issued\":{\"date-parts\":[[2012,4,25]]}," + |
|
40 |
"\"URL\":\"http:\\/\\/dx.doi.org\\/10.1523\\/jneurosci.2900-11.2012\",\"ISSN\":[\"0270-6474\",\"1529-2401\"]," + |
|
41 |
"\"subject\":[\"Neuroscience(all)\"]}],\"total-results\":1,\"facets\":{}}}" + |
|
42 |
""; |
|
43 |
|
|
44 |
|
|
45 |
@Test |
|
46 |
public void crossref2ResultTest(){ |
|
47 |
Result result = ExternalRecordParser.crossref2Result(crossrefJson); |
|
48 |
|
|
49 |
Assert.assertNull(result.getAccessRights()); |
|
50 |
Assert.assertNull(result.getBestLicense()); |
|
51 |
Assert.assertEquals("openaire____::crossref", result.getCollectedFrom()); |
|
52 |
Assert.assertEquals("10.1523/jneurosci.2900-11.2012", result.getDoi()); |
|
53 |
Assert.assertNull(result.getOai()); |
|
54 |
Assert.assertNotNull(result.getOpenaireId());// Assert.assertNull(result.getOpenaireId()); |
|
55 |
Assert.assertNull(result.getPmcid()); |
|
56 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
57 |
Assert.assertEquals("Imaging Microglial/Macrophage Activation in Spinal Cords of Experimental Autoimmune Encephalomyelitis Rats by Positron Emission Tomography Using the Mitochondrial 18 kDa Translocator Protein Radioligand [18F]DPA-714", result.getTitle()); |
|
58 |
Assert.assertEquals("json", result.getRecordFormat()); |
|
59 |
Assert.assertEquals("https://dx.doi.org/10.1523/jneurosci.2900-11.2012", result.getExternalUrl()); |
|
60 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
61 |
Assert.assertNull(result.getOrcidworkid()); |
|
62 |
|
|
63 |
Assert.assertEquals(9, result.getAuthors().size()); |
|
64 |
Assert.assertEquals("G. Abourbeh", result.getAuthors().get(0+"")); |
|
65 |
Assert.assertEquals("Y. Fontyn", result.getAuthors().get(5+"")); |
|
66 |
} |
|
67 |
|
|
68 |
private String orcidXml2 = "<orcid-message xmlns=\"http://www.orcid.org/ns/orcid\">\n" + |
|
69 |
" <message-version>1.1</message-version>\n" + |
|
70 |
" <orcid-profile type=\"user\">\n" + |
|
71 |
" <orcid-identifier>\n" + |
|
72 |
" <uri>http://orcid.org/0000-0002-9414-646X</uri>\n" + |
|
73 |
" <path>0000-0002-9414-646X</path>\n" + |
|
74 |
" <host>orcid.org</host>\n" + |
|
75 |
" </orcid-identifier>\n" + |
|
76 |
" <orcid-preferences>\n" + |
|
77 |
" <locale>es</locale>\n" + |
|
78 |
" </orcid-preferences>\n" + |
|
79 |
" <orcid-history>\n" + |
|
80 |
" <creation-method>website</creation-method>\n" + |
|
81 |
" <completion-date>2013-01-11T14:07:54.194Z</completion-date>\n" + |
|
82 |
" <submission-date>2013-01-11T13:27:46.558Z</submission-date>\n" + |
|
83 |
" <last-modified-date>2016-01-27T16:06:13.543Z</last-modified-date>\n" + |
|
84 |
" <claimed>true</claimed>\n" + |
|
85 |
" </orcid-history>\n" + |
|
86 |
" <orcid-activities>\n" + |
|
87 |
" <orcid-works>\n" + |
|
88 |
" <orcid-work put-code=\"21755327\" visibility=\"public\">\n" + |
|
89 |
" <work-title>\n" + |
|
90 |
" <title>Providing Ubiquitous Positioning in Outdoor Environments</title>\n" + |
|
91 |
" </work-title>\n" + |
|
92 |
" <journal-title>2015 IEEE International Conference on Systems, Man, and Cybernetics</journal-title>\n" + |
|
93 |
" <work-citation>\n" + |
|
94 |
" <work-citation-type>bibtex</work-citation-type>\n" + |
|
95 |
" <citation>@inproceedings{Moreno_2015,doi = {10.1109/smc.2015.229},url = {http://dx.doi.org/10.1109/smc.2015.229},year = 2015,month = {oct},publisher = {Institute of Electrical {\\&} Electronics Engineers ({IEEE})},author = {Daniel Moreno and Sergio F. Ochoa and Roc Meseguer},title = {Providing Ubiquitous Positioning in Outdoor Environments},booktitle = {2015 {IEEE} International Conference on Systems, Man, and Cybernetics}}</citation>\n" + |
|
96 |
" </work-citation>\n" + |
|
97 |
" <work-type>conference-paper</work-type>\n" + |
|
98 |
" <publication-date>\n" + |
|
99 |
" <year>2015</year>\n" + |
|
100 |
" <month>10</month>\n" + |
|
101 |
" </publication-date>\n" + |
|
102 |
" <work-external-identifiers>\n" + |
|
103 |
" <work-external-identifier>\n" + |
|
104 |
" <work-external-identifier-type>doi</work-external-identifier-type>\n" + |
|
105 |
" <work-external-identifier-id>10.1109/smc.2015.229</work-external-identifier-id>\n" + |
|
106 |
" </work-external-identifier>\n" + |
|
107 |
" </work-external-identifiers>\n" + |
|
108 |
" <work-contributors>\n" + |
|
109 |
" <contributor>\n" + |
|
110 |
" <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" + |
|
111 |
" <contributor-attributes>\n" + |
|
112 |
" <contributor-role>author</contributor-role>\n" + |
|
113 |
" </contributor-attributes>\n" + |
|
114 |
" </contributor>\n" + |
|
115 |
" <contributor>\n" + |
|
116 |
" <credit-name visibility=\"public\">Sergio F. Ochoa</credit-name>\n" + |
|
117 |
" <contributor-attributes>\n" + |
|
118 |
" <contributor-role>author</contributor-role>\n" + |
|
119 |
" </contributor-attributes>\n" + |
|
120 |
" </contributor>\n" + |
|
121 |
" <contributor>\n" + |
|
122 |
" <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" + |
|
123 |
" <contributor-attributes>\n" + |
|
124 |
" <contributor-role>author</contributor-role>\n" + |
|
125 |
" </contributor-attributes>\n" + |
|
126 |
" </contributor>\n" + |
|
127 |
" </work-contributors>\n" + |
|
128 |
" <work-source>\n" + |
|
129 |
" <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" + |
|
130 |
" <path>0000-0002-3054-1567</path>\n" + |
|
131 |
" <host>orcid.org</host>\n" + |
|
132 |
" </work-source>\n" + |
|
133 |
" </orcid-work>\n" + |
|
134 |
" <orcid-work put-code=\"19191618\" visibility=\"public\">\n" + |
|
135 |
" <work-title>\n" + |
|
136 |
" <title>A Context-Aware Model to Provide Positioning in Disaster Relief Scenarios</title>\n" + |
|
137 |
" </work-title>\n" + |
|
138 |
" <journal-title>Sensors</journal-title>\n" + |
|
139 |
" <work-citation>\n" + |
|
140 |
" <work-citation-type>bibtex</work-citation-type>\n" + |
|
141 |
" <citation>@article{Moreno_2015,doi = {10.3390/s151025176},url = {http://dx.doi.org/10.3390/s151025176},year = 2015,month = {sep},publisher = {{MDPI} {AG}},volume = {15},number = {10},pages = {25176--25207},author = {Daniel Moreno and Sergio Ochoa and Roc Meseguer},title = {A Context-Aware Model to Provide Positioning in Disaster Relief Scenarios},journal = {Sensors}}</citation>\n" + |
|
142 |
" </work-citation>\n" + |
|
143 |
" <work-type>journal-article</work-type>\n" + |
|
144 |
" <publication-date>\n" + |
|
145 |
" <year>2015</year>\n" + |
|
146 |
" <month>09</month>\n" + |
|
147 |
" </publication-date>\n" + |
|
148 |
" <work-external-identifiers>\n" + |
|
149 |
" <work-external-identifier>\n" + |
|
150 |
" <work-external-identifier-type>doi</work-external-identifier-type>\n" + |
|
151 |
" <work-external-identifier-id>10.3390/s151025176</work-external-identifier-id>\n" + |
|
152 |
" </work-external-identifier>\n" + |
|
153 |
" </work-external-identifiers>\n" + |
|
154 |
" <work-contributors>\n" + |
|
155 |
" <contributor>\n" + |
|
156 |
" <credit-name visibility=\"public\">Daniel Moreno</credit-name>\n" + |
|
157 |
" <contributor-attributes>\n" + |
|
158 |
" <contributor-role>author</contributor-role>\n" + |
|
159 |
" </contributor-attributes>\n" + |
|
160 |
" </contributor>\n" + |
|
161 |
" <contributor>\n" + |
|
162 |
" <credit-name visibility=\"public\">Sergio Ochoa</credit-name>\n" + |
|
163 |
" <contributor-attributes>\n" + |
|
164 |
" <contributor-role>author</contributor-role>\n" + |
|
165 |
" </contributor-attributes>\n" + |
|
166 |
" </contributor>\n" + |
|
167 |
" <contributor>\n" + |
|
168 |
" <credit-name visibility=\"public\">Roc Meseguer</credit-name>\n" + |
|
169 |
" <contributor-attributes>\n" + |
|
170 |
" <contributor-role>author</contributor-role>\n" + |
|
171 |
" </contributor-attributes>\n" + |
|
172 |
" </contributor>\n" + |
|
173 |
" </work-contributors>\n" + |
|
174 |
" <work-source>\n" + |
|
175 |
" <uri>http://orcid.org/0000-0002-3054-1567</uri>\n" + |
|
176 |
" <path>0000-0002-3054-1567</path>\n" + |
|
177 |
" <host>orcid.org</host>\n" + |
|
178 |
" </work-source>\n" + |
|
179 |
" </orcid-work>" + |
|
180 |
"</orcid-works></orcid-activities></orcid-profile></orcid-message>"; |
|
181 |
|
|
182 |
private String orcidXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + |
|
183 |
"<activities:works path=\"/0000-0002-9414-646X/works\" xmlns:internal=\"http://www.orcid.org/ns/internal\" xmlns:funding=\"http://www.orcid.org/ns/funding\" xmlns:preferences=\"http://www.orcid.org/ns/preferences\" xmlns:address=\"http://www.orcid.org/ns/address\" xmlns:education=\"http://www.orcid.org/ns/education\" xmlns:work=\"http://www.orcid.org/ns/work\" xmlns:deprecated=\"http://www.orcid.org/ns/deprecated\" xmlns:other-name=\"http://www.orcid.org/ns/other-name\" xmlns:history=\"http://www.orcid.org/ns/history\" xmlns:employment=\"http://www.orcid.org/ns/employment\" xmlns:error=\"http://www.orcid.org/ns/error\" xmlns:common=\"http://www.orcid.org/ns/common\" xmlns:person=\"http://www.orcid.org/ns/person\" xmlns:activities=\"http://www.orcid.org/ns/activities\" xmlns:record=\"http://www.orcid.org/ns/record\" xmlns:researcher-url=\"http://www.orcid.org/ns/researcher-url\" xmlns:peer-review=\"http://www.orcid.org/ns/peer-review\" xmlns:personal-details=\"http://www.orcid.org/ns/personal-details\" xmlns:bulk=\"http://www.orcid.org/ns/bulk\" xmlns:keyword=\"http://www.orcid.org/ns/keyword\" xmlns:email=\"http://www.orcid.org/ns/email\" xmlns:external-identifier=\"http://www.orcid.org/ns/external-identifier\">\n" + |
|
184 |
" <common:last-modified-date>2017-11-07T11:56:05.454Z</common:last-modified-date>\n" + |
|
185 |
|
|
186 |
" <activities:group>\n" + |
|
187 |
" <common:last-modified-date>2016-01-22T14:32:26.233Z</common:last-modified-date>\n" + |
|
188 |
" <common:external-ids>\n" + |
|
189 |
" <common:external-id>\n" + |
|
190 |
" <common:external-id-type>doi</common:external-id-type>\n" + |
|
191 |
" <common:external-id-value>10.1109/smc.2015.229</common:external-id-value>\n" + |
|
192 |
" <common:external-id-relationship>self</common:external-id-relationship>\n" + |
|
193 |
" </common:external-id>\n" + |
|
194 |
" </common:external-ids>\n" + |
|
195 |
" <work:work-summary put-code=\"21755327\" path=\"/0000-0002-9414-646X/work/21755327\" visibility=\"public\" display-index=\"0\">\n" + |
|
196 |
" <common:created-date>2016-01-22T14:30:35.071Z</common:created-date>\n" + |
|
197 |
" <common:last-modified-date>2016-01-22T14:32:26.233Z</common:last-modified-date>\n" + |
|
198 |
" <common:source>\n" + |
|
199 |
" <common:source-client-id>\n" + |
|
200 |
" <common:uri>https://orcid.org/client/0000-0002-3054-1567</common:uri>\n" + |
|
201 |
" <common:path>0000-0002-3054-1567</common:path>\n" + |
|
202 |
" <common:host>orcid.org</common:host>\n" + |
|
203 |
" </common:source-client-id>\n" + |
|
204 |
" <common:source-name>CrossRef Metadata Search</common:source-name>\n" + |
|
205 |
" </common:source>\n" + |
|
206 |
" <work:title>\n" + |
|
207 |
" <common:title>Providing Ubiquitous Positioning in Outdoor Environments</common:title>\n" + |
|
208 |
" </work:title>\n" + |
|
209 |
" <common:external-ids>\n" + |
|
210 |
" <common:external-id>\n" + |
|
211 |
" <common:external-id-type>doi</common:external-id-type>\n" + |
|
212 |
" <common:external-id-value>10.1109/smc.2015.229</common:external-id-value>\n" + |
|
213 |
" <common:external-id-relationship>self</common:external-id-relationship>\n" + |
|
214 |
" </common:external-id>\n" + |
|
215 |
" </common:external-ids>\n" + |
|
216 |
" <work:type>conference-paper</work:type>\n" + |
|
217 |
" <common:publication-date>\n" + |
|
218 |
" <common:year>2015</common:year>\n" + |
|
219 |
" <common:month>10</common:month>\n" + |
|
220 |
" </common:publication-date>\n" + |
|
221 |
" </work:work-summary>\n" + |
|
222 |
" </activities:group>\n" + |
|
223 |
|
|
224 |
"</activities:works>\n"; |
|
225 |
@Test |
|
226 |
public void orcid2ResultTest() { |
|
227 |
Result result = ExternalRecordParser.orcid2Result(orcidXml, "0000-0002-9414-646X-21755327"); |
|
228 |
System.out.println(result.getTitle() + result.getAccessRights()); |
|
229 |
Assert.assertNull(result.getAccessRights()); |
|
230 |
Assert.assertNull(result.getBestLicense()); |
|
231 |
Assert.assertEquals("openaire____::orcid", result.getCollectedFrom()); |
|
232 |
Assert.assertEquals("10.1109/smc.2015.229", result.getDoi()); |
|
233 |
Assert.assertEquals("0000-0002-9414-646X-21755327", result.getOrcidworkid()); |
|
234 |
Assert.assertNull(result.getOai()); |
|
235 |
Assert.assertNotNull(result.getOpenaireId());// Assert.assertNull(result.getOpenaireId()); |
|
236 |
Assert.assertNull(result.getPmcid()); |
|
237 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
238 |
Assert.assertEquals("Providing Ubiquitous Positioning in Outdoor Environments", result.getTitle()); |
|
239 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
240 |
Assert.assertEquals("https://dx.doi.org/10.1109/smc.2015.229", result.getExternalUrl()); |
|
241 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
242 |
|
|
243 |
} |
|
244 |
|
|
245 |
|
|
246 |
private String dataciteXml = "<rdf:RDF\n" + |
|
247 |
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + |
|
248 |
" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" + |
|
249 |
" xmlns:j.0=\"http://purl.org/dc/terms/\" > \n" + |
|
250 |
" <rdf:Description rdf:about=\"http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041\">\n" + |
|
251 |
" <j.0:creator>Krimmel, Robert</j.0:creator>\n" + |
|
252 |
" <j.0:publisher>National Snow and Ice Data Center/World Data Center for Glaciology, Boulder</j.0:publisher>\n" + |
|
253 |
" <j.0:title>Chocolate Glacier</j.0:title>\n" + |
|
254 |
" <j.0:date>2008</j.0:date>\n" + |
|
255 |
" <owl:sameAs>doi:10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" + |
|
256 |
" <owl:sameAs>info:doi/10.5060/D4RN35SD/USGS85K1_041</owl:sameAs>\n" + |
|
257 |
" <j.0:identifier>10.5060/D4RN35SD/USGS85K1_041</j.0:identifier>\n" + |
|
258 |
" </rdf:Description>\n" + |
|
259 |
"</rdf:RDF>\n"; |
|
260 |
|
|
261 |
private String dataciteJson = "{\"data\":{\"id\":\"https://doi.org/10.5281/ZENODO.54730\",\"type\":\"works\",\"attributes\":{\"doi\":\"10.5281/ZENODO.54730\",\"url\":null,\"author\":[{\"family\":\"Manola\",\"given\":\"Natalia\"}],\"title\":\"From Open Access to Open Science\",\"container-title\":\"Zenodo\",\"description\":\"Presentation given at the PASTEUR4OA conference - Green Light for Open Access: Aligning Europe’s OA Policies, Amsterdam, 17th-18th May 2016.\",\"resource-type-subtype\":\"Presentation\",\"data-center-id\":\"cern.zenodo\",\"member-id\":\"cern\",\"resource-type-id\":\"text\",\"version\":null,\"license\":\"https://creativecommons.org/licenses/by/4.0/\",\"schema-version\":\"3\",\"results\":[],\"related-identifiers\":[],\"published\":\"2016\",\"deposited\":\"2016-06-03T17:03:51Z\",\"updated\":\"2016-06-03T17:03:51Z\",\"media\":null,\"xml\":\"PHJlc291cmNlIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSIgeHNpOnNjaGVtYUxvY2F0aW9uPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC0zL21ldGFkYXRhLnhzZCI+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9IkRPSSI+MTAuNTI4MS96ZW5vZG8uNTQ3MzA8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZT5NYW5vbGEsIE5hdGFsaWEgPC9jcmVhdG9yTmFtZT4KICAgICAgPGFmZmlsaWF0aW9uPk9wZW5BSVJFPC9hZmZpbGlhdGlvbj4KICAgIDwvY3JlYXRvcj4KICA8L2NyZWF0b3JzPgogIDx0aXRsZXM+CiAgICA8dGl0bGU+RnJvbSBPcGVuIEFjY2VzcyB0byBPcGVuIFNjaWVuY2U8L3RpdGxlPgogIDwvdGl0bGVzPgogIDxwdWJsaXNoZXI+WmVub2RvPC9wdWJsaXNoZXI+CiAgPHB1YmxpY2F0aW9uWWVhcj4yMDE2PC9wdWJsaWNhdGlvblllYXI+CiAgPHN1YmplY3RzPgogICAgPHN1YmplY3Q+UEFTVEVVUjRPQTwvc3ViamVjdD4KICAgIDxzdWJqZWN0Pk9wZW4gQWNjZXNzPC9zdWJqZWN0PgogICAgPHN1YmplY3Q+UHJlc2VudGF0aW9uPC9zdWJqZWN0PgogIDwvc3ViamVjdHM+CiAgPGNvbnRyaWJ1dG9ycz4KICAgIDxjb250cmlidXRvciBjb250cmlidXRvclR5cGU9IkZ1bmRlciI+CiAgICAgIDxjb250cmlidXRvck5hbWU+RXVyb3BlYW4gQ29tbWlzc2lvbjwvY29udHJpYnV0b3JOYW1lPgogICAgICA8bmFtZUlkZW50aWZpZXIgbmFtZUlkZW50aWZpZXJTY2hlbWU9ImluZm8iPmluZm86ZXUtcmVwby9ncmFudEFncmVlbWVudC9FQy9GUDcvNjExNzQyPC9uYW1lSWRlbnRpZmllcj4KICAgIDwvY29udHJpYnV0b3I+CiAgPC9jb250cmlidXRvcnM+CiAgPGRhdGVzPgogICAgPGRhdGUgZGF0ZVR5cGU9Iklzc3VlZCI+MjAxNi0wNS0xODwvZGF0ZT4KICA8L2RhdGVzPgogIDxyZXNvdXJjZVR5cGUgcmVzb3VyY2VUeXBlR2VuZXJhbD0iVGV4dCI+UHJlc2VudGF0aW9uPC9yZXNvdXJjZVR5cGU+CiAgPGFsdGVybmF0ZUlkZW50aWZpZXJzPgogICAgPGFsdGVybmF0ZUlkZW50aWZpZXIgYWx0ZXJuYXRlSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cDovL3plbm9kby5vcmcvcmVjb3JkLzU0NzMwPC9hbHRlcm5hdGVJZGVudGlmaWVyPgogICAgPGFsdGVybmF0ZUlkZW50aWZpZXIgYWx0ZXJuYXRlSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cDovL3d3dy5wYXN0ZXVyNG9hLmV1L3NpdGVzL3Bhc3RldXI0b2EvZmlsZXMvZ2VuZXJpYy9OYXRhbGlhJTIwTWFub2xhJTIwUERGLnBkZjwvYWx0ZXJuYXRlSWRlbnRpZmllcj4KICA8L2FsdGVybmF0ZUlkZW50aWZpZXJzPgogIDxyZWxhdGVkSWRlbnRpZmllcnM+CiAgICA8cmVsYXRlZElkZW50aWZpZXIgcmVsYXRpb25UeXBlPSJIYXNQYXJ0IiByZWxhdGVkSWRlbnRpZmllclR5cGU9IlVSTCI+aHR0cHM6Ly96ZW5vZG8ub3JnL3JlY29yZC81NDczMC9maWxlcy8xOF9OYXRhbGlhX01hbm9sYV9QREYucGRmPC9yZWxhdGVkSWRlbnRpZmllcj4KICA8L3JlbGF0ZWRJZGVudGlmaWVycz4KICA8cmlnaHRzTGlzdD4KICAgIDxyaWdodHMgcmlnaHRzVVJJPSJpbmZvOmV1LXJlcG8vc2VtYW50aWNzL29wZW5BY2Nlc3MiPk9wZW4gQWNjZXNzPC9yaWdodHM+CiAgICA8cmlnaHRzIHJpZ2h0c1VSST0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbGljZW5zZXMvYnkvNC4wLyI+Q3JlYXRpdmUgQ29tbW9ucyBBdHRyaWJ1dGlvbiA0LjAgSW50ZXJuYXRpb25hbDwvcmlnaHRzPgogIDwvcmlnaHRzTGlzdD4KICA8ZGVzY3JpcHRpb25zPgogICAgPGRlc2NyaXB0aW9uIGRlc2NyaXB0aW9uVHlwZT0iQWJzdHJhY3QiPiZsdDtwJmd0O1ByZXNlbnRhdGlvbiBnaXZlbiBhdCB0aGUgUEFTVEVVUjRPQSBjb25mZXJlbmNlIC0mYW1wO25ic3A7R3JlZW4gTGlnaHQgZm9yIE9wZW4gQWNjZXNzOiBBbGlnbmluZyBFdXJvcGUmYW1wO3JzcXVvO3MgT0EgUG9saWNpZXMsIEFtc3RlcmRhbSwgMTd0aC0xOHRoIE1heSAyMDE2LiZsdDsvcCZndDs8L2Rlc2NyaXB0aW9uPgogIDwvZGVzY3JpcHRpb25zPgo8L3Jlc291cmNlPgo=\"},\"relationships\":{\"data-center\":{\"meta\":{}},\"member\":{\"meta\":{}},\"resource-type\":{\"meta\":{}}}}}"; |
|
262 |
|
|
263 |
@Test |
|
264 |
public void datacite2ResultTest() { |
|
265 |
Result result = ExternalRecordParser.datacite2Result(dataciteXml); |
|
266 |
|
|
267 |
Assert.assertNull(result.getAccessRights()); |
|
268 |
Assert.assertNull(result.getBestLicense()); |
|
269 |
Assert.assertEquals("openaire____::datacite", result.getCollectedFrom()); |
|
270 |
Assert.assertEquals("10.5060/D4RN35SD/USGS85K1_041", result.getDoi()); |
|
271 |
Assert.assertNull(result.getOrcidworkid()); |
|
272 |
Assert.assertNull(result.getOai()); |
|
273 |
Assert.assertNotNull(result.getOpenaireId());// Assert.assertNull(result.getOpenaireId()); |
|
274 |
Assert.assertNull(result.getPmcid()); |
|
275 |
Assert.assertEquals(ClaimUtils.DATASET, result.getResultType()); |
|
276 |
Assert.assertEquals("Chocolate Glacier", result.getTitle()); |
|
277 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
278 |
Assert.assertEquals("http://dx.doi.org/10.5060/D4RN35SD/USGS85K1_041", result.getExternalUrl()); |
|
279 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
280 |
|
|
281 |
} |
|
282 |
|
|
283 |
@Test |
|
284 |
public void dataciteJsonResultTest() { |
|
285 |
Result result = ExternalRecordParser.dataciteJson2Result(dataciteJson); |
|
286 |
|
|
287 |
Assert.assertNull(result.getAccessRights()); |
|
288 |
Assert.assertNull(result.getBestLicense()); |
|
289 |
Assert.assertEquals("openaire____::datacite", result.getCollectedFrom()); |
|
290 |
Assert.assertEquals("10.5281/ZENODO.54730", result.getDoi()); |
|
291 |
Assert.assertNull(result.getOrcidworkid()); |
|
292 |
Assert.assertNull(result.getOai()); |
|
293 |
Assert.assertNotNull(result.getOpenaireId());// Assert.assertNull(result.getOpenaireId()); |
|
294 |
Assert.assertNull(result.getPmcid()); |
|
295 |
Assert.assertEquals(ClaimUtils.DATASET, result.getResultType()); |
|
296 |
Assert.assertEquals("From Open Access to Open Science", result.getTitle()); |
|
297 |
Assert.assertEquals("json", result.getRecordFormat()); |
|
298 |
Assert.assertEquals("https://dx.doi.org/10.5281/ZENODO.54730", result.getExternalUrl()); |
|
299 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
300 |
|
|
301 |
} |
|
302 |
@Test |
|
303 |
public void testMD5() throws Exception { |
|
304 |
String id = "10.1016/j.engstruct.2013.03.014"; |
|
305 |
String createdId = ExternalRecordParser.createOpenaireId(id); |
|
306 |
String openaireId = "userclaim___::07ec9eb2278a11e352e3fa93a621411d"; |
|
307 |
Assert.assertEquals(createdId,openaireId); |
|
308 |
|
|
309 |
} |
|
310 |
} |
modules/uoa-claims/branches/refactorConnections/src/test/java/eu/dnetlib/data/claims/migration/parser/OafParserTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration.parser; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.Result; |
|
4 |
import eu.dnetlib.data.claimsDemo.ClaimUtils; |
|
5 |
import eu.dnetlib.data.claims.migration.entity.Project; |
|
6 |
import org.apache.log4j.BasicConfigurator; |
|
7 |
import org.junit.Assert; |
|
8 |
import org.junit.Before; |
|
9 |
import org.junit.Test; |
|
10 |
import org.xml.sax.SAXException; |
|
11 |
|
|
12 |
import javax.xml.parsers.ParserConfigurationException; |
|
13 |
import javax.xml.transform.TransformerException; |
|
14 |
import javax.xml.xpath.XPathExpressionException; |
|
15 |
import java.io.IOException; |
|
16 |
|
|
17 |
/** |
|
18 |
* Created by kiatrop on 22/2/2016. |
|
19 |
*/ |
|
20 |
public class OafParserTest { |
|
21 |
|
|
22 |
@Before() |
|
23 |
public void init(){ |
|
24 |
BasicConfigurator.configure(); |
|
25 |
} |
|
26 |
|
|
27 |
private String publicationOaf = "<response>\n" + |
|
28 |
"\t <header>\n" + |
|
29 |
"\t\t <query>(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (objidentifier exact od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46)</query>\n" + |
|
30 |
"\t\t\t\t <locale>en_GB</locale>\t\n" + |
|
31 |
"\t\t\t\t\t<size>10</size>\n" + |
|
32 |
"\t\t\t <page>1</page>\n" + |
|
33 |
"\t\t\t <total>1</total>\n" + |
|
34 |
"\t\t\t\t\t</header>\n" + |
|
35 |
"\t <results>\n" + |
|
36 |
"\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
|
37 |
" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"\n" + |
|
38 |
" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
39 |
" <header>\n" + |
|
40 |
" <dri:objIdentifier>od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46</dri:objIdentifier>\n" + |
|
41 |
" <dri:dateOfCollection>2016-02-02T08:07:14Z</dri:dateOfCollection>\n" + |
|
42 |
" </header>\n" + |
|
43 |
" <metadata>\n" + |
|
44 |
" <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\n" + |
|
45 |
"\t\t <oaf:result>\n" + |
|
46 |
" <title classid=\"main title\" classname=\"main title\" schemeid=\"dnet:dataCite_title\"\n" + |
|
47 |
" schemename=\"dnet:dataCite_title\">ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ</title>\n" + |
|
48 |
" <dateofacceptance>2010-01-01</dateofacceptance>\n" + |
|
49 |
" <resulttype classid=\"publication\" classname=\"publication\" schemeid=\"dnet:result_typologies\"\n" + |
|
50 |
" schemename=\"dnet:result_typologies\"/>\n" + |
|
51 |
" <country classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
52 |
" <relevantdate classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
53 |
" <embargoenddate>2099-12-31</embargoenddate>\n" + |
|
54 |
" <originalId>oai:cyberleninka.ru:article/5969541</originalId>\n" + |
|
55 |
" <collectedfrom name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
56 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
57 |
" <pid classid=\"oai\" classname=\"oai\" schemeid=\"dnet:pid_types\"\n" + |
|
58 |
" schemename=\"dnet:pid_types\">oai:cyberleninka.ru:article/5969541</pid>\n" + |
|
59 |
" <pid classid=\"pmc\" classname=\"pmc\" schemeid=\"dnet:pid_types\"\n" + |
|
60 |
" schemename=\"dnet:pid_types\">pmc_test</pid>\n" + |
|
61 |
" <pid classid=\"orcidworkid\" classname=\"orcidworkid\" schemeid=\"dnet:pid_types\"\n" + |
|
62 |
" schemename=\"dnet:pid_types\">orcidworkid_test</pid>\n" + |
|
63 |
" <bestlicense classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
64 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
65 |
"\t\t <children>\n" + |
|
66 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
67 |
"\t\t\t <licence classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
68 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
69 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
70 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
71 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
72 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
73 |
"\t\t\t\t <webresource>\n" + |
|
74 |
"\t\t\t\t <url>http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki</url>\n" + |
|
75 |
"\t\t\t\t </webresource>\n" + |
|
76 |
"\t\t\t\t <webresource>\n" + |
|
77 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
78 |
"\t\t\t\t </webresource>\n" + |
|
79 |
"\t\t\t </instance>\n" + |
|
80 |
"\t\t </children>\n" + |
|
81 |
"\t\t </oaf:result>\n" + |
|
82 |
" </oaf:entity>\n" + |
|
83 |
" </metadata>\n" + |
|
84 |
" </result>\n" + |
|
85 |
"\t\t\t\t\t\t</results>\n" + |
|
86 |
"\t <browseResults>\n" + |
|
87 |
"\t\t\t</browseResults>\n" + |
|
88 |
"</response>"; |
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
/* |
|
93 |
"\t\t <children>\n" + |
|
94 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
95 |
"\t\t\t <licence classid=\"CLOSED\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
96 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
97 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
98 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
99 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
100 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
101 |
"\t\t\t\t <webresource>\n" + |
|
102 |
"\t\t\t\t <url>h CLOSED_ACCESS_URL</url>\n" + |
|
103 |
"\t\t\t\t </webresource>\n" + |
|
104 |
"\t\t\t\t <webresource>\n" + |
|
105 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
106 |
"\t\t\t\t </webresource>\n" + |
|
107 |
"\t\t\t </instance>\n" + |
|
108 |
"\t\t </children>\n" + |
|
109 |
*/ |
|
110 |
@Test |
|
111 |
public void oaf2PublicationTest() throws Exception, ParserConfigurationException, SAXException, XPathExpressionException, IOException, TransformerException { |
|
112 |
Result result = OafParser.oaf2Result(publicationOaf); |
|
113 |
System.out.println(result.getExternalUrl()); |
|
114 |
Assert.assertNull(result.getAccessRights()); |
|
115 |
Assert.assertEquals("EMBARGO",result.getBestLicense()); |
|
116 |
Assert.assertEquals("infrastruct_::openaire", result.getCollectedFrom()); |
|
117 |
Assert.assertNull(result.getDoi()); |
|
118 |
Assert.assertEquals("oai:cyberleninka.ru:article/5969541",result.getOai()); |
|
119 |
Assert.assertEquals("od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46",result.getOpenaireId()); |
|
120 |
Assert.assertEquals("pmc_test",result.getPmcid()); |
|
121 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
122 |
Assert.assertEquals("ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ",result.getTitle()); |
|
123 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
124 |
|
|
125 |
Assert.assertEquals("http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki", result.getExternalUrl()); |
|
126 |
Assert.assertEquals("2099-12-31",result.getEmbargoEndDate()); |
|
127 |
Assert.assertEquals("orcidworkid_test", result.getOrcidworkid()); |
|
128 |
|
|
129 |
} |
|
130 |
private String publicationOpenAccessUrl = "<response>\n" + |
|
131 |
"\t <header>\n" + |
|
132 |
"\t\t <query>(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (objidentifier exact od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46)</query>\n" + |
|
133 |
"\t\t\t\t <locale>en_GB</locale>\t\n" + |
|
134 |
"\t\t\t\t\t<size>10</size>\n" + |
|
135 |
"\t\t\t <page>1</page>\n" + |
|
136 |
"\t\t\t <total>1</total>\n" + |
|
137 |
"\t\t\t\t\t</header>\n" + |
|
138 |
"\t <results>\n" + |
|
139 |
"\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
|
140 |
" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"\n" + |
|
141 |
" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
142 |
" <header>\n" + |
|
143 |
" <dri:objIdentifier>od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46</dri:objIdentifier>\n" + |
|
144 |
" <dri:dateOfCollection>2016-02-02T08:07:14Z</dri:dateOfCollection>\n" + |
|
145 |
" </header>\n" + |
|
146 |
" <metadata>\n" + |
|
147 |
" <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\n" + |
|
148 |
"\t\t <oaf:result>\n" + |
|
149 |
" <title classid=\"main title\" classname=\"main title\" schemeid=\"dnet:dataCite_title\"\n" + |
|
150 |
" schemename=\"dnet:dataCite_title\">ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ</title>\n" + |
|
151 |
" <dateofacceptance>2010-01-01</dateofacceptance>\n" + |
|
152 |
" <resulttype classid=\"publication\" classname=\"publication\" schemeid=\"dnet:result_typologies\"\n" + |
|
153 |
" schemename=\"dnet:result_typologies\"/>\n" + |
|
154 |
" <country classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
155 |
" <relevantdate classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
156 |
" <embargoenddate>2099-12-31</embargoenddate>\n" + |
|
157 |
" <originalId>oai:cyberleninka.ru:article/5969541</originalId>\n" + |
|
158 |
" <collectedfrom name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
159 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
160 |
" <pid classid=\"oai\" classname=\"oai\" schemeid=\"dnet:pid_types\"\n" + |
|
161 |
" schemename=\"dnet:pid_types\">oai:cyberleninka.ru:article/5969541</pid>\n" + |
|
162 |
" <pid classid=\"pmc\" classname=\"pmc\" schemeid=\"dnet:pid_types\"\n" + |
|
163 |
" schemename=\"dnet:pid_types\">pmc_test</pid>\n" + |
|
164 |
" <pid classid=\"orcidworkid\" classname=\"orcidworkid\" schemeid=\"dnet:pid_types\"\n" + |
|
165 |
" schemename=\"dnet:pid_types\">orcidworkid_test</pid>\n" + |
|
166 |
" <bestlicense classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
167 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
168 |
"\t\t <children>\n" + |
|
169 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
170 |
"\t\t\t <licence classid=\"CLOSED\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
171 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
172 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
173 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
174 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
175 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
176 |
"\t\t\t\t <webresource>\n" + |
|
177 |
"\t\t\t\t <url>http://CLOSED_ACCESS_URL</url>\n" + |
|
178 |
"\t\t\t\t </webresource>\n" + |
|
179 |
"\t\t\t\t <webresource>\n" + |
|
180 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
181 |
"\t\t\t\t </webresource>\n" + |
|
182 |
"\t\t\t </instance>\n" + |
|
183 |
"\t\t </children>\n" + |
|
184 |
"\t\t <children>\n" + |
|
185 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
186 |
"\t\t\t <licence classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
187 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
188 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
189 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
190 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
191 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
192 |
"\t\t\t\t <webresource>\n" + |
|
193 |
"\t\t\t\t <url>http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki</url>\n" + |
|
194 |
"\t\t\t\t </webresource>\n" + |
|
195 |
"\t\t\t\t <webresource>\n" + |
|
196 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
197 |
"\t\t\t\t </webresource>\n" + |
|
198 |
"\t\t\t </instance>\n" + |
|
199 |
"\t\t </children>\n" + |
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
"\t\t </oaf:result>\n" + |
|
204 |
" </oaf:entity>\n" + |
|
205 |
" </metadata>\n" + |
|
206 |
" </result>\n" + |
|
207 |
"\t\t\t\t\t\t</results>\n" + |
|
208 |
"\t <browseResults>\n" + |
|
209 |
"\t\t\t</browseResults>\n" + |
|
210 |
"</response>"; |
|
211 |
/* |
|
212 |
In this test, the oaf xml has multiple urls. The method should get the first "more" open Access with the following order (Open Access,Embargo, Closed ) |
|
213 |
*/ |
|
214 |
@Test |
|
215 |
public void oaf2PublicationOpenAccessUrlTest() throws Exception, ParserConfigurationException, SAXException, XPathExpressionException, IOException, TransformerException { |
|
216 |
Result result = OafParser.oaf2Result(publicationOpenAccessUrl); |
|
217 |
System.out.println(result.getExternalUrl()); |
|
218 |
Assert.assertNull(result.getAccessRights()); |
|
219 |
Assert.assertEquals("EMBARGO",result.getBestLicense()); |
|
220 |
Assert.assertEquals("infrastruct_::openaire", result.getCollectedFrom()); |
|
221 |
Assert.assertNull(result.getDoi()); |
|
222 |
Assert.assertEquals("oai:cyberleninka.ru:article/5969541",result.getOai()); |
|
223 |
Assert.assertEquals("od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46",result.getOpenaireId()); |
|
224 |
Assert.assertEquals("pmc_test",result.getPmcid()); |
|
225 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
226 |
Assert.assertEquals("ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ",result.getTitle()); |
|
227 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
228 |
|
|
229 |
Assert.assertEquals("http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki", result.getExternalUrl()); |
|
230 |
Assert.assertEquals("2099-12-31",result.getEmbargoEndDate()); |
|
231 |
Assert.assertEquals("orcidworkid_test", result.getOrcidworkid()); |
|
232 |
|
|
233 |
} |
|
234 |
private String publicationWithDoiOaf = "<response>\n" + |
|
235 |
"\t <header>\n" + |
|
236 |
"\t\t <query>(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (objidentifier exact od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46)</query>\n" + |
|
237 |
"\t\t\t\t <locale>en_GB</locale>\t\n" + |
|
238 |
"\t\t\t\t\t<size>10</size>\n" + |
|
239 |
"\t\t\t <page>1</page>\n" + |
|
240 |
"\t\t\t <total>1</total>\n" + |
|
241 |
"\t\t\t\t\t</header>\n" + |
|
242 |
"\t <results>\n" + |
|
243 |
"\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
|
244 |
" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"\n" + |
|
245 |
" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
246 |
" <header>\n" + |
|
247 |
" <dri:objIdentifier>od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46</dri:objIdentifier>\n" + |
|
248 |
" <dri:dateOfCollection>2016-02-02T08:07:14Z</dri:dateOfCollection>\n" + |
|
249 |
" </header>\n" + |
|
250 |
" <metadata>\n" + |
|
251 |
" <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\n" + |
|
252 |
"\t\t <oaf:result>\n" + |
|
253 |
" <title classid=\"main title\" classname=\"main title\" schemeid=\"dnet:dataCite_title\"\n" + |
|
254 |
" schemename=\"dnet:dataCite_title\">ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ</title>\n" + |
|
255 |
" <dateofacceptance>2010-01-01</dateofacceptance>\n" + |
|
256 |
" <resulttype classid=\"publication\" classname=\"publication\" schemeid=\"dnet:result_typologies\"\n" + |
|
257 |
" schemename=\"dnet:result_typologies\"/>\n" + |
|
258 |
" <country classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
259 |
" <relevantdate classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
260 |
" <embargoenddate>2099-12-31</embargoenddate>\n" + |
|
261 |
" <originalId>oai:cyberleninka.ru:article/5969541</originalId>\n" + |
|
262 |
" <collectedfrom name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
263 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
264 |
" <pid classid=\"doi\" classname=\"doi\" schemeid=\"dnet:pid_types\"\n" + |
|
265 |
" schemename=\"dnet:pid_types\">doi_test</pid>\n" + |
|
266 |
" <pid classid=\"oai\" classname=\"oai\" schemeid=\"dnet:pid_types\"\n" + |
|
267 |
" schemename=\"dnet:pid_types\">oai:cyberleninka.ru:article/5969541</pid>\n" + |
|
268 |
" <pid classid=\"pmc\" classname=\"pmc\" schemeid=\"dnet:pid_types\"\n" + |
|
269 |
" schemename=\"dnet:pid_types\">pmc_test</pid>\n" + |
|
270 |
" <pid classid=\"orcidworkid\" classname=\"orcidworkid\" schemeid=\"dnet:pid_types\"\n" + |
|
271 |
" schemename=\"dnet:pid_types\">orcidworkid_test</pid>\n" + |
|
272 |
" <bestlicense classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
273 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
274 |
"\t\t <children>\n" + |
|
275 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
276 |
"\t\t\t <licence classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
277 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
278 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
279 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
280 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
281 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
282 |
"\t\t\t\t <webresource>\n" + |
|
283 |
"\t\t\t\t <url>http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki</url>\n" + |
|
284 |
"\t\t\t\t </webresource>\n" + |
|
285 |
"\t\t\t\t <webresource>\n" + |
|
286 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
287 |
"\t\t\t\t </webresource>\n" + |
|
288 |
"\t\t\t </instance>\n" + |
|
289 |
"\t\t </children>\n" + |
|
290 |
"\t\t </oaf:result>\n" + |
|
291 |
" </oaf:entity>\n" + |
|
292 |
" </metadata>\n" + |
|
293 |
" </result>\n" + |
|
294 |
"\t\t\t\t\t\t</results>\n" + |
|
295 |
"\t <browseResults>\n" + |
|
296 |
"\t\t\t</browseResults>\n" + |
|
297 |
"</response>"; |
|
298 |
@Test |
|
299 |
public void oafWithDoi2PublicationTest() throws Exception, ParserConfigurationException, SAXException, XPathExpressionException, IOException, TransformerException { |
|
300 |
Result result = OafParser.oaf2Result(publicationWithDoiOaf); |
|
301 |
Assert.assertNull(result.getAccessRights()); |
|
302 |
Assert.assertEquals("EMBARGO",result.getBestLicense()); |
|
303 |
Assert.assertEquals("infrastruct_::openaire", result.getCollectedFrom()); |
|
304 |
Assert.assertNotNull(result.getDoi()); |
|
305 |
Assert.assertEquals("oai:cyberleninka.ru:article/5969541",result.getOai()); |
|
306 |
Assert.assertEquals("od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46",result.getOpenaireId()); |
|
307 |
Assert.assertEquals("pmc_test",result.getPmcid()); |
|
308 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
309 |
Assert.assertEquals("ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ",result.getTitle()); |
|
310 |
|
|
311 |
Assert.assertEquals("http://dx.doi.org/doi_test", result.getExternalUrl()); |
|
312 |
Assert.assertEquals("2099-12-31",result.getEmbargoEndDate()); |
|
313 |
Assert.assertEquals("orcidworkid_test", result.getOrcidworkid()); |
|
314 |
Assert.assertEquals("doi_test", result.getDoi()); |
|
315 |
|
|
316 |
|
|
317 |
} |
|
318 |
private String datasetOaf = "<response>\n" + |
|
319 |
"\t <header>\n" + |
|
320 |
"\t\t <query>(((deletedbyinference = false) AND (oaftype exact result)) and (resulttypeid exact publication)) and (objidentifier exact od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46)</query>\n" + |
|
321 |
"\t\t\t\t <locale>en_GB</locale>\t\n" + |
|
322 |
"\t\t\t\t\t<size>10</size>\n" + |
|
323 |
"\t\t\t <page>1</page>\n" + |
|
324 |
"\t\t\t <total>1</total>\n" + |
|
325 |
"\t\t\t\t\t</header>\n" + |
|
326 |
"\t <results>\n" + |
|
327 |
"\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
|
328 |
" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"\n" + |
|
329 |
" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
330 |
" <header>\n" + |
|
331 |
" <dri:objIdentifier>od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46</dri:objIdentifier>\n" + |
|
332 |
" <dri:dateOfCollection>2016-02-02T08:07:14Z</dri:dateOfCollection>\n" + |
|
333 |
" </header>\n" + |
|
334 |
" <metadata>\n" + |
|
335 |
" <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\n" + |
|
336 |
"\t\t <oaf:result>\n" + |
|
337 |
" <title classid=\"main title\" classname=\"main title\" schemeid=\"dnet:dataCite_title\"\n" + |
|
338 |
" schemename=\"dnet:dataCite_title\">ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ</title>\n" + |
|
339 |
" <dateofacceptance>2010-01-01</dateofacceptance>\n" + |
|
340 |
" <resulttype classid=\"dataset\" classname=\"dataset\" schemeid=\"dnet:result_typologies\"\n" + |
|
341 |
" schemename=\"dnet:result_typologies\"/>\n" + |
|
342 |
" <country classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
343 |
" <relevantdate classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
344 |
" <embargoenddate>2099-12-31</embargoenddate>\n" + |
|
345 |
" <originalId>oai:cyberleninka.ru:article/5969541</originalId>\n" + |
|
346 |
" <collectedfrom name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
347 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
348 |
" <pid classid=\"oai\" classname=\"oai\" schemeid=\"dnet:pid_types\"\n" + |
|
349 |
" schemename=\"dnet:pid_types\">oai:cyberleninka.ru:article/5969541</pid>\n" + |
|
350 |
" <pid classid=\"doi\" classname=\"doi\" schemeid=\"dnet:pid_types\"\n" + |
|
351 |
" schemename=\"dnet:pid_types\">doi_test</pid>\n" + |
|
352 |
" <pid classid=\"pmc\" classname=\"pmc\" schemeid=\"dnet:pid_types\"\n" + |
|
353 |
" schemename=\"dnet:pid_types\">pmc_test</pid>\n" + |
|
354 |
" <pid classid=\"orcidworkid\" classname=\"orcidworkid\" schemeid=\"dnet:pid_types\"\n" + |
|
355 |
" schemename=\"dnet:pid_types\">orcidworkid_test</pid>\n" + |
|
356 |
" <bestlicense classid=\"EMBARGO\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
357 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
358 |
"\t\t <children>\n" + |
|
359 |
"\t\t\t <instance id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\">\n" + |
|
360 |
"\t\t\t <licence classid=\"OPEN\" classname=\"Open Access\" schemeid=\"dnet:access_modes\"\n" + |
|
361 |
" schemename=\"dnet:access_modes\"/>\n" + |
|
362 |
" <instancetype classid=\"0001\" classname=\"Article\" schemeid=\"dnet:publication_resource\"\n" + |
|
363 |
" schemename=\"dnet:publication_resource\"/>\n" + |
|
364 |
" <hostedby name=\"CyberLeninka - Russian open access scientific library\"\n" + |
|
365 |
" id=\"opendoar____::c0f971d8cd24364f2029fcb9ac7b71f5\"/>\n" + |
|
366 |
"\t\t\t\t <webresource>\n" + |
|
367 |
"\t\t\t\t <url>http://cyberleninka.ru/article/n/postkonversionnaya-asistoliya-zheludochkov-serdtsa-u-bolnyh-infarktom-miokarda-i-vozmozhnosti-ee-profilaktiki</url>\n" + |
|
368 |
"\t\t\t\t </webresource>\n" + |
|
369 |
"\t\t\t\t <webresource>\n" + |
|
370 |
"\t\t\t\t <url>http://cyberleninka.ru/article_covers/5969541.png</url>\n" + |
|
371 |
"\t\t\t\t </webresource>\n" + |
|
372 |
"\t\t\t </instance>\n" + |
|
373 |
"\t\t </children>\n" + |
|
374 |
"\t\t </oaf:result>\n" + |
|
375 |
" </oaf:entity>\n" + |
|
376 |
" </metadata>\n" + |
|
377 |
" </result>\n" + |
|
378 |
"\t\t\t\t\t\t</results>\n" + |
|
379 |
"\t <browseResults>\n" + |
|
380 |
"\t\t\t</browseResults>\n" + |
|
381 |
"</response>"; |
|
382 |
|
|
383 |
|
|
384 |
@Test |
|
385 |
public void oaf2DatasetTest() throws Exception, ParserConfigurationException, SAXException, XPathExpressionException, IOException, TransformerException { |
|
386 |
Result result = OafParser.oaf2Result(datasetOaf); |
|
387 |
|
|
388 |
Assert.assertNull(result.getAccessRights()); |
|
389 |
Assert.assertEquals("EMBARGO",result.getBestLicense()); |
|
390 |
Assert.assertEquals("infrastruct_::openaire", result.getCollectedFrom()); |
|
391 |
Assert.assertEquals("oai:cyberleninka.ru:article/5969541",result.getOai()); |
|
392 |
Assert.assertEquals("od______2806::d19b8560e0c4ce1f25dd9d661f4b2b46",result.getOpenaireId()); |
|
393 |
Assert.assertEquals("pmc_test",result.getPmcid()); |
|
394 |
Assert.assertEquals(ClaimUtils.DATASET, result.getResultType()); |
|
395 |
Assert.assertEquals("ПОСТКОНВЕРСИОННАЯ АСИСТОЛИЯ ЖЕЛУДОЧКОВ СЕРДЦА У БОЛЬНЫХ ИНФАРКТОМ МИОКАРДА И ВОЗМОЖНОСТИ ЕЕ ПРОФИЛАКТИКИ",result.getTitle()); |
|
396 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
397 |
|
|
398 |
Assert.assertEquals("http://dx.doi.org/doi_test", result.getExternalUrl()); |
|
399 |
Assert.assertEquals("2099-12-31",result.getEmbargoEndDate()); |
|
400 |
Assert.assertEquals("orcidworkid_test", result.getOrcidworkid()); |
|
401 |
Assert.assertEquals("doi_test", result.getDoi()); |
|
402 |
|
|
403 |
} |
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
private String projectOaf = "<response>\n" + |
|
408 |
"\t <header>\n" + |
|
409 |
"\t\t <query>((deletedbyinference = false) AND (oaftype exact project)) and (projectcode exact 314867)</query>\n" + |
|
410 |
"\t\t\t\t <locale>en_GB</locale>\t\n" + |
|
411 |
"\t\t\t\t\t<size>10</size>\n" + |
|
412 |
"\t\t\t <page>1</page>\n" + |
|
413 |
"\t\t\t <total>1</total>\n" + |
|
414 |
"\t\t\t\t\t</header>\n" + |
|
415 |
"\t <results>\n" + |
|
416 |
"\t\t\t\t\t\t\t\t\t<result xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
|
417 |
" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\"\n" + |
|
418 |
" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
419 |
" <header>\n" + |
|
420 |
" <dri:objIdentifier>corda_______::073d0a668885f9e7292a5d9c323e4a20</dri:objIdentifier>\n" + |
|
421 |
" <dri:dateOfCollection>2015-08-24</dri:dateOfCollection>\n" + |
|
422 |
" <counters>\n" + |
|
423 |
"\t <counter_participation value=\"8\"/>\n" + |
|
424 |
" <counter_contactPerson value=\"1\"/>\n" + |
|
425 |
"\t </counters>\n" + |
|
426 |
" </header>\n" + |
|
427 |
" <metadata>\n" + |
|
428 |
" <oaf:entity xsi:schemaLocation=\"http://namespace.openaire.eu/oaf https://www.openaire.eu/schema/0.3/oaf-0.3.xsd\">\n" + |
|
429 |
"\t\t <oaf:project>\n" + |
|
430 |
"\t\t\t <code>314867</code>\n" + |
|
431 |
" <acronym>ADAW</acronym>\n" + |
|
432 |
" <title>Saponification pre-treatment and biosensors based control system for slaughterhouse waste anaerobic digestion improvement</title>\n" + |
|
433 |
" <startdate>2013-03-01</startdate>\n" + |
|
434 |
" <enddate>2015-02-28</enddate>\n" + |
|
435 |
" <callidentifier>FP7-SME-2012</callidentifier>\n" + |
|
436 |
" <ecsc39>false</ecsc39>\n" + |
|
437 |
" <oamandatepublications>false</oamandatepublications>\n" + |
|
438 |
" <contracttype classid=\"BSG\" classname=\"Research for the benefit of specific groups\"\n" + |
|
439 |
" schemeid=\"ec:FP7contractTypes\"\n" + |
|
440 |
" schemename=\"ec:FP7contractTypes\"/>\n" + |
|
441 |
" <fundingtree>\n" + |
|
442 |
" <funder>\n" + |
|
443 |
" <id>ec__________::EC</id>\n" + |
|
444 |
" <shortname>EC</shortname>\n" + |
|
445 |
" <name>European Commission</name>\n" + |
|
446 |
" <jurisdiction>EU</jurisdiction>\n" + |
|
447 |
" </funder>\n" + |
|
448 |
" <funding_level_2>\n" + |
|
449 |
" <id>ec__________::EC::FP7::SP4::SME</id>\n" + |
|
450 |
" <description>Research for the benefit of SMEs</description>\n" + |
|
451 |
" <name>SME</name>\n" + |
|
452 |
" <class>ec:program</class>\n" + |
|
453 |
" <parent>\n" + |
|
454 |
" <funding_level_1>\n" + |
|
455 |
" <id>ec__________::EC::FP7::SP4</id>\n" + |
|
456 |
" <description>SP4-Capacities</description>\n" + |
|
457 |
" <name>SP4</name>\n" + |
|
458 |
" <class>ec:specificprogram</class>\n" + |
|
459 |
" <parent>\n" + |
|
460 |
" <funding_level_0>\n" + |
|
461 |
" <id>ec__________::EC::FP7</id>\n" + |
|
462 |
" <description>SEVENTH FRAMEWORK PROGRAMME</description>\n" + |
|
463 |
" <name>FP7</name>\n" + |
|
464 |
" <parent/>\n" + |
|
465 |
" <class>ec:frameworkprogram</class>\n" + |
|
466 |
" </funding_level_0>\n" + |
|
467 |
" </parent>\n" + |
|
468 |
" </funding_level_1>\n" + |
|
469 |
" </parent>\n" + |
|
470 |
" </funding_level_2>\n" + |
|
471 |
" </fundingtree>\n" + |
|
472 |
" <websiteurl/>\n" + |
|
473 |
" <keywords/>\n" + |
|
474 |
" <duration/>\n" + |
|
475 |
" <ecarticle29_3/>\n" + |
|
476 |
" <subjects classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
477 |
" <originalId>corda_______::314867</originalId>\n" + |
|
478 |
" <collectedfrom name=\"CORDA - COmmon Research DAta Warehouse\"\n" + |
|
479 |
" id=\"openaire____::b30dac7baac631f3da7c2bb18dd9891f\"/>\n" + |
|
480 |
" <pid classid=\"\" classname=\"\" schemeid=\"\" schemename=\"\"/>\n" + |
|
481 |
" <datainfo>\n" + |
|
482 |
" <inferred>false</inferred>\n" + |
|
483 |
" <deletedbyinference>false</deletedbyinference>\n" + |
|
484 |
" <trust>0.9</trust>\n" + |
|
485 |
" <inferenceprovenance/>\n" + |
|
486 |
" <provenanceaction classid=\"sysimport:crosswalk:entityregistry\"\n" + |
|
487 |
" classname=\"sysimport:crosswalk:entityregistry\"\n" + |
|
488 |
" schemeid=\"dnet:provenanceActions\"\n" + |
|
489 |
" schemename=\"dnet:provenanceActions\"/>\n" + |
|
490 |
" </datainfo>\n" + |
|
491 |
"\t\t <rels>\n" + |
|
492 |
"<rel inferred=\"true\" trust=\"0.9\" inferenceprovenance=\"\" provenanceaction=\"UNKNOWN\"><to class=\"hasContact\" scheme=\"dnet:project_person_relations\" type=\"person\">dedup_wf_001::2b56ecf626015b620e97915cb0686ca1</to><fax> </fax><email>email@gmail.com</email><phone> </phone><fullname>Contact, Name</fullname></rel>" + |
|
493 |
"\t\t </rels>\n" + |
|
494 |
"\t\t <children>\n" + |
|
495 |
"\t\t </children>\n" + |
|
496 |
"\t\t </oaf:project>\n" + |
|
497 |
"\n" + |
|
498 |
" </oaf:entity>\n" + |
|
499 |
" </metadata>\n" + |
|
500 |
" </result>\n" + |
|
501 |
"\t\t\t\t\t\t</results>\n" + |
|
502 |
"\t <browseResults>\n" + |
|
503 |
"\t\t\t</browseResults>\n" + |
|
504 |
"</response>"; |
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
@Test |
|
509 |
public void oaf2ProjectTest() throws Exception { |
|
510 |
Project project = OafParser.oaf2Project(projectOaf); |
|
511 |
|
|
512 |
Assert.assertEquals("corda_______::073d0a668885f9e7292a5d9c323e4a20", project.getOpenaireId()); |
|
513 |
Assert.assertEquals("ADAW", project.getAcronym()); |
|
514 |
Assert.assertEquals("ec__________::EC", project.getFunderId()); |
|
515 |
Assert.assertEquals("EC", project.getFunderShortName()); |
|
516 |
Assert.assertEquals("European Commission", project.getFunderName()); |
|
517 |
Assert.assertEquals("Saponification pre-treatment and biosensors based control system for slaughterhouse waste anaerobic digestion improvement", project.getName()); |
|
518 |
Assert.assertEquals(1, project.getContactEmails().size()); |
|
519 |
Assert.assertEquals("email@gmail.com", project.getContactEmails().get(0)); |
|
520 |
} |
|
521 |
|
|
522 |
|
|
523 |
} |
modules/uoa-claims/branches/refactorConnections/src/test/java/eu/dnetlib/data/claims/migration/parser/DMFParserTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration.parser; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.Context; |
|
4 |
import eu.dnetlib.data.claims.migration.entity.Result; |
|
5 |
import eu.dnetlib.data.claims.migration.handler.DMFContextHandler; |
|
6 |
import org.junit.Assert; |
|
7 |
import org.junit.Test; |
|
8 |
import org.xml.sax.SAXException; |
|
9 |
|
|
10 |
import javax.xml.parsers.ParserConfigurationException; |
|
11 |
import javax.xml.xpath.XPathExpressionException; |
|
12 |
import java.io.IOException; |
|
13 |
|
|
14 |
/** |
|
15 |
* Created by kiatrop on 23/2/2016. |
|
16 |
*/ |
|
17 |
public class DMFParserTest { |
|
18 |
|
|
19 |
private String publicationDmf= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
|
20 |
"<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
21 |
" <header xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
22 |
" <dri:objIdentifier>crossref____::47593e13b24bcdd0f3d5573499f1d3a9</dri:objIdentifier>\n" + |
|
23 |
" <dri:recordIdentifier>10.1088/0004-637X/761/1/34</dri:recordIdentifier>\n" + |
|
24 |
" <dri:dateOfCollection></dri:dateOfCollection>\n" + |
|
25 |
" <dri:mdFormat></dri:mdFormat>\n" + |
|
26 |
" <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" + |
|
27 |
" <dri:repositoryId></dri:repositoryId>\n" + |
|
28 |
" <dr:objectIdentifier></dr:objectIdentifier>\n" + |
|
29 |
" <dr:dateOfCollection>2014-10-10T14:59:49+00:00</dr:dateOfCollection>\n" + |
|
30 |
" <oaf:datasourceprefix>crossref____</oaf:datasourceprefix>\n" + |
|
31 |
" </header>\n" + |
|
32 |
" <metadata xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
33 |
" <dc:dateAccepted>2012-01-01T00:00:00Z</dc:dateAccepted>\n" + |
|
34 |
" <dc:identifier>http://stacks.iop.org/0004-637X/761/i=1/a=34?key=crossref.d14dae8ac205453af63561a69c108e13</dc:identifier>\n" + |
|
35 |
" <dc:title>A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)</dc:title>\n" + |
|
36 |
" <oaf:collectedDatasourceid>openaire____::crossref</oaf:collectedDatasourceid>\n" + |
|
37 |
" <oaf:accessrights></oaf:accessrights>\n" + |
|
38 |
" <oaf:hostedBy name=\"Unknown Repository\" id=\"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\"/>\n" + |
|
39 |
" <oaf:collectedFrom name=\"Crossref\" id=\"openaire____::crossref\" />\n" + |
|
40 |
" \n" + |
|
41 |
" <dc:creator>Liimets, T.</dc:creator>\n" + |
|
42 |
" <dc:creator>Corradi, R. L. M.</dc:creator>\n" + |
|
43 |
" <dc:creator>Santander-García, M.</dc:creator>\n" + |
|
44 |
" <dc:creator>Villaver, E.</dc:creator>\n" + |
|
45 |
" <dc:creator>Rodríguez-Gil, P.</dc:creator>\n" + |
|
46 |
" <dc:creator>Verro, K.</dc:creator>\n" + |
|
47 |
" <dc:creator>Kolka, I.</dc:creator>\n" + |
|
48 |
" \n" + |
|
49 |
" <dc:identifier identifierType=\"doi\">10.1088/0004-637X/761/1/34</dc:identifier>\n" + |
|
50 |
//" <dr:CobjIdentifier>10.1088/0004-637X/761/1/34</dr:CobjIdentifier>\n" + |
|
51 |
" <dc:identifier identifierType=\"orcidworkid\">0000-0002-1112-1292-12694010</dc:identifier>\n" + |
|
52 |
//" <dr:CobjIdentifier>0000-0002-1112-1292-12694010</dr:CobjIdentifier>" + |
|
53 |
" </metadata>\n" + |
|
54 |
"</record>"; |
|
55 |
|
|
56 |
@Test |
|
57 |
public void dmf2PublicationTest() throws IOException, SAXException, ParserConfigurationException { |
|
58 |
Result result = DMFParser.dmf2Result(publicationDmf); |
|
59 |
|
|
60 |
Assert.assertNull(result.getAccessRights()); |
|
61 |
Assert.assertNull(result.getBestLicense()); |
|
62 |
Assert.assertEquals("openaire____::crossref", result.getCollectedFrom()); |
|
63 |
Assert.assertEquals("10.1088/0004-637X/761/1/34", result.getDoi()); |
|
64 |
Assert.assertEquals("0000-0002-1112-1292-12694010", result.getOrcidworkid()); |
|
65 |
Assert.assertNull(result.getOai()); |
|
66 |
Assert.assertEquals("crossref____::47593e13b24bcdd0f3d5573499f1d3a9", result.getOpenaireId()); |
|
67 |
Assert.assertNull(result.getPmcid()); |
|
68 |
Assert.assertEquals("A THREE-DIMENSIONAL VIEW OF THE REMNANT OF NOVA PERSEI 1901 (GK Per)", result.getTitle()); |
|
69 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
70 |
Assert.assertEquals("http://dx.doi.org/10.1088/0004-637X/761/1/34", result.getExternalUrl()); |
|
71 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
private String contextDmf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
|
76 |
"<record xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:prov=\"http://www.openarchives.org/OAI/2.0/provenance\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dri=\"http://www.driver-repository.eu/namespace/dri\" xmlns:dr=\"http://www.driver-repository.eu/namespace/dr\" xmlns:oaf=\"http://namespace.openaire.eu/oaf\">\n" + |
|
77 |
" <header xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
78 |
" <dri:objIdentifier>od______1031::ec6940963d90d1e275970ed2a0ac2508</dri:objIdentifier>\n" + |
|
79 |
" <dri:recordIdentifier>od______1031::ec6940963d90d1e275970ed2a0ac2508</dri:recordIdentifier>\n" + |
|
80 |
" <dri:dateOfCollection></dri:dateOfCollection>\n" + |
|
81 |
" <dri:mdFormat></dri:mdFormat>\n" + |
|
82 |
" <dri:mdFormatInterpretation></dri:mdFormatInterpretation>\n" + |
|
83 |
" <dri:repositoryId></dri:repositoryId>\n" + |
|
84 |
" <dr:objectIdentifier></dr:objectIdentifier>\n" + |
|
85 |
" <dr:dateOfCollection>2015-01-22T11:40:51+00:00</dr:dateOfCollection>\n" + |
|
86 |
" <oaf:datasourceprefix>openaire____</oaf:datasourceprefix>\n" + |
|
87 |
" </header>\n" + |
|
88 |
" <metadata xmlns=\"http://namespace.openaire.eu/\">\n" + |
|
89 |
" <oaf:collectedDatasourceid></oaf:collectedDatasourceid>\n" + |
|
90 |
" <oaf:hostedBy name=\"\" id=\"\"/>\n" + |
|
91 |
" <oaf:collectedFrom name=\"\" id=\"\" />\n" + |
|
92 |
" \n" + |
|
93 |
" <oaf:concept id=\"egi::country::gr\" />\n" + |
|
94 |
"\n" + |
|
95 |
"\n" + |
|
96 |
"\n" + |
|
97 |
" </metadata>\n" + |
|
98 |
"</record>"; |
|
99 |
|
|
100 |
@Test |
|
101 |
public void dmf2ContextTest() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { |
|
102 |
DMFParser dmfParser= new DMFParser(); |
|
103 |
DMFContextHandler dmfContextHandler = new DMFContextHandler(); |
|
104 |
Context context = dmfContextHandler.extractContextFromDMF(contextDmf); |
|
105 |
|
|
106 |
Assert.assertEquals("egi::country::gr", context.getOpenaireId()); |
|
107 |
Assert.assertEquals("EGI Federation> EGI Countries> Greece", context.getTitle()); |
|
108 |
} |
|
109 |
|
|
110 |
} |
modules/uoa-claims/branches/refactorConnections/src/test/java/eu/dnetlib/data/claims/migration/parser/ContextUtilsTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration.parser; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claimsDemo.ContextUtils; |
|
4 |
import org.junit.Assert; |
|
5 |
import org.junit.Test; |
|
6 |
|
|
7 |
/** |
|
8 |
* Created by argirok on 29/5/2018. |
|
9 |
*/ |
|
10 |
public class ContextUtilsTest { |
|
11 |
|
|
12 |
@Test |
|
13 |
public void dmf2ContextTest() throws Exception { |
|
14 |
|
|
15 |
String id= "egi::country::gr"; |
|
16 |
|
|
17 |
Assert.assertEquals("EGI Federation> EGI Countries> Greece", ContextUtils.extractLabel(id)); |
|
18 |
id= "egi"; |
|
19 |
Assert.assertEquals("EGI Federation", ContextUtils.extractLabel(id)); |
|
20 |
id="egi::classification"; |
|
21 |
Assert.assertEquals("EGI Federation> EGI classification scheme", ContextUtils.extractLabel(id)); |
|
22 |
id="egi::classification::natsc"; |
|
23 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Natural Sciences", ContextUtils.extractLabel(id)); |
|
24 |
id="egi::classification::natsc::math"; |
|
25 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Mathematics", ContextUtils.extractLabel(id)); |
|
26 |
id="egi::classification::natsc::math::applied"; |
|
27 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", ContextUtils.extractLabel(id)); |
|
28 |
id="egi::classification::natsc::math::applied"; |
|
29 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", ContextUtils.extractLabel(id)); |
|
30 |
id="aginfra::projects"; |
|
31 |
Assert.assertEquals("AGINFRA> AGINFRA+ Projects", ContextUtils.extractLabel(id)); |
|
32 |
id="aginfra::projects::1"; |
|
33 |
Assert.assertEquals("AGINFRA> AGINFRA+ Projects> European Foodbusiness Transfer Laboratory for stimulating entrepreneurial skills, for fostering innovation and for business creation in the Food Sector", ContextUtils.extractLabel(id)); |
|
34 |
|
|
35 |
/* |
|
36 |
|
|
37 |
0 |
|
38 |
id "aginfra::projects" |
|
39 |
label "AGINFRA+ Projects" |
|
40 |
1 |
|
41 |
id "aginfra::subcommunity" |
|
42 |
label "AGINFRA+ communities" |
|
43 |
0 |
|
44 |
id "aginfra::projects::1" |
|
45 |
label "European Foodbusiness Transfer Laboratory for stimulating entrepreneurial skills, for fostering innovation and for business creation in the Food Sector" |
|
46 |
concepts |
|
47 |
*/ |
|
48 |
} |
|
49 |
} |
modules/uoa-claims/branches/refactorConnections/src/test/java/eu/dnetlib/data/claims/migration/parser/RelationParserTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration.parser; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.Relation; |
|
4 |
import eu.dnetlib.data.claimsDemo.ClaimUtils; |
|
5 |
import org.junit.Assert; |
|
6 |
import org.junit.Test; |
|
7 |
|
|
8 |
/** |
|
9 |
* Created by kiatrop on 9/2/2016. |
|
10 |
*/ |
|
11 |
public class RelationParserTest { |
|
12 |
|
|
13 |
private final String projectResultXml = |
|
14 |
"<RELATIONS>" + |
|
15 |
"<RELATION type='resultProject' source='50|od______2367::63368dc45b69d3eac6bf94b0181b4e64' target='40|corda_______::fe4cbcc8f465c016c034a4f93965074c' />" + |
|
16 |
"</RELATIONS>"; |
|
17 |
|
|
18 |
private final String publicationDatasetXml = |
|
19 |
"<RELATIONS>" + |
|
20 |
"<RELATION type='resultResult_publicationdataset_isRelatedTo' source='50|dedup_wf_001::f81ff2795647ddd5756b046c026e22ec' target='50|datacite____::6302a4307468b410343413c04b11453b' />" + |
|
21 |
"</RELATIONS>"; |
|
22 |
|
|
23 |
private final String datasetPublicationXml = |
|
24 |
"<RELATIONS>" + |
|
25 |
"<RELATION type='resultResult_datasetpublication_isRelatedTo' source='50|r37b0ad08687::f016cea0f48814bea455804017883872' target='50|crossref____::68178723a3e54b2ab18acb8e2859ddaf' />" + |
|
26 |
"</RELATIONS>"; |
|
27 |
|
|
28 |
|
|
29 |
@Test |
|
30 |
public void xml2Relation_projectResult_test() { |
|
31 |
Relation relation = RelationParser.xml2Relation(projectResultXml); |
|
32 |
Assert.assertEquals(relation.getSourceId(), "corda_______::fe4cbcc8f465c016c034a4f93965074c"); |
|
33 |
Assert.assertEquals(relation.getSourceType(), ClaimUtils.PROJECT); |
|
34 |
Assert.assertEquals(relation.getTargetId(), "od______2367::63368dc45b69d3eac6bf94b0181b4e64"); |
|
35 |
Assert.assertEquals(relation.getTargetType(), ClaimUtils.PUBLICATION); |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void xml2Relation_publicationDataset_test() { |
|
40 |
Relation relation = RelationParser.xml2Relation(publicationDatasetXml); |
|
41 |
Assert.assertEquals(relation.getSourceId(), "datacite____::6302a4307468b410343413c04b11453b"); |
|
42 |
Assert.assertEquals(relation.getSourceType(), ClaimUtils.DATASET); |
|
43 |
Assert.assertEquals(relation.getTargetId(), "dedup_wf_001::f81ff2795647ddd5756b046c026e22ec"); |
|
44 |
Assert.assertEquals(relation.getTargetType(), ClaimUtils.PUBLICATION); |
|
45 |
} |
|
46 |
|
|
47 |
@Test |
|
48 |
public void xml2Relation_datasetPublication_test() { |
|
49 |
Relation relation = RelationParser.xml2Relation(datasetPublicationXml); |
|
50 |
Assert.assertEquals(relation.getSourceId(), "crossref____::68178723a3e54b2ab18acb8e2859ddaf"); |
|
51 |
Assert.assertEquals(relation.getSourceType(), ClaimUtils.PUBLICATION); |
|
52 |
Assert.assertEquals(relation.getTargetId(), "r37b0ad08687::f016cea0f48814bea455804017883872"); |
|
53 |
Assert.assertEquals(relation.getTargetType(), ClaimUtils.DATASET); |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/uoa-claims/branches/refactorConnections/src/main/java/eu/dnetlib/data/claims/migration/ClaimValidationException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration; |
|
2 |
|
|
3 |
/** |
|
4 |
* Created by kiatrop on 21/4/2016. |
|
5 |
*/ |
|
6 |
public class ClaimValidationException extends Exception { |
|
7 |
|
|
8 |
public ClaimValidationException() { |
|
9 |
super(); |
|
10 |
} |
|
11 |
|
|
12 |
public ClaimValidationException(String message, Throwable cause) { |
|
13 |
super(message, cause); |
|
14 |
} |
|
15 |
|
|
16 |
public ClaimValidationException(String message) { |
|
17 |
super(message); |
|
18 |
} |
|
19 |
|
|
20 |
public ClaimValidationException(Throwable cause) { |
|
21 |
super(cause); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/uoa-claims/branches/refactorConnections/src/main/java/eu/dnetlib/data/claims/migration/Test.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.Project; |
|
4 |
import eu.dnetlib.data.claims.migration.entity.Result; |
|
5 |
|
|
6 |
import java.util.Calendar; |
|
7 |
|
|
8 |
public class Test { |
|
9 |
|
|
10 |
public static void main(String[] args) { |
|
11 |
|
|
12 |
ClaimGenerics<Object, Result> claim = new ClaimGenerics<Object, Result>(); |
|
13 |
claim.setDate(Calendar.getInstance().getTime()); |
|
14 |
claim.setId("claimId"); |
|
15 |
claim.setUserMail("claim mail"); |
|
16 |
Project project = new Project(); |
|
17 |
project.setFunderName("EC"); |
|
18 |
project.setOpenaireId("openaireID1234"); |
|
19 |
project.setName("PrTitle"); |
|
20 |
Result result = new Result(); |
|
21 |
result.setAccessRights("accessRights"); |
|
22 |
result.setCollectedFrom("collectedFrom"); |
|
23 |
result.setExternalUrl("external_url"); |
|
24 |
result.setOpenaireId("openaire_id"); |
|
25 |
result.setTitle("title"); |
|
26 |
result.setResultType("type"); |
|
27 |
result.setMetadataRecord("xmlString"); |
|
28 |
claim.setBody(project); |
|
29 |
claim.setTarget(result); |
|
30 |
System.out.println("test"); |
|
31 |
System.out.println(JsonldBuilder.toJsonld(claim)); |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
} |
modules/uoa-claims/branches/refactorConnections/src/main/java/eu/dnetlib/data/claims/migration/ClaimValidation.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.migration.entity.*; |
|
4 |
import eu.dnetlib.data.claimsDemo.ClaimUtils; |
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import java.io.BufferedWriter; |
|
8 |
import java.io.FileWriter; |
|
9 |
import java.io.PrintWriter; |
|
10 |
|
|
11 |
/** |
|
12 |
* Created by argirok on 21/1/2016. |
|
13 |
*/ |
|
14 |
public class ClaimValidation { |
|
15 |
private PrintWriter out; |
|
16 |
String pathToSaveReport = null; |
|
17 |
|
|
18 |
private static Logger logger = Logger.getLogger(ClaimValidation.class); |
|
19 |
|
|
20 |
/* |
|
21 |
Claim: |
|
22 |
Mandatory Fields : id, sourceType,targetType, User e-mail, Date, Target, Source |
|
23 |
|
|
24 |
*/ |
|
25 |
public boolean validateClaim(Claim claim){ |
|
26 |
boolean isValid=true; |
|
27 |
try { |
|
28 |
out = new PrintWriter(new BufferedWriter(new FileWriter(pathToSaveReport+"/validationFile.txt", true))); |
|
29 |
|
|
30 |
} catch (Exception e) { |
|
31 |
out = null; |
|
32 |
logger.error("Couldn't write to file " + "validationFile.txt", e); |
|
33 |
} |
|
34 |
|
|
35 |
if(claim==null){ |
|
36 |
isValid=false; |
|
37 |
if(out!=null) { |
|
38 |
out.println("Claim invalid (null)..."); |
|
39 |
} |
|
40 |
logger.warn("Claim invalid (null)..."); |
|
41 |
// }else if(claim.getId()==null||claim.getId().isEmpty()){ |
|
42 |
// isValid=false; |
|
43 |
// out.println("Claim invalid (id)..." ); |
|
44 |
}else if(claim.getTargetType()==null||claim.getTargetType().isEmpty()){ |
|
45 |
isValid=false; |
|
46 |
if(out!=null) { |
|
47 |
out.println("Claim invalid (target type): " + claim.getId()); |
|
48 |
} |
|
49 |
logger.warn("Claim invalid (target type): "+claim.getId()); |
|
50 |
|
|
51 |
}else if(claim.getSourceType()==null||claim.getSourceType().isEmpty()){ |
|
52 |
isValid=false; |
|
53 |
if(out!=null) { |
|
54 |
out.println("Claim invalid (source type): " + claim.getId()); |
|
55 |
} |
|
56 |
logger.warn("Claim invalid (source type): "+claim.getId()); |
|
57 |
|
|
58 |
}else if(claim.getDate()==null){ |
|
59 |
isValid=false; |
|
60 |
if(out!=null) { |
|
61 |
out.println("Claim invalid (date): " + claim.getId()); |
|
62 |
} |
|
63 |
logger.warn("Claim invalid (date): "+claim.getId()); |
|
64 |
|
|
65 |
}else if(claim.getUserMail()==null||claim.getUserMail().isEmpty()){ |
|
66 |
isValid=false; |
|
67 |
if(out!=null) { |
|
68 |
out.println("Claim invalid (mail): " + claim.getId()); |
|
69 |
} |
|
70 |
logger.warn("Claim invalid (mail): "+claim.getId()); |
|
71 |
|
|
72 |
}else if(claim.getSource()==null || claim.getTarget()==null){ |
|
73 |
isValid=false; |
|
74 |
if(out!=null) { |
|
75 |
out.println("Result invalid : " + claim.getId()); |
|
76 |
} |
|
77 |
logger.warn("Result invalid : "+claim.getId()); |
|
78 |
|
|
79 |
}else if(claim.getSource()==null || claim.getTarget()==null){ |
|
80 |
isValid=false; |
|
81 |
if(out!=null) { |
|
82 |
out.println("Result invalid : " + claim.getId()); |
|
83 |
} |
|
84 |
logger.warn("Result invalid : "+claim.getId()); |
|
85 |
|
|
86 |
}else if(claim.getSource().getOpenaireId()!=null && claim.getTarget().getOpenaireId()!=null && claim.getSource().getOpenaireId().equals(claim.getTarget().getOpenaireId())){ |
|
87 |
isValid=false; |
|
88 |
if(out!=null) { |
|
89 |
out.println("Claim invalid (source == target): " + claim.getId()); |
|
90 |
} |
|
91 |
logger.warn("Claim invalid (source == target): "+claim.getId()); |
|
92 |
|
|
93 |
}else{ |
|
94 |
boolean sourceIsValid=validateByType(claim.getSource(),claim.getSourceType(),claim.getId()); |
|
95 |
boolean targetIsValid=validateByType(claim.getTarget(),claim.getTargetType(),claim.getId()); |
|
96 |
isValid= isValid&&sourceIsValid&&targetIsValid; |
|
97 |
if(!isValid){ |
|
98 |
if(out!=null) { |
|
99 |
out.println("Claim invalid (source /target): " + claim.getId() + "\n"); |
|
100 |
} |
|
101 |
logger.warn("Claim invalid (source /target): "+claim.getId()+"\n"); |
|
102 |
} |
|
103 |
} |
|
104 |
if(out!=null) { |
|
105 |
out.close(); |
|
106 |
} |
|
107 |
|
|
108 |
return isValid; |
|
109 |
} |
|
110 |
/* |
|
111 |
Project: |
|
112 |
Mandatory Fields : id, type, Collected from |
|
113 |
|
|
114 |
*/ |
|
115 |
public boolean validateResult(Result result, String claimId){ |
|
116 |
boolean isValid=true; |
|
117 |
if(result==null){ |
|
118 |
isValid=false; |
|
119 |
out.println("Result invalid (null): - claimId:"+claimId); |
|
120 |
// }else if(result.getOpenaireId()==null||result.getOpenaireId().isEmpty()){ |
|
121 |
// isValid=false; |
|
122 |
// out.println("Result invalid (Id): - claimId:"+claimId); |
|
123 |
}else if(result.getResultType()==null||result.getResultType().isEmpty()){ |
|
124 |
isValid=false; |
|
125 |
out.println("Result invalid (Type): "+result.getOpenaireId()+"- claimId:"+claimId); |
|
126 |
}/* |
|
127 |
//http://services.openaire.eu:8380/search/search?action=search&sTransformer=results_openaire&query=%28%28%28deletedbyinference+%3D+false%29+AND+%28oaftype+exact+result%29%29+and+%28%28resulttypeid+exact+publication%29+or+%28resulttypeid+exact+dataset%29%29%29+and+%28%28objIdentifier+ |
|
128 |
//exact+od______1389%3A%3A6ba133c8460d5a67dfb18f34cc5303fb%29+or+%28resultdupid+exact+od______1389%3A%3A6ba133c8460d5a67dfb18f34cc5303fb%29%29&size=10&locale=en_GB |
|
129 |
//There are resuts with no title |
|
130 |
//so I am |
|
131 |
else if(result.getTitle()==null||result.getTitle().isEmpty()){ |
|
132 |
isValid=false; |
|
133 |
out.println("Result invalid (title): "+result.getOpenaireId()+"- claimId:"+claimId); |
|
134 |
}*/else if(result.getCollectedFrom()==null||result.getCollectedFrom().isEmpty()){ |
|
135 |
isValid=false; |
|
136 |
out.println("Result invalid (collectedFrom) : "+result.getOpenaireId()+"- claimId:"+claimId); |
|
137 |
}else if (result.getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_OPENAIRE) && result.getOpenaireId()==null) { |
|
138 |
isValid = false; |
|
139 |
out.println("Result invalid (Openaire - no id): - claimId:" + claimId); |
|
140 |
}else if ((result.getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_DATACITE)|| result.getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_CROSSREF) ) && result.getDoi()==null) { |
|
141 |
isValid = false; |
|
142 |
out.println("Result invalid (Crossref/Datacite - no doi): - claimId:" + claimId); |
|
143 |
}else if (result.getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_ORCID) && result.getOrcidworkid()==null) { |
|
144 |
isValid = false; |
|
145 |
out.println("Result invalid (Orcid - no work id): - claimId:" + claimId); |
|
146 |
} |
|
147 |
|
|
148 |
return isValid; |
|
149 |
} |
|
150 |
/* |
|
151 |
Project: |
|
152 |
Mandatory Fields : id, name |
|
153 |
|
|
154 |
*/ |
|
155 |
public boolean validateProject(Project project, String claimId){ |
|
156 |
boolean isValid=true; |
|
157 |
if(project==null){ |
|
158 |
isValid=false; |
|
159 |
out.println("Project invalid (null): - claimId:"+claimId); |
|
160 |
}else if(project.getOpenaireId()==null||project.getOpenaireId().isEmpty()){ |
|
161 |
isValid=false; |
|
162 |
out.println("Project invalid (id): - claimId:"+claimId); |
|
163 |
}else if((project.getName()==null||project.getName().isEmpty())&&(project.getAcronym()==null||project.getAcronym().isEmpty())){ |
|
164 |
isValid=false; |
|
165 |
out.println("Project invalid (name/acronym): "+project.getOpenaireId()+"- claimId:"+claimId); |
|
166 |
}else if(project.getFunderId()==null||project.getFunderId().isEmpty()){ |
|
167 |
isValid=false; |
|
168 |
out.println("Project invalid (funder id): "+project.getOpenaireId()+"- claimId:"+claimId); |
|
169 |
} |
|
170 |
else if(project.getFunderName()==null||project.getFunderName().isEmpty()){ |
|
171 |
isValid=false; |
|
172 |
out.println("Project invalid (funder name): "+project.getOpenaireId()+"- claimId:"+claimId); |
|
173 |
} |
|
174 |
|
|
175 |
return isValid; |
|
176 |
} |
|
177 |
/* |
|
178 |
Context: |
|
179 |
Mandatory Fields : id, title |
|
180 |
|
|
181 |
*/ |
|
182 |
public boolean validateContext(Context context, String claimId){ |
|
183 |
boolean isValid=true; |
|
184 |
if(context==null){ |
|
185 |
isValid=false; |
|
186 |
out.println("Context invalid (null): - claimId:"+claimId); |
|
187 |
}else if(context.getOpenaireId()==null||context.getOpenaireId().isEmpty()){ |
|
188 |
isValid=false; |
|
189 |
out.println("Context invalid (id): - claimId:"+claimId); |
|
190 |
}/* |
|
191 |
//This is commented since There isn't a way to fill this field right now. |
|
192 |
else if(context.getTitle()==null||context.getTitle().isEmpty()){ |
|
193 |
isValid=false; |
|
194 |
out.println("Context invalid : "+context.getOpenaireId()+"- claimId:"+claimId); |
|
195 |
}*/ |
|
196 |
return isValid; |
|
197 |
} |
|
198 |
private boolean validateByType(OpenaireEntity entity,String type , String claimId ){ |
|
199 |
//TODO add more types (e.g. patends) when they are available |
|
200 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE) ||type.equals(ClaimUtils.OTHER)){ |
|
201 |
return validateResult((Result)entity,claimId); |
|
202 |
} else if(type.equals(ClaimUtils.CONTEXT)){ |
|
203 |
return validateContext((Context)entity,claimId); |
|
204 |
}else if(type.equals(ClaimUtils.PROJECT)){ |
|
205 |
return validateProject((Project)entity,claimId); |
|
206 |
}else{ |
|
207 |
if(entity.getOpenaireId()!=null){ |
|
208 |
out.println("Entity invalid type ("+type+"):"+entity.getOpenaireId()+" - claimId:"+claimId); |
|
209 |
}else { |
|
210 |
out.println("Entity invalid type (" + type + "): - claimId:" + claimId); |
|
211 |
} |
|
212 |
} |
|
213 |
return false; |
|
214 |
} |
|
215 |
|
|
216 |
public static boolean validateCollectedFrom(String collectedFrom) throws ClaimValidationException { |
|
217 |
//TODO add more collected from when they are available |
|
218 |
if (collectedFrom==null || collectedFrom.isEmpty()) { |
|
219 |
logger.error("CollectedFrom field of source and/or target is null or empty"); |
|
220 |
throw new ClaimValidationException("CollectedFrom field of source and/or target cannot be empty."); |
|
221 |
|
|
222 |
} else if (!collectedFrom.equals(ClaimUtils.OPENAIRE) && |
|
223 |
!collectedFrom.equals(ClaimUtils.DATACITE) && |
|
224 |
!collectedFrom.equals(ClaimUtils.CROSSREF) && |
|
225 |
!collectedFrom.equals(ClaimUtils.ORCID)) { |
|
226 |
logger.error("CollectedFrom field of source and/or target is invalid. Value is:"+collectedFrom); |
|
227 |
throw new ClaimValidationException("CollectedFrom field of source and/or target is invalid. The allowed " + |
|
228 |
"types are: " + ClaimUtils.OPENAIRE + ", " + ClaimUtils.DATACITE |
|
229 |
+ ", " + ClaimUtils.CROSSREF + ", " + ClaimUtils.ORCID +"."); |
|
230 |
|
|
231 |
|
|
232 |
} |
|
233 |
|
|
234 |
return true; |
|
235 |
} |
|
236 |
|
|
237 |
public static boolean validateType(String type) throws ClaimValidationException { |
|
238 |
if (type == null || type.isEmpty()) { |
|
239 |
throw new ClaimValidationException("The type of source and/or target cannot be empty."); |
|
240 |
|
|
241 |
} else if (!type.equals(ClaimUtils.PUBLICATION) && !type.equals(ClaimUtils.DATASET) && |
|
242 |
!type.equals(ClaimUtils.CONTEXT) && !type.equals(ClaimUtils.PROJECT)) { |
|
243 |
throw new ClaimValidationException("The given type is invalid. The allowed types are: " + |
|
244 |
ClaimUtils.PUBLICATION + ", " + ClaimUtils.DATASET + ", " + ClaimUtils.CONTEXT + ", " + |
|
245 |
ClaimUtils.PROJECT); |
|
246 |
} |
|
247 |
|
|
248 |
return true; |
|
249 |
} |
|
250 |
|
|
251 |
// /* |
|
252 |
// Checks if the doi is valid. If it is not then replaces the existing DOI with the valid one. |
|
253 |
// */ |
|
254 |
// public static void checkForDOI(Result r) throws Exception { |
|
255 |
// if(r.getDOI()==null){ |
|
256 |
// return ; |
|
257 |
// } |
|
258 |
// String validDOI=isValidDoi(r.getDOI()); |
|
259 |
// if(!validDOI.equals(r.getDOI())){ |
|
260 |
// if(r.getMetadataRecord()!=null) { |
|
261 |
// r.setMetadataRecord(r.getMetadataRecord().replace(r.getDOI(), validDOI)); |
|
262 |
// } |
|
263 |
// if(r.getExternalUrl()!=null){ |
|
264 |
// r.setExternalUrl(r.getExternalUrl().replace(r.getDOI(), validDOI)); |
|
265 |
// } |
|
266 |
// r.setDoi(validDOI); |
|
267 |
// } |
|
268 |
// } |
|
269 |
// public static String isValidDoi(String doi) throws Exception { |
|
270 |
// if(doi==null){ |
|
271 |
// return null; |
|
272 |
// } |
|
273 |
// try{ |
|
274 |
// PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("invalid_dois.txt", true))); |
|
275 |
// boolean valid=SearchUtils.isDoiValid(doi); |
|
276 |
// if(!valid&&(doi.length() - (doi.replace("_", "")).length() > 1)){ |
|
277 |
// String transformDoi = doi.replace("_", "-"); |
|
278 |
// valid=SearchUtils.isDoiValid(transformDoi); |
|
279 |
// if(valid){ |
|
280 |
// Date date= new java.util.Date(); |
|
281 |
// out.println(new Timestamp(date.getTime())+" - Invalid doi: "+doi+" replaced with : "+transformDoi); |
|
282 |
// doi=transformDoi; |
|
283 |
// } |
|
284 |
// }else if(!valid&&(doi.length() - (doi.replace("_", "")).length() == 1)) { |
|
285 |
// String transformDoi = doi.replace("_", "-"); |
|
286 |
// valid=SearchUtils.isDoiValid(transformDoi); |
|
287 |
// if(valid){ |
|
288 |
// Date date= new java.util.Date(); |
|
289 |
// out.println(new Timestamp(date.getTime())+" - Invalid doi: "+doi+" replaced with : "+transformDoi); |
|
290 |
// doi = transformDoi; |
|
291 |
// } |
|
292 |
// }else if(!valid) { |
|
293 |
// String transformDoi =doi.replaceAll("\\p{C}", ""); |
|
294 |
// valid=SearchUtils.isDoiValid(transformDoi); |
|
295 |
// if(valid){ |
|
296 |
// Date date= new java.util.Date(); |
|
297 |
// out.println(new Timestamp(date.getTime())+" - Invalid doi: "+doi+" replaced with (zero-width-char): "+transformDoi); |
|
298 |
// doi = transformDoi; |
|
299 |
// } |
|
300 |
// } |
|
301 |
// out.close(); |
|
302 |
// }catch (IOException e) { |
|
303 |
// e.printStackTrace(); |
|
304 |
// System.err.println("Couldn't write to file " + "invalid_dois.txt"); |
|
305 |
// } |
|
306 |
// return doi; |
|
307 |
// } |
|
308 |
|
|
309 |
|
|
310 |
public String getPathToSaveReport() { |
|
311 |
return pathToSaveReport; |
|
312 |
} |
|
313 |
|
|
314 |
public void setPathToSaveReport(String pathToSaveReport) { |
|
315 |
this.pathToSaveReport = pathToSaveReport; |
|
316 |
} |
|
317 |
} |
modules/uoa-claims/branches/refactorConnections/src/main/java/eu/dnetlib/data/claims/migration/JsonldBuilder.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration; |
|
2 |
import java.util.ArrayList; |
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.gson.*; |
|
6 |
import eu.dnetlib.data.claims.migration.entity.Claim; |
|
7 |
import eu.dnetlib.data.claims.migration.entity.Result; |
|
8 |
import org.springframework.web.client.RestTemplate; |
|
9 |
|
|
10 |
import javax.lang.model.type.ArrayType; |
|
11 |
|
|
12 |
public class JsonldBuilder { |
|
13 |
|
|
14 |
public static String toJsonld(ClaimGenerics<Object, Result> claim) { |
|
15 |
Gson gson = new GsonBuilder().setPrettyPrinting().create(); |
Also available in: Unified diff
Creating a branch of project for refactor con
nections issue