diff --git a/src/main/resources/application-context-ontology-model-service.xml b/src/main/resources/application-context-ontology-model-service.xml index 2fcca492..1d4d58b8 100644 --- a/src/main/resources/application-context-ontology-model-service.xml +++ b/src/main/resources/application-context-ontology-model-service.xml @@ -87,10 +87,11 @@ PREFIX owl: SELECT ?annotation_value_uri - WHERE { - <$CONCEPT_URI> rdfs:subClassOf* ?annotation_value_uri . - } - ]]> + WHERE + { + <$CONCEPT_URI> (rdf:type|owl:equivalentClass*|(owl:sameAs|^owl:sameAs)*)/rdfs:subClassOf* ?annotation_value_uri . + } + ]]> diff --git a/src/test/java/org/dataone/cn/indexer/annotation/OntologyModelServiceTest.java b/src/test/java/org/dataone/cn/indexer/annotation/OntologyModelServiceTest.java index 61f19064..3b77812e 100644 --- a/src/test/java/org/dataone/cn/indexer/annotation/OntologyModelServiceTest.java +++ b/src/test/java/org/dataone/cn/indexer/annotation/OntologyModelServiceTest.java @@ -67,6 +67,8 @@ public void testECSOMeasurementTypeExpansion() { values.add("http://purl.dataone.org/odo/ECSO_00000514"); values.add("http://ecoinformatics.org/oboe/oboe.1.2/oboe-core.owl#MeasurementType"); values.add("http://www.w3.org/2000/01/rdf-schema#Resource"); + values.add("http://www.w3.org/2000/01/rdf-schema#Class"); + values.add("http://www.w3.org/2002/07/owl#Class"); assertEquals(values, concepts.get("annotation_value_uri")); } catch (Exception e) { @@ -93,4 +95,109 @@ public void testPropertyExpansion() { fail(e.getMessage()); } } + + @Test + public void testMOSAiCExpansion() { + try { + Map> concepts = OntologyModelService.getInstance().expandConcepts("https://purl.dataone.org/odo/MOSAIC_00000865"); + + Set values = new HashSet(); + values.add("https://purl.dataone.org/odo/MOSAIC_00000865"); + values.add("https://purl.dataone.org/odo/MOSAIC_00000036"); + values.add("https://purl.dataone.org/odo/MOSAIC_00012000"); + values.add("http://www.w3.org/2000/01/rdf-schema#Resource"); + values.add("http://www.w3.org/2000/01/rdf-schema#Class"); + values.add("http://www.w3.org/2002/07/owl#Class"); + + assertEquals(values, concepts.get("annotation_value_uri")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void testMOSAiCSameAsExpansion() { + try { + Map> concepts = OntologyModelService.getInstance().expandConcepts("https://purl.dataone.org/odo/MOSAIC_00000225"); + + Set values = new HashSet(); + values.add("https://purl.dataone.org/odo/MOSAIC_00000022"); // Project + values.add("https://purl.dataone.org/odo/MOSAIC_00000225"); // MOSAiC + values.add("https://purl.dataone.org/odo/MOSAIC_00000226"); // Multidisciplinary drifting Observatory for the Study of Arctic Climate (sameAs) + values.add("https://purl.dataone.org/odo/MOSAIC_00000023"); // MOSAiC20192020 (sameAs) + values.add("http://www.w3.org/2002/07/owl#NamedIndividual"); + values.add("http://www.w3.org/2000/01/rdf-schema#Resource"); + + assertEquals(values, concepts.get("annotation_value_uri")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void testARCRCExpansion() { + try { + Map> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.dataone.org/odo/ARCRC_00000051"); + + Set values = new HashSet(); + /** + * Add values for ARCRC:SnowDepth and its supertypes: + * + * SnowDepth -> Snow Key Variable Arctic Key Variable -> Arctic Report Card Component + */ + values.add("http://purl.dataone.org/odo/ARCRC_00000051"); // ARCRC:SnowDepth + values.add("http://purl.dataone.org/odo/ARCRC_00000502"); // ARCRC:SnowKeyVariable + values.add("http://purl.dataone.org/odo/ARCRC_00000040"); // ARCRC:KeyVariable + values.add("http://purl.dataone.org/odo/ARCRC_00000500"); // ARCRC:ArcticReportCardComponent + + + /** + * Add values for ARCRC:SnowDepth's equivalentClass of ECSO:SnowDepth and its supertypes: + * + * SnowDepth -> Water Depth -> Depth -> linearMeasurementType -> Measurement Type + */ + values.add("http://purl.dataone.org/odo/ECSO_00001205"); // ECSO:SnowDepth + values.add("http://purl.dataone.org/odo/ECSO_00000553"); // ECSO:linearMeasurementType + values.add("http://purl.dataone.org/odo/ECSO_00001203"); // ECSO:WaterDepth + values.add("http://purl.dataone.org/odo/ECSO_00001250"); // ECSO:Depth + values.add("http://ecoinformatics.org/oboe/oboe.1.2/oboe-core.owl#MeasurementType"); + + // Values for high level stuff + values.add("http://www.w3.org/2000/01/rdf-schema#Resource"); + values.add("http://www.w3.org/2000/01/rdf-schema#Class"); + values.add("http://www.w3.org/2002/07/owl#Class"); + values.add("http://www.w3.org/2002/07/owl#NamedIndividual"); + + assertEquals(values, concepts.get("annotation_value_uri")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void testNamedIndividualExpansion() { + try { + Map> concepts = OntologyModelService.getInstance().expandConcepts("http://purl.dataone.org/odo/ARCRC_00000507"); + + Set values = new HashSet(); + values.add("http://purl.dataone.org/odo/ARCRC_00000507"); // ARCRC:Greenland itself + values.add("http://www.w3.org/2002/07/owl#NamedIndividual"); // the type of ARCRC:Greenland + values.add("http://purl.dataone.org/odo/ARCRC_00000505"); // ARCRC:GeographicNamedPlace (type of ARCRC:Greenland) + values.add("http://purl.dataone.org/odo/ARCRC_00000506"); // ARCRC:Place (supertype of GeographicNamedPlace) + values.add("http://purl.dataone.org/odo/ARCRC_00000500"); // ARCRC:ArcticReportCardComponent + values.add("http://purl.obolibrary.org/obo/GAZ_00001507"); // sameAs + + assertEquals(values, concepts.get("annotation_value_uri")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + fail(e.getMessage()); + } + } }