Revision 41197
Added by Argiro Kokogiannaki over 8 years ago
ParsingClaimUtils.java | ||
---|---|---|
226 | 226 |
buildContext(context); |
227 | 227 |
claim.setSource(context); |
228 | 228 |
} |
229 |
static public Context getConceptFromDMF( String xml) { |
|
230 |
Context context =new Context(); |
|
231 |
try { |
|
232 |
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); |
|
233 |
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); |
|
234 |
InputSource inputSource= new InputSource(new StringReader(xml)); |
|
235 |
Document document=dBuilder.parse(inputSource); |
|
236 |
XPathFactory xPathfactory= XPathFactory.newInstance(); |
|
237 |
XPath xpath = xPathfactory.newXPath(); |
|
238 |
NodeList nl = (NodeList) xpath.compile("//*[local-name()='concept']/@id").evaluate(document, XPathConstants.NODESET); |
|
239 |
if (nl.getLength() > 0) { |
|
240 |
context.setOpenaireId(nl.item(0).getNodeValue()); |
|
241 |
} |
|
242 |
} catch (Exception e) { |
|
243 |
e.printStackTrace(); |
|
244 |
} |
|
245 |
buildContext(context); |
|
246 |
return context; |
|
247 |
|
|
248 |
} |
|
229 | 249 |
static public void getRelationClaim(Claim claim, String xml) throws IOException, SAXException, ParserConfigurationException { |
230 | 250 |
String relationType=""; |
231 | 251 |
String sourceId=""; //Annotation source |
... | ... | |
598 | 618 |
r.setCollectedFrom(ClaimUtils.COLLECTED_FROM_CROSSREF); |
599 | 619 |
} |
600 | 620 |
} |
601 |
public static void getXmlfromOrcid(Result r){ |
|
602 |
r.setResultType(ClaimUtils.PUBLICATION); |
|
621 |
public static void getXmlfromOrcid(Result result){
|
|
622 |
result.setResultType(ClaimUtils.PUBLICATION);
|
|
603 | 623 |
SearchUtils searchUtils= new SearchUtils(); |
604 |
if(r!=null&&r.getOrcidworkid()==null){
|
|
624 |
if(result!=null&&result.getOrcidworkid()==null){
|
|
605 | 625 |
return ; |
606 | 626 |
} |
607 |
System.out.println("OWI: " + r.getOrcidworkid()); |
|
608 |
String orcid=r.getOrcidworkid().substring(0,19); |
|
609 |
String orcidworkid=r.getOrcidworkid().substring(20,r.getOrcidworkid().length());
|
|
627 |
System.out.println("OWI: " + result.getOrcidworkid());
|
|
628 |
String orcid=result.getOrcidworkid().substring(0,19);
|
|
629 |
String orcidworkid=result.getOrcidworkid().substring(20,result.getOrcidworkid().length());
|
|
610 | 630 |
//0000-0003-5000-0001 |
611 | 631 |
System.out.println("orcid: "+orcid); |
612 | 632 |
System.out.println("OWI: "+orcidworkid); |
... | ... | |
622 | 642 |
Document document= document=dBuilder.parse(is); |
623 | 643 |
XPathFactory xPathfactory= XPathFactory.newInstance(); |
624 | 644 |
XPath xpath = xPathfactory.newXPath(); |
625 |
NodeList nl ; |
|
626 |
// getParent().toXML() |
|
627 |
// <orcid-work put-code="19500531" visibility="public"> |
|
628 |
String s = (String) xpath.compile("//orcid-work[@put-code="+orcidworkid+"]").evaluate(document, XPathConstants.STRING); |
|
629 |
System.out.println("Here: "+s); |
|
630 |
|
|
631 |
|
|
645 |
NodeList nl; |
|
632 | 646 |
NodeList worknl = (NodeList) xpath.compile("//orcid-work[@put-code="+orcidworkid+"]").evaluate(document,XPathConstants.NODESET); |
633 | 647 |
if (worknl.getLength() > 0) { |
648 |
/* |
|
649 |
<work-title><title>TagTick: A tool for annotation tagging over solr indexes</title></work-title> |
|
650 |
<journal-title>Digital Libraries (JCDL), 2014 IEEE/ACM Joint Conference on</journal-title> |
|
651 |
<work-citation><work-citation-type>bibtex</work-citation-type><citation>@inproceedings{demoTPDL2014, Author= {Artini, M. and Atzori, C. and Bardi, A. and La Bruzzo, S. and Manghi, P.}, Booktitle= {Digital Libraries (JCDL), 2014 IEEE/ACM Joint Conference on}, Date-Added= {2015-05-12 13:56:09 +0000}, Date-Modified= {2015-05-12 13:56:25 +0000}, Doi= {10.1109/JCDL.2014.6970198}, Keywords= {indexing;information filtering;query formulation;Solr indexes;TagTick;annotation tagging tools;authorized data curators;full-text index Apache Solr;functional annotation tagging environment;information space;real-time temporary bulk tagging;History;Indexes;Real-time systems;Search problems;Standards;Tagging;Vocabulary;Apache Solr;annotation tagging;full-text index;real-time update}, Month= {Sept}, Pages= {407-408}, Title= {TagTick: A tool for annotation tagging over solr indexes}, Year= {2014}, Bdsk-Url-1= {http://dx.doi.org/10.1109/JCDL.2014.6970198}} |
|
634 | 652 |
|
653 |
</citation></work-citation> |
|
654 |
<work-type>conference-paper</work-type><publication-date><year>2014</year></publication-date> |
|
655 |
<work-external-identifiers><work-external-identifier><work-external-identifier-type>doi</work-external-identifier-type><work-external-identifier-id>10.1109/JCDL.2014.6970198</work-external-identifier-id></work-external-identifier></work-external-identifiers><work-source><uri>http://orcid.org/0000-0001-7291-3210</uri><path>0000-0001-7291-3210</path><host>orcid.org</host></work-source>*/ |
|
656 |
|
|
657 |
|
|
658 |
// nl = (NodeList) xpath.compile("//title").evaluate(document, XPathConstants.NODESET); |
|
659 |
// if (nl.getLength() > 0) { |
|
660 |
// result.setTitle(nl.item(0).getNodeValue()); |
|
661 |
// } |
|
662 |
// nl = (NodeList) xpath.compile("//work-external-identifier").evaluate(document, XPathConstants.NODESET); |
|
663 |
// for (int i = 0; i < nl.getLength(); i++) { |
|
664 |
// nl = (NodeList) xpath.compile("//work-external-identifier").evaluate(nl.item(i), XPathConstants.NODESET); |
|
665 |
// result.setTitle(nl.item(0).getNodeValue()); |
|
666 |
// } |
|
667 |
|
|
668 |
|
|
635 | 669 |
nl = (NodeList) xpath.compile("//orcid-work").evaluate(document, XPathConstants.NODESET); |
636 | 670 |
for (int i = 0; i < nl.getLength(); i++) { |
637 | 671 |
if(!worknl.item(0).isEqualNode(nl.item(i))) { |
638 | 672 |
nl.item(i).getParentNode().removeChild(nl.item(i)); |
639 | 673 |
} |
640 | 674 |
} |
641 |
|
|
642 |
|
|
643 | 675 |
DOMSource domSource = new DOMSource(document); |
644 | 676 |
StringWriter writer = new StringWriter(); |
645 |
StreamResult result = new StreamResult(writer);
|
|
677 |
StreamResult streamResult = new StreamResult(writer);
|
|
646 | 678 |
TransformerFactory tf = TransformerFactory.newInstance(); |
647 | 679 |
Transformer transformer = tf.newTransformer(); |
648 |
transformer.transform(domSource, result);
|
|
680 |
transformer.transform(domSource, streamResult);
|
|
649 | 681 |
System.out.println("XML IN String format is: \n" + writer.toString()); |
650 |
r.setXml(xml); |
|
651 |
r.setCollectedFrom(ClaimUtils.COLLECTED_FROM_ORCID); |
|
652 |
r.setFound(true); |
|
682 |
result.setXml(xml);
|
|
683 |
result.setCollectedFrom(ClaimUtils.COLLECTED_FROM_ORCID);
|
|
684 |
result.setFound(true);
|
|
653 | 685 |
} |
654 | 686 |
nl = (NodeList) xpath.compile("//j.0:identifier/text()").evaluate(document, XPathConstants.NODESET); |
655 | 687 |
if (nl.getLength() > 0) { |
656 |
r.setDoi(nl.item(0).getNodeValue()); |
|
657 |
r.setExternal_url("http://dx.doi.org/"+r.getDoi());
|
|
688 |
result.setDoi(nl.item(0).getNodeValue());
|
|
689 |
result.setExternal_url("http://dx.doi.org/" + result.getDoi());
|
|
658 | 690 |
} |
659 | 691 |
} catch (Exception e) { |
660 | 692 |
e.printStackTrace(); |
... | ... | |
662 | 694 |
} |
663 | 695 |
public static Project buildProject(String id, String claimId, boolean useAPI){ |
664 | 696 |
Project body=new Project(); |
665 |
if (id.contains("|")) { |
|
666 |
id = id.split("\\|")[1]; |
|
667 |
} |
|
697 |
// if (id.contains("|")) {
|
|
698 |
// id = id.split("\\|")[1];
|
|
699 |
// }
|
|
668 | 700 |
body.setOpenaireId(id); |
669 | 701 |
if(useAPI){ |
670 | 702 |
getProjectFromAPI(body,claimId); |
Also available in: Unified diff
adding ParsingClaimUtils.getConceptFromDMF()