In KnowWE the content of an article is managed as a hierarchical structure of the content elements. Every node of that tree contains a particular fragment of the source text of the page. We call such a node a Section. No matter what kind of extension for KnowWE should be implemented, sections will play a fundamental role in any case. Therefore handling, searching, navigation, and modification of sections are hot topics in KnowWE programming.
Each section has an id that is unique wiki-wide. When having such an id, the corresponding section object can be retrieved using the following method of the class Sections:
public static Section<?> getSection(String id) {
Please regard the following notes:
Instead do: Use the method replaceSections provided by the Sections class.
public static Map<String, String> replaceSections(UserActionContext context, Map<String, String> sectionsMap) throws IOException {
Beside the context of the user, that is responsible for triggering these changes, a map is passed. This map contains all the change operations that are supposed to be applied on the wiki pages source(s). The keys of this map are section ids of existing sections. The value for each id is the new content string, the old section should be replaced with. After modifying the content as specified by this map of replacements, this method will take care of all additional organizational issues (e.g., persistence, parsing, compilation, message handling, event handling). Then, the updated version of the section tree can be accessed in the common way, e.g., by starting at the root section of an article.
The method returns a map containing a mapping from the old section ids to the corresponding new sections id, if structural equivalence is given. Not in every case this information is required by the caller.
The method you should use to store something is:
KnowWEUtils.storeObject(KnowWEArticle article, Section<?> s, String key, Object o)
The method to look up stored information is:
KnowWEUtils.getStoredObject(KnowWEArticle article, Section<?> s, String key)