Revision 58341
Added by Argiro Kokogiannaki about 4 years ago
modules/uoa-claims/trunk/src/test/java/eu/dnetlib/data/claims/TestClass.java | ||
---|---|---|
61 | 61 |
ClaimValidation claimValidation = null; |
62 | 62 |
|
63 | 63 |
EmailSender emailSender = null; |
64 |
ContextUtils contextUtils = null; |
|
64 | 65 |
|
65 | 66 |
|
66 | 67 |
@Before |
... | ... | |
83 | 84 |
claimValidation = context.getBean(ClaimValidation.class); |
84 | 85 |
|
85 | 86 |
emailSender = context.getBean(EmailSender.class); |
87 |
contextUtils = context.getBean(ContextUtils.class); |
|
86 | 88 |
|
87 | 89 |
assertNotNull(sqlDAO); |
88 | 90 |
|
... | ... | |
174 | 176 |
} |
175 | 177 |
@Test |
176 | 178 |
public void testContext(){ |
177 |
System.out.print(ContextUtils.fetchContextById("egi::organisation::uom", false)); |
|
179 |
|
|
180 |
System.out.print(contextUtils.fetchContextById("egi::organisation::uom")); |
|
178 | 181 |
} |
179 | 182 |
@Test |
180 | 183 |
public void testInsert() throws Exception, SQLStoreException { |
... | ... | |
195 | 198 |
*/ |
196 | 199 |
// String id=claimHandler.buildAndInsertClaim("argirok_1@hotmail.com", "project", "corda__h2020::94c962e736df90a5075a7f660ba3d7f6", "openaire", "OPEN", null,"software", "10.1007/978-3-540-76323-9_4", "crossref", "EMBARGO","2028-11-10T13:55:47.935Z"); |
197 | 200 |
// String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "project", "corda__h2020::94c962e736df90a5075a7f660ba3d7f6", "openaire", "OPEN", null,"publication", "0000-0002-9414-646X-21755327", "orcid", "EMBARGO","2028-11-10T13:55:47.935Z"); |
198 |
String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "project", "corda__h2020::94c962e736df90a5075a7f660ba3d7f6", "openaire", "OPEN", null,"publication", "10.5555/987654", "crossref", "EMBARGO","2028-11-10T13:55:47.935Z"); |
|
201 |
// {user:argirok@di.uoa.gr, sourceType:project, sourceId:corda_______::2c37878a0cede85dbbd1081bb9b4a2f8, sourceCollectedFrom:openaire, sourceAccessRights:OPEN, sourceEmbargoDate:null, |
|
202 |
// targetType:publication, targetId:0000-0002-3477-3082-5288650, targetCollectedFrom:orcid, targetAccessRights:OPEN, targetEmbargoDate:null} |
|
203 |
// String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "project", "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "openaire", "OPEN", null,"publication", "0000-0002-3477-3082-5288651", "orcid", "OPEN",null, "development_explore"); |
|
199 | 204 |
|
200 | 205 |
|
201 | 206 |
// String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "context", "egi::country::gr", |
202 |
// "openaire", null, null,"dataset", "10.4225/41/55A111BDE741C", "datacite", "OPEN","2017-05-01"); |
|
207 |
// "openaire", null, null,"dataset", "10.4225/41/55A111BDE741C", "datacite", "OPEN","2017-05-01","development_explore");
|
|
203 | 208 |
} |
204 | 209 |
@Test |
205 | 210 |
public void testDelete() throws Exception, SQLStoreException { |
modules/uoa-claims/trunk/src/test/java/eu/dnetlib/data/claims/parser/ExternalParserTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.claims.parser; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.data.claims.entity.Result; |
4 |
import eu.dnetlib.data.claims.handler.DirectIndexHandler; |
|
4 | 5 |
import eu.dnetlib.data.claims.utils.ClaimUtils; |
6 |
import eu.dnetlib.data.claims.utils.SearchUtils; |
|
5 | 7 |
import org.apache.log4j.BasicConfigurator; |
6 | 8 |
import org.junit.Assert; |
7 | 9 |
import org.junit.Before; |
8 | 10 |
import org.junit.Test; |
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.context.ApplicationContext; |
|
13 |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
9 | 14 |
|
10 | 15 |
/** |
11 | 16 |
* Created by kiatrop on 23/2/2016. |
12 | 17 |
*/ |
13 | 18 |
public class ExternalParserTest { |
19 |
// @Autowired |
|
20 |
SearchUtils searchUtils; |
|
14 | 21 |
|
15 |
|
|
16 | 22 |
@Before |
17 | 23 |
public void init() throws Exception { |
18 | 24 |
BasicConfigurator.configure(); |
25 |
ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/springContext-claims.xml"); |
|
26 |
|
|
27 |
searchUtils = context.getBean(SearchUtils.class); |
|
28 |
|
|
19 | 29 |
} |
20 | 30 |
private String crossrefJson = "{\"status\":\"ok\",\"message-type\":\"work-list\",\"message-version\":\"1.0.0\",\"message\":" + |
21 | 31 |
"{\"query\":{\"search-terms\":null,\"start-index\":0},\"items-per-page\":20,\"items\":[{\"indexed\":" + |
... | ... | |
65 | 75 |
Assert.assertEquals("Y. Fontyn", result.getAuthors().get(5+"")); |
66 | 76 |
} |
67 | 77 |
|
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>"; |
|
78 |
private String orcidXml2 = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + |
|
79 |
"<activities:works path=\"/0000-0002-3477-3082/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" + |
|
80 |
"<common:last-modified-date>2015-07-16T22:57:28.480Z</common:last-modified-date>\n" + |
|
81 |
"<activities:group>\n" + |
|
82 |
"<common:last-modified-date>2015-07-16T22:57:28.344Z</common:last-modified-date>\n" + |
|
83 |
"<common:external-ids>\n" + |
|
84 |
"<common:external-id>\n" + |
|
85 |
"<common:external-id-type>doi</common:external-id-type>\n" + |
|
86 |
"<common:external-id-value>10.1007/978-3-642-27169-4_2</common:external-id-value>\n" + |
|
87 |
"<common:external-id-url/>\n" + |
|
88 |
"<common:external-id-relationship>self</common:external-id-relationship>\n" + |
|
89 |
"</common:external-id>\n" + |
|
90 |
"</common:external-ids>\n" + |
|
91 |
"<work:work-summary put-code=\"5288651\" path=\"/0000-0002-3477-3082/work/5288651\" visibility=\"public\" display-index=\"0\">\n" + |
|
92 |
"<common:created-date>2013-03-08T03:19:36.095Z</common:created-date>\n" + |
|
93 |
"<common:last-modified-date>2015-07-16T22:57:28.264Z</common:last-modified-date>\n" + |
|
94 |
"<common:source>\n" + |
|
95 |
"<common:source-orcid>\n" + |
|
96 |
"<common:uri>https://orcid.org/0000-0002-3477-3082</common:uri>\n" + |
|
97 |
"<common:path>0000-0002-3477-3082</common:path>\n" + |
|
98 |
"<common:host>orcid.org</common:host>\n" + |
|
99 |
"</common:source-orcid>\n" + |
|
100 |
"<common:source-name>Natalia Manola</common:source-name>\n" + |
|
101 |
"</common:source>\n" + |
|
102 |
"<work:title>\n" + |
|
103 |
"<common:title>\n" + |
|
104 |
"A Survey of Context-Aware Cross-Digital Library Personalization\n" + |
|
105 |
"</common:title>\n" + |
|
106 |
"</work:title>\n" + |
|
107 |
"<common:external-ids>\n" + |
|
108 |
"<common:external-id>\n" + |
|
109 |
"<common:external-id-type>doi</common:external-id-type>\n" + |
|
110 |
"<common:external-id-value>10.1007/978-3-642-27169-4_2</common:external-id-value>\n" + |
|
111 |
"<common:external-id-url/>\n" + |
|
112 |
"<common:external-id-relationship>self</common:external-id-relationship>\n" + |
|
113 |
"</common:external-id>\n" + |
|
114 |
"</common:external-ids>\n" + |
|
115 |
"<work:type>book-chapter</work:type>\n" + |
|
116 |
"<common:publication-date>\n" + |
|
117 |
"<common:year>2012</common:year>\n" + |
|
118 |
"</common:publication-date>\n" + |
|
119 |
"</work:work-summary>\n" + |
|
120 |
"<work:work-summary put-code=\"5288654\" path=\"/0000-0002-3477-3082/work/5288654\" visibility=\"public\" display-index=\"0\">\n" + |
|
121 |
"<common:created-date>2013-03-08T03:19:36.116Z</common:created-date>\n" + |
|
122 |
"<common:last-modified-date>2015-07-16T22:57:28.344Z</common:last-modified-date>\n" + |
|
123 |
"<common:source>\n" + |
|
124 |
"<common:source-client-id>\n" + |
|
125 |
"<common:uri>https://orcid.org/client/0000-0002-5982-8983</common:uri>\n" + |
|
126 |
"<common:path>0000-0002-5982-8983</common:path>\n" + |
|
127 |
"<common:host>orcid.org</common:host>\n" + |
|
128 |
"</common:source-client-id>\n" + |
|
129 |
"<common:source-name>Scopus - Elsevier</common:source-name>\n" + |
|
130 |
"</common:source>\n" + |
|
131 |
"<work:title>\n" + |
|
132 |
"<common:title>\n" + |
|
133 |
"A survey of context-aware cross-digital library personalization\n" + |
|
134 |
"</common:title>\n" + |
|
135 |
"</work:title>\n" + |
|
136 |
"<common:external-ids>\n" + |
|
137 |
"<common:external-id>\n" + |
|
138 |
"<common:external-id-type>doi</common:external-id-type>\n" + |
|
139 |
"<common:external-id-value>10.1007/978-3-642-27169-4_2</common:external-id-value>\n" + |
|
140 |
"<common:external-id-url/>\n" + |
|
141 |
"<common:external-id-relationship>self</common:external-id-relationship>\n" + |
|
142 |
"</common:external-id>\n" + |
|
143 |
"</common:external-ids>\n" + |
|
144 |
"<work:type>journal-article</work:type>\n" + |
|
145 |
"<common:publication-date>\n" + |
|
146 |
"<common:year>2011</common:year>\n" + |
|
147 |
"</common:publication-date>\n" + |
|
148 |
"</work:work-summary>\n" + |
|
149 |
"</activities:group>\n" + |
|
150 |
"</activities:works>"; |
|
181 | 151 |
|
182 | 152 |
private String orcidXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + |
183 | 153 |
"<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" + |
... | ... | |
246 | 216 |
|
247 | 217 |
} |
248 | 218 |
@Test |
219 |
public void orcidSecond2ResultTest() throws Exception { |
|
220 |
String id = "0000-0002-3477-3082-5288650"; |
|
221 |
Result result = ExternalRecordParser.orcid2Result(searchUtils.fetchResultXMLFromOrcid(id.substring(0, 19)),id); |
|
222 |
System.out.println(result); |
|
223 |
id = "0000-0002-3477-3082-5288651"; |
|
224 |
result = ExternalRecordParser.orcid2Result(searchUtils.fetchResultXMLFromOrcid(id.substring(0, 19)),id); |
|
225 |
System.out.println(result); |
|
226 |
// System.out.println(result.getTitle() + result.getAccessRights()); |
|
227 |
Assert.assertNull(result.getAccessRights()); |
|
228 |
Assert.assertNull(result.getBestLicense()); |
|
229 |
Assert.assertEquals("openaire____::orcid", result.getCollectedFrom()); |
|
230 |
// Assert.assertEquals("10.1109/smc.2015.229", result.getDoi()); |
|
231 |
Assert.assertEquals(id, result.getOrcidworkid()); |
|
232 |
Assert.assertNull(result.getOai()); |
|
233 |
Assert.assertNotNull(result.getOpenaireId());// Assert.assertNull(result.getOpenaireId()); |
|
234 |
Assert.assertNull(result.getPmcid()); |
|
235 |
Assert.assertEquals(ClaimUtils.PUBLICATION, result.getResultType()); |
|
236 |
// Assert.assertEquals("A Survey of Context-Aware Cross-Digital Library Personalization\n", result.getTitle()); |
|
237 |
Assert.assertEquals("xml", result.getRecordFormat()); |
|
238 |
// Assert.assertEquals("https://dx.doi.org/10.1007/978-3-642-27169-4_2", result.getExternalUrl()); |
|
239 |
Assert.assertNull(result.getEmbargoEndDate()); |
|
240 |
|
|
241 |
} |
|
242 |
@Test |
|
249 | 243 |
public void orcid2Result2Test() { |
250 | 244 |
Result result = ExternalRecordParser.orcid2Result(orcidXml, "0000-0001-5264-4324-43079714"); |
251 | 245 |
System.out.println(result); |
... | ... | |
266 | 260 |
} |
267 | 261 |
|
268 | 262 |
|
263 |
|
|
269 | 264 |
private String dataciteXml = "<rdf:RDF\n" + |
270 | 265 |
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + |
271 | 266 |
" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n" + |
modules/uoa-claims/trunk/src/test/java/eu/dnetlib/data/claims/parser/ContextUtilsTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.claims.parser; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.data.claims.utils.ContextUtils; |
4 |
import org.apache.log4j.BasicConfigurator; |
|
4 | 5 |
import org.junit.Assert; |
6 |
import org.junit.Before; |
|
5 | 7 |
import org.junit.Test; |
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
import org.springframework.context.ApplicationContext; |
|
10 |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
6 | 11 |
|
7 | 12 |
/** |
8 | 13 |
* Created by argirok on 29/5/2018. |
9 | 14 |
*/ |
10 | 15 |
public class ContextUtilsTest { |
16 |
ContextUtils contextUtils; |
|
11 | 17 |
|
18 |
@Before |
|
19 |
public void init() throws Exception { |
|
20 |
BasicConfigurator.configure(); |
|
21 |
ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/springContext-claims.xml"); |
|
22 |
|
|
23 |
contextUtils = context.getBean(ContextUtils.class); |
|
24 |
|
|
25 |
|
|
26 |
} |
|
12 | 27 |
@Test |
13 | 28 |
public void dmf2ContextTest() throws Exception { |
14 | 29 |
|
15 | 30 |
String id= "egi::country::gr"; |
16 | 31 |
|
17 |
Assert.assertEquals("EGI Federation> EGI Countries> Greece", ContextUtils.extractLabel(id, false));
|
|
32 |
Assert.assertEquals("EGI Federation> EGI Countries> Greece", contextUtils.extractLabel(id));
|
|
18 | 33 |
id= "egi"; |
19 |
Assert.assertEquals("EGI Federation", ContextUtils.extractLabel(id, false));
|
|
34 |
Assert.assertEquals("EGI Federation", contextUtils.extractLabel(id));
|
|
20 | 35 |
id="egi::classification"; |
21 |
Assert.assertEquals("EGI Federation> EGI classification scheme", ContextUtils.extractLabel(id, false));
|
|
36 |
Assert.assertEquals("EGI Federation> EGI classification scheme", contextUtils.extractLabel(id));
|
|
22 | 37 |
id="egi::classification::natsc"; |
23 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Natural Sciences", ContextUtils.extractLabel(id, false));
|
|
38 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Natural Sciences", contextUtils.extractLabel(id));
|
|
24 | 39 |
id="egi::classification::natsc::math"; |
25 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Mathematics", ContextUtils.extractLabel(id, false));
|
|
40 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Mathematics", contextUtils.extractLabel(id));
|
|
26 | 41 |
id="egi::classification::natsc::math::applied"; |
27 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", ContextUtils.extractLabel(id, false));
|
|
42 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));
|
|
28 | 43 |
id="egi::classification::natsc::math::applied"; |
29 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", ContextUtils.extractLabel(id, false));
|
|
44 |
Assert.assertEquals("EGI Federation> EGI classification scheme> Applied Mathematics", contextUtils.extractLabel(id));
|
|
30 | 45 |
|
31 | 46 |
/* |
32 | 47 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/sql/SqlStore.java | ||
---|---|---|
130 | 130 |
*/ |
131 | 131 |
public ResultSet executeStoredProcedure(String command, ArrayList<String> values) throws SQLException { |
132 | 132 |
java.sql.CallableStatement callableStatement = null; |
133 |
log.debug(" Executing Query ..." + command); |
|
133 |
log.debug(" Executing Query ..." + command.substring(0,(command.length()>150?150:command.length())));
|
|
134 | 134 |
|
135 | 135 |
callableStatement = this.connection.prepareCall(command); |
136 | 136 |
int pos = 1; |
... | ... | |
157 | 157 |
* @throws SQLException |
158 | 158 |
*/ |
159 | 159 |
public ResultSet executeStoredProcedure(String command) throws SQLException { |
160 |
log.debug(" Executing Query ..." + command); |
|
160 |
log.debug(" Executing Query ..." + command.substring(0,(command.length()>150?150:command.length())));
|
|
161 | 161 |
java.sql.CallableStatement callableStatement = null; |
162 | 162 |
|
163 | 163 |
callableStatement = this.connection.prepareCall(command); |
... | ... | |
177 | 177 |
* @throws SQLException |
178 | 178 |
*/ |
179 | 179 |
public ResultSet executeQuery(String command) throws SQLException, SQLStoreException { |
180 |
log.debug(" Executing Query ... " + command);
|
|
180 |
log.debug(" Executing Query: " + command.substring(0,(command.length()>150?150:command.length()))+"....");
|
|
181 | 181 |
|
182 | 182 |
Statement st = null; |
183 | 183 |
ResultSet rs = null; |
... | ... | |
219 | 219 |
* @throws SQLException |
220 | 220 |
*/ |
221 | 221 |
public CachedRowSet executeQuery(String command, ArrayList<Object> values) throws SQLException, SQLStoreException { |
222 |
log.debug(" Executing Query ...\n" + command +"\n"+values); |
|
222 |
log.debug(" Executing Query ...\n" + command.substring(0,(command.length()>150?150:command.length())) +"\n"+values);
|
|
223 | 223 |
|
224 | 224 |
PreparedStatement st = null; |
225 | 225 |
ResultSet rs = null; |
... | ... | |
311 | 311 |
* @throws SQLException |
312 | 312 |
*/ |
313 | 313 |
public void executeUpdate(String command) throws SQLException { |
314 |
log.debug(" Executing Query ..." + command); |
|
314 |
log.debug(" Executing Query ..." + command.substring(0,(command.length()>150?150:command.length())));
|
|
315 | 315 |
|
316 | 316 |
Statement st = null; |
317 | 317 |
|
... | ... | |
350 | 350 |
* @values as parameters |
351 | 351 |
*/ |
352 | 352 |
public boolean executeUpdate(String command, ArrayList<Object> values) throws SQLException { |
353 |
log.debug(" Executing Query ..." + command); |
|
353 |
log.debug(" Executing Query ..." + command.substring(0,(command.length()>(command.length()>150?150:command.length())?150:command.length())));
|
|
354 | 354 |
|
355 | 355 |
PreparedStatement st = null; |
356 | 356 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/utils/ContextUtils.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.data.claims.entity.Context; |
5 | 5 |
import eu.dnetlib.data.claims.handler.ClaimHandler; |
6 | 6 |
import org.apache.log4j.Logger; |
7 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 | 8 |
|
8 | 9 |
import java.util.List; |
9 | 10 |
|
... | ... | |
12 | 13 |
*/ |
13 | 14 |
public class ContextUtils { |
14 | 15 |
private static final Logger logger = Logger.getLogger(ClaimHandler.class); |
15 |
private SearchUtils searchUtils = new SearchUtils();
|
|
16 |
private SearchUtils searchUtils; |
|
16 | 17 |
|
17 |
public static Context fetchContextById(String openaireId, Boolean production) {
|
|
18 |
public Context fetchContextById(String openaireId) {
|
|
18 | 19 |
Context context = new Context(); |
19 | 20 |
if(openaireId == null ){ |
20 | 21 |
return null; |
21 | 22 |
} |
22 | 23 |
context.setOpenaireId(openaireId); |
23 | 24 |
try { |
24 |
context.setTitle(ContextUtils.extractLabel(context.getOpenaireId(),production));
|
|
25 |
context.setTitle(extractLabel(context.getOpenaireId()));
|
|
25 | 26 |
|
26 | 27 |
} catch (Exception e) { |
27 | 28 |
logger.error("ContextUtils: Couldn't get Egi label for id " + context.getOpenaireId(),e); |
... | ... | |
29 | 30 |
return context; |
30 | 31 |
|
31 | 32 |
} |
32 |
public static String extractLabel(String code, Boolean production) throws Exception {
|
|
33 |
public String extractLabel(String code) throws Exception {
|
|
33 | 34 |
String[] codeParts = code.split("::"); |
34 | 35 |
String level0 = ""; |
35 | 36 |
String level1 = ""; |
36 | 37 |
String level2 = ""; |
37 | 38 |
String level3 = ""; |
38 | 39 |
if (codeParts.length >0) { |
39 |
String json = SearchUtils.fetchContext("s/", production);
|
|
40 |
String json = searchUtils.fetchContext("s/");
|
|
40 | 41 |
level0 = getLabel(json, codeParts[0]); |
41 | 42 |
} |
42 | 43 |
if (codeParts.length >1) { |
43 |
String json = SearchUtils.fetchContext("/"+codeParts[0], production);
|
|
44 |
String json = searchUtils.fetchContext("/"+codeParts[0]);
|
|
44 | 45 |
level1 = getLabel(json, codeParts[0]+"::"+codeParts[1]); |
45 | 46 |
} |
46 | 47 |
if (codeParts.length >2) { |
47 |
String json = SearchUtils.fetchContext("/category/"+codeParts[0]+"::"+codeParts[1], production);
|
|
48 |
String json = searchUtils.fetchContext("/category/"+codeParts[0]+"::"+codeParts[1]);
|
|
48 | 49 |
level2 = getLabel(json, codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]); |
49 | 50 |
} |
50 | 51 |
if (codeParts.length >3) { |
51 |
String json = SearchUtils.fetchContext("/category/concept/"+codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2], production);
|
|
52 |
String json = searchUtils.fetchContext("/category/concept/"+codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]);
|
|
52 | 53 |
level3 = getSubLabel(json, codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2], codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]+"::"+codeParts[3],((codeParts.length>4)?(codeParts[0]+"::"+codeParts[1]+"::"+codeParts[2]+"::"+codeParts[3]+"::"+codeParts[4]):null)); |
53 | 54 |
} |
54 | 55 |
|
... | ... | |
188 | 189 |
} |
189 | 190 |
} |
190 | 191 |
|
191 |
public static void main(String[] args) throws Exception {
|
|
192 |
// System.out.println(ContextUtils.extractLabel("egi::classification::natsc::math::applied", false));
|
|
193 |
System.out.println(ContextUtils.extractLabel("aginfra::projects::10", false));
|
|
192 |
public SearchUtils getSearchUtils() {
|
|
193 |
return searchUtils;
|
|
194 |
}
|
|
194 | 195 |
|
196 |
public void setSearchUtils(SearchUtils searchUtils) { |
|
197 |
this.searchUtils = searchUtils; |
|
195 | 198 |
} |
196 | 199 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/utils/SearchUtils.java | ||
---|---|---|
29 | 29 |
private static final Logger logger = Logger.getLogger(SearchUtils.class); |
30 | 30 |
public static String searchAPIUrl=null;//"http://beta.services.openaire.eu:8480/search/"; |
31 | 31 |
|
32 |
private static String crossrefUrl="https://api.crossref.org/works?filter=doi:"; |
|
33 |
private static String dataciteUrl="https://data.datacite.org/application/rdf+xml/"; |
|
34 |
private static String dataciteNewAPIUrl="https://api.datacite.org/works/"; |
|
35 |
private static String orcidUrlPrefix="https://pub.orcid.org/v2.1/"; |
|
36 |
private static String orcidUrlSuffix="/works"; |
|
37 |
// private static String contextsAPIUrl="https://dev-openaire.d4science.org/openaire/context"; |
|
38 |
private static String contextsAPIUrl="http://beta.services.openaire.eu:8080/openaire/context"; |
|
39 |
private static String contextsAPIUrlProduction="http://services.openaire.eu:8080/openaire/context"; |
|
40 |
private boolean useApi=true; |
|
32 |
private static String crossrefUrl=null; |
|
33 |
private static String dataciteUrl=null; |
|
34 |
private static String orcidUrlPrefix=null; |
|
35 |
private static String orcidUrlSuffix=null; |
|
36 |
private static String contextsAPIUrl=null; |
|
41 | 37 |
private ClaimValidation claimValidation = null; |
42 | 38 |
|
43 | 39 |
public SearchUtils(){ |
... | ... | |
93 | 89 |
|
94 | 90 |
} |
95 | 91 |
|
96 |
public static String fetchResultXMLFromDatacite(String id) throws Exception{
|
|
92 |
public String fetchResultXMLFromDatacite(String id) throws Exception{ |
|
97 | 93 |
return getRequest(getDataciteUrl(id)); |
98 | 94 |
} |
99 |
public static String fetchResultXMLFromOrcid(String id) throws Exception{
|
|
95 |
public String fetchResultXMLFromOrcid(String id) throws Exception{ |
|
100 | 96 |
|
101 | 97 |
return getRequest(getOrcidUrl(id)); |
102 | 98 |
} |
103 |
public static String fetchContext(String suffix, boolean production) throws Exception{
|
|
99 |
public String fetchContext(String suffix) throws Exception{
|
|
104 | 100 |
|
105 |
return getRequest(getContextsAPIUrl(production)+suffix);
|
|
101 |
return getRequest(getContextsAPIUrl()+suffix); |
|
106 | 102 |
} |
107 | 103 |
|
108 | 104 |
public String getProjectApiUrl(String id) { |
... | ... | |
128 | 124 |
|
129 | 125 |
private static String getDataciteUrl(String id) { |
130 | 126 |
|
131 |
return dataciteNewAPIUrl+id;
|
|
127 |
return dataciteUrl+id; |
|
132 | 128 |
} |
133 | 129 |
|
134 | 130 |
private static String getOrcidUrl(String id) { |
135 | 131 |
|
136 | 132 |
return orcidUrlPrefix+id+orcidUrlSuffix; |
137 | 133 |
} |
138 |
private static String getContextsAPIUrl( boolean production) {
|
|
134 |
private static String getContextsAPIUrl() { |
|
139 | 135 |
|
140 |
return ((production)?contextsAPIUrlProduction:contextsAPIUrl);
|
|
136 |
return contextsAPIUrl;
|
|
141 | 137 |
} |
142 | 138 |
|
143 | 139 |
|
... | ... | |
251 | 247 |
public void setSearchAPIUrl(String searchAPIUrl) { |
252 | 248 |
this.searchAPIUrl = searchAPIUrl; |
253 | 249 |
} |
250 |
|
|
251 |
public static void setContextsAPIUrl(String contextsAPIUrl) { |
|
252 |
SearchUtils.contextsAPIUrl = contextsAPIUrl; |
|
253 |
} |
|
254 |
|
|
255 |
public static String getCrossrefUrl() { |
|
256 |
return crossrefUrl; |
|
257 |
} |
|
258 |
|
|
259 |
public static void setCrossrefUrl(String crossrefUrl) { |
|
260 |
SearchUtils.crossrefUrl = crossrefUrl; |
|
261 |
} |
|
262 |
|
|
263 |
public static String getDataciteUrl() { |
|
264 |
return dataciteUrl; |
|
265 |
} |
|
266 |
|
|
267 |
public static void setDataciteUrl(String dataciteUrl) { |
|
268 |
SearchUtils.dataciteUrl = dataciteUrl; |
|
269 |
} |
|
270 |
|
|
271 |
public static String getOrcidUrlPrefix() { |
|
272 |
return orcidUrlPrefix; |
|
273 |
} |
|
274 |
|
|
275 |
public static void setOrcidUrlPrefix(String orcidUrlPrefix) { |
|
276 |
SearchUtils.orcidUrlPrefix = orcidUrlPrefix; |
|
277 |
} |
|
278 |
|
|
279 |
public static String getOrcidUrlSuffix() { |
|
280 |
return orcidUrlSuffix; |
|
281 |
} |
|
282 |
|
|
283 |
public static void setOrcidUrlSuffix(String orcidUrlSuffix) { |
|
284 |
SearchUtils.orcidUrlSuffix = orcidUrlSuffix; |
|
285 |
} |
|
254 | 286 |
} |
255 | 287 |
|
256 | 288 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/utils/QueryGenerator.java | ||
---|---|---|
200 | 200 |
" RETURNING openaire_id"; |
201 | 201 |
//TODO update on insert when exists |
202 | 202 |
} |
203 |
private String generateInsertClaimQuery(Date date, String claimedBy, String source_type, String target_type , String source_id , String target_id, String semantics, ArrayList<Object> params) { |
|
203 |
private String generateInsertClaimQuery(Date date, String claimedBy, String source_type, String target_type , String source_id , String target_id, String claimedInDashboard, String semantics, ArrayList<Object> params) {
|
|
204 | 204 |
|
205 | 205 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
206 | 206 |
String dateStr=null; |
... | ... | |
209 | 209 |
if(semantics!=null){ |
210 | 210 |
fields+=",semantics"; |
211 | 211 |
} |
212 |
if(claimedInDashboard!=null){ |
|
213 |
fields+=",claimed_in_dashboard"; |
|
214 |
} |
|
212 | 215 |
String values="?::timestamp,?,?,?,?,?"; |
213 | 216 |
params.add(dateStr); |
214 | 217 |
params.add(claimedBy); |
... | ... | |
220 | 223 |
values+=",?"; |
221 | 224 |
params.add(semantics); |
222 | 225 |
} |
223 |
|
|
226 |
if(claimedInDashboard!=null){ |
|
227 |
values+=",?"; |
|
228 |
params.add(claimedInDashboard); |
|
229 |
} |
|
224 | 230 |
return " INSERT INTO claim( "+fields+")\n" + |
225 | 231 |
" VALUES ( "+values+")\n" + |
226 | 232 |
" RETURNING id, source_id, target_id\n"; |
... | ... | |
240 | 246 |
" ),\n source AS (\n" + |
241 | 247 |
sourceQuery+ |
242 | 248 |
" ),\n myclaim AS (\n" + |
243 |
generateInsertClaimQuery(claim.getDate(), claim.getUserMail(), claim.getSourceType(), claim.getTargetType(), claim.getSource().getOpenaireId(), claim.getTarget().getOpenaireId(),this.createSemanticsType(claim.getSourceType(),claim.getTargetType()), params) + |
|
249 |
generateInsertClaimQuery(claim.getDate(), claim.getUserMail(), claim.getSourceType(), claim.getTargetType(), claim.getSource().getOpenaireId(), claim.getTarget().getOpenaireId(), claim.getClaimedInDashboard(), this.createSemanticsType(claim.getSourceType(),claim.getTargetType()), params) +
|
|
244 | 250 |
" ),\n ins4 AS (\n" + |
245 | 251 |
" INSERT INTO "+sourceTableName+" (claim_id, openaire_id)\n" + |
246 | 252 |
" SELECT id, source_id\n" + |
... | ... | |
302 | 308 |
" ),\n ins2 AS (\n" + |
303 | 309 |
sourceQuery+ |
304 | 310 |
" ),\n ins3 AS (\n" + |
305 |
generateInsertClaimQuery(claim.getDate(), claim.getUserMail(), claim.getSourceType(), claim.getTargetType(), claim.getSource().getOpenaireId(), claim.getTarget().getOpenaireId(),this.createSemanticsType(claim.getSourceType(),claim.getTargetType()), params) + |
|
311 |
generateInsertClaimQuery(claim.getDate(), claim.getUserMail(), claim.getSourceType(), claim.getTargetType(), claim.getSource().getOpenaireId(), claim.getTarget().getOpenaireId(), claim.getClaimedInDashboard(), this.createSemanticsType(claim.getSourceType(),claim.getTargetType()), params) +
|
|
306 | 312 |
" ),\n ins4 AS (\n" + |
307 | 313 |
" INSERT INTO has_source_result (claim_id, openaire_id)\n" + |
308 | 314 |
" SELECT id, source_id\n" + |
... | ... | |
469 | 475 |
" id serial primary key NOT NULL,\n" + |
470 | 476 |
" claim_date timestamp without time zone NOT NULL,\n" + |
471 | 477 |
" claimedBy text NOT NULL,\n" + |
478 |
" claimed_in_dashboard varchar(50),\n" + |
|
472 | 479 |
" source_type varchar(30) NOT NULL,\n" + |
473 | 480 |
" target_type varchar(30) NOT NULL,\n" + |
474 | 481 |
" source_id varchar(60) NOT NULL,\n" + |
... | ... | |
730 | 737 |
clauseParams.add(dateTo); |
731 | 738 |
return generateSelectClaimQueryAsUnionOfAllRelations(limit, offset, orderBy,desc,clause, clauseParams,keyword,types, params); |
732 | 739 |
} |
740 |
//used in CopyFromBetaToProduction |
|
741 |
public String generateFetchClaimsByDateForDashboards(String dateFrom, String dateTo, Integer limit, Integer offset,String keyword, String orderBy, boolean desc,List<String> types, ArrayList<Object> params, ArrayList<String> dashboards) { |
|
742 |
String clause= " claim.claim_date >= ?::timestamp and claim.claim_date <= ?::timestamp "; |
|
743 |
ArrayList<Object> clauseParams = new ArrayList<>(); |
|
744 |
clauseParams.add(dateFrom); |
|
745 |
clauseParams.add(dateTo); |
|
746 |
if(dashboards.size()>0){ |
|
747 |
clause = clause.concat(" and ("); |
|
748 |
} |
|
749 |
for(int i =0; i < dashboards.size(); i++){ |
|
750 |
if(i > 0){ |
|
751 |
clause = clause.concat(" or "); |
|
752 |
} |
|
753 |
clause = clause.concat(" claim.claimed_in_dashboard = ?"); |
|
754 |
clauseParams.add("beta_connect_"+dashboards.get(i)); |
|
755 |
} |
|
756 |
if(dashboards.size()>0){ |
|
757 |
clause = clause.concat(")"); |
|
758 |
} |
|
733 | 759 |
|
760 |
// logger.debug("\n\nClause:"+clause+"\n\n"); |
|
761 |
return generateSelectClaimQueryAsUnionOfAllRelations(limit, offset, orderBy,desc,clause, clauseParams,keyword,types, params); |
|
762 |
} |
|
763 |
|
|
734 | 764 |
public String generateFetchNumberOfClaimsByDateAndOpenaireId(String dateFrom, String dateTo, String openaireId, Integer limit, Integer offset,String keyword, String orderBy, boolean desc,List<String> types, ArrayList<Object> params) { |
735 | 765 |
String clause= " claim.claim_date >= ?::timestamp and claim.claim_date <= ?::timestamp and source.openaire_id =? "; |
736 | 766 |
ArrayList<Object> clauseParams = new ArrayList<>(); |
... | ... | |
916 | 946 |
String query = "select * from ("+ |
917 | 947 |
|
918 | 948 |
" ( " +generateSelectclaimQuery(ClaimUtils.PUBLICATION,ClaimUtils.PUBLICATION,null,null,null,false, specificWhereClause,whereParams,keyword, params)+" ) \nunion "+ |
919 |
" ( " +generateSelectclaimQuery(ClaimUtils.DATASET,ClaimUtils.DATASET,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
|
920 |
" ( " +generateSelectclaimQuery(ClaimUtils.SOFTWARE,ClaimUtils.SOFTWARE,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
|
921 |
" ( " +generateSelectclaimQuery(ClaimUtils.OTHER,ClaimUtils.OTHER,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
|
949 |
// " ( " +generateSelectclaimQuery(ClaimUtils.DATASET,ClaimUtils.DATASET,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+
|
|
950 |
// " ( " +generateSelectclaimQuery(ClaimUtils.SOFTWARE,ClaimUtils.SOFTWARE,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+
|
|
951 |
// " ( " +generateSelectclaimQuery(ClaimUtils.OTHER,ClaimUtils.OTHER,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+
|
|
922 | 952 |
" ( " +generateSelectclaimQuery(ClaimUtils.PROJECT,ClaimUtils.PUBLICATION, null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
923 | 953 |
" ( " +generateSelectclaimQuery(ClaimUtils.CONTEXT,ClaimUtils.PUBLICATION,null,null,null,false, specificWhereClause, whereParams, keyword, params)+" )" + |
924 | 954 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/stepsTomigrateFromBetaToProduction | ||
---|---|---|
1 |
1.[beta] work on beta |
|
2 |
1.1 connect to beta |
|
3 |
ssh argiro.kokogiannaki@beta.services.openaire.eu |
|
4 |
1.2 Export tables from beta |
|
5 |
pg_dump -U dnet -h localhost dnet_openaireplus -t context -t project -t result -t has_source_context -t has_source_project -t has_source_result -t has_target_project -t has_target_result -t claim -t notification --password >claims20190720.sql |
|
6 |
|
|
7 |
pg_dump --column-inserts --data-only -U dnet -h localhost dnet_openaireplus -t notification --password >notifications20190801.sql |
|
8 |
1.3 Get records |
|
9 |
|
|
10 |
ll /srv/claims/records/ |
|
11 |
tar -czvf records.beta.20190801.tar.gz /srv/claims/records/ |
|
12 |
scp records.beta.20190801.tar.gz argirok@scoobydoo.di.uoa.gr:~/ |
|
13 |
|
|
14 |
2. dump in local db |
|
15 |
|
|
16 |
2.1 create local db |
|
17 |
create database claims_beta |
|
18 |
|
|
19 |
|
|
20 |
2.2 insert records |
|
21 |
psql -h localhost -U postgres claims_beta --password < claims20190720.sql |
|
22 |
|
|
23 |
|
|
24 |
3. prepare db to put new records |
|
25 |
|
|
26 |
3.1 create db |
|
27 |
create database claims_prod |
|
28 |
|
|
29 |
3.2 create claim tables for local db |
|
30 |
|
|
31 |
3.3 set sequence numbers not to override anything in production: |
|
32 |
ALTER SEQUENCE result_id_seq RESTART WITH 10000; ALTER SEQUENCE claim_id_seq RESTART WITH 12000; |
|
33 |
|
|
34 |
|
|
35 |
4. Run Java migration |
|
36 |
|
|
37 |
5. export prod records |
|
38 |
|
|
39 |
pg_dump --column-inserts --data-only -U postgres -h localhost movedb -t context -t project -t result -t has_source_context -t has_source_project -t has_source_result -t has_target_project -t has_target_result -t claim -t --password >claims_new_20190720.sql |
|
40 |
|
|
41 |
6. [prod] set sequence numbers after the ids of the new claims |
|
42 |
psql -h postgresql.services.openaire.eu dnet_openaireplus -U dnet |
|
43 |
ALTER SEQUENCE result_id_seq RESTART WITH 11000; ALTER SEQUENCE claim_id_seq RESTART WITH 12800; |
|
44 |
|
|
45 |
7.[prod] |
|
46 |
|
|
47 |
7.1 insert records in production db |
|
48 |
psql -U dnet -h postgresql.services.openaire.eu dnet_openaireplus --password < claims_new_20190720.sql |
|
49 |
|
|
50 |
8.[prod] notifications in production |
|
51 |
|
|
52 |
8.1 insert notifications records in production db |
|
53 |
psql -U dnet -h postgresql.services.openaire.eu dnet_openaireplus --password < notifications20190801.sql |
|
54 |
|
|
55 |
|
|
56 |
9. Copy files |
|
57 |
|
|
58 |
9.1[beta] In /srv/claims/records/ folder of beta run copy.sh script |
|
59 |
set date in case you don't want to get them all (but all are new anyway) |
|
60 |
9.2 [prod] copy new records folder in production add in /srv/claims/ folder |
|
61 |
|
|
62 |
9.3 [prod] in /srv/claims/ folder run copyToProduction.sh script |
|
63 |
|
|
64 |
|
|
65 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/updateField.sql | ||
---|---|---|
1 |
-- add column |
|
2 |
#altered in beta & production |
|
3 |
#ALTER TABLE claim ADD COLUMN claimed_in_dashboard varchar(50); |
|
4 |
|
|
5 |
-- update column with specific value: |
|
6 |
#run in production 25-11-2019select |
|
7 |
#UPDATE claim SET claimed_in_dashboard = 'production_explore'; |
|
8 |
|
|
9 |
-- update claims linked to a community |
|
10 |
#run in beta 25-11-2019 |
|
11 |
#UPDATE claim SET claimed_in_dashboard = concat('beta_connect_',split_part(source_id,'::',1)) where source_type = 'context' and claim_date between '2018-03-01' and '2019-12-31' ; |
|
12 |
|
|
13 |
--which users claims since connect release |
|
14 |
select claimedby,claimed_in_dashboard, source_id, target_id from claim where claim_date between '2018-03-01' and '2019-12-31'; |
|
15 |
|
|
16 |
|
|
17 |
-- update claims made by a community user/manager |
|
18 |
#run in beta 25-11-2019 |
|
19 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_ni' where ( claimedby = 'sorina.pop@creatis.insa-lyon.fr' or claimedby = 'xavier.rolland@inria.fr' or claimedby = 'micheL.dojat@inserm.fr' or claimedby = 'camille.maumet@inria.fr') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
20 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_elexir-gr' where ( claimedby = 'schatz@imis.athena-innovation.gr' or claimedby = 'vergoulis@imis.athena-innovation.gr' ) and claim_date between '2018-03-01' and '2019-12-31' ; |
|
21 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_fam' where ( claimedby = 'taha.imzilen@ird.fr' or claimedby = 'bastien.merigot@umontpellier.fr' or claimedby = 'paul.taconet@ird.fr' or claimedby = 'julien.barde@ird.fr') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
22 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_mes' where ( claimedby = 'spesant@marum.de' or claimedby = 'javier.moreno@gm.uca.es') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
23 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_ni' where ( claimedby = 'sorina.pop@creatis.insa-lyon.fr' or claimedby = 'xavier.rolland@inria.fr' or claimedby = 'micheL.dojat@inserm.fr' or claimedby = 'camille.maumet@inria.fr') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
24 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_rda' where ( claimedby = 'ilaria.fava@gmail.com') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
25 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_dh-ch' where ( claimedby = 'achille.felicetti@gmail.com' or claimedby = 'francesca.murano@unifi.it' or claimedby = 'sokhi.huda@uinsby.ac.id') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
26 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_ee' where ( claimedby = 'evita.mailli@icre8.eu' or claimedby = 'avassilopoulos.aua@gmail.com' or claimedby = 'ebun.akinsete@icre8.eu') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
27 |
#UPDATE claim SET claimed_in_dashboard = 'beta_connect_dariah' where ( claimedby = 'erzsebet.toth-czifra@dariah.eu') and claim_date between '2018-03-01' and '2019-12-31' ; |
|
28 |
|
|
29 |
# init rest values with explore |
|
30 |
select claimedby,claimed_in_dashboard, source_id, target_id from claim where claimed_in_dashboard is null; |
|
31 |
#run in beta 25-11-2019 |
|
32 |
#UPDATE claim SET claimed_in_dashboard = 'beta_explore' where claimed_in_dashboard is null; |
|
33 |
-- |
|
34 |
|
|
35 |
|
|
36 |
#if the properties file is cached and there is no value for dashboard, the claimed_in_dashboard value may be 'production_undefined'. Correct with: |
|
37 |
# select * from claim where claimed_in_dashboard = 'production_undefined' ; |
|
38 |
#UPDATE claim SET claimed_in_dashboard = 'production_explore' where claimed_in_dashboard = 'production_undefined' ; |
|
39 |
-- |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
select * from claim where claim_date between '2018-03-01' and '2019-12-31' and ( claimed_in_dashboard ='beta_connect_mes' or claimed_in_dashboard ='beta_connect_ee' or claimed_in_dashboard ='beta_connect_ni' or claimed_in_dashboard ='beta_connect_dh-ch' or claimed_in_dashboard ='beta_connect_fam'); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/CopyFromBetaToProduction.java | ||
---|---|---|
1 |
package eu.dnetlib.data.claims.migration; |
|
2 |
|
|
3 |
import eu.dnetlib.data.claims.entity.Claim; |
|
4 |
import eu.dnetlib.data.claims.handler.ClaimHandler; |
|
5 |
import eu.dnetlib.data.claims.handler.FetchClaimHandler; |
|
6 |
import eu.dnetlib.data.claims.sql.SQLStoreException; |
|
7 |
import eu.dnetlib.data.claims.utils.QueryGenerator; |
|
8 |
import org.apache.log4j.BasicConfigurator; |
|
9 |
import org.apache.log4j.Level; |
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.springframework.context.ApplicationContext; |
|
12 |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
|
13 |
|
|
14 |
import java.io.IOException; |
|
15 |
import java.util.ArrayList; |
|
16 |
import java.util.List; |
|
17 |
|
|
18 |
|
|
19 |
public class CopyFromBetaToProduction { |
|
20 |
private static final Logger logger = Logger.getLogger(CopyFromBetaToProduction.class); |
|
21 |
ClaimHandler claimHandler = null; |
|
22 |
FetchClaimHandler fetchClaimHandler = null; |
|
23 |
|
|
24 |
public CopyFromBetaToProduction() { |
|
25 |
ApplicationContext context = new ClassPathXmlApplicationContext("eu/dnetlib/data/claims/springContext-claims.xml"); |
|
26 |
claimHandler = context.getBean(ClaimHandler.class); |
|
27 |
fetchClaimHandler = context.getBean(FetchClaimHandler.class); |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
private void saveClaims(List<Claim> claims) throws Exception, SQLStoreException { |
|
32 |
for(Claim claim : claims){ |
|
33 |
/* if(claim.getTargetType().equals(ClaimUtils.DATASET)||claim.getTargetType().equals(ClaimUtils.PUBLICATION)){ |
|
34 |
String path = resultHandler.exportMetadataFileForResult((Result)claim.getTarget()); |
|
35 |
((Result) claim.getTarget()).setRecordPath(path); |
|
36 |
} |
|
37 |
if(claim.getSourceType().equals(ClaimUtils.DATASET)||claim.getSourceType().equals(ClaimUtils.PUBLICATION)){ |
|
38 |
String path = resultHandler.exportMetadataFileForResult((Result)claim.getSource()); |
|
39 |
((Result) claim.getSource()).setRecordPath(path); |
|
40 |
}*/ |
|
41 |
claim = claimHandler.exportMedatataForClaim(claim); |
|
42 |
claimHandler.saveClaim(claim); |
|
43 |
} |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
public static void main(String[] args) throws IOException { |
|
50 |
BasicConfigurator.configure(); |
|
51 |
logger.setLevel(Level.DEBUG); |
|
52 |
QueryGenerator q = new QueryGenerator(); |
|
53 |
System.out.println(q.generateCreateClaimTablesQuery()); |
|
54 |
CopyFromBetaToProduction migration = new CopyFromBetaToProduction(); |
|
55 |
try { |
|
56 |
|
|
57 |
|
|
58 |
// migration.fetchClaimHandler.getQueryGenerator().setMigrationTable("claims_beta"); |
|
59 |
ArrayList<String> communities = new ArrayList<>(); |
|
60 |
communities.add("ee"); |
|
61 |
communities.add("mes"); |
|
62 |
communities.add("fam"); |
|
63 |
communities.add("ni"); |
|
64 |
communities.add("dh-ch"); |
|
65 |
String startDate = "2018-03-01"; |
|
66 |
String endDate = "2019-12-31"; |
|
67 |
|
|
68 |
migration.fetchClaimHandler.getSqlDAO().getSqlStore().setDbUrl("jdbc:postgresql://scoobydoo.di.uoa.gr:5432/claims_beta"); |
|
69 |
List<Claim> claims = migration.fetchClaimHandler.fetchClaimsByDateForDashboards(startDate,endDate, null,null,true, communities); |
|
70 |
System.out.println("Beta claims: "); |
|
71 |
System.out.println(claims.size()); |
|
72 |
|
|
73 |
/*migration.claimHandler.getSqlDAO().getSqlStore().setDbUrl("jdbc:postgresql://scoobydoo.di.uoa.gr:5432/movedb"); |
|
74 |
|
|
75 |
for (Claim claim : claims) { |
|
76 |
// System.out.println(claim); |
|
77 |
migration.claimHandler.saveClaim(claim); |
|
78 |
} |
|
79 |
List<Claim> claimsmoveDB = migration.fetchClaimHandler.fetchClaimsByDate(startDate,endDate, null, null, true); |
|
80 |
System.out.println("Movedb claims:"); |
|
81 |
System.out.println(claimsmoveDB.size());*/ |
|
82 |
|
|
83 |
|
|
84 |
} catch (Exception | SQLStoreException e) { |
|
85 |
logger.error("Error in migration",e); |
|
86 |
|
|
87 |
} |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/entity/Claim.java | ||
---|---|---|
8 | 8 |
public class Claim { |
9 | 9 |
|
10 | 10 |
private String id; |
11 |
private String claimedInDashboard; |
|
11 | 12 |
private String userMail; |
12 | 13 |
private Date date; |
13 | 14 |
private String sourceType; |
... | ... | |
109 | 110 |
this.approved = approved; |
110 | 111 |
} |
111 | 112 |
|
113 |
public String getClaimedInDashboard() { |
|
114 |
return claimedInDashboard; |
|
115 |
} |
|
116 |
|
|
117 |
public void setClaimedInDashboard(String claimedInDashboard) { |
|
118 |
this.claimedInDashboard = claimedInDashboard; |
|
119 |
} |
|
120 |
|
|
112 | 121 |
@Override |
113 | 122 |
public String toString() { |
114 | 123 |
return "Claim{" + |
115 |
"\nid='" + id + '\'' + |
|
116 |
",\n userMail='" + userMail + '\'' + |
|
117 |
",\n date=" + date + |
|
118 |
",\n sourceType='" + sourceType + '\'' + |
|
119 |
",\n targetType='" + targetType + '\'' + |
|
120 |
",\n semantics='" + semantics + '\'' + |
|
121 |
",\n curationDate='" + curationDate + '\'' + |
|
122 |
",\n curatedBy='" + curatedBy + '\'' + |
|
123 |
",\n approved=" + approved + |
|
124 |
",\ntarget={" + ((target==null)?"null":target.toString())+ |
|
125 |
"},\n source={" + ((source==null)?"null":source.toString()) + |
|
124 |
"id='" + id + '\'' + |
|
125 |
", claimedInDashboard='" + claimedInDashboard + '\'' + |
|
126 |
", userMail='" + userMail + '\'' + |
|
127 |
", date=" + date + |
|
128 |
", sourceType='" + sourceType + '\'' + |
|
129 |
", targetType='" + targetType + '\'' + |
|
130 |
", semantics='" + semantics + '\'' + |
|
131 |
", curationDate=" + curationDate + |
|
132 |
", curatedBy='" + curatedBy + '\'' + |
|
133 |
", approved=" + approved + |
|
134 |
", source=" + source + |
|
135 |
", target=" + target + |
|
126 | 136 |
'}'; |
127 | 137 |
} |
128 |
|
|
129 | 138 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/handler/ExternalRecordHandler.java | ||
---|---|---|
3 | 3 |
import eu.dnetlib.data.claims.entity.Result; |
4 | 4 |
import eu.dnetlib.data.claims.parser.ExternalRecordParser; |
5 | 5 |
import eu.dnetlib.data.claims.utils.SearchUtils; |
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 | 7 |
|
7 | 8 |
/** |
8 | 9 |
* Created by kiatrop on 8/2/2016. |
9 | 10 |
*/ |
10 | 11 |
public class ExternalRecordHandler { |
11 |
|
|
12 |
//@Autowired |
|
12 | 13 |
SearchUtils searchUtils; |
13 | 14 |
ExternalRecordParser externalRecordParser = null; |
14 | 15 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/handler/ClaimHandler.java | ||
---|---|---|
12 | 12 |
import eu.dnetlib.data.claims.sql.SQLStoreException; |
13 | 13 |
import eu.dnetlib.data.claims.sql.SqlDAO; |
14 | 14 |
import org.apache.log4j.Logger; |
15 |
import org.springframework.beans.factory.annotation.Autowired; |
|
15 | 16 |
|
16 | 17 |
import java.sql.ResultSet; |
17 | 18 |
import java.sql.SQLException; |
... | ... | |
29 | 30 |
ResultHandler resultHandler = null; |
30 | 31 |
ProjectHandler projectHandler = null; |
31 | 32 |
ClaimValidation claimValidation = null; |
32 |
Boolean useProductionIndex = null; |
|
33 |
@Autowired |
|
34 |
IndexResultHandler indexResultHandler; |
|
35 |
ContextUtils contextUtils; |
|
36 |
ExternalRecordHandler externalRecordHandler; |
|
33 | 37 |
|
34 | 38 |
private static final Logger logger = Logger.getLogger(ClaimHandler.class); |
35 | 39 |
|
... | ... | |
93 | 97 |
* @param targetCollectedFrom |
94 | 98 |
* @throws Exception |
95 | 99 |
*/ |
96 |
public String buildAndInsertClaim(String user, String sourceType, String sourceId, String sourceCollectedFrom, String sourceAccessRights, String sourceEmbargoDate, String targetType, String targetId, String targetCollectedFrom, String targetAccessRights, String targetEmbargoDate) throws Exception, SQLStoreException { |
|
100 |
public String buildAndInsertClaim(String user, String sourceType, String sourceId, String sourceCollectedFrom, String sourceAccessRights, String sourceEmbargoDate, String targetType, String targetId, String targetCollectedFrom, String targetAccessRights, String targetEmbargoDate, String claimedInDashboard ) throws Exception, SQLStoreException {
|
|
97 | 101 |
String id = null; |
98 | 102 |
|
99 | 103 |
claimValidation.validateCollectedFrom(targetCollectedFrom); |
... | ... | |
101 | 105 |
logger.info("Trying to create a claim {user:"+user+", sourceType:"+sourceType+", sourceId:"+sourceId+", sourceCollectedFrom:"+sourceCollectedFrom+", sourceAccessRights:"+sourceAccessRights |
102 | 106 |
+", sourceEmbargoDate:"+sourceEmbargoDate +", targetType:"+targetType +", targetId:"+targetId +", targetCollectedFrom:"+targetCollectedFrom +", targetAccessRights:"+targetAccessRights |
103 | 107 |
+", targetEmbargoDate:"+targetEmbargoDate+"}"); |
104 |
Claim claim = buildClaim(user,sourceType,sourceId,sourceCollectedFrom, sourceAccessRights, sourceEmbargoDate, targetType, targetId, targetCollectedFrom, targetAccessRights, targetEmbargoDate); |
|
108 |
Claim claim = buildClaim(user,sourceType,sourceId,sourceCollectedFrom, sourceAccessRights, sourceEmbargoDate, targetType, targetId, targetCollectedFrom, targetAccessRights, targetEmbargoDate, claimedInDashboard);
|
|
105 | 109 |
if(claimValidation.validateClaim(claim)) { |
106 | 110 |
claim = exportMedatataForClaim(claim); |
107 | 111 |
id = saveClaim(claim); |
... | ... | |
124 | 128 |
* @return a claim object |
125 | 129 |
* @throws Exception |
126 | 130 |
*/ |
127 |
public Claim buildClaim(String user, String sourceType,String sourceId,String sourceCollectedFrom, String sourceAccessRights, String sourceEmbargoDate, String targetType,String targetId,String targetCollectedFrom, String targetAccessRights, String targetEmbargoDate ) throws Exception {
|
|
131 |
public Claim buildClaim(String user, String sourceType, String sourceId,String sourceCollectedFrom, String sourceAccessRights, String sourceEmbargoDate, String targetType,String targetId,String targetCollectedFrom, String targetAccessRights, String targetEmbargoDate, String claimedInDashboard ) throws Exception {
|
|
128 | 132 |
Claim claim = new Claim(); |
129 | 133 |
claim.setUserMail(user); |
134 |
claim.setClaimedInDashboard(claimedInDashboard); |
|
130 | 135 |
claim.setDate(new Date()); |
131 | 136 |
//date |
132 | 137 |
claim.setSourceType(sourceType); |
... | ... | |
175 | 180 |
* @throws Exception |
176 | 181 |
*/ |
177 | 182 |
public OpenaireEntity buildOpenaireEntity(String id, String type, String collectedFrom, String accessRights, String embargoDate) throws Exception { |
183 |
logger.debug(id+" "+ type+" "+collectedFrom); |
|
178 | 184 |
if(type==null){ |
179 | 185 |
return null; |
180 | 186 |
} |
181 | 187 |
else if(type.equals(ClaimUtils.CONTEXT)){ |
182 |
return ContextUtils.fetchContextById(id, useProductionIndex);
|
|
188 |
return contextUtils.fetchContextById(id);
|
|
183 | 189 |
}else if (type.equals(ClaimUtils.PROJECT)){ |
184 | 190 |
Project project = projectHandler.fetchProjectByID(id); |
191 |
// if(project == null){ |
|
192 |
// project = projectHandler.fetchProjectByID(id); |
|
193 |
// } |
|
185 | 194 |
if(project == null){ |
186 |
project = projectHandler.fetchProjectByID(id); |
|
187 |
} |
|
188 |
if(project == null){ |
|
189 | 195 |
logger.error("Project with id:"+id + " couldn't be fetched."); |
190 | 196 |
} |
191 | 197 |
|
192 | 198 |
return project; |
193 | 199 |
}else if (type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE) ||type.equals(ClaimUtils.OTHER) ){ |
194 |
ExternalRecordHandler externalRecordHandler = new ExternalRecordHandler(); |
|
195 | 200 |
if(collectedFrom == null){ |
196 | 201 |
return null; |
197 | 202 |
}else if(collectedFrom.equals(ClaimUtils.CROSSREF)){ |
... | ... | |
223 | 228 |
} |
224 | 229 |
return result; |
225 | 230 |
}else if (collectedFrom.equals(ClaimUtils.OPENAIRE)){ |
226 |
IndexResultHandler indexResultHandler = new IndexResultHandler(); |
|
227 | 231 |
Result result = null; |
228 | 232 |
if(type.equals(ClaimUtils.PUBLICATION)){ |
229 | 233 |
result = indexResultHandler.fetchPublicationById(id); |
... | ... | |
355 | 359 |
this.claimValidation = claimValidation; |
356 | 360 |
} |
357 | 361 |
|
358 |
public Boolean getUseProductionIndex() {
|
|
359 |
return useProductionIndex;
|
|
362 |
public ContextUtils getContextUtils() {
|
|
363 |
return contextUtils;
|
|
360 | 364 |
} |
361 | 365 |
|
362 |
public void setUseProductionIndex(Boolean useProductionIndex) {
|
|
363 |
this.useProductionIndex = useProductionIndex;
|
|
366 |
public void setContextUtils(ContextUtils contextUtils) {
|
|
367 |
this.contextUtils = contextUtils;
|
|
364 | 368 |
} |
369 |
|
|
370 |
public IndexResultHandler getIndexResultHandler() { |
|
371 |
return indexResultHandler; |
|
372 |
} |
|
373 |
|
|
374 |
public void setIndexResultHandler(IndexResultHandler indexResultHandler) { |
|
375 |
this.indexResultHandler = indexResultHandler; |
|
376 |
} |
|
377 |
|
|
378 |
public ExternalRecordHandler getExternalRecordHandler() { |
|
379 |
return externalRecordHandler; |
|
380 |
} |
|
381 |
|
|
382 |
public void setExternalRecordHandler(ExternalRecordHandler externalRecordHandler) { |
|
383 |
this.externalRecordHandler = externalRecordHandler; |
|
384 |
} |
|
365 | 385 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/handler/IndexResultHandler.java | ||
---|---|---|
3 | 3 |
import eu.dnetlib.data.claims.entity.Result; |
4 | 4 |
import eu.dnetlib.data.claims.parser.OafParser; |
5 | 5 |
import eu.dnetlib.data.claims.utils.SearchUtils; |
6 |
import org.apache.log4j.Logger; |
|
6 | 7 |
|
7 | 8 |
/** |
8 | 9 |
* Created by kiatrop on 8/2/2016. |
... | ... | |
10 | 11 |
public class IndexResultHandler { |
11 | 12 |
|
12 | 13 |
SearchUtils searchUtils; |
14 |
private Logger log = Logger.getLogger(this.getClass()); |
|
13 | 15 |
|
14 | 16 |
private String fetchPublicationResult(String id) throws Exception { |
15 | 17 |
return searchUtils.fetchPublicationXmlFromIndex(id); |
... | ... | |
22 | 24 |
} |
23 | 25 |
|
24 | 26 |
private String fetchDatasetResult(String id) throws Exception { |
27 |
if(searchUtils == null ){ |
|
28 |
log.debug("searchUtils is null"); |
|
29 |
} |
|
30 |
if(id == null ){ |
|
31 |
log.debug("id is null"); |
|
32 |
} |
|
25 | 33 |
return searchUtils.fetchDatasetXmlFromIndex(id); |
26 | 34 |
} |
27 | 35 |
/** |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/handler/FetchClaimHandler.java | ||
---|---|---|
124 | 124 |
ResultSet rs = sqlDAO.executePreparedQuery(query, params); |
125 | 125 |
return fetchClaimsByResultSet(rs, addCurationInfo); |
126 | 126 |
} |
127 |
|
|
128 |
public List<Claim> fetchClaimsByDateForDashboards(String dateFrom, String dataTo, Integer limit, Integer offset, boolean addCurationInfo, ArrayList<String> dashboards) throws Exception, SQLStoreException { |
|
129 |
ArrayList<Object> params = new ArrayList<>(); |
|
130 |
String query = queryGenerator.generateFetchClaimsByDateForDashboards(dateFrom, dataTo, limit, offset,null, "claim.claim_date", true,new ArrayList<String>(), params, dashboards); |
|
131 |
ResultSet rs = sqlDAO.executePreparedQuery(query, params); |
|
132 |
return fetchClaimsByResultSet(rs, addCurationInfo); |
|
133 |
} |
|
127 | 134 |
/** |
128 | 135 |
* |
129 | 136 |
* @param dateFrom |
modules/uoa-claims/trunk/src/main/resources/eu/dnetlib/data/claims/springContext-claims.properties | ||
---|---|---|
1 |
services.claims.crossrefUrl=https://api.crossref.org/works?filter=doi: |
|
2 |
services.claims.dataciteUrl=https://api.datacite.org/works/ |
|
3 |
services.claims.orcidUrlPrefix=https://pub.orcid.org/v2.1/ |
|
4 |
services.claims.orcidUrlSuffix=/works |
|
5 |
services.claims.contextsAPIUrl=http://beta.services.openaire.eu/openaire/context |
|
1 | 6 |
|
2 | 7 |
services.claims.db.driverClassName = org.postgresql.Driver |
3 |
services.claims.db.url = jdbc:postgresql://scoobydoo.di.uoa.gr:5432/claims_www_last
|
|
8 |
services.claims.db.url = jdbc:postgresql://scoobydoo.di.uoa.gr:5432/claimsnewschema
|
|
4 | 9 |
services.claims.db.username = postgres |
5 | 10 |
services.claims.db.password = snowflakes |
6 |
services.claims.useProductionIndex = false |
|
7 | 11 |
|
8 | 12 |
services.claims.communityAPI = https://dev-openaire.d4science.org/openaire/community/ |
9 | 13 |
services.claims.searchAPIUrl = http://services.openaire.eu:8480/search/ |
... | ... | |
31 | 35 |
services.claims.directClaimAPIUrl = http://beta.services.openaire.eu:8980/provision/mvc/api/results |
32 | 36 |
|
33 | 37 |
|
34 |
services.claims.mail.enabledCommunities = invalid_community_pid |
|
38 |
services.claims.mail.enabledCommunities = invalid_community_pid |
modules/uoa-claims/trunk/src/main/resources/eu/dnetlib/data/claims/springContext-claims.xml | ||
---|---|---|
22 | 22 |
<property name="projectHandler" ref="projectHandler"/> |
23 | 23 |
<property name="resultHandler" ref="resultHandler"/> |
24 | 24 |
<property name="claimValidation" ref="claimValidation"/> |
25 |
<property name="useProductionIndex" value="${services.claims.useProductionIndex}"/> |
|
25 |
<property name="contextUtils" ref="contextUtils"/> |
|
26 |
<property name="externalRecordHandler" ref="externalRecordHandler"/> |
|
26 | 27 |
</bean> |
27 | 28 |
<bean id="externalRecordHandler" class="eu.dnetlib.data.claims.handler.ExternalRecordHandler"> |
28 | 29 |
<property name="searchUtils" ref="searchUtils"/> |
... | ... | |
73 | 74 |
<bean id="oafParser" class="eu.dnetlib.data.claims.parser.OafParser"></bean> |
74 | 75 |
<bean id="externalRecordParser" class="eu.dnetlib.data.claims.parser.ExternalRecordParser"></bean> |
75 | 76 |
<!-- end of Parsers --> |
77 |
<bean id="contextUtils" class="eu.dnetlib.data.claims.utils.ContextUtils"> |
|
78 |
<property name="searchUtils" ref="searchUtils"/> |
|
79 |
</bean> |
|
76 | 80 |
<bean id="searchUtils" class="eu.dnetlib.data.claims.utils.SearchUtils"> |
77 | 81 |
<property name="searchAPIUrl" value="${services.claims.searchAPIUrl}"/> |
78 |
|
|
82 |
<property name="contextsAPIUrl" value="${services.claims.contextsAPIUrl}"/> |
|
83 |
<property name="crossrefUrl" value="${services.claims.crossrefUrl}"/> |
|
84 |
<property name="dataciteUrl" value="${services.claims.dataciteUrl}"/> |
|
85 |
<property name="orcidUrlPrefix" value="${services.claims.orcidUrlPrefix}"/> |
|
86 |
<property name="orcidUrlSuffix" value="${services.claims.orcidUrlSuffix}"/> |
|
79 | 87 |
</bean> |
80 | 88 |
|
81 | 89 |
<bean id="claimValidation" class="eu.dnetlib.data.claims.utils.ClaimValidation"> |
Also available in: Unified diff
ClaimEntity: Add information about the dashboard where the claim was created
Properties:
add properties for the different services
create beans properly
production or beta is decided from the services urls in properties
Migration:
create migration method: CopyFromBetaToProduction for communities