package eu.dnetlib.dhp.oa.graph.dump.complete; import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import com.google.gson.Gson; import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.dump.oaf.graph.Relation; import eu.dnetlib.dhp.schema.oaf.Datasource; import eu.dnetlib.dhp.schema.oaf.Project; import eu.dnetlib.dhp.utils.DHPUtils; class CreateRelationTest { List communityContext = Arrays .asList( "\n" + " all\n" + " CLARIN\n" + " https://www.clarin.eu/sites/default/files/clarin-frontpage-logo.jpg\n" + " Common Language Resources and Technology Infrastructure\n" + " maria@clarin.eu,dieter@clarin.eu,f.m.g.dejong@uu.nl,paolo.manghi@isti.cnr.it\n" + " \n" + " (Part of) the work reported here was made possible by using the CLARIN infrastructure.\n" + " The work reported here has received funding through <CLARIN national consortium member, e.g. CLARIN.SI>, <XYZ> project, grant no. <XYZ>.\n" + " The work reported here has received funding (through CLARIN ERIC) from the European Union’s Horizon 2020 research and innovation programme under grant agreement No <0-9> for project <XYZ>.\n" + " (E.g. No 676529 for project CLARIN-PLUS.)\n" + " oac_clarin\n" + " 2018-03-01T12:00:00\n" + " \n" + " \n" + " CLARIN-PLUS\n" + " \n" + " \n" + " 676529\n" + " http://www.clarin.eu\n" + " EC\n" + " H2020-INFRADEV-1-2015-1\n" + " CLARIN+\n" + " \n" + " \n" + " Common Language Resources and Technology Infrastructure\n" + " CLARIN\n" + " 212230\n" + " EC\n" + " corda_______::ef782b2d85676aa3e5a907427feb18c4\n" + " \n" + " \n" + " " + "\n" + " \n" + " LINDAT/CLARIN repository\n" + " LINDAT/CLARIN repository\n" + " true\n" + " \n" + " \n" + " \n" + " \n" + " CLARIN-D\n" + " https://www.clarin-d.de/en/\n" + " \n" + " http://www.lrec-conf.org/proceedings/lrec2018/pdf/504.pdf\n" + " Germany\n" + " \n" + " \n" + " \n" + " \n" + "", "\n" + " all\n" + " This community gathers research results, data, scientific publications and projects related to the domain of Digital Humanities. This broad definition includes Humanities, Cultural Heritage, History, Archaeology and related fields.\n" + " http://sanmamante.org/DH_CH_logo.png\n" + " Digital Humanities and Cultural Heritage\n" + " ileniagalluccio87@gmail.com,achille.felicetti@gmail.com,paolo.manghi@isti.cnr.it,tim.evans@york.ac.uk\n" + " modern art,monuments,europeana data model,sites,field walking,frescoes,LIDO metadata schema,art history,excavation,Arts and Humanities General,cities,coins,temples,numismatics,lithics,roads,environmental archaeology,digital cultural heritage,archaeological reports,history,CRMba,churches,cultural heritage,archaeological stratigraphy,religious art,buidings,digital humanities,survey,archaeological sites,linguistic studies,bioarchaeology,architectural orders,palaeoanthropology,fine arts,europeana,CIDOC CRM,decorations,classic art,stratigraphy,digital archaeology,intangible cultural heritage,walls,humanities,chapels,CRMtex,Language and Literature,paintings,archaeology,fair data,mosaics,burials,architecture,medieval art,castles,CARARE metadata schema,statues,natural language processing,inscriptions,CRMsci,vaults,contemporary art,Arts and Humanities,CRMarchaeo,pottery,site,architectural,vessels\n" + " The present work has been partially supported by the PARTHENOS project, funded by the European Commission (Grant Agreement No. 654119) under the HORIZON 2020 - INFRADEV-4-2014/2015 call\n" + " oac_dh-ch\n" + " 2018-03-01T12:00:00\n" + " \n" + " \n" + " Pooling Activities, Resources and Tools for Heritage E-research Networking, Optimization and Synergies\n" + " The present work has been partially supported by the PARTHENOS project, funded by the European Commission (Grant Agreement No. 654119) under the HORIZON 2020 - INFRADEV-4-2014/2015 call\n" + " \n" + " 654119\n" + " http://www.parthenos-project.eu\n" + " EC\n" + " PARTHENOS\n" + " \n" + " \n" + " \n" + " \n" + " re3data_____::9ebe127e5f3a0bf401875690f3bb6b81\n" + " The UK's largest collection of digital research data in the social sciences and humanities\n" + " UK Data Archive\n" + " true\n" + " \n" + " \n" + " doajarticles::c6cd4b532e12868c1d760a8d7cda6815\n" + " Journal of Data Mining and Digital Humanities\n" + " Journal of Data Mining and Digital Humanities\n" + " true\n" + " \n" + " \n" + " doajarticles::a6de4499bb87bf3c01add0a9e2c9ed0b\n" + " Frontiers in Digital Humanities\n" + " Frontiers in Digital Humanities\n" + " true\n" + " \n" + " \n" + " doajarticles::6eb31d13b12bc06bbac06aef63cf33c9\n" + " Il Capitale Culturale: Studies on the Value of Cultural Heritage\n" + " Il Capitale Culturale: Studies on the Value of Cultural Heritage\n" + " true\n" + " \n" + " \n" + " doajarticles::0da84e9dfdc8419576169e027baa8028\n" + " Conservation Science in Cultural Heritage\n" + " Conservation Science in Cultural Heritage\n" + " true\n" + " \n" + " \n" + " re3data_____::84e123776089ce3c7a33db98d9cd15a8\n" + " Electronic Archiving System\n" + " EASY\n" + " true\n" + " \n" + " \n" + " openaire____::c5502a43e76feab55dd00cf50f519125\n" + " DANS-KB Harvester\n" + " Gemeenschappelijke Harvester DANS-KB\n" + " true\n" + " \n" + " \n" + " re3data_____::a48f09c562b247a9919acfe195549b47\n" + " ads\n" + " Archaeology Data Service\n" + " true\n" + " \n" + " \n" + " opendoar____::97275a23ca44226c9964043c8462be96\n" + " KNAW Repository\n" + " KNAW Repository\n" + " true\n" + " \n" + " \n" + " doajarticles::2899208a99aa7d142646e0a80bfeef05\n" + " Internet Archaeology\n" + " Internet Archaeology\n" + " true\n" + " \n" + " \n" + " \n" + "\n", "\n" + " all\n" + " The neuroinformatics dashboard gathers research outputs from the 'neuroinformatics' community at large including the fields of: neuroscience, neuroinformatics, brain imaging databases and standards, brain imaging techniques, neuroimaging methods including statistics and machine learning. The dashboard covers a wide range of imaging methods including (but not limited to): MRI, TEP, EEG, MEG, and studies involving human participants as well as animal studies.\n" + " https://docs.google.com/drawings/u/0/d/10e191xGoGf4uaRluMqbt_7cCj6LSCs2a29im4CmWjqU/export/png\n" + " Neuroinformatics\n" + " sorina.pop@creatis.insa-lyon.fr,camille.maumet@inria.fr,christian.barillot@irisa.fr,xavier.rolland@irisa.fr,axel.bonnet@creatis.insa-lyon.fr,paolo.manghi@isti.cnr.it\n" + " brain mapping,brain imaging,electroencephalography,arterial spin labelling,brain fingerprinting,brain,neuroimaging,Multimodal Brain Image Analysis,fMRI,neuroinformatics,fetal brain,brain ultrasonic imaging,topographic brain mapping,diffusion tensor imaging,computerized knowledge assessment,connectome mapping,brain magnetic resonance imaging,brain abnormalities\n" + " \n" + " oac_ni\n" + " 2018-03-01T12:00:00\n" + " \n" + " \n" + " \n" + " re3data_____::5b9bf9171d92df854cf3c520692e9122\n" + " Formerly:OpenFMRI\n" + " OpenNeuro\n" + " true\n" + " \n" + " \n" + " doajarticles::c7d3de67dc77af72f6747157441252ec\n" + " Research Ideas and Outcomes\n" + " Research Ideas and Outcomes\n" + " true\n" + " \n" + " \n" + " re3data_____::8515794670370f49c1d176c399c714f5\n" + " Neuroimaging Informatics Tools and Resources Clearinghouse\n" + " NITRC\n" + " true\n" + " \n" + " \n" + " doajarticles::d640648c84b10d425f96f11c3de468f3\n" + " Frontiers in Neuroinformatics\n" + " Frontiers in Neuroinformatics\n" + " true\n" + " \n" + " \n" + " doajarticles::0c0e74daa5d95504eade9c81ebbd5b8a\n" + " NeuroImage: Clinical\n" + " NeuroImage: Clinical\n" + " true\n" + " \n" + " \n" + " rest________::fb1a3d4523c95e63496e3bc7ba36244b\n" + " NeuroVault\n" + " NeuroVault\n" + " true\n" + " \n" + " \n" + "\n", "\n" + " all\n" + " Instruct-ERIC is the European Research Infrastructure for Structural Biology\n" + " https://instruct-eric.eu/templates/instructeric/images/logos/instruct-eric-logo-noline.png\n" + " Instruct-ERIC\n" + " claudia@instruct-eric.eu,carazo@cnb.csic.es,echrysina@eie.gr,susan@instruct-eric.eu,naomi@instruct-eric.eu,natalie@instruct-eric.eu,pmarie@igbmc.fr,darren.hart@ibs.fr,claudia@strubi.ox.ac.uk,paolo.manghi@isti.cnr.it\n" + " \n" + " The authors acknowledge the support and the use of resources of Instruct-ERIC.\n" + " The authors acknowledge the support and the use of resources of Instruct (PID # or APPID #), a Landmark ESFRI project\n" + " oac_instruct\n" + " 2018-03-01T12:00:00\n" + " \n" + " \n" + " Authentication and Authorisation For Research and Collaboration\n" + " \n" + " 730941\n" + " \n" + " H2020-EINFRA-2016-1\n" + " AARC2\n" + " EC\n" + " \n" + " \n" + " Building data bridges between biological and medical infrastructures in Europe\n" + " \n" + " 284209\n" + " \n" + " FP7-INFRASTRUCTURES-2011-1\n" + " EC\n" + " BioMedBridges\n" + " \n" + " \n" + " Transnational access and enhancement of integrated Biological Structure determination at synchrotron X-ray radiation facilities\n" + " \n" + " 283570\n" + " \n" + " FP7-INFRASTRUCTURES-2011-1\n" + " EC\n" + " BioStruct-X\n" + " \n" + " \n" + " Coordinated Research Infrastructures Building Enduring Life-science services\n" + " \n" + " 654248\n" + " \n" + " H2020-INFRADEV-1-2014-1\n" + " EC\n" + " CORBEL\n" + " \n" + " \n" + " Infrastructure for NMR, EM and X-rays for translational research\n" + " \n" + " 653706\n" + " \n" + " H2020-INFRAIA-2014-2015\n" + " EC\n" + " iNEXT\n" + " \n" + " \n" + " Integrated Structural Biology Infrastructure\n" + " \n" + " 211252\n" + " \n" + " FP7-INFRASTRUCTURES-2007-1\n" + " EC\n" + " INSTRUCT\n" + " \n" + " \n" + " Releasing the full potential of Instruct to expand and consolidate infrastructure services for integrated structural life science research\n" + " \n" + " 731005\n" + " \n" + " H2020-INFRADEV-2016-1\n" + " EC\n" + " INSTRUCT-ULTRA\n" + " \n" + " \n" + " Opening Synchrotron Light for Experimental Science and Applications in the Middle East\n" + " \n" + " 730943\n" + " \n" + " H2020-INFRASUPP-2016-1\n" + " EC\n" + " OPEN SESAME\n" + " \n" + " \n" + " Infrastructure for Protein Production Platforms\n" + " \n" + " 227764\n" + " \n" + " FP7-INFRASTRUCTURES-2008-1\n" + " EC\n" + " PCUBE\n" + " \n" + " \n" + " European Vaccine Research and Development Infrastructure\n" + " \n" + " 730964\n" + " \n" + " H2020-INFRAIA-2016-1\n" + " EC\n" + " TRAMSVAC2\n" + " \n" + " \n" + " World-wide E-infrastructure for structural biology\n" + " \n" + " 675858\n" + " \n" + " EC | H2020 | RIA\n" + " EC\n" + " West-Life\n" + " \n" + " \n" + " Expanding research infrastructure visibility to strengthen strategic partnerships\n" + " RI-VIS\n" + " 824063\n" + " EC\n" + " corda__h2020::af93b591b76991d8437993a8f6fc6538\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " instruct\n" + " \n" + " \n" + " \n" + " west-life\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " FRISBI\n" + " aHR0cDovL2ZyaXNiaS5ldS9zdGF0aWMvaW1hZ2VzL2xvZ29zL2xvZ28tZnJpc2JpLnBuZw==\n" + " aHR0cDovL2ZyaXNiaS5ldS8=\n" + " \n" + " \n" + " RI-VIS\n" + " aHR0cHM6Ly9yaS12aXMuZXUvbmV0d29yay9yaXZpcy90ZW1wbGF0ZXMvcml2aXMvaW1hZ2VzL1JJLVZJU0xvZ29GaW5hbC0wNi5wbmc=\n" + " aHR0cHM6Ly9yaS12aXMuZXU=\n" + " \n" + " \n" + " CIISB\n" + " aHR0cDovL2JpYy5jZWl0ZWMuY3ovZmlsZXMvMjkyLzEyNS5KUEc=\n" + " aHR0cHM6Ly93d3cuY2lpc2Iub3Jn\n" + " \n" + " \n" + "\n", "\n" + " all\n" + " ELIXIR-GR enhances the potential of the Greek bioinformatics community to offer open, easily accessible and state -of- the- art services to the Greek and the international academic community and other stakeholders, such as industry and the health sector. More importantly, by providing these services, the infrastructure facilitates discoveries in the field of the life-sciences, having strong spill over effects in promoting innovation in sectors such as discovery of new drug targets and development of novel therapeutic agents, development of innovative diagnostics, personalized medicine, and development of innovative biotechnological products and processes.\n" + " https://elixir-greece.org/sites/default/files/ELIXIR_GREECE_white_background.png\n" + " The Greek National Node of the ESFRI European RI ELIXIR\n" + " vergoulis@imis.athena-innovation.gr,schatz@imis.athena-innovation.gr,paolo.manghi@isti.cnr.it\n" + " \n" + " \n" + " oaa_elixir-gr\n" + " 2018-03-01T12:00:00\n" + " \n" + " \n" + " BIO-INFORMATICS RESEARCH NETWORK COORDINATING CENTER (BIRN-CC)\n" + " \n" + " 1U24RR025736-01\n" + " NIH\n" + " \n" + " \n" + " COLLABORATIVE RESEARCH: The Cognitive Neuroscience of Category Learning\n" + " \n" + " 0223843\n" + " NSF\n" + " \n" + " \n" + " The Cognitive Atlas: Developing an Interdisciplinary Knowledge Base Through Socia\n" + " \n" + " 5R01MH082795-05\n" + " NIH\n" + " \n" + " \n" + " Fragmented early life environmental and emotional / cognitive vulnerabilities\n" + " \n" + " 1P50MH096889-01A1\n" + " NIH\n" + " \n" + " \n" + " Enhancement of the 1000 Functional Connectome Project\n" + " \n" + " 1R03MH096321-01A1\n" + " TUBITAK\n" + " \n" + " \n" + " CRCNS Data Sharing: An open data repository for cognitive neuroscience: The OpenfMRI Project\n" + " \n" + " 1131441\n" + " NSF\n" + " \n" + " \n" + " Enhancing Human Cortical Plasticity: Visual Psychophysics and fMRI\n" + " \n" + " 0121950\n" + " NSF\n" + " \n" + " \n" + " Transforming statistical methodology for neuroimaging meta-analysis.\n" + " \n" + " 100309\n" + " WT\n" + " \n" + " " + " \n" + " \n" + " rest________::b8e502674c3c3499d5374e9b2ea6d8d5\n" + " bio.tools\n" + " bio.tools\n" + " false\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " ATHENA RC\n" + " aHR0cHM6Ly9lbGl4aXItZ3JlZWNlLm9yZy9zaXRlcy9kZWZhdWx0L2ZpbGVzL3N0eWxlcy90aHVtYm5haWwvcHVibGljL3BhcnRuZXJfbG9nb3MvYXRoZW5hX2xvZ28uanBnP2l0b2s9VXdGWFNpZng=\n" + " aHR0cHM6Ly93d3cuYXRoZW5hLWlubm92YXRpb24uZ3IvZW4=\n" + " \n" + " \n" + ""); private QueryInformationSystem queryInformationSystem; private Map map; @BeforeEach public void setUp() { queryInformationSystem = new QueryInformationSystem(); queryInformationSystem.setContextRelationResult(communityContext); } @Test void test1() { List cInfoList = new ArrayList<>(); final Consumer consumer = ci -> cInfoList.add(ci); queryInformationSystem .getContextRelation(consumer, "contentproviders", ModelSupport.getIdPrefix(Datasource.class)); cInfoList.forEach(c -> System.out.println(new Gson().toJson(c))); List rList = new ArrayList<>(); cInfoList.forEach(cInfo -> Process.getRelation(cInfo).forEach(rList::add)); Assertions.assertEquals(34, rList.size()); Assertions .assertTrue( rList .stream() .map(r -> r.getSource().getId()) .collect(Collectors.toSet()) .contains( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("dh-ch")))); Assertions .assertEquals( 10, rList .stream() .filter( r -> r .getSource() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("dh-ch")))) .collect(Collectors.toList()) .size()); Assertions .assertEquals( 10, rList .stream() .filter( r -> r .getTarget() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("dh-ch")))) .collect(Collectors.toList()) .size()); Set tmp = rList .stream() .filter( r -> r .getSource() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("dh-ch")))) .map(r -> r.getTarget().getId()) .collect(Collectors.toSet()); Assertions .assertTrue( tmp.contains("10|re3data_____::9ebe127e5f3a0bf401875690f3bb6b81") && tmp.contains("10|doajarticles::c6cd4b532e12868c1d760a8d7cda6815") && tmp.contains("10|doajarticles::a6de4499bb87bf3c01add0a9e2c9ed0b") && tmp.contains("10|doajarticles::6eb31d13b12bc06bbac06aef63cf33c9") && tmp.contains("10|doajarticles::0da84e9dfdc8419576169e027baa8028") && tmp.contains("10|re3data_____::84e123776089ce3c7a33db98d9cd15a8") && tmp.contains("10|openaire____::c5502a43e76feab55dd00cf50f519125") && tmp.contains("10|re3data_____::a48f09c562b247a9919acfe195549b47") && tmp.contains("10|opendoar____::97275a23ca44226c9964043c8462be96") && tmp.contains("10|doajarticles::2899208a99aa7d142646e0a80bfeef05")); } @Test public void test2() { List cInfoList = new ArrayList<>(); final Consumer consumer = ci -> cInfoList.add(ci); queryInformationSystem .getContextRelation(consumer, "projects", ModelSupport.getIdPrefix(Project.class)); cInfoList.forEach(c -> System.out.println(new Gson().toJson(c))); List rList = new ArrayList<>(); cInfoList.forEach(cInfo -> Process.getRelation(cInfo).forEach(rList::add)); Assertions.assertEquals(44, rList.size()); Assertions .assertFalse( rList .stream() .map(r -> r.getSource().getId()) .collect(Collectors.toSet()) .contains( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("dh-ch")))); Assertions .assertEquals( 2, rList .stream() .filter( r -> r .getSource() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("clarin")))) .collect(Collectors.toList()) .size()); Assertions .assertEquals( 2, rList .stream() .filter( r -> r .getTarget() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("clarin")))) .collect(Collectors.toList()) .size()); Set tmp = rList .stream() .filter( r -> r .getSource() .getId() .equals( String .format( "%s|%s::%s", Constants.CONTEXT_ID, Constants.CONTEXT_NS_PREFIX, DHPUtils.md5("clarin")))) .map(r -> r.getTarget().getId()) .collect(Collectors.toSet()); Assertions .assertTrue( tmp.contains("40|corda__h2020::b5a4eb56bf84bef2ebc193306b4d423f") && tmp.contains("40|corda_______::ef782b2d85676aa3e5a907427feb18c4")); rList.forEach(rel -> { if (rel.getSource().getId().startsWith("40|")) { String proj = rel.getSource().getId().substring(3); Assertions.assertTrue(proj.substring(0, proj.indexOf("::")).length() == 12); } }); } }