Java Code Examples for com.hp.hpl.jena.rdf.model.Resource#isURIResource()

The following examples show how to use com.hp.hpl.jena.rdf.model.Resource#isURIResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirectoryServlet.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
protected void doGet(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
	D2RServer server = D2RServer.fromServletContext(getServletContext());
	server.checkMappingFileChanged();
	if (request.getPathInfo() == null) {
		response.sendError(404);
		return;
	}
	String classMapName = request.getPathInfo().substring(1);
	int limit = server.getConfig().getLimitPerClassMap();
	Model resourceList = server.getMapping().getResourceCollection(classMapName).getInventoryModel(limit);
	if (resourceList == null) {
		response.sendError(404, "Sorry, class map '" + classMapName + "' not found.");
		return;
	}
	Map<String,String> resources = new TreeMap<String,String>();
	ResIterator subjects = resourceList.listSubjects();
	while (subjects.hasNext()) {
		Resource resource = subjects.nextResource();
		if (!resource.isURIResource()) {
			continue;
		}
		String uri = resource.getURI();
		Statement labelStmt = PageServlet.getBestLabel(resource);
		String label = (labelStmt == null) ? resource.getURI() : labelStmt.getString();
		resources.put(uri, label);
	}
	Map<String,String> classMapLinks = new TreeMap<String,String>();
	for (String name: server.getMapping().getResourceCollectionNames()) {
		classMapLinks.put(name, server.baseURI() + "directory/" + name);
	}
	VelocityWrapper velocity = new VelocityWrapper(this, request, response);
	Context context = velocity.getContext();
	context.put("rdf_link", server.baseURI() + "all/" + classMapName);
	context.put("classmap", classMapName);
	context.put("classmap_links", classMapLinks);
	context.put("resources", resources);
	context.put("limit_per_class_map", server.getConfig().getLimitPerClassMap());
	velocity.mergeTemplateXHTML("directory_page.vm");
}