@Override public UpdateContainer doIt(VWorkspace vWorkspace) throws CommandException { OntologyManager ontMgr = vWorkspace.getWorkspace().getOntologyManager(); JSONArray classesList = new JSONArray(); JSONArray classesMap = new JSONArray(); JSONArray propertiesList = new JSONArray(); JSONArray propertiesMap = new JSONArray(); Map<String, String> prefixMap = vWorkspace.getWorkspace().getOntologyManager().getPrefixMap(); ExtendedIterator<OntClass> iter = ontMgr.getOntModel().listNamedClasses(); // ExtendedIterator<DatatypeProperty> propsIter = ontMgr.getOntModel() // .listDatatypeProperties(); ExtendedIterator<OntProperty> propsIter = ontMgr.getOntModel().listAllOntProperties(); final JSONObject outputObj = new JSONObject(); try { while (iter.hasNext()) { OntClass cls = iter.next(); String pr = prefixMap.get(cls.getNameSpace()); String classLabel = cls.getLocalName(); // if (cls.getLabel(null) != null && !cls.getLabel(null).equals("")) // classLabel = cls.getLabel(null); String clsStr = (pr != null && !pr.equals("")) ? pr + ":" + classLabel : classLabel; classesList.put(clsStr); JSONObject classKey = new JSONObject(); classKey.put(clsStr, cls.getURI()); classesMap.put(classKey); } while (propsIter.hasNext()) { // DatatypeProperty prop = propsIter.next(); OntProperty prop = propsIter.next(); if (prop.isObjectProperty() && !prop.isDatatypeProperty()) continue; String pr = prefixMap.get(prop.getNameSpace()); String propLabel = prop.getLocalName(); // if (prop.getLabel(null) != null && !prop.getLabel(null).equals("")) // propLabel = prop.getLabel(null); String propStr = (pr != null && !pr.equals("")) ? pr + ":" + propLabel : propLabel; propertiesList.put(propStr); JSONObject propKey = new JSONObject(); propKey.put(propStr, prop.getURI()); propertiesMap.put(propKey); } // Populate the JSON object that will hold everything in output outputObj.put(JsonKeys.classList.name(), classesList); outputObj.put(JsonKeys.classMap.name(), classesMap); outputObj.put(JsonKeys.propertyList.name(), propertiesList); outputObj.put(JsonKeys.propertyMap.name(), propertiesMap); } catch (JSONException e) { logger.error("Error populating JSON!"); } UpdateContainer upd = new UpdateContainer( new AbstractUpdate() { @Override public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) { pw.print(outputObj.toString()); } }); return upd; }