Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
[#584] do not show links to unlisted items in owner report
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Pozzi committed Jun 24, 2021
1 parent 0e74900 commit e3a022f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/main/java/de/bonndan/nivio/output/docs/HtmlGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.util.StringUtils;

import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -69,7 +70,7 @@ protected ContainerTag getHead(Landscape landscape) {
);
}

protected ContainerTag writeItem(Item item, Assessment assessment) {
protected ContainerTag writeItem(Item item, Assessment assessment, Collection<Item> allItems) {
boolean hasRelations = !item.getRelations().isEmpty();
boolean hasInterfaces = !item.getInterfaces().isEmpty();
String groupColor = "#" + Color.nameToRGB(item.getGroup(), Color.GRAY);
Expand Down Expand Up @@ -147,11 +148,16 @@ protected ContainerTag writeItem(Item item, Assessment assessment) {
Item end = (df.getSource().equals(item)) ?
df.getTarget() : df.getSource();

ContainerTag endTag = span(end.toString());
if (allItems.contains(end)) {
endTag = a(end.toString()).attr("href", "#" + end.getFullyQualifiedIdentifier());
}

return li(rawHtml((df.getType() != null ? df.getType() : "") + " "
+ ifPresent(df.getFormat()) + " "
+ ifPresent(df.getDescription())
+ direction),
a(end.toString()).attr("href", "#" + end.getFullyQualifiedIdentifier()));
endTag);
})
)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private String writeOwnerGroups(GroupedBy ownerGroups, Assessment assessment) {
builder.append(
h2("Owner: " + owner).render()
);
List<ContainerTag> collect = items.stream().map(item -> div(writeItem(item, assessment)).withClass("col-sm")).collect(Collectors.toList());
List<ContainerTag> collect = items.stream().map(item -> div(writeItem(item, assessment, items)).withClass("col-sm")).collect(Collectors.toList());
builder.append(div().withClass("row").with(collect).render());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.bonndan.nivio.assessment.Assessment;
import de.bonndan.nivio.model.Group;
import de.bonndan.nivio.model.Item;
import de.bonndan.nivio.model.Landscape;
import de.bonndan.nivio.output.Color;
import de.bonndan.nivio.output.LocalServer;
Expand All @@ -12,6 +13,7 @@

import java.util.Map;
import java.util.Objects;
import java.util.Set;

import static de.bonndan.nivio.output.FormatUtils.nice;
import static de.bonndan.nivio.output.map.MapController.MAP_SVG_ENDPOINT;
Expand All @@ -20,8 +22,6 @@

/**
* Generates a report containing all landscape groups and items.
*
*
*/
public class ReportGenerator extends HtmlGenerator {

Expand Down Expand Up @@ -50,7 +50,8 @@ private String writeLandscape(final Landscape landscape, final Assessment assess

private String writeGroups(Landscape landscape, Assessment assessment) {
final StringBuilder builder = new StringBuilder();
Map<String, Group> groups = landscape.getGroups();
final Map<String, Group> groups = landscape.getGroups();
final Set<Item> all = landscape.getItems().all();
groups.forEach((s, groupItem) -> {
String color = "#" + Color.getGroupColor(groupItem);
builder.append(
Expand All @@ -59,7 +60,7 @@ private String writeGroups(Landscape landscape, Assessment assessment) {
);
builder.append(
div().attr("class", "group")
.with(groupItem.getItems().stream().map(item -> this.writeItem(item, assessment)))
.with(groupItem.getItems().stream().map(item -> this.writeItem(item, assessment, all)))
.render()
);
});
Expand Down

0 comments on commit e3a022f

Please sign in to comment.