Revision 49865
Added by Argiro Kokogiannaki over 6 years ago
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/ClaimValidation.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
*/ |
25 | 25 |
public boolean validateClaim(Claim claim){ |
26 |
logger.info("Validating..."); |
|
27 | 26 |
boolean isValid=true; |
28 | 27 |
try { |
29 | 28 |
out = new PrintWriter(new BufferedWriter(new FileWriter(pathToSaveReport+"/validationFile.txt", true))); |
... | ... | |
198 | 197 |
} |
199 | 198 |
private boolean validateByType(OpenaireEntity entity,String type , String claimId ){ |
200 | 199 |
//TODO add more types (e.g. patends) when they are available |
201 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)){ |
|
200 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE)){
|
|
202 | 201 |
return validateResult((Result)entity,claimId); |
203 | 202 |
} else if(type.equals(ClaimUtils.CONTEXT)){ |
204 | 203 |
return validateContext((Context)entity,claimId); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/Migration.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.data.claims.migration.handler.*; |
5 | 5 |
import eu.dnetlib.data.claimsDemo.ClaimUtils; |
6 | 6 |
import eu.dnetlib.data.claimsDemo.SQLStoreException; |
7 |
import org.apache.log4j.BasicConfigurator; |
|
8 |
import org.apache.log4j.Level; |
|
7 | 9 |
import org.apache.log4j.Logger; |
8 | 10 |
import org.springframework.context.ApplicationContext; |
9 | 11 |
import org.springframework.context.support.ClassPathXmlApplicationContext; |
... | ... | |
100 | 102 |
return claims; |
101 | 103 |
|
102 | 104 |
} |
105 |
public void createAndSaveRelationsClaims(boolean save) throws Exception, SQLStoreException { |
|
106 |
/*for stats*/ |
|
107 |
List<Claim> claimsOp= new ArrayList<Claim>(); |
|
108 |
List<Claim> claimsCr= new ArrayList<Claim>(); |
|
109 |
List<Claim> claimsDat= new ArrayList<Claim>(); |
|
110 |
List<Claim> claimsOrc= new ArrayList<Claim>(); |
|
111 |
Integer targetOp=0; |
|
112 |
Integer targetCr=0; |
|
113 |
Integer targetDat=0; |
|
114 |
Integer targetOrc=0; |
|
115 |
Integer sourceRes=0; |
|
116 |
Integer sourceOp=0; |
|
117 |
Integer sourceCr=0; |
|
118 |
Integer sourceDat=0; |
|
119 |
Integer sourceOrc=0; |
|
120 |
Integer projects=0; |
|
121 |
Integer contexts=0; |
|
122 |
Integer totalClaims=0; |
|
123 |
|
|
124 |
|
|
125 |
List<Relation> relations = relationHandler.fetchAllRelations(); |
|
126 |
List<Claim> claims = new ArrayList<Claim>(); |
|
127 |
logger.info("Relation size: "+relations.size()); |
|
128 |
for (Relation relation : relations) { |
|
129 |
try { |
|
130 |
Claim claim = new Claim(); |
|
131 |
|
|
132 |
claim.setUserMail(relation.getClaimedBy()); |
|
133 |
claim.setDate(relation.getClaimDate()); |
|
134 |
claim.setId(relation.getClaimId()); |
|
135 |
logger.info("Claim id:" + claim.getId()); |
|
136 |
OpenaireEntity source = null; |
|
137 |
//first work with the Source |
|
138 |
if (relation.getSourceType().equals(ClaimUtils.PROJECT)) { |
|
139 |
source = buildProject(relation.getSourceId(), relation.getClaimId()); |
|
140 |
claim.setSourceType(ClaimUtils.PROJECT); |
|
141 |
} else if (relation.getSourceType().equals(ClaimUtils.CONTEXT)) { |
|
142 |
Context context = dmfContextHandler.fetchContextByIdFromDmf(relation.getSourceId()); |
|
143 |
source = context; |
|
144 |
claim.setSourceType(ClaimUtils.CONTEXT); |
|
145 |
} else if (relation.getSourceType().equals(ClaimUtils.DATASET) || relation.getSourceType().equals(ClaimUtils.PUBLICATION)) { |
|
146 |
Result result = buildResult(relation.getDmf(), relation.getCollectedFrom(), relation.getSourceId(), relation.getClaimId()); |
|
147 |
source = result; |
|
148 |
claim.setSourceType(result.getResultType()); |
|
149 |
} |
|
150 |
|
|
151 |
claim.setSource(source); |
|
152 |
|
|
153 |
Result target = null; |
|
154 |
if (relation.getTargetType().equals(ClaimUtils.DATASET) || relation.getTargetType().equals(ClaimUtils.PUBLICATION)) { |
|
155 |
target = buildResult(relation.getDmf(), relation.getCollectedFrom(), relation.getTargetId(), relation.getClaimId()); |
|
156 |
|
|
157 |
} |
|
158 |
if (target != null) { |
|
159 |
claim.setTarget(target); |
|
160 |
claim.setTargetType(target.getResultType()); |
|
161 |
} |
|
162 |
|
|
163 |
if (claimValidation.validateClaim(claim)) { // is valid |
|
164 |
if(save) { |
|
165 |
claim = claimHandler.exportMedatataForClaim(claim); |
|
166 |
claimHandler.saveClaim(claim); |
|
167 |
} |
|
168 |
/*for stats*/ |
|
169 |
if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_CROSSREF)){ |
|
170 |
targetCr++; |
|
171 |
}else if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_DATACITE)){ |
|
172 |
targetDat++; |
|
173 |
}else if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_ORCID)){ |
|
174 |
targetOrc++; |
|
175 |
}else { |
|
176 |
targetOp++; |
|
177 |
} |
|
178 |
if(claim.getSourceType().equals(ClaimUtils.PUBLICATION)||claim.getSourceType().equals(ClaimUtils.DATASET)){ |
|
179 |
sourceRes++; |
|
180 |
if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_CROSSREF)){ |
|
181 |
sourceCr++; |
|
182 |
}else if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_DATACITE)){ |
|
183 |
sourceDat++; |
|
184 |
}else if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_ORCID)){ |
|
185 |
sourceOrc++; |
|
186 |
}else { |
|
187 |
sourceOp++; |
|
188 |
} |
|
189 |
}else if(claim.getSourceType().equals(ClaimUtils.PROJECT)) { |
|
190 |
projects++; |
|
191 |
}else if(claim.getSourceType().equals(ClaimUtils.CONTEXT)){ |
|
192 |
contexts++; |
|
193 |
} |
|
194 |
|
|
195 |
} |
|
196 |
}catch (Exception e){ |
|
197 |
e.printStackTrace(); |
|
198 |
logger.error("Exception: "+e.getMessage()); |
|
199 |
|
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/*for stats*/ |
|
204 |
System.out.println("\n\nTargets:\n\nCrossref : "+targetCr+ " DataCite :"+targetDat+" Orcid : "+targetOrc+" OpenAire : "+targetOp); |
|
205 |
System.out.println("\n\nSources:\n\nAll : "+sourceRes+" Crossref : "+sourceCr+ " DataCite :"+sourceDat+" Orcid : "+sourceOrc+" OpenAire : "+sourceOp); |
|
206 |
System.out.println("\n\nTotalClaims: "+totalClaims+" Projects: "+projects+ " Contexts :"+contexts); |
|
207 |
|
|
208 |
|
|
209 |
} |
|
103 | 210 |
public List<Claim> createContextRelationClaims() throws Exception, SQLStoreException { |
104 | 211 |
|
105 | 212 |
|
... | ... | |
132 | 239 |
|
133 | 240 |
|
134 | 241 |
} |
242 |
public void createAndSaveContextRelationClaims(Boolean save) throws Exception, SQLStoreException { |
|
243 |
/*for stats*/ |
|
244 |
List<Claim> claimsOp= new ArrayList<Claim>(); |
|
245 |
List<Claim> claimsCr= new ArrayList<Claim>(); |
|
246 |
List<Claim> claimsDat= new ArrayList<Claim>(); |
|
247 |
List<Claim> claimsOrc= new ArrayList<Claim>(); |
|
248 |
Integer targetOp=0; |
|
249 |
Integer targetCr=0; |
|
250 |
Integer targetDat=0; |
|
251 |
Integer targetOrc=0; |
|
252 |
Integer sourceRes=0; |
|
253 |
Integer sourceOp=0; |
|
254 |
Integer sourceCr=0; |
|
255 |
Integer sourceDat=0; |
|
256 |
Integer sourceOrc=0; |
|
257 |
Integer projects=0; |
|
258 |
Integer contexts=0; |
|
259 |
Integer totalClaims=0; |
|
135 | 260 |
|
261 |
List<ContextRelation> relations = contextRelationHandler.fetchAllConceptRelations(); |
|
262 |
// List<Claim> claims = new ArrayList<Claim>(); |
|
263 |
for (ContextRelation relation : relations) { |
|
264 |
|
|
265 |
Claim claim= new Claim(); |
|
266 |
claim.setId(relation.getClaimId()); |
|
267 |
claim.setUserMail(relation.getClaimedBy()); |
|
268 |
claim.setDate(relation.getClaimDate()); |
|
269 |
logger.info("Claim id:" + claim.getId()); |
|
270 |
|
|
271 |
//first work with the Source |
|
272 |
Context context = dmfContextHandler.extractContextFromDMF(relation.getContextDmf()); |
|
273 |
claim.setSourceType(ClaimUtils.CONTEXT); |
|
274 |
claim.setSource(context); |
|
275 |
|
|
276 |
Result target = buildResult(relation.getResultDmf(), relation.getCollectedFrom(), relation.getResultId(), relation.getClaimId()); |
|
277 |
if( target != null){ |
|
278 |
claim.setTarget(target); |
|
279 |
claim.setTargetType(target.getResultType()); |
|
280 |
} |
|
281 |
if(claimValidation.validateClaim(claim)){ // is valid |
|
282 |
if(save){ |
|
283 |
claim = claimHandler.exportMedatataForClaim(claim); |
|
284 |
claimHandler.saveClaim(claim); |
|
285 |
} |
|
286 |
|
|
287 |
/*for stats*/ |
|
288 |
if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_CROSSREF)){ |
|
289 |
targetCr++; |
|
290 |
}else if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_DATACITE)){ |
|
291 |
targetDat++; |
|
292 |
}else if(((Result)claim.getTarget()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_ORCID)){ |
|
293 |
targetOrc++; |
|
294 |
}else { |
|
295 |
targetOp++; |
|
296 |
} |
|
297 |
if(claim.getSourceType().equals(ClaimUtils.PUBLICATION)||claim.getSourceType().equals(ClaimUtils.DATASET)){ |
|
298 |
sourceRes++; |
|
299 |
if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_CROSSREF)){ |
|
300 |
sourceCr++; |
|
301 |
}else if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_DATACITE)){ |
|
302 |
sourceDat++; |
|
303 |
}else if(((Result)claim.getSource()).getCollectedFrom().equals(ClaimUtils.COLLECTED_FROM_ORCID)){ |
|
304 |
sourceOrc++; |
|
305 |
}else { |
|
306 |
sourceOp++; |
|
307 |
} |
|
308 |
}else if(claim.getSourceType().equals(ClaimUtils.PROJECT)) { |
|
309 |
projects++; |
|
310 |
}else if(claim.getSourceType().equals(ClaimUtils.CONTEXT)){ |
|
311 |
contexts++; |
|
312 |
} |
|
313 |
} |
|
314 |
|
|
315 |
|
|
316 |
} |
|
317 |
|
|
318 |
/*for stats*/ |
|
319 |
System.out.println("\n\nTargets:\n\nCrossref : "+targetCr+ " DataCite :"+targetDat+" Orcid : "+targetOrc+" OpenAire : "+targetOp); |
|
320 |
System.out.println("\n\nSources:\n\nAll : "+sourceRes+" Crossref : "+sourceCr+ " DataCite :"+sourceDat+" Orcid : "+sourceOrc+" OpenAire : "+sourceOp); |
|
321 |
System.out.println("\n\nTotalClaims: "+totalClaims+" Projects: "+projects+ " Contexts :"+contexts); |
|
322 |
|
|
323 |
} |
|
324 |
|
|
136 | 325 |
/** |
137 | 326 |
*Returns a project from Openaire. |
138 | 327 |
* In case the project id has a "welcometrust" prefix changes it to "wt__________", before search for it in the index. |
... | ... | |
147 | 336 |
if(projectId != null && projectId.contains("welcometrust")){ |
148 | 337 |
id=projectId.replace("welcometrust","wt__________"); |
149 | 338 |
} |
150 |
Project project = projectHandler.fetchProjectByID(id); |
|
339 |
Project project = projectHandler.fetchProjectByID(id, false);
|
|
151 | 340 |
if (project == null) { |
341 |
project = projectHandler.fetchProjectByID(id, true); |
|
342 |
} |
|
343 |
if (project == null) { |
|
152 | 344 |
try{ |
153 |
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("missing_projects.txt", true))); |
|
345 |
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(claimValidation.getPathToSaveReport()+"missing_projects.txt", true)));
|
|
154 | 346 |
Date date= new java.util.Date(); |
155 | 347 |
out.println(new Timestamp(date.getTime())+" ProjectId: "+id+ " ClaimId: "+claimId); |
156 | 348 |
out.close(); |
... | ... | |
257 | 449 |
public Result buildOpenaireResult(String resultId, String claimId ){ |
258 | 450 |
|
259 | 451 |
Result result = null; |
260 |
|
|
261 | 452 |
try { |
262 |
result = indexResultHandler.fetchResultById(resultId);
|
|
453 |
result = indexResultHandler.fetchPublicationById(resultId, false);
|
|
263 | 454 |
} catch (Exception e) { |
264 | 455 |
logger.error("Error fetching result from Openaire",e); |
456 |
System.out.println("Error fetching result from Openaire"); |
|
265 | 457 |
} |
266 | 458 |
|
267 | 459 |
//If it is not found in the index |
268 | 460 |
if (result == null) { |
269 | 461 |
//give a second chance as dedup |
462 |
// try { |
|
463 |
// result = indexResultHandler.fetchDedupResultById(resultId); |
|
464 |
// } catch (Exception e) { |
|
465 |
// logger.error("Error fetching dedup Result",e); |
|
466 |
// } |
|
467 |
//give a second chance in production |
|
270 | 468 |
try { |
271 |
result = indexResultHandler.fetchDedupResultById(resultId);
|
|
469 |
result = indexResultHandler.fetchPublicationById(resultId, true);
|
|
272 | 470 |
} catch (Exception e) { |
273 |
logger.error("Error fetching dedup Result",e); |
|
471 |
logger.error("Error fetching result from Openaire",e); |
|
472 |
System.out.println("Error fetching result from Openaire"); |
|
274 | 473 |
} |
474 |
if (result == null) { |
|
475 |
try { |
|
476 |
result = indexResultHandler.fetchDatasetById(resultId, false); |
|
477 |
} catch (Exception e) { |
|
478 |
logger.error("Error fetching result from Openaire",e); |
|
479 |
System.out.println("Error fetching result from Openaire"); |
|
480 |
} |
|
481 |
} |
|
482 |
if (result == null) { |
|
483 |
try { |
|
484 |
result = indexResultHandler.fetchDatasetById(resultId, true); |
|
485 |
} catch (Exception e) { |
|
486 |
logger.error("Error fetching result from Openaire",e); |
|
487 |
System.out.println("Error fetching result from Openaire"); |
|
488 |
} |
|
489 |
} |
|
490 |
if (result == null) { |
|
491 |
try { |
|
492 |
result = indexResultHandler.fetchDedupById(resultId, false); |
|
493 |
} catch (Exception e) { |
|
494 |
logger.error("Error fetching result from Openaire",e); |
|
495 |
System.out.println("Error fetching result from Openaire"); |
|
496 |
} |
|
497 |
} |
|
498 |
// if (result == null) { |
|
499 |
// try { |
|
500 |
// result = indexResultHandler.fetchDedupById(resultId, true); |
|
501 |
// } catch (Exception e) { |
|
502 |
// logger.error("Error fetching result from Openaire",e); |
|
503 |
// System.out.println("Error fetching result from Openaire"); |
|
504 |
// } |
|
505 |
// } |
|
275 | 506 |
if (result != null) { |
276 | 507 |
try { |
277 | 508 |
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(claimValidation.getPathToSaveReport()+"dedup_results_found.txt", true))); |
... | ... | |
346 | 577 |
|
347 | 578 |
|
348 | 579 |
public static void main(String[] args) throws IOException { |
349 |
|
|
580 |
BasicConfigurator.configure(); |
|
581 |
logger.setLevel(Level.DEBUG); |
|
350 | 582 |
Migration migration = new Migration(); |
351 | 583 |
try { |
352 |
migration.claimHandler.getQueryGenerator().setMigrationTable("claims_view"); |
|
353 |
List<Claim> claims = null; |
|
354 |
// claims = migration.createContextRelationClaims(); |
|
355 |
claims = migration.createRelationsClaims(); |
|
584 |
// migration.claimHandler.getQueryGenerator().setMigrationTable("claims_view"); |
|
585 |
// migration.createAndSaveRelationsClaims(true); |
|
586 |
// migration.createAndSaveContextRelationClaims(true); |
|
356 | 587 |
|
357 |
migration.printStatistics(claims); |
|
358 |
migration.saveClaims(claims); |
|
588 |
migration.claimHandler.getQueryGenerator().setMigrationTable("export_last_claims"); |
|
589 |
migration.createAndSaveRelationsClaims(true); |
|
590 |
migration.createAndSaveContextRelationClaims(true); |
|
359 | 591 |
|
592 |
|
|
360 | 593 |
} catch (Exception e) { |
361 | 594 |
logger.error("Error in migration",e); |
362 | 595 |
} catch (SQLStoreException e) { |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/entity/Result.java | ||
---|---|---|
216 | 216 |
",\n recordPath='" + recordPath + '\'' + |
217 | 217 |
",\n recordFormat='" + recordFormat + '\'' + |
218 | 218 |
",\n resultType='" + resultType + '\'' + |
219 |
",\n authors='" + authors + '\'' + |
|
219 | 220 |
'}'; |
220 | 221 |
} |
221 | 222 |
//method to ask from API of search to get the metadataRecord |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/parser/OafParser.java | ||
---|---|---|
59 | 59 |
NodeList nl = (NodeList) xpath.compile("/response/header/total/text()").evaluate(document, XPathConstants.NODESET); |
60 | 60 |
if (nl.getLength() > 0) { |
61 | 61 |
size= nl.item(0).getNodeValue(); |
62 |
}else{ |
|
63 |
nl = (NodeList) xpath.compile("//objIdentifier/text()").evaluate(document, XPathConstants.NODESET); |
|
64 |
if (nl.getLength() > 0) { |
|
65 |
// result.setOpenaireId(nl.item(0).getNodeValue()); |
|
66 |
size="1"; |
|
67 |
} |
|
62 | 68 |
} |
63 | 69 |
if(size!=null && Integer.parseInt(size)>0){ |
64 | 70 |
result = new Result(); |
... | ... | |
74 | 80 |
if (nl.getLength() > 0) { |
75 | 81 |
result.setBestLicense(nl.item(0).getNodeValue()); |
76 | 82 |
} |
83 |
nl = (NodeList) xpath.compile("//bestaccessright/@classid").evaluate(document, XPathConstants.NODESET); |
|
84 |
if (nl.getLength() > 0) { |
|
85 |
result.setBestLicense(nl.item(0).getNodeValue()); |
|
86 |
} |
|
77 | 87 |
nl = (NodeList) xpath.compile("//embargoenddate/text()").evaluate(document, XPathConstants.NODESET); |
78 | 88 |
if (nl.getLength() > 0) { |
79 | 89 |
result.setEmbargoEndDate(nl.item(0).getNodeValue()); |
... | ... | |
141 | 151 |
nl.item(0).getParentNode().removeChild(nl.item(0)); |
142 | 152 |
} |
143 | 153 |
|
144 |
nl = (NodeList) xpath.compile("//rels/rel/to[@class='hasAuthor']").evaluate(document, XPathConstants.NODESET); |
|
154 |
nl = (NodeList) xpath.compile("//rel[@class='hasAuthor']").evaluate(document, XPathConstants.NODESET); |
|
155 |
System.out.println("Author length"+nl.getLength()); |
|
145 | 156 |
if (nl.getLength() > 0) { |
146 | 157 |
for (int i = 0; i < nl.getLength(); i++) { |
147 | 158 |
String ranking = ((Element)(nl.item(i).getParentNode())).getElementsByTagName("ranking").item(0).getTextContent(); |
... | ... | |
150 | 161 |
} |
151 | 162 |
|
152 | 163 |
} |
164 |
nl = (NodeList) xpath.compile("//creator/text()").evaluate(document, XPathConstants.NODESET); |
|
165 |
System.out.println("Creator length"+nl.getLength()); |
|
166 |
if (nl.getLength() > 0) { |
|
167 |
for (int i = 0; i < nl.getLength(); i++) { |
|
168 |
String ranking = ((Element)(nl.item(i).getParentNode())).getAttribute("rank"); |
|
169 |
String fullname = (((Element)(nl.item(i).getParentNode())).getTextContent().replace(",", " ")); |
|
170 |
result.getAuthors().put(ranking,fullname); |
|
171 |
} |
|
153 | 172 |
|
173 |
} |
|
174 |
|
|
154 | 175 |
DOMSource domSource = new DOMSource(document); |
155 | 176 |
StringWriter writer = new StringWriter(); |
156 | 177 |
StreamResult streamResult = new StreamResult(writer); |
... | ... | |
248 | 269 |
return project; |
249 | 270 |
|
250 | 271 |
} |
272 |
public static Result oaf2Software(String oaf) throws ParserConfigurationException, IOException, SAXException, XPathExpressionException, TransformerException { |
|
273 |
Result result = null; |
|
274 |
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
|
275 |
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); |
|
276 |
InputSource is = new InputSource(new StringReader(oaf)); |
|
277 |
Document document= dBuilder.parse(is); |
|
278 |
XPathFactory xPathfactory= XPathFactory.newInstance(); |
|
279 |
XPath xpath = xPathfactory.newXPath(); |
|
251 | 280 |
|
281 |
String size = null; |
|
282 |
NodeList nl = (NodeList) xpath.compile("/response/header/total/text()").evaluate(document, XPathConstants.NODESET); |
|
283 |
if (nl.getLength() > 0) { |
|
284 |
size= nl.item(0).getNodeValue(); |
|
285 |
} |
|
286 |
System.out.println("size:"+size); |
|
287 |
if(size!=null && Integer.parseInt(size)>0){ |
|
288 |
result = new Result(); |
|
289 |
nl = (NodeList) xpath.compile("//field[@name = \"resultId\"]/@value").evaluate(document, XPathConstants.NODESET); |
|
290 |
if (nl.getLength() > 0) { |
|
291 |
result.setOpenaireId(nl.item(0).getNodeValue()); |
|
292 |
} |
|
293 |
nl = (NodeList) xpath.compile("//field[@name = \"resulttypeid\"]/@value").evaluate(document, XPathConstants.NODESET); |
|
294 |
if (nl.getLength() > 0) { |
|
295 |
result.setResultType(nl.item(0).getNodeValue()); |
|
296 |
} |
|
297 |
nl = (NodeList) xpath.compile("//field[@name = \"bestaccessright\"]/@value").evaluate(document, XPathConstants.NODESET); |
|
298 |
if (nl.getLength() > 0) { |
|
299 |
result.setBestLicense(nl.item(0).getNodeValue()); |
|
300 |
} |
|
301 |
nl = (NodeList) xpath.compile("//field[@name = \"embargoenddate\"]/@value").evaluate(document, XPathConstants.NODESET); |
|
302 |
if (nl.getLength() > 0) { |
|
303 |
result.setEmbargoEndDate(nl.item(0).getNodeValue()); |
|
304 |
} |
|
305 |
nl = (NodeList) xpath.compile("//field[@name = \"title\"]/@value").evaluate(document, XPathConstants.NODESET); |
|
306 |
if (nl.getLength() > 0) { |
|
307 |
result.setTitle(nl.item(0).getNodeValue()); |
|
308 |
} |
|
309 |
// |
|
310 |
nl = (NodeList) xpath.compile("//field[@name = \"pid\"]").evaluate(document, XPathConstants.NODESET); |
|
311 |
System.out.println("size: pid"+nl.getLength()); |
|
312 |
if (nl.getLength() > 0) { |
|
313 |
for (int i = 0; i < nl.getLength(); i++) { |
|
314 |
NodeList list = (NodeList) xpath.compile("./field[@name = \"classid\"]/@value").evaluate(nl.item(i), XPathConstants.NODESET); |
|
315 |
System.out.println("size: classid"+list.getLength()); |
|
316 |
|
|
317 |
if (list.getLength() > 0 && list.item(0).getNodeValue() !=null ) { |
|
318 |
|
|
319 |
if (list.item(0).getNodeValue().equals("doi")) { |
|
320 |
list = (NodeList) xpath.compile("./field[@name = \"value\"]/@value").evaluate(nl.item(i), XPathConstants.NODESET); |
|
321 |
result.setDoi(list.item(0).getNodeValue()); |
|
322 |
result.setExternalUrl("http://dx.doi.org/" + result.getDoi()); |
|
323 |
|
|
324 |
|
|
325 |
} else if (list.item(0).getNodeValue().equals("pmc")) { |
|
326 |
list = (NodeList) xpath.compile("./field[@name = \"value\"]/@value").evaluate(nl.item(i), XPathConstants.NODESET); |
|
327 |
result.setDoi(list.item(0).getNodeValue()); |
|
328 |
result.setExternalUrl("http://dx.doi.org/" + result.getDoi()); |
|
329 |
|
|
330 |
|
|
331 |
}else if (list.item(0).getNodeValue().equals("orcidworkid")) { |
|
332 |
list = (NodeList) xpath.compile("./field[@name = \"value\"]/@value").evaluate(nl.item(i), XPathConstants.NODESET); |
|
333 |
result.setDoi(list.item(0).getNodeValue()); |
|
334 |
result.setExternalUrl("http://dx.doi.org/" + result.getDoi()); |
|
335 |
|
|
336 |
|
|
337 |
}else if (list.item(0).getNodeValue().equals("oai")) { |
|
338 |
list = (NodeList) xpath.compile("./field[@name = \"value\"]/@value").evaluate(nl.item(i), XPathConstants.NODESET); |
|
339 |
result.setDoi(list.item(0).getNodeValue()); |
|
340 |
result.setExternalUrl("http://dx.doi.org/" + result.getDoi()); |
|
341 |
|
|
342 |
|
|
343 |
} |
|
344 |
} |
|
345 |
} |
|
346 |
} |
|
347 |
nl = (NodeList) xpath.compile("//rels/rel/to[@class='hasAuthor']").evaluate(document, XPathConstants.NODESET); |
|
348 |
if (nl.getLength() > 0) { |
|
349 |
for (int i = 0; i < nl.getLength(); i++) { |
|
350 |
String ranking = ((Element)(nl.item(i).getParentNode())).getElementsByTagName("ranking").item(0).getTextContent(); |
|
351 |
String fullname = (((Element)(nl.item(i).getParentNode())).getElementsByTagName("fullname").item(0).getTextContent().replace(",", " ")); |
|
352 |
result.getAuthors().put(ranking,fullname); |
|
353 |
} |
|
354 |
|
|
355 |
} |
|
356 |
if(result.getExternalUrl()==null){ |
|
357 |
// nl = (NodeList) xpath.compile("//webresource/url/text()").evaluate(document, XPathConstants.NODESET); |
|
358 |
// if (nl.getLength() > 0) { |
|
359 |
// result.setExternalUrl(nl.item(0).getNodeValue()); |
|
360 |
// } |
|
361 |
nl = (NodeList) xpath.compile("//children/instance/licence[@classid='OPEN']").evaluate(document, XPathConstants.NODESET); |
|
362 |
if (nl.getLength() > 0) { |
|
363 |
NodeList list = (NodeList) xpath.compile("./webresource/url/text()").evaluate(nl.item(0).getParentNode(), XPathConstants.NODESET); |
|
364 |
if (list.getLength() > 0) { |
|
365 |
result.setExternalUrl(list.item(0).getNodeValue()); |
|
366 |
} |
|
367 |
}else{ |
|
368 |
nl = (NodeList) xpath.compile("//children/instance/licence[@classid='EMBARGO']").evaluate(document, XPathConstants.NODESET); |
|
369 |
if (nl.getLength() > 0) { |
|
370 |
NodeList list = (NodeList) xpath.compile("./webresource/url/text()").evaluate(nl.item(0).getParentNode(), XPathConstants.NODESET); |
|
371 |
if (list.getLength() > 0) { |
|
372 |
result.setExternalUrl(list.item(0).getNodeValue()); |
|
373 |
} |
|
374 |
}else{ |
|
375 |
nl = (NodeList) xpath.compile("//children/instance/licence[@classid='CLOSED']").evaluate(document, XPathConstants.NODESET); |
|
376 |
if (nl.getLength() > 0) { |
|
377 |
NodeList list = (NodeList) xpath.compile("./webresource/url/text()").evaluate(nl.item(0).getParentNode(), XPathConstants.NODESET); |
|
378 |
if (list.getLength() > 0) { |
|
379 |
result.setExternalUrl(list.item(0).getNodeValue()); |
|
380 |
} |
|
381 |
} |
|
382 |
} |
|
383 |
} |
|
384 |
} |
|
385 |
|
|
386 |
|
|
387 |
nl = (NodeList) xpath.compile("//response/header").evaluate(document, XPathConstants.NODESET); |
|
388 |
if(nl.getLength()>0){ |
|
389 |
nl.item(0).getParentNode().removeChild(nl.item(0)); |
|
390 |
} |
|
391 |
|
|
392 |
|
|
393 |
|
|
394 |
DOMSource domSource = new DOMSource(document); |
|
395 |
StringWriter writer = new StringWriter(); |
|
396 |
StreamResult streamResult = new StreamResult(writer); |
|
397 |
TransformerFactory tf = TransformerFactory.newInstance(); |
|
398 |
Transformer transformer = tf.newTransformer(); |
|
399 |
transformer.transform(domSource, streamResult); |
|
400 |
result.setMetadataRecord(writer.toString()); |
|
401 |
result.setCollectedFrom(ClaimUtils.COLLECTED_FROM_OPENAIRE); |
|
402 |
result.setRecordFormat(ClaimUtils.FORMAT_XML); |
|
403 |
// result.setFound(true); |
|
404 |
|
|
405 |
} |
|
406 |
return result; |
|
407 |
} |
|
408 |
|
|
409 |
|
|
252 | 410 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/parser/ExternalRecordParser.java | ||
---|---|---|
71 | 71 |
} |
72 | 72 |
} |
73 | 73 |
} |
74 |
System.out.println(item.getDOI()); |
|
74 |
// System.out.println(item.getDOI());
|
|
75 | 75 |
result.setDoi(item.getDOI()); |
76 | 76 |
result.setOpenaireId(createOpenaireId(item.getDOI())); |
77 | 77 |
result.setExternalUrl(item.getUrl()); |
... | ... | |
272 | 272 |
return result; |
273 | 273 |
} |
274 | 274 |
public static String createOpenaireId(String id){ |
275 |
System.out.println("createOpenaireId from id:" +id); |
|
275 |
// System.out.println("createOpenaireId from id:" +id);
|
|
276 | 276 |
if(id==null){ |
277 | 277 |
return null; |
278 | 278 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/DirectIndexHandler.java | ||
---|---|---|
79 | 79 |
response.append(inputLine); |
80 | 80 |
} |
81 | 81 |
in.close(); |
82 |
if(response.toString().equals("true")){ |
|
83 |
return true; |
|
84 |
}else{ |
|
82 |
if(responseCode != 200){ |
|
85 | 83 |
logger.error("An error occured. Record isn't saved in the Index.\n"+response.toString()); |
86 | 84 |
return false; |
85 |
}else{ |
|
86 |
return true; |
|
87 | 87 |
} |
88 | 88 |
} catch (IOException e) { |
89 | 89 |
logger.error("An error occured while trying to feed object" ,e); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/ClaimHandler.java | ||
---|---|---|
29 | 29 |
DMFContextHandler dmfContextHandler = null; |
30 | 30 |
ProjectHandler projectHandler = null; |
31 | 31 |
ClaimValidation claimValidation = null; |
32 |
Boolean useProductionIndex = false; |
|
32 | 33 |
|
33 | 34 |
private static final Logger logger = Logger.getLogger(ClaimHandler.class); |
34 | 35 |
|
... | ... | |
174 | 175 |
* @throws Exception |
175 | 176 |
*/ |
176 | 177 |
private OpenaireEntity buildOpenaireEntity(String id, String type, String collectedFrom, String accessRights, String embargoDate) throws Exception { |
178 |
logger.info("HEEEEREEE"); |
|
177 | 179 |
if(type==null){ |
178 | 180 |
return null; |
179 | 181 |
} |
180 | 182 |
else if(type.equals(ClaimUtils.CONTEXT)){ |
181 | 183 |
return DMFContextHandler.fetchContextById(id); |
182 | 184 |
}else if (type.equals(ClaimUtils.PROJECT)){ |
183 |
Project project = projectHandler.fetchProjectByID(id); |
|
185 |
Project project = projectHandler.fetchProjectByID(id, false);
|
|
184 | 186 |
if(project == null){ |
187 |
project = projectHandler.fetchProjectByID(id, true); |
|
188 |
} |
|
189 |
if(project == null){ |
|
185 | 190 |
logger.error("Project with id:"+id + " couldn't be fetched."); |
186 | 191 |
} |
187 | 192 |
|
188 | 193 |
return project; |
189 |
}else if (type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)){ |
|
194 |
}else if (type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE) ){
|
|
190 | 195 |
ExternalRecordHandler externalRecordHandler = new ExternalRecordHandler(); |
191 | 196 |
if(collectedFrom == null){ |
192 | 197 |
return null; |
... | ... | |
220 | 225 |
return result; |
221 | 226 |
}else if (collectedFrom.equals(ClaimUtils.OPENAIRE)){ |
222 | 227 |
IndexResultHandler indexResultHandler = new IndexResultHandler(); |
223 |
Result result = indexResultHandler.fetchResultById(id); |
|
228 |
Result result = null; |
|
229 |
if(type.equals(ClaimUtils.PUBLICATION)){ |
|
230 |
result = indexResultHandler.fetchPublicationById(id,useProductionIndex); |
|
231 |
|
|
232 |
}else if(type.equals(ClaimUtils.DATASET)){ |
|
233 |
result = indexResultHandler.fetchDatasetById(id,useProductionIndex); |
|
234 |
}else if(type.equals(ClaimUtils.SOFTWARE)){ |
|
235 |
result = indexResultHandler.fetchSoftwareById(id,useProductionIndex); |
|
236 |
} |
|
224 | 237 |
if(result == null){ |
225 |
logger.error("Record with id:"+id + " couldn't be fetched from openaire."); |
|
238 |
logger.error("Record with id:"+id + " and type " + type + " couldn't be fetched from openaire.");
|
|
226 | 239 |
} |
227 | 240 |
return result; |
228 | 241 |
} |
... | ... | |
346 | 359 |
public void setClaimValidation(ClaimValidation claimValidation) { |
347 | 360 |
this.claimValidation = claimValidation; |
348 | 361 |
} |
362 |
|
|
363 |
public Boolean getUseProductionIndex() { |
|
364 |
return useProductionIndex; |
|
365 |
} |
|
366 |
|
|
367 |
public void setUseProductionIndex(Boolean useProductionIndex) { |
|
368 |
this.useProductionIndex = useProductionIndex; |
|
369 |
} |
|
349 | 370 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/DMFResultHandler.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.claims.migration.handler; |
2 | 2 |
|
3 |
import eu.dnetlib.data.claims.migration.ClaimValidation; |
|
3 | 4 |
import eu.dnetlib.data.claims.migration.entity.Result; |
4 | 5 |
import eu.dnetlib.data.claims.migration.parser.DMFParser; |
5 | 6 |
import eu.dnetlib.data.claimsDemo.*; |
... | ... | |
157 | 158 |
public void setDmfParser(DMFParser dmfParser) { |
158 | 159 |
this.dmfParser = dmfParser; |
159 | 160 |
} |
161 |
|
|
160 | 162 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/IndexResultHandler.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
SearchUtils searchUtils; |
13 | 13 |
|
14 |
private String fetchPublicationResult(String id) throws Exception { |
|
15 |
return searchUtils.fetchPublicationXmlFromIndex(id); |
|
14 |
private String fetchPublicationResult(String id, boolean production) throws Exception {
|
|
15 |
return searchUtils.fetchPublicationXmlFromIndex(id, production);
|
|
16 | 16 |
} |
17 |
|
|
18 |
private String fetchDatasetResult(String id) throws Exception { |
|
19 |
return searchUtils.fetchDatasetXmlFromIndex(id); |
|
17 |
private String fetchSoftwareResult(String id, boolean production) throws Exception { |
|
18 |
return searchUtils.fetchSoftwareXmlFromIndex(id, production); |
|
20 | 19 |
} |
21 |
private String fetchDedupPublicationResult(String id) throws Exception { |
|
22 |
return searchUtils.fetchDedupPublicationXmlFromIndex(id); |
|
23 |
} |
|
24 | 20 |
|
25 |
private String fetchDedupDatasetResult(String id) throws Exception {
|
|
26 |
return searchUtils.fetchDedupDatasetXmlFromIndex(id);
|
|
21 |
private String fetchDatasetResult(String id, boolean production) throws Exception {
|
|
22 |
return searchUtils.fetchDatasetXmlFromIndex(id, production);
|
|
27 | 23 |
} |
24 |
// private String fetchDedupPublicationResult(String id) throws Exception { |
|
25 |
// return searchUtils.fetchDedupPublicationXmlFromIndex(id); |
|
26 |
// } |
|
27 |
// |
|
28 |
// private String fetchDedupDatasetResult(String id) throws Exception { |
|
29 |
// return searchUtils.fetchDedupDatasetXmlFromIndex(id); |
|
30 |
// } |
|
28 | 31 |
/** |
29 | 32 |
*Searches for both publications and datasets |
30 | 33 |
* @param id |
31 | 34 |
* @return Result or null |
32 | 35 |
* @throws Exception |
33 | 36 |
*/ |
34 |
public Result fetchResultById(String id) throws Exception { |
|
37 |
public Result fetchResultById(String id, boolean production) throws Exception {
|
|
35 | 38 |
|
36 |
String oaf = fetchPublicationResult(id); |
|
39 |
String oaf = fetchPublicationResult(id, production);
|
|
37 | 40 |
|
38 | 41 |
if (oaf == null) { |
39 |
oaf = fetchDatasetResult(id); |
|
42 |
oaf = fetchDatasetResult(id, production);
|
|
40 | 43 |
} |
41 | 44 |
|
42 | 45 |
if (oaf == null) { |
... | ... | |
45 | 48 |
|
46 | 49 |
return OafParser.oaf2Result(oaf); |
47 | 50 |
} |
48 |
public Result fetchDedupResultById(String id) throws Exception { |
|
51 |
public Result fetchDedupById(String id, boolean production) throws Exception { |
|
52 |
String oaf = searchUtils.fetchDedupXmlFromIndex(id, production); |
|
53 |
if (oaf == null) { |
|
54 |
return null; |
|
55 |
} |
|
56 |
return OafParser.oaf2Result(oaf); |
|
57 |
} |
|
58 |
public Result fetchPublicationById(String id, boolean production) throws Exception { |
|
49 | 59 |
|
50 |
String oaf = fetchDedupPublicationResult(id);
|
|
60 |
String oaf = fetchPublicationResult(id, production);
|
|
51 | 61 |
|
52 | 62 |
if (oaf == null) { |
53 |
oaf = fetchDedupDatasetResult(id);
|
|
63 |
return null;
|
|
54 | 64 |
} |
55 | 65 |
|
66 |
return OafParser.oaf2Result(oaf); |
|
67 |
} |
|
68 |
public Result fetchDatasetById(String id, boolean production) throws Exception { |
|
69 |
|
|
70 |
String oaf = fetchDatasetResult(id, production); |
|
56 | 71 |
if (oaf == null) { |
57 | 72 |
return null; |
58 | 73 |
} |
59 | 74 |
|
60 | 75 |
return OafParser.oaf2Result(oaf); |
61 | 76 |
} |
77 |
public Result fetchSoftwareById(String id, boolean production) throws Exception { |
|
78 |
|
|
79 |
String oaf = fetchSoftwareResult(id, production); |
|
80 |
if (oaf == null) { |
|
81 |
return null; |
|
82 |
} |
|
83 |
return OafParser.oaf2Result(oaf); |
|
84 |
} |
|
85 |
// public Result fetchDedupResultById(String id) throws Exception { |
|
86 |
// |
|
87 |
// String oaf = fetchDedupPublicationResult(id); |
|
88 |
// |
|
89 |
// if (oaf == null) { |
|
90 |
// oaf = fetchDedupDatasetResult(id); |
|
91 |
// } |
|
92 |
// |
|
93 |
// if (oaf == null) { |
|
94 |
// return null; |
|
95 |
// } |
|
96 |
// |
|
97 |
// return OafParser.oaf2Result(oaf); |
|
98 |
// } |
|
62 | 99 |
public SearchUtils getSearchUtils() { |
63 | 100 |
return searchUtils; |
64 | 101 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/ProjectHandler.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
private static Logger logger = Logger.getLogger(ProjectHandler.class); |
24 | 24 |
|
25 |
private String fetchProjectById(String id) throws Exception { |
|
26 |
return searchUtils.fetchProjectXmlFromIndex(id); |
|
25 |
private String fetchProjectById(String id, boolean production) throws Exception {
|
|
26 |
return searchUtils.fetchProjectXmlFromIndex(id, production);
|
|
27 | 27 |
} |
28 | 28 |
|
29 |
public Project fetchProjectByID(String id) throws Exception { |
|
30 |
return fetchProjectByOaf(fetchProjectById(id)); |
|
29 |
public Project fetchProjectByID(String id, boolean production) throws Exception {
|
|
30 |
return fetchProjectByOaf(fetchProjectById(id, production));
|
|
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
public Project fetchProjectByOaf(String oaf) throws Exception { |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/RelationHandler.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
return relations; |
48 | 48 |
} |
49 |
public List<Relation> fetchRelationbyID() throws Exception, SQLStoreException { |
|
49 |
public List<Relation> fetchRelationbyID(String id) throws Exception, SQLStoreException {
|
|
50 | 50 |
List<Relation> relations = null; |
51 |
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateSelectRelationClaimByIDEnrichedWithDMFClaimsQuery(-1,"169149"));
|
|
51 |
ResultSet rs = sqlDAO.executePreparedQuery(queryGenerator.generateSelectRelationClaimByIDEnrichedWithDMFClaimsQuery(-1,id));
|
|
52 | 52 |
relations = new ArrayList<Relation>(); |
53 | 53 |
|
54 | 54 |
while(rs.next()) { |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claims/migration/handler/FetchClaimHandler.java | ||
---|---|---|
425 | 425 |
OpenaireEntity openaireEntity = null; |
426 | 426 |
if(type == null){ |
427 | 427 |
openaireEntity = null; |
428 |
}else if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)) { |
|
428 |
}else if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE)) {
|
|
429 | 429 |
openaireEntity= buildResult(rs, index); |
430 | 430 |
}else if(type.equals(ClaimUtils.PROJECT)){ |
431 | 431 |
openaireEntity = buildProject(rs,index); |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/TestClass.java | ||
---|---|---|
150 | 150 |
types.add(ClaimUtils.PUBLICATION); |
151 | 151 |
|
152 | 152 |
|
153 |
// claims = fetchClaimHandler.fetchClaimsByUser("i.fava@cineca.it",30,0,types);
|
|
153 |
claims = fetchClaimHandler.fetchClaimsByUser("argirok_1@hotmail.com",1,0,types, false);
|
|
154 | 154 |
// claims = fetchClaimHandler.fetchClaimsByUser("argirok@di.uoa.gr",3,0,null,"claim.claim_date",false,types,false); |
155 | 155 |
// |
156 | 156 |
// claims = fetchClaimHandler.fetchClaimsByProject("corda_______::ab9c77ce02967b24fc9c1a74276e4677",5,0); |
157 |
claims = fetchClaimHandler.fetchClaimsByProject("corda__h2020::94c962e736df90a5075a7f660ba3d7f6",12,0,null, "claim.claim_date",false,types,true); |
|
157 |
// claims = fetchClaimHandler.fetchClaimsByProject("corda__h2020::94c962e736df90a5075a7f660ba3d7f6",12,0,null, "claim.claim_date",false,types,true);
|
|
158 | 158 |
//claims = fetchClaimHandler.fetchClaimsByToken("corda__h2020::94c962e736df90a5075a7f660ba3d7f6","argiro@gmail.com",12,0,null, "claim.claim_date",false,types,false); |
159 | 159 |
|
160 | 160 |
// claims = fetchClaimHandler.fetchClaimsByDate("2016-01-14 14:53:50","2016-04-21",10,0); |
... | ... | |
192 | 192 |
public void testInsert() throws Exception, SQLStoreException { |
193 | 193 |
//acm_________::31e0e5e7cbd6e2556336d7e795f55c49 |
194 | 194 |
//dedup_wf_001::64ca1e3a4d1590456ad3dd7df8a18cd7 |
195 |
|
|
196 |
// String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "project", "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "openaire", "OPEN", null,"dataset", "10.5281/ZENODO.154647", "datacite", "EMBARGO","2017-05-01"); |
|
195 |
/* |
|
196 |
claimedBy argirok_1@hotmail.com |
|
197 |
sourceId corda_______::2c37878a0cede85dbbd1081bb9b4a2f8 |
|
198 |
sourceType project |
|
199 |
sourceCollectedFrom openaire |
|
200 |
sourceAccessRights OPEN |
|
201 |
sourceEmbargoEndDate |
|
202 |
targetId 10.1007/978-3-540-76323-9_4 |
|
203 |
targetType software |
|
204 |
targetCollectedFrom crossref |
|
205 |
targetAccessRights EMBARGO |
|
206 |
targetEmbargoEndDate 2028-11-10T13:55:47.935Z |
|
207 |
*/ |
|
208 |
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 | 209 |
|
198 | 210 |
|
199 | 211 |
// String id=claimHandler.buildAndInsertClaim("argirok@di.uoa.gr", "context", "egi::country::gr", |
... | ... | |
238 | 250 |
@Test |
239 | 251 |
public void testHttpRequest() throws Exception { |
240 | 252 |
SearchUtils searchUtils= new SearchUtils(); |
241 |
log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b")); |
|
242 |
log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b")); |
|
253 |
log.info(searchUtils.fetchPublicationXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
|
|
254 |
log.info(searchUtils.fetchDatasetXmlFromIndex("doajarticles::eb8a123eb82b25013b0001d0e2d1842b", false));
|
|
243 | 255 |
} |
244 | 256 |
|
245 | 257 |
@Test |
246 | 258 |
public void testXpath() throws Exception { |
247 |
Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85"); |
|
259 |
Result r=indexResultHandler.fetchResultById("dedup_wf_001::88a1eedd1ffce63dccf51d8ce2053c85", false);
|
|
248 | 260 |
} |
249 | 261 |
|
250 | 262 |
@Test |
263 |
public void testSoftwareXpath() throws Exception { |
|
264 |
// http://scoobydoo.di.uoa.gr:5000/search/software?softwareId=datacite____%3A%3Aabe9e916b29d028789d7ae3c6f79f254 |
|
265 |
Result r=indexResultHandler.fetchSoftwareById("datacite____::abe9e916b29d028789d7ae3c6f79f254", false); |
|
266 |
if(r!=null){ |
|
267 |
System.out.println(r.toString()); |
|
268 |
} |
|
269 |
|
|
270 |
} |
|
271 |
@Test |
|
272 |
public void testPublicationXpath() throws Exception { |
|
273 |
Result r=indexResultHandler.fetchPublicationById("od________18::5acd89ab4df2b877a7a208ea2a123a87", false); |
|
274 |
if(r!=null){ |
|
275 |
System.out.println(r.toString()); |
|
276 |
} |
|
277 |
|
|
278 |
} |
|
279 |
|
|
280 |
@Test |
|
251 | 281 |
public void testParsingDMF() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException, TransformerException { |
252 | 282 |
Result r=DMFParser.dmf2Result("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
253 | 283 |
"<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" + |
... | ... | |
307 | 337 |
@Test |
308 | 338 |
public void buildProject() throws Exception { |
309 | 339 |
String id = "arc_________::089188bbc5db213fb2b00a0d93043fc4"; |
310 |
Project pr = projectHandler.fetchProjectByID(id); |
|
340 |
Project pr = projectHandler.fetchProjectByID(id,false);
|
|
311 | 341 |
log.info(pr.toString()); |
312 | 342 |
id="corda_______::404d91e07cd4d32fddd8fc636ad4daf7"; |
313 |
pr = projectHandler.fetchProjectByID(id); |
|
343 |
pr = projectHandler.fetchProjectByID(id, false);
|
|
314 | 344 |
log.info(pr.toString()); |
315 | 345 |
|
316 | 346 |
} |
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/ClaimUtils.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
public static final String PUBLICATION = "publication"; |
12 | 12 |
public static final String DATASET = "dataset"; |
13 |
public static final String SOFTWARE = "software"; |
|
13 | 14 |
public static final String PROJECT = "project"; |
14 | 15 |
public static final String CONTEXT = "context"; |
15 | 16 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/SearchUtils.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.claimsDemo; |
2 | 2 |
|
3 |
import eu.dnetlib.data.claims.migration.ClaimValidation; |
|
3 | 4 |
import org.apache.log4j.Logger; |
4 | 5 |
import org.w3c.dom.Document; |
5 | 6 |
import org.w3c.dom.NodeList; |
... | ... | |
14 | 15 |
import java.net.HttpURLConnection; |
15 | 16 |
import java.net.URL; |
16 | 17 |
import java.net.URLEncoder; |
18 |
import java.sql.Timestamp; |
|
19 |
import java.util.Date; |
|
17 | 20 |
|
18 | 21 |
/** |
19 | 22 |
* Created by argirok on 20/11/2015. |
... | ... | |
27 | 30 |
private static final Logger logger = Logger.getLogger(SearchUtils.class); |
28 | 31 |
|
29 | 32 |
private static String searchUrl="http://beta.services.openaire.eu:8480/search/search?action=search"; |
30 |
// private static String searchUrl="http://services.openaire.eu:8480/search/search?action=search"; |
|
31 |
private static String apiUrlForResults=" http://beta.services.openaire.eu:8480/search/api/";//"http://api.openaire.eu/search/"; |
|
32 |
private static String apiUrlForDedupResults="http://rudie.di.uoa.gr:8080/dnet-functionality-services-1.2.0-SNAPSHOT/api/"; |
|
33 |
private static String apiUrlForProjects="http://beta.services.openaire.eu:8480/search/api/";//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-1.2.0-SNAPSHOT/api/"; |
|
33 |
private static String apiUrlForResults="http://beta.services.openaire.eu:8480/search/api";//"http://api.openaire.eu/search"; |
|
34 |
// private static String apiUrlForDedupResults="http://rudie.di.uoa.gr:8080/dnet-functionality-services-1.2.0-SNAPSHOT/api/"; |
|
35 |
private static String apiUrlForProjects="http://beta.services.openaire.eu:8480/search/api";//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-1.2.0-SNAPSHOT/api/"; |
|
36 |
|
|
37 |
private static String searchUrlProduction="http://services.openaire.eu:8480/search/search?action=search"; |
|
38 |
private static String apiUrlForResultsProduction="http://services.openaire.eu:8480/search/api";//"http://api.openaire.eu/search"; |
|
39 |
private static String apiUrlForProjectsProduction="http://services.openaire.eu:8480/search/api";//"http://rudie.di.uoa.gr:8080/dnet-functionality-services-1.2.0-SNAPSHOT/api/"; |
|
40 |
|
|
41 |
|
|
34 | 42 |
private static String crossrefUrl="https://api.crossref.org/works?filter=doi:"; |
35 | 43 |
private static String dataciteUrl="https://data.datacite.org/application/rdf+xml/"; |
36 | 44 |
private static String dataciteNewAPIUrl="https://api.datacite.org/works/"; |
37 | 45 |
private static String orcidUrlPrefix="https://pub.orcid.org/"; |
38 | 46 |
private static String orcidUrlSuffix="/orcid-works"; |
39 | 47 |
private boolean useApi=true; |
48 |
private ClaimValidation claimValidation = null; |
|
40 | 49 |
|
41 | 50 |
public SearchUtils(){ |
42 | 51 |
|
43 | 52 |
} |
44 | 53 |
|
45 |
public static String fetchProjectXmlFromIndex(String id) throws Exception{ |
|
46 |
return getRequest(getProjectApiUrl(id)); |
|
54 |
public static String fetchProjectXmlFromIndex(String id, boolean production) throws Exception{
|
|
55 |
return getRequest(getProjectApiUrl(id, production));
|
|
47 | 56 |
} |
48 | 57 |
|
49 | 58 |
/** |
... | ... | |
54 | 63 |
* @return xml or null |
55 | 64 |
* @throws Exception |
56 | 65 |
*/ |
57 |
public static String fetchPublicationXmlFromIndex(String id) throws Exception{ |
|
66 |
public static String fetchPublicationXmlFromIndex(String id, boolean production) throws Exception{
|
|
58 | 67 |
|
59 |
String xml=getRequest(getPublicationApiUrl(id)); |
|
68 |
String xml=getRequest(getPublicationApiUrl(id, production));
|
|
60 | 69 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
61 |
String objId=getResultObjIdentifierFromSearch(id); |
|
62 |
if(objId!=null){ |
|
63 |
xml=getRequest(getPublicationApiUrl(objId)); |
|
64 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
65 |
xml=null; |
|
66 |
} |
|
67 |
}else{ |
|
68 |
xml=null; |
|
69 |
} |
|
70 |
xml=null; |
|
70 | 71 |
} |
71 | 72 |
return xml; |
72 | 73 |
} |
73 |
public static String fetchDedupPublicationXmlFromIndex(String id) throws Exception{
|
|
74 |
public static String fetchDedupXmlFromIndex(String id, boolean production) throws Exception{
|
|
74 | 75 |
|
75 |
String xml=getRequest(getDedupPublicationApiUrl(id)); |
|
76 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
77 |
String objId=getResultObjIdentifierFromSearch(id); |
|
76 |
String xml= null; |
|
77 |
String objId=getResultObjIdentifierFromSearch(id,production); |
|
78 | 78 |
if(objId!=null){ |
79 |
xml=getRequest(getDedupPublicationApiUrl(objId)); |
|
80 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
81 |
xml=null; |
|
82 |
} |
|
83 |
}else{ |
|
84 |
xml = null; |
|
79 |
xml=getRequest(getPublicationApiUrl(objId, production)); |
|
85 | 80 |
} |
86 |
} |
|
87 | 81 |
return xml; |
88 | 82 |
} |
89 | 83 |
|
84 |
public static String fetchSoftwareXmlFromIndex(String id, boolean production) throws Exception{ |
|
85 |
String xml=getRequest(getSoftwareApiUrl(id,production)); |
|
86 |
return xml; |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 | 90 |
/** |
91 | 91 |
*Look up in API, if there is no result, |
92 | 92 |
* consider that id is a dedup id and search for the objIdentifier id. |
... | ... | |
96 | 96 |
* @return xml |
97 | 97 |
* @throws Exception |
98 | 98 |
*/ |
99 |
public static String fetchDatasetXmlFromIndex(String id) throws Exception{ |
|
99 |
public static String fetchDatasetXmlFromIndex(String id, boolean production) throws Exception{
|
|
100 | 100 |
|
101 |
String xml=getRequest(getDatasetApiUrl(id)); |
|
101 |
String xml=getRequest(getDatasetApiUrl(id, production));
|
|
102 | 102 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
103 |
String objId=getResultObjIdentifierFromSearch(id); |
|
104 |
if(objId!=null){ |
|
105 |
xml=getRequest(getDatasetApiUrl(objId)); |
|
106 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
107 |
xml=null; |
|
108 |
} |
|
109 |
}else{ |
|
110 |
xml=null; |
|
111 |
} |
|
103 |
xml=null; |
|
112 | 104 |
} |
113 | 105 |
return xml; |
114 | 106 |
|
115 | 107 |
} |
116 |
public static String fetchDedupDatasetXmlFromIndex(String id) throws Exception{ |
|
117 | 108 |
|
118 |
String xml=getRequest(getDedupDatasetApiUrl(id)); |
|
119 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
120 |
String objId=getResultObjIdentifierFromSearch(id); |
|
121 |
if(objId!=null){ |
|
122 |
xml=getRequest(getDedupDatasetApiUrl(objId)); |
|
123 |
if(getNumberOfResultsInAPIXML(xml)==0){ |
|
124 |
xml=null; |
|
125 |
} |
|
126 |
}else{ |
|
127 |
xml = null; |
|
128 |
} |
|
129 |
} |
|
130 |
return xml; |
|
131 |
|
|
132 |
} |
|
133 |
|
|
134 | 109 |
public static String fetchResultXMLFromDatacite(String id) throws Exception{ |
135 | 110 |
return getRequest(getDataciteUrl(id)); |
136 | 111 |
} |
... | ... | |
139 | 114 |
return getRequest(getOrcidUrl(id)); |
140 | 115 |
} |
141 | 116 |
|
142 |
public static String getProjectApiUrl(String id) { |
|
117 |
public static String getProjectApiUrl(String id, boolean production) {
|
|
143 | 118 |
|
144 |
return apiUrlForProjects+"/projects?openaireProjectID="+id;
|
|
119 |
return ((production)?apiUrlForProjectsProduction:apiUrlForProjects)+"/projects?openaireProjectID="+id;
|
|
145 | 120 |
} |
146 | 121 |
|
147 |
public static String getDatasetApiUrl(String id) { |
|
122 |
public static String getDatasetApiUrl(String id, boolean production) {
|
|
148 | 123 |
|
149 |
return apiUrlForResults+"/datasets?openaireDatasetID="+id;
|
|
124 |
return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/datasets?openaireDatasetID="+id;
|
|
150 | 125 |
} |
151 |
public static String getDedupDatasetApiUrl(String id) { |
|
152 | 126 |
|
153 |
return apiUrlForDedupResults+"/datasets?openaireDatasetID="+id; |
|
154 |
} |
|
155 |
public static String getPublicationApiUrl(String id) { |
|
127 |
public static String getPublicationApiUrl(String id, boolean production) { |
|
156 | 128 |
|
157 |
return apiUrlForResults+"/publications?openairePublicationID="+id;
|
|
129 |
return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/publications?openairePublicationID="+id;
|
|
158 | 130 |
} |
159 |
public static String getDedupPublicationApiUrl(String id) { |
|
160 |
|
|
161 |
return apiUrlForDedupResults+"/publications?openairePublicationID="+id; |
|
131 |
public static String getSoftwareApiUrl(String id, boolean production) { |
|
132 |
//TODO change to beta when it's ready |
|
133 |
// return ((production)?apiUrlForResultsProduction:apiUrlForResults)+"/software/"+id; |
|
134 |
return "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/api"+"/software?openaireSoftwareID="+id; |
|
162 | 135 |
} |
136 |
// public static String getDedupPublicationApiUrl(String id) { |
|
137 |
// |
|
138 |
// return apiUrlForDedupResults+"/publications?openairePublicationID="+id; |
|
139 |
// } |
|
163 | 140 |
private static String getDataciteUrl(String id) { |
164 | 141 |
|
165 | 142 |
return dataciteNewAPIUrl+id; |
... | ... | |
176 | 153 |
* @param resultdupid |
177 | 154 |
* @return |
178 | 155 |
*/ |
179 |
private static String getResultXMLByResultdupidSearchByUrl(String resultdupid) { |
|
156 |
private static String getResultXMLByResultdupidSearchByUrl(String resultdupid, boolean production) {
|
|
180 | 157 |
String url= null; |
181 | 158 |
try { |
182 |
url = searchUrl+"&sTransformer=results_openaire&query="+
|
|
159 |
url = ((production)?searchUrlProduction:searchUrl)+"&sTransformer=results_openaire&query="+
|
|
183 | 160 |
URLEncoder.encode("(((deletedbyinference = false) AND (oaftype exact result)) )" + |
184 | 161 |
" and (resultdupid exact " + resultdupid + ")", "UTF-8") |
185 | 162 |
+"&size=10&locale=en_GB"; |
... | ... | |
188 | 165 |
} |
189 | 166 |
return url; |
190 | 167 |
} |
168 |
// private static String getSoftwareXMLByIdSearchByUrl(String id, boolean production) { |
|
169 |
// String url= null; |
|
170 |
// try { |
|
171 |
// url = ((production)?searchUrlProduction:searchUrl)+"&sTransformer=results_openaire&query="+ |
|
172 |
// URLEncoder.encode("(((deletedbyinference = false) AND (resulttypeid exact software) AND (oaftype exact result)) )" + |
|
173 |
// " and (objIdentifier exact " + id + ")", "UTF-8") |
|
174 |
// +"&size=1&locale=en_GB"; |
|
175 |
// } catch (UnsupportedEncodingException e) { |
|
176 |
// logger.error("UnsupportedEncodingException",e); |
|
177 |
// } |
|
178 |
// return url; |
|
179 |
// } |
|
191 | 180 |
|
192 |
|
|
193 | 181 |
// HTTP GET request |
194 | 182 |
private static String getRequest(String url) throws Exception { |
195 | 183 |
URL obj = new URL(url); |
184 |
// logger.debug(url); |
|
196 | 185 |
HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
197 | 186 |
int responseCode = con.getResponseCode(); |
198 | 187 |
if(responseCode != 200){ |
... | ... | |
229 | 218 |
} catch (Exception e) { |
230 | 219 |
try{ |
231 | 220 |
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("dois_malformed_urls.txt", true))); |
232 |
out.println("Doi:"+doi+" Url:"+url); |
|
221 |
Date date= new java.util.Date(); |
|
222 |
out.println(new Timestamp(date.getTime())+"Doi:"+doi+" Url:"+url); |
|
233 | 223 |
out.close(); |
234 | 224 |
|
235 | 225 |
}catch (IOException e1) { |
... | ... | |
260 | 250 |
* @param resultdupid Openaire Id |
261 | 251 |
* @return objIdentifier |
262 | 252 |
*/ |
263 |
private static String getResultObjIdentifierFromSearch(String resultdupid) throws Exception { |
|
264 |
String xml=getRequest(getResultXMLByResultdupidSearchByUrl(resultdupid)); |
|
253 |
private static String getResultObjIdentifierFromSearch(String resultdupid, boolean production) throws Exception {
|
|
254 |
String xml=getRequest(getResultXMLByResultdupidSearchByUrl(resultdupid,production));
|
|
265 | 255 |
String objIdentifier=null; |
266 | 256 |
String size=null; |
267 | 257 |
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
... | ... | |
311 | 301 |
return total; |
312 | 302 |
} |
313 | 303 |
|
304 |
public ClaimValidation getClaimValidation() { |
|
305 |
return claimValidation; |
|
306 |
} |
|
314 | 307 |
|
308 |
public void setClaimValidation(ClaimValidation claimValidation) { |
|
309 |
this.claimValidation = claimValidation; |
|
310 |
} |
|
315 | 311 |
} |
316 | 312 |
|
317 | 313 |
|
modules/uoa-claims/trunk/src/main/java/eu/dnetlib/data/claimsDemo/QueryGenerator.java | ||
---|---|---|
261 | 261 |
if(type==null){ |
262 | 262 |
return null; |
263 | 263 |
} |
264 |
if(type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.PUBLICATION)){ |
|
264 |
if(type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.SOFTWARE)){
|
|
265 | 265 |
Result result=(Result)openaireEntity; |
266 | 266 |
query=generateInsertResultQuery(result.getOpenaireId(),result.getResultType(),result.getTitle(),result.getCollectedFrom(),result.getExternalUrl(),result.getDoi(), result.getOrcidworkid(), result.getAccessRights(),result.getEmbargoEndDate(),result.getBestLicense(),result.getRecordPath(), result.getRecordFormat(), params); |
267 | 267 |
}else if(type.equals(ClaimUtils.PROJECT)){ |
... | ... | |
318 | 318 |
*/ |
319 | 319 |
private String createSemanticsType(String sourceType,String targetType){ |
320 | 320 |
String semantics=null; |
321 |
if((targetType.equals(ClaimUtils.PUBLICATION))&&(sourceType.equals(ClaimUtils.DATASET))){ |
|
322 |
semantics="resultResult_publicationDataset_isRelatedTo"; |
|
321 |
// if((targetType.equals(ClaimUtils.PUBLICATION))&&(sourceType.equals(ClaimUtils.DATASET))){ |
|
322 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
323 |
// } |
|
324 |
// else if(targetType.equals(ClaimUtils.DATASET)&&sourceType.equals(ClaimUtils.PUBLICATION)){ |
|
325 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
326 |
// } |
|
327 |
// if((targetType.equals(ClaimUtils.PUBLICATION))&&(sourceType.equals(ClaimUtils.SOFTWARE))){ |
|
328 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
329 |
// } |
|
330 |
// else if(targetType.equals(ClaimUtils.SOFTWARE)&&sourceType.equals(ClaimUtils.PUBLICATION)){ |
|
331 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
332 |
// } |
|
333 |
// if((targetType.equals(ClaimUtils.DATASET))&&(sourceType.equals(ClaimUtils.SOFTWARE))){ |
|
334 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
335 |
// } |
|
336 |
// else if(targetType.equals(ClaimUtils.SOFTWARE)&&sourceType.equals(ClaimUtils.DATASET)){ |
|
337 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
338 |
// } |
|
339 |
// else if((targetType.equals(ClaimUtils.PUBLICATION))&&(sourceType.equals(ClaimUtils.PUBLICATION))){ |
|
340 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
341 |
// } |
|
342 |
// else if(targetType.equals(ClaimUtils.DATASET)&&sourceType.equals(ClaimUtils.DATASET)){ |
|
343 |
// semantics="resultResult_relationship_isRelatedTo"; |
|
344 |
// } |
|
345 |
// else if(targetType.equals(ClaimUtils.SOFTWARE)&&sourceType.equals(ClaimUtils.SOFTWARE)){ |
|
346 |
// semantics="resultResult_supplement_isSupplementTo"; |
|
347 |
// } |
|
348 |
//add above more specific semantics for pub,data and software |
|
349 |
if((targetType.equals(ClaimUtils.PUBLICATION)||targetType.equals(ClaimUtils.DATASET)||targetType.equals(ClaimUtils.SOFTWARE))&&(sourceType.equals(ClaimUtils.PUBLICATION)||sourceType.equals(ClaimUtils.DATASET)||sourceType.equals(ClaimUtils.SOFTWARE))){ |
|
350 |
semantics="resultResult_relationship_isRelatedTo"; |
|
323 | 351 |
} |
324 |
else if(targetType.equals(ClaimUtils.DATASET)&&sourceType.equals(ClaimUtils.PUBLICATION)){ |
|
325 |
semantics="resultResult_publicationDataset_isRelatedTo"; |
|
326 |
} |
|
327 |
else if((targetType.equals(ClaimUtils.PUBLICATION))&&(sourceType.equals(ClaimUtils.PUBLICATION))){ |
|
328 |
semantics="resultResult_supplement_isSupplementedBy"; |
|
329 |
} |
|
330 |
else if(targetType.equals(ClaimUtils.DATASET)&&sourceType.equals(ClaimUtils.DATASET)){ |
|
331 |
semantics="resultResult_supplement_isSupplementTo"; |
|
332 |
} |
|
333 |
else if((targetType.equals(ClaimUtils.PUBLICATION)||targetType.equals(ClaimUtils.DATASET))&&(sourceType.equals(ClaimUtils.PROJECT))){ |
|
352 |
else if((targetType.equals(ClaimUtils.PUBLICATION)||targetType.equals(ClaimUtils.DATASET)||targetType.equals(ClaimUtils.SOFTWARE))&&(sourceType.equals(ClaimUtils.PROJECT))){ |
|
334 | 353 |
semantics= "resultProject_outcome_produces"; //"resultProject_outcome_isProducedBy"; |
335 | 354 |
} |
336 |
else if((targetType.equals(ClaimUtils.PUBLICATION)||targetType.equals(ClaimUtils.DATASET))&&(sourceType.equals(ClaimUtils.CONTEXT))){ |
|
355 |
else if((targetType.equals(ClaimUtils.PUBLICATION)||targetType.equals(ClaimUtils.DATASET)||targetType.equals(ClaimUtils.SOFTWARE))&&(sourceType.equals(ClaimUtils.CONTEXT))){
|
|
337 | 356 |
semantics= "isRelevantTo"; |
338 | 357 |
} |
339 | 358 |
|
... | ... | |
582 | 601 |
private String addFilterByType( List<String> types, ArrayList<Object> params) { |
583 | 602 |
if(types == null || types.isEmpty()){ |
584 | 603 |
return null; |
585 |
}else if (types.contains(ClaimUtils.PUBLICATION) && types.contains(ClaimUtils.DATASET) && types.contains(ClaimUtils.PROJECT) && types.contains(ClaimUtils.CONTEXT) ){ |
|
604 |
}else if (types.contains(ClaimUtils.PUBLICATION) && types.contains(ClaimUtils.DATASET) && types.contains(ClaimUtils.SOFTWARE) && types.contains(ClaimUtils.PROJECT) && types.contains(ClaimUtils.CONTEXT) ){
|
|
586 | 605 |
//it's all types - no need to filter |
587 | 606 |
return null; |
588 | 607 |
} |
... | ... | |
770 | 789 |
ArrayList<Object> clauseParams = new ArrayList<>(); |
771 | 790 |
clauseParams.add(claimId); |
772 | 791 |
String orderbyLimitClause= null; |
773 |
if(sourceType.equals(ClaimUtils.PUBLICATION)||sourceType.equals(ClaimUtils.DATASET)){ |
|
792 |
if(sourceType.equals(ClaimUtils.PUBLICATION)||sourceType.equals(ClaimUtils.DATASET)||sourceType.equals(ClaimUtils.SOFTWARE)){
|
|
774 | 793 |
return generateSelectclaimQuery(sourceType,targetType,null,null,null,false, clause,clauseParams,keyword, params); |
775 | 794 |
}else if(sourceType.equals(ClaimUtils.PROJECT)){ |
776 | 795 |
return generateSelectclaimQuery(sourceType,targetType,null,null,null,false, clause,clauseParams,keyword, params); |
... | ... | |
797 | 816 |
String fields= null; |
798 | 817 |
|
799 | 818 |
if (type != null) { |
800 |
if (type.equals(ClaimUtils.PUBLICATION) || type.equals(ClaimUtils.DATASET)) { |
|
819 |
if (type.equals(ClaimUtils.PUBLICATION) || type.equals(ClaimUtils.DATASET) || type.equals(ClaimUtils.SOFTWARE)) {
|
|
801 | 820 |
fields = getResultFields(tableAlias); |
802 | 821 |
|
803 | 822 |
} else if (type.equals(ClaimUtils.PROJECT)) { |
... | ... | |
840 | 859 |
return ""; |
841 | 860 |
} |
842 | 861 |
keyword=keyword.toLowerCase(); |
843 |
if (type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)){ |
|
862 |
if (type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)||type.equals(ClaimUtils.SOFTWARE)){
|
|
844 | 863 |
params.add("%" + keyword + "%"); |
845 | 864 |
params.add("%" + keyword + "%"); |
846 | 865 |
return " (lower("+tableAlias+".title) like ? or lower("+tableAlias+".doi) like ?"+")"; |
... | ... | |
873 | 892 |
|
874 | 893 |
" ( " +generateSelectclaimQuery(ClaimUtils.PUBLICATION,ClaimUtils.PUBLICATION,null,null,null,false, specificWhereClause,whereParams,keyword, params)+" ) \nunion "+ |
875 | 894 |
" ( " +generateSelectclaimQuery(ClaimUtils.DATASET,ClaimUtils.DATASET,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
895 |
" ( " +generateSelectclaimQuery(ClaimUtils.SOFTWARE,ClaimUtils.SOFTWARE,null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
|
876 | 896 |
" ( " +generateSelectclaimQuery(ClaimUtils.PROJECT,ClaimUtils.PUBLICATION, null,null,null,false, specificWhereClause, whereParams,keyword, params)+" ) \nunion "+ |
877 | 897 |
" ( " +generateSelectclaimQuery(ClaimUtils.CONTEXT,ClaimUtils.PUBLICATION,null,null,null,false, specificWhereClause, whereParams, keyword, params)+" )" + |
878 | 898 |
|
... | ... | |
888 | 908 |
if(type == null){ |
889 | 909 |
return null; |
890 | 910 |
} |
891 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)){ |
|
911 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET) ||type.equals(ClaimUtils.SOFTWARE)){
|
|
892 | 912 |
return "result"; |
893 | 913 |
}else{ |
894 | 914 |
return type; |
... | ... | |
913 | 933 |
return null; |
914 | 934 |
} |
915 | 935 |
String query = null; |
916 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET)){ |
|
936 |
if(type.equals(ClaimUtils.PUBLICATION)||type.equals(ClaimUtils.DATASET) ||type.equals(ClaimUtils.SOFTWARE)){
|
|
917 | 937 |
query = generateDeleteResultQuery(resultid,claimId, params); |
918 | 938 |
}else if(type.equals(ClaimUtils.PROJECT)){ |
919 | 939 |
query = generateDeleteProjectQuery(resultid,claimId, params); |
modules/uoa-claims/trunk/src/main/resources/eu/dnetlib/data/claims/migration/springContext-claimsDemo.xml | ||
---|---|---|
34 | 34 |
<property name="projectHandler" ref="projectHandler"/> |
35 | 35 |
<property name="resultHandler" ref="resultHandler"/> |
36 | 36 |
<property name="claimValidation" ref="claimValidation"/> |
37 |
<property name="useProductionIndex" value="${services.claimsDemo.useProductionIndex}"/> |
|
37 | 38 |
</bean> |
38 | 39 |
<bean id="externalRecordHandler" class="eu.dnetlib.data.claims.migration.handler.ExternalRecordHandler"> |
39 | 40 |
<property name="searchUtils" ref="searchUtils"/> |
modules/uoa-claims/trunk/src/main/resources/eu/dnetlib/data/claims/migration/springContext-claimsDemo.properties | ||
---|---|---|
1 | 1 |
|
2 | 2 |
services.claimsDemo.db.driverClassName = org.postgresql.Driver |
3 |
services.claimsDemo.db.url = jdbc:postgresql://scoobydoo.di.uoa.gr:5432/claims_beta_last
|
|
3 |
services.claimsDemo.db.url = jdbc:postgresql://scoobydoo.di.uoa.gr:5432/claimsnewschema
|
|
4 | 4 |
services.claimsDemo.db.username = postgres |
5 | 5 |
services.claimsDemo.db.password = snowflakes |
6 | 6 |
services.claimsDemo.directClaim.APIURL = http://beta.services.openaire.eu:8280/is/mvc/api/publications |
7 |
services.claimsDemo.useProductionIndex = false |
|
7 | 8 |
|
8 | 9 |
#email properties |
9 | 10 |
## EMAIL SETTINGS |
... | ... | |
14 | 15 |
services.claims.mail.angularUrl = http://duffy.di.uoa.gr:3000/claims-project-manager?token= |
15 | 16 |
services.claims.mail.specialRecipients = invalid_recipient@email.com |
16 | 17 |
|
17 |
services.claimsDemo.results.pathToSaveRecord = /home/argirok/claims_beta/records/ |
|
18 |
services.claimsDemo.reports.pathToSaveReport = /home/argirok/claims_beta/reports/ |
|
18 |
services.claimsDemo.results.pathToSaveRecord = /home/argirok/claims_www/records/ |
|
19 |
services.claimsDemo.reports.pathToSaveReport = /home/argirok/claims_www/reports/ |
Also available in: Unified diff
change migration procedure: search first in beta then in production| add software | change directIndexHandler check for response