ExplorableDatasetRest { private Optional<Ontology> getOntology(Model model, Value value) { Optional<Resource> recordId = getObjectOf(model, value, DatasetRecord.linksToRecord_IRI); Optional<Resource> branchId = getObjectOf(model, value, DatasetRecord.linksToBranch_IRI); Optional<Resource> commitId = getObjectOf(model, value, DatasetRecord.linksToCommit_IRI); if (recordId.isPresent() && branchId.isPresent() && commitId.isPresent()) { return ontologyManager.retrieveOntology(recordId.get(), branchId.get(), commitId.get()); } return Optional.empty(); }  @Reference void setDatasetManager(DatasetManager datasetManager); @Reference void setFactory(ValueFactory factory); @Reference void setCatalogManager(CatalogManager catalogManager); @Reference void setModelFactory(ModelFactory modelFactory); @Reference void setSesameTransformer(SesameTransformer sesameTransformer); @Reference(policyOption = ReferencePolicyOption.GREEDY) void setOntologyManager(OntologyManager ontologyManager); @Reference void setOntologyRecordFactory(OntologyRecordFactory ontologyRecordFactory); @Reference void setBNodeService(BNodeService bNodeService); @GET @Path("{recordIRI}/class-details") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves all the data associated with ontology objects, from a Dataset in the local Catalog") Response getClassDetails(@PathParam("recordIRI") String recordIRI); @GET @Path("{recordIRI}/classes/{classIRI}/instance-details") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves an aggregated summary of all ontology objects from a Dataset in the local Catalog") Response getInstanceDetails(@Context UriInfo uriInfo,
                                @PathParam("recordIRI") String recordIRI,
                                @PathParam("classIRI") String classIRI,
                                @QueryParam("offset") int offset,
                                @QueryParam("limit") int limit,
                                @DefaultValue("true") @QueryParam("ascending") boolean asc,
                                @DefaultValue("false") @QueryParam("infer") boolean infer); @GET @Path("{recordIRI}/classes/{classIRI}/property-details") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves a list of all properties available for a class from a Dataset in the local Catalog") Response getClassPropertyDetails(@PathParam("recordIRI") String recordIRI,
                                     @PathParam("classIRI") String classIRI); @POST @Path("{recordIRI}/instances") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) @RolesAllowed("user") @ApiOperation("Creates an instance of a particular class type in a Dataset in the local Catalog") Response createInstance(@PathParam("recordIRI") String recordIRI,
                            String newInstanceJson); @GET @Path("{recordIRI}/instances/{instanceIRI}") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves an instance of a particular class type from a Dataset in the local Catalog") Response getInstance(@PathParam("recordIRI") String recordIRI,
                         @PathParam("instanceIRI") String instanceIRI); @PUT @Path("{recordIRI}/instances/{instanceIRI}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Updates an instance of a particular class type from a Dataset in the local Catalog") Response updateInstance(@PathParam("recordIRI") String recordIRI,
                            @PathParam("instanceIRI") String instanceIRI,
                            String json); @DELETE @Path("{recordIRI}/instances/{instanceIRI}") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Deletes an instance by its ID.") Response deleteInstance(@PathParam("recordIRI") String recordIRI,
                            @PathParam("instanceIRI") String instanceIRI);  }
@Test public void getClassPropertyDetailsWithSamePropertyIRI() throws Exception { String ontologyId = "https: String branchId = "https: String commitId = "https: OntologyIdentifier identifier = new OntologyIdentifier(ontologyId, branchId, commitId, vf, mf); Set<Value> nodes = record.getOntology(); nodes.add(identifier.getNode()); record.setOntology(nodes); record.getModel().addAll(identifier.getStatements()); Ontology ontology2 = mock(Ontology.class); when(ontology2.containsClass(any(IRI.class))).thenReturn(true); when(ontology2.getAllClassDataProperties(classId)).thenReturn(dataProperties); when(ontology2.getAllClassObjectProperties(classId)).thenReturn(objectProperties); when(ontology2.getDataPropertyRange(dataProperty)).thenReturn(Collections.EMPTY_SET); when(ontology2.getObjectPropertyRange(objectProperty)).thenReturn(Collections.EMPTY_SET); when(ontology2.getTupleQueryResults(anyString(), anyBoolean())).thenReturn(new TestQueryResult(Collections.emptyList(), Collections.emptyList(), 0, vf)); when(ontologyManager.retrieveOntology(vf.createIRI(ontologyId), vf.createIRI(branchId), vf.createIRI(commitId))).thenReturn(Optional.of(ontology2)); JSONArray expected = JSONArray.fromObject(IOUtils.toString(getClass() .getResourceAsStream("/expected-class-property-details.json"))); Response response = target().path("explorable-datasets/" + encode(RECORD_ID_STR) + "/classes/" + encode(CLASS_ID_STR) + "/property-details").request().get(); assertEquals(response.getStatus(), 200); JSONArray details = JSONArray.fromObject(response.readEntity(String.class)); verify(ontology, times(0)).getAllNoDomainDataProperties(); verify(ontology, times(0)).getAllNoDomainObjectProperties(); verify(ontology2, times(0)).getAllNoDomainDataProperties(); verify(ontology2, times(0)).getAllNoDomainObjectProperties(); verify(ontology).getAllClassDataProperties(any(IRI.class)); verify(ontology).getAllClassObjectProperties(any(IRI.class)); verify(ontology2).getAllClassDataProperties(any(IRI.class)); verify(ontology2).getAllClassObjectProperties(any(IRI.class)); assertEquals(details, expected); }