Skip to content

Commit

Permalink
CONCONDEC-32: Fix that freezing the history and manual changing of im…
Browse files Browse the repository at this point in the history
…ported elements is not working (#77)

* Remove macroId and pageId attributes from KnowledgeElement class

* Remove macroId from REST API because it is not needed anymore

* Rename REST API to better match conventions

* Update Confluence version

* Use ObjectMapper to serialize and deserialize knowledge elements

* Serialize with alphabetical sorting

* Update version to v0.0.5
  • Loading branch information
kleebaum authored Feb 4, 2022
1 parent baa0fc1 commit 17d047e
Show file tree
Hide file tree
Showing 19 changed files with 249 additions and 345 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ The authentication type needs to be **OAuth (impersonation)**.
The *Decision Knowledge Import Macro* can be used to create a stand-up table in meetings.

![Decision Knowledge Import Macro](doc/macro_edit_dialog.png)

*Macro to import decision knowledge from Jira*

The stand-up table lists open and solved decision problems, decisions, and other decision knowledge elements for a certain time frame.
The list of decision knowledge elements supports the developers in discussing recently made decisions and open decision problems during meetings.

![Decision Knowledge List](doc/imported_decision_knowledge.png)

*List of decision knowledge elements as part of a meeting agenda/protocol (used as stand-up table)*

ConDec's decision knowledge import macro is different to the Jira issue import macro in the following ways:
Expand All @@ -58,9 +60,19 @@ code comments, commit messages, and entire Jira issues.
The Jira issue import macro would only enable to import decision knowledge elements documented as entire Jira issues.
- It enables to **freeze** the imported elements so that changes made in the decision knowledge documentation after the meeting are not shown in the meeting protocol of a former meeting.
That means that ConDec's decision knowledge import macro enables to **preserve the history**.
- It enables to manually input a JSON String exported from Jira, e.g. if there are no application links, and to **manually edit the JSON String**.
- The unresolved decision problems (issues) are highlighted using red text color to **nudge the developers
to collaboratively make and document a decision**.

![Configuration Possibilities](doc/macro_configuration_possibilities.png)

*Configuration possibilities for the decision knowledge import macro when editing a Confluence page.
The macro enables to manually edit the imported knowledge elements.*

![Dialog to Manually Edit JSON](doc/macro_json_edit_dialog.png)

*Dialog to manually paste a JSON String exported from Jira or to manually edit the imported knowledge elements.*

### Design Details
The decision knowledge is imported from [ConDec Jira](https://github.com/cures-hub/cures-condec-jira) via the REST API.
To access ConDec Jira's REST API, the application link between Confluence and Jira is used in the [JiraClient class](src/main/java/de/uhd/ifi/se/decision/management/confluence/oauth).
Binary file added doc/macro_configuration_possibilities.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/macro_json_edit_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.uhd.ifi.se.decision</groupId>
<artifactId>management.confluence</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>

<organization>
<name>Software Engineering Research Group, Heidelberg University</name>
Expand Down Expand Up @@ -167,6 +166,11 @@
<version>20211205</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand Down Expand Up @@ -313,13 +317,12 @@
</profiles>

<properties>
<confluence.version>7.14.1-xpln-1903</confluence.version>
<confluence.version>7.16.0</confluence.version>
<amps.version>8.3.0-128eead6d</amps.version>
<plugin.testrunner.version>2.0.2</plugin.testrunner.version>
<atlassian.spring.scanner.version>2.2.3</atlassian.spring.scanner.version>
<jacoco-version>0.8.7</jacoco-version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml
and the key to generate bundle. -->
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
import org.slf4j.LoggerFactory;

import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.content.render.xhtml.storage.macro.MacroId;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
import com.atlassian.confluence.renderer.radeox.macros.MacroUtils;
import com.atlassian.confluence.util.velocity.VelocityUtils;
import com.atlassian.confluence.xhtml.api.MacroDefinition;
import com.atlassian.fugue.Option;

import de.uhd.ifi.se.decision.management.confluence.model.KnowledgeElement;
import de.uhd.ifi.se.decision.management.confluence.oauth.JiraClient;
Expand All @@ -33,9 +30,8 @@ public class DecisionKnowledgeImportMacro implements Macro {
public String execute(Map<String, String> map, String s, ConversionContext conversionContext)
throws MacroExecutionException {
int pageId = Integer.parseInt(conversionContext.getEntity().getIdAsString());
String macroId = getMacroId(conversionContext);

List<KnowledgeElement> knowledgeElements = KnowledgePersistenceManager.getElements(pageId, macroId);
List<KnowledgeElement> knowledgeElements = KnowledgePersistenceManager.getElements(pageId);
LOGGER.info("Number of elements in database:" + knowledgeElements.size());

boolean freeze = "true".equals(map.get("freeze"));
Expand Down Expand Up @@ -102,13 +98,9 @@ public String execute(Map<String, String> map, String s, ConversionContext conve
endDate, knowledgeTypes, status);
LOGGER.info("Number of elements imported from Jira:" + knowledgeElements.size());

KnowledgePersistenceManager.removeKnowledgeElements(pageId, macroId);
KnowledgePersistenceManager.removeKnowledgeElements(pageId);
knowledgeElements.sort(Comparator.comparing(KnowledgeElement::getKey));
for (KnowledgeElement element : knowledgeElements) {
element.setPageId(pageId);
element.setMacroId(macroId);
KnowledgePersistenceManager.addKnowledgeElement(element);
}
KnowledgePersistenceManager.addKnowledgeElements(knowledgeElements, pageId);
}
}

Expand Down Expand Up @@ -142,18 +134,6 @@ private long convertToUnixTimeStamp(String dateString) {
return unixTimeStamp;
}

private String getMacroId(ConversionContext conversionContext) {
String macroId = "0";
try {
MacroDefinition macroDefinition = (MacroDefinition) conversionContext.getProperty("macroDefinition");
Option<MacroId> option = macroDefinition.getMacroId();
macroId = option.get().getId();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
return macroId;
}

@Override
public BodyType getBodyType() {
return BodyType.NONE;
Expand Down
Loading

0 comments on commit 17d047e

Please sign in to comment.