public void testFindShortestPath() { System.out.println("-------Test findShortestPath--------"); OntModel model = ontProcessor.getOntModel(); String url1 = "http://geni-orca.renci.org/owl/ben-6509.rdf#Renci/Cisco/6509/TenGigabitEthernet/3/7/fiber"; String url2 = "http://geni-orca.renci.org/owl/ben-6509.rdf#UNC/Cisco/6509/TenGigabitEthernet/3/7/fiber"; ArrayList<ArrayList<OntResource>> path = ontProcessor.findShortestPath(model, model.getOntResource(url1), model.getOntResource(url2), 100000, "VM", "VM", null); ArrayList<OntResource> hop = null; if (path == null) { System.out.println("No Path"); } else { LinkedList<OntResource> deviceList = ontProcessor.getDeviceListInPath(path); for (int i = 0; i < deviceList.size(); i++) { System.out.println(deviceList.get(i)); } System.out.println("\n"); for (int i = 0; i < path.size(); i++) { hop = path.get(i); System.out.println(hop.get(0) + ":" + hop.get(1)); System.out.println("\n"); } } }
/** * A workaround to obtain the label for the onProperty field for a {@link Restriction}. Ideally, this should be done * by using the {@link Restriction#onProperty(Property)}, however for ORDO, the stored node cannot be converted into * an OntProperty class. * * @param restriction the restriction being examined * @return the onProperty label as a string */ private String getOnPropertyFromRestriction(@Nonnull final Restriction restriction) { final ExtendedIterator<Statement> statements = restriction.listProperties(); while (statements.hasNext()) { final Statement statement = statements.next(); // Workaround for getting the property label. if (ON_PROPERTY_LABEL.equals(statement.getPredicate().getLocalName())) { final String onPropertyLink = statement.getObject().toString(); return restriction.getOntModel().getOntResource(onPropertyLink).getLabel(null); } } statements.close(); return null; }
/** * A workaround to obtain the label for the onProperty field for a {@link Restriction}. Ideally, this should be done * by using the {@link Restriction#onProperty(Property)}, however for Orphanet, the stored node cannot be converted * into an OntProperty class. * * @param restriction the restriction being examined * @return the onProperty label as a string */ private String getOnPropertyFromRestriction(@Nonnull final Restriction restriction) { final ExtendedIterator<Statement> statements = restriction.listProperties(); while (statements.hasNext()) { final Statement statement = statements.next(); // Workaround for getting the property label. if (ON_PROPERTY_LABEL.equals(statement.getPredicate().getLocalName())) { final String onPropertyLink = statement.getObject().toString(); return restriction.getOntModel().getOntResource(onPropertyLink).getLabel(null); } } statements.close(); return null; }