List of usage examples for java.util.concurrent ConcurrentMap containsKey
boolean containsKey(Object key);
From source file:com.github.podd.example.ExamplePoddClient.java
/** * @param projectUriMap// ww w . j a v a 2 s . c om * @param baseProjectName * @return * @throws PoddClientException */ private Map<URI, InferredOWLOntologyID> getProjectDetails( final ConcurrentMap<String, ConcurrentMap<URI, InferredOWLOntologyID>> projectUriMap, final String baseProjectName) throws PoddClientException { if (!projectUriMap.containsKey(baseProjectName)) { this.log.error("Did not find an existing project for a line in the CSV file: {}", baseProjectName); // TODO: Create a new project? // return; throw new PoddClientException( "Did not find an existing project for a line in the CSV file: " + baseProjectName); } return projectUriMap.get(baseProjectName); }
From source file:com.github.podd.example.ExamplePoddClient.java
/** * @param potUriMap//from w w w. java 2 s . c om * @param plantId * @param nextProjectID * @param nextTrayURI * @return * @throws PoddClientException * @throws GraphUtilException */ private URI getPotUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> potUriMap, final String plantId, final InferredOWLOntologyID nextProjectID, final URI nextTrayURI) throws PoddClientException, GraphUtilException { URI nextPotURI; if (potUriMap.containsKey(plantId)) { nextPotURI = potUriMap.get(plantId).keySet().iterator().next(); } else { final Model plantIdSparqlResults = this.doSPARQL( String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS, RenderUtils.escape(plantId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_POT)), Arrays.asList(nextProjectID)); if (plantIdSparqlResults.isEmpty()) { this.log.debug( "Could not find an existing container for pot barcode, assigning a temporary URI: {} {}", plantId, nextProjectID); nextPotURI = RestletPoddClientImpl.vf .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "pot:" + UUID.randomUUID().toString()); } else { nextPotURI = GraphUtil.getUniqueSubjectURI(plantIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_POT); } ConcurrentMap<URI, URI> nextPotUriMap = new ConcurrentHashMap<>(); final ConcurrentMap<URI, URI> putIfAbsent2 = potUriMap.putIfAbsent(plantId, nextPotUriMap); if (putIfAbsent2 != null) { nextPotUriMap = putIfAbsent2; } nextPotUriMap.put(nextPotURI, nextTrayURI); } return nextPotURI; }
From source file:com.github.podd.example.ExamplePoddClient.java
/** * @param trayUriMap/* w ww . ja v a 2 s . c om*/ * @param trayId * @param nextProjectID * @param nextExperimentUri * @return * @throws PoddClientException * @throws GraphUtilException */ private URI getTrayUri(final ConcurrentMap<String, ConcurrentMap<URI, URI>> trayUriMap, final String trayId, final InferredOWLOntologyID nextProjectID, final URI nextExperimentUri) throws PoddClientException, GraphUtilException { // Check whether trayId already has an assigned URI URI nextTrayURI; if (trayUriMap.containsKey(trayId)) { nextTrayURI = trayUriMap.get(trayId).keySet().iterator().next(); } else { final Model trayIdSparqlResults = this.doSPARQL( String.format(ExampleSpreadsheetConstants.TEMPLATE_SPARQL_BY_TYPE_LABEL_STRSTARTS, RenderUtils.escape(trayId), RenderUtils.getSPARQLQueryString(PODD.PODD_SCIENCE_TRAY)), Arrays.asList(nextProjectID)); if (trayIdSparqlResults.isEmpty()) { this.log.debug( "Could not find an existing container for tray barcode, assigning a temporary URI: {} {}", trayId, nextProjectID); nextTrayURI = RestletPoddClientImpl.vf .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "tray:" + UUID.randomUUID().toString()); } else { nextTrayURI = GraphUtil.getUniqueSubjectURI(trayIdSparqlResults, RDF.TYPE, PODD.PODD_SCIENCE_TRAY); } ConcurrentMap<URI, URI> nextTrayUriMap = new ConcurrentHashMap<>(); final ConcurrentMap<URI, URI> putIfAbsent2 = trayUriMap.putIfAbsent(trayId, nextTrayUriMap); if (putIfAbsent2 != null) { nextTrayUriMap = putIfAbsent2; } nextTrayUriMap.put(nextTrayURI, nextExperimentUri); } return nextTrayURI; }
From source file:com.github.podd.example.ExamplePoddClient.java
/** * Gets a material URI matching the given pot and genotype URIs, creating a new entry if * necessary and giving it a temporary URI. * //from www . j ava2s . c o m * @param materialUriMap * @param nextProjectID * @param nextPotUri * @return */ private URI getMaterialUri(final ConcurrentMap<URI, ConcurrentMap<URI, Model>> materialUriMap, final URI nextGenotypeUri, final InferredOWLOntologyID nextProjectID, final URI nextPotUri, final String potNumber, final String lineNumber, final String control) { URI nextMaterialURI = null; if (materialUriMap.containsKey(nextPotUri)) { final ConcurrentMap<URI, Model> nextPotMaterialMap = materialUriMap.get(nextPotUri); for (final URI existingMaterialURI : nextPotMaterialMap.keySet()) { final Model nextModel = nextPotMaterialMap.get(existingMaterialURI); if (nextModel.contains(existingMaterialURI, PODD.PODD_SCIENCE_REFERS_TO_GENOTYPE, nextGenotypeUri)) { nextMaterialURI = existingMaterialURI; } else { this.log.debug("Did not find any materials with the given genotype in this pot: {} {}", nextPotUri, nextGenotypeUri); } } } // If no material was found, then create a new description and assign it a temporary URI if (nextMaterialURI == null) { this.log.debug( "Could not find an existing material for description provided, assigning a temporary URI: {} {} {}", nextProjectID, nextPotUri, nextGenotypeUri); nextMaterialURI = RestletPoddClientImpl.vf .createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "material:" + UUID.randomUUID().toString()); final Model newModel = new LinkedHashModel(); newModel.add(nextPotUri, PODD.PODD_SCIENCE_HAS_MATERIAL, nextMaterialURI); newModel.add(nextMaterialURI, RDF.TYPE, PODD.PODD_SCIENCE_MATERIAL); newModel.add(nextMaterialURI, RDFS.LABEL, RestletPoddClientImpl.vf .createLiteral("Material for pot " + potNumber + " containing line " + lineNumber)); newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_REFERS_TO_GENOTYPE, nextGenotypeUri); if (control.equalsIgnoreCase("Yes")) { newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_YES); } else if (control.equalsIgnoreCase("No")) { newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_NO); } else { this.log.warn("Did not recognise control label: {} (should be Yes or No", control); newModel.add(nextMaterialURI, PODD.PODD_SCIENCE_HAS_CONTROL, PODD.PODD_SCIENCE_HAS_CONTROL_UNKNOWN); } ConcurrentMap<URI, Model> nextGenotypeUriMap = new ConcurrentHashMap<>(); final ConcurrentMap<URI, Model> putIfAbsent = materialUriMap.putIfAbsent(nextPotUri, nextGenotypeUriMap); if (putIfAbsent != null) { nextGenotypeUriMap = putIfAbsent; } final Model putIfAbsent2 = nextGenotypeUriMap.putIfAbsent(nextMaterialURI, newModel); if (putIfAbsent2 != null) { this.log.error("ERROR: Generated two temporary Material URIs that were identical! : {} {}", nextPotUri, nextMaterialURI); } } return nextMaterialURI; }
From source file:com.github.podd.example.ExamplePoddClient.java
/** * Gets a genotype URI matching the given genus, species, and plantName (line) from the given * cache, creating a new entry if necessary and giving it a temporary URI. * /* w w w. j av a 2s .c o m*/ * @param genotypeUriMap * @param genus * @param species * @param plantName * @param control * @param nextProjectID * @param nextProjectUri * @return */ private URI getGenotypeUri(final ConcurrentMap<URI, ConcurrentMap<URI, Model>> genotypeUriMap, final String genus, final String species, final String plantName, final String plantLineNumber, final String control, final InferredOWLOntologyID nextProjectID, final URI nextProjectUri) { URI nextGenotypeURI = null; if (genotypeUriMap.containsKey(nextProjectUri)) { final ConcurrentMap<URI, Model> nextProjectGenotypeMap = genotypeUriMap.get(nextProjectUri); for (final URI existingGenotypeURI : nextProjectGenotypeMap.keySet()) { final Model nextModel = nextProjectGenotypeMap.get(existingGenotypeURI); if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_GENUS, RestletPoddClientImpl.vf.createLiteral(genus))) { if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_SPECIES, RestletPoddClientImpl.vf.createLiteral(species))) { if (nextModel.contains(existingGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE, RestletPoddClientImpl.vf.createLiteral(plantName))) { nextGenotypeURI = existingGenotypeURI; break; } else { this.log.debug( "Did not find any genotypes with the given genus and species and line in this project: {} {} {} {}", nextProjectUri, genus, species, plantName); } } else { this.log.debug( "Did not find any genotypes with the given genus and species in this project: {} {} {}", nextProjectUri, genus, species); } } else { this.log.debug("Did not find any genotypes with the given genus in this project: {} {}", nextProjectUri, genus); } } } // If no genotype was found, then create a new description and assign it a temporary URI if (nextGenotypeURI == null) { this.log.debug( "Could not find an existing genotype for description provided, assigning a temporary URI: {} {} {} {}", nextProjectID, genus, species, plantName); nextGenotypeURI = RestletPoddClientImpl.vf.createURI(RestletPoddClientImpl.TEMP_UUID_PREFIX + "genotype:" + plantLineNumber + ":" + UUID.randomUUID().toString()); final Model newModel = new LinkedHashModel(); newModel.add(nextProjectUri, PODD.PODD_SCIENCE_HAS_GENOTYPE, nextGenotypeURI); newModel.add(nextGenotypeURI, RDF.TYPE, PODD.PODD_SCIENCE_GENOTYPE); newModel.add(nextGenotypeURI, RDFS.LABEL, RestletPoddClientImpl.vf.createLiteral(genus + " " + species + " (" + plantName + ")")); newModel.add(nextGenotypeURI, RDFS.COMMENT, RestletPoddClientImpl.vf.createLiteral("Plant line in : " + genus + " " + species + " named, " + plantName + " : labelled as number " + plantLineNumber)); newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_GENUS, RestletPoddClientImpl.vf.createLiteral(genus)); newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_SPECIES, RestletPoddClientImpl.vf.createLiteral(species)); newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE, RestletPoddClientImpl.vf.createLiteral(plantName)); newModel.add(nextGenotypeURI, PODD.PODD_SCIENCE_HAS_LINE_NUMBER, RestletPoddClientImpl.vf.createLiteral(plantLineNumber)); ConcurrentMap<URI, Model> nextGenotypeUriMap = new ConcurrentHashMap<>(); final ConcurrentMap<URI, Model> putIfAbsent = genotypeUriMap.putIfAbsent(nextProjectUri, nextGenotypeUriMap); if (putIfAbsent != null) { nextGenotypeUriMap = putIfAbsent; } final Model putIfAbsent2 = nextGenotypeUriMap.putIfAbsent(nextGenotypeURI, newModel); if (putIfAbsent2 != null) { this.log.error("ERROR: Generated two temporary Genotype URIs that were identical! : {} {}", nextProjectUri, nextGenotypeURI); } } return nextGenotypeURI; }
From source file:com.github.podd.utils.test.OntologyUtilsTest.java
private void assertA1B2C3(final ConcurrentMap<URI, Set<URI>> nextImportsMap) { Assert.assertEquals(5, nextImportsMap.size()); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriA1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriB1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriB2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriC1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testVersionUriC3)); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testVersionUriA1).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testVersionUriB1).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testVersionUriB2).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testVersionUriC1).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testVersionUriC3).size()); Assert.assertTrue(/*w w w. java 2 s .co m*/ nextImportsMap.get(OntologyConstant.testVersionUriB1).contains(OntologyConstant.testVersionUriA1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testVersionUriB2).contains(OntologyConstant.testVersionUriA1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testVersionUriC1).contains(OntologyConstant.testVersionUriA1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testVersionUriC1).contains(OntologyConstant.testVersionUriB1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testVersionUriC3).contains(OntologyConstant.testVersionUriA1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testVersionUriC3).contains(OntologyConstant.testVersionUriB2)); }
From source file:com.github.podd.utils.test.OntologyUtilsTest.java
private void assertRealisticImportsMapV2(final ConcurrentMap<URI, Set<URI>> nextImportsMap) { Assert.assertEquals(12, nextImportsMap.size()); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV2)); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV1).size()); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV2).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV1).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV2).size()); Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).size()); Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).size()); Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV1).size()); Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV2).size()); Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).size()); Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).size()); Assert.assertTrue(/*from ww w . j a v a2 s.co m*/ nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddUserUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddUserUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddScienceUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddScienceUriV2)); }
From source file:com.github.podd.utils.test.OntologyUtilsTest.java
private void assertRealisticImportsMapV3(final ConcurrentMap<URI, Set<URI>> nextImportsMap) { Assert.assertEquals(22, nextImportsMap.size()); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddFoafUriV3)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddUserUriV3)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddBaseUriV3)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddScienceUriV3)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV1)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV2)); Assert.assertTrue(nextImportsMap.containsKey(OntologyConstant.testPoddPlantUriV3)); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV1).size()); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV2).size()); Assert.assertEquals(0, nextImportsMap.get(OntologyConstant.testPoddDcUriV3).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).size()); Assert.assertEquals(1, nextImportsMap.get(OntologyConstant.testPoddFoafUriV3).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV1).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV2).size()); Assert.assertEquals(2, nextImportsMap.get(OntologyConstant.testPoddUserUriV3).size()); Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).size()); Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).size()); Assert.assertEquals(3, nextImportsMap.get(OntologyConstant.testPoddBaseUriV3).size()); Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV1).size()); Assert.assertEquals(6, nextImportsMap.get(OntologyConstant.testPoddScienceUriV2).size()); Assert.assertEquals(4, nextImportsMap.get(OntologyConstant.testPoddScienceUriV3).size()); Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).size()); Assert.assertEquals(7, nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).size()); Assert.assertEquals(5, nextImportsMap.get(OntologyConstant.testPoddPlantUriV3).size()); Assert.assertTrue(//ww w. ja v a2s .com nextImportsMap.get(OntologyConstant.testPoddFoafUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddFoafUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddFoafUriV3).contains(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddUserUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddUserUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddUserUriV3).contains(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddUserUriV3) .contains(OntologyConstant.testPoddFoafUriV3)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddBaseUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddBaseUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddBaseUriV3).contains(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV3) .contains(OntologyConstant.testPoddFoafUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddBaseUriV3) .contains(OntologyConstant.testPoddUserUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3) .contains(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3) .contains(OntologyConstant.testPoddFoafUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3) .contains(OntologyConstant.testPoddUserUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV1) .contains(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV2) .contains(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddScienceUriV3) .contains(OntologyConstant.testPoddBaseUriV3)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddPlantUriV1).contains(OntologyConstant.testPoddDcUriV1)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddPlantUriV2).contains(OntologyConstant.testPoddDcUriV2)); Assert.assertTrue( nextImportsMap.get(OntologyConstant.testPoddPlantUriV3).contains(OntologyConstant.testPoddDcUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddFoafUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddFoafUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3) .contains(OntologyConstant.testPoddFoafUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddUserUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddUserUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3) .contains(OntologyConstant.testPoddUserUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddBaseUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddBaseUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3) .contains(OntologyConstant.testPoddBaseUriV3)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV1) .contains(OntologyConstant.testPoddScienceUriV1)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV2) .contains(OntologyConstant.testPoddScienceUriV2)); Assert.assertTrue(nextImportsMap.get(OntologyConstant.testPoddPlantUriV3) .contains(OntologyConstant.testPoddScienceUriV3)); }
From source file:com.github.podd.utils.test.OntologyUtilsTest.java
@Test public void testImportsOrderZeroLevels() throws Exception { final Model model = new LinkedHashModel(); OntologyUtils.ontologyIDsToModel(Arrays.asList(OntologyConstant.testOntologyID), model); final Set<URI> schemaOntologyUris = new HashSet<URI>(); final Set<URI> schemaVersionUris = new HashSet<URI>(); schemaOntologyUris.add(OntologyConstant.testOntologyUri1); schemaVersionUris.add(OntologyConstant.testVersionUri1); final ConcurrentMap<URI, Set<URI>> importsMap = new ConcurrentHashMap<URI, Set<URI>>(); // Expected output solution from importsMap after calling orderImports // importsMap.put(testVersionUri1, new HashSet<URI>()); final List<URI> orderImports = OntologyUtils.orderImports(model, schemaOntologyUris, schemaVersionUris, importsMap, false);/*from ww w . j a va 2 s .co m*/ Assert.assertEquals(1, orderImports.size()); Assert.assertEquals(OntologyConstant.testVersionUri1, orderImports.get(0)); Assert.assertEquals(1, importsMap.size()); Assert.assertTrue(importsMap.containsKey(OntologyConstant.testVersionUri1)); final Set<URI> importsRoot = importsMap.get(OntologyConstant.testVersionUri1); Assert.assertNotNull(importsRoot); Assert.assertEquals(0, importsRoot.size()); }
From source file:com.github.podd.utils.test.OntologyUtilsTest.java
@Test public void testImportsOrderOneLevel() throws Exception { final Model model = new LinkedHashModel(); OntologyUtils.ontologyIDsToModel(Arrays.asList(OntologyConstant.testOntologyID), model); model.add(OntologyConstant.testVersionUri1, OWL.IMPORTS, OntologyConstant.testImportOntologyUri1); model.add(OntologyConstant.testImportOntologyUri1, RDF.TYPE, OWL.ONTOLOGY); model.add(OntologyConstant.testImportOntologyUri1, OWL.VERSIONIRI, OntologyConstant.testImportVersionUri1); model.add(OntologyConstant.testImportVersionUri1, RDF.TYPE, OWL.ONTOLOGY); final Set<URI> schemaOntologyUris = new HashSet<URI>(); final Set<URI> schemaVersionUris = new HashSet<URI>(); schemaOntologyUris.add(OntologyConstant.testOntologyUri1); schemaOntologyUris.add(OntologyConstant.testImportOntologyUri1); schemaVersionUris.add(OntologyConstant.testVersionUri1); schemaVersionUris.add(OntologyConstant.testImportVersionUri1); final ConcurrentMap<URI, Set<URI>> importsMap = new ConcurrentHashMap<URI, Set<URI>>(); // Expected output solution from importsMap after calling orderImports // importsMap.put(testVersionUri1, // Collections.singleton(OntologyConstant.testImportVersionUri1)); // importsMap.put(testImportVersionUri1, new HashSet<URI>()); final List<URI> orderImports = OntologyUtils.orderImports(model, schemaOntologyUris, schemaVersionUris, importsMap, false);//from w ww.j ava 2 s.c o m Assert.assertEquals(2, orderImports.size()); Assert.assertEquals(OntologyConstant.testImportVersionUri1, orderImports.get(0)); Assert.assertEquals(OntologyConstant.testVersionUri1, orderImports.get(1)); Assert.assertEquals(2, importsMap.size()); Assert.assertTrue(importsMap.containsKey(OntologyConstant.testImportVersionUri1)); Assert.assertTrue(importsMap.containsKey(OntologyConstant.testVersionUri1)); final Set<URI> imports1 = importsMap.get(OntologyConstant.testImportVersionUri1); Assert.assertNotNull(imports1); Assert.assertEquals(0, imports1.size()); final Set<URI> importsRoot = importsMap.get(OntologyConstant.testVersionUri1); Assert.assertNotNull(importsRoot); Assert.assertEquals(1, importsRoot.size()); Assert.assertEquals(OntologyConstant.testImportVersionUri1, importsRoot.iterator().next()); }