public String parseData(JsonNode node, String f) throws JsonProcessingException, IOException, JSONException { System.out.println("---"); ObjectNode json = factory.objectNode(); type.push(f); Iterator<String> fieldNames = node.fieldNames(); String uri = type.toString().replaceAll(", ", ".").replaceAll("[\\[\\]]", ""); json.put("type_uri", uri); ObjectNode object = factory.objectNode(); while (fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode fieldValue = node.get(fieldName); // if (node.findParent("description").get("description") != null) // json.set("value", node.findParent("description").get("description")); if (fieldValue.isObject()) { ObjectNode assoc = factory.objectNode(); assoc.set(uri + "." + parseData(fieldValue, fieldName).replaceAll("\n", ""), fieldValue); json.set("composite", assoc); } else { json.set(fieldName, fieldValue); } } // json.append("}"); System.out.println("xxx"); System.out.println(m.writerWithDefaultPrettyPrinter().writeValueAsString(json)); TopicModel t = new TopicModel(new JSONObject(json.toString())); System.err.println(t.getUri()); System.err.println(t.getChildTopicsModel()); return type.pop(); }
Topic storeTopic(TopicModel model, ClientState clientState, Directives directives) { setDefaults(model); dms.storage.createTopic(model); associateWithTopicType(model.getId(), model.getTypeUri()); // AttachedTopic topic = new AttachedTopic(model, dms); topic.storeValue(clientState, directives); // return topic; }
/** Low-level method. Used for bootstrapping. */ void _createTopic(TopicModel model) { // Note: low-level (storage) call used here ### explain dms.storage.createTopic(model); dms.storage.setTopicValue(model.getId(), model.getSimpleValue()); }