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

584 exclude links nonexistent report items #590

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private Optional<ExternalLinkHandler> createHandler(String key, Class<? extends
try {
return Optional.of(beanFactory.createBean(aClass));
} catch (BeansException e) {
LOGGER.error(String.format("Failed to create external link handler of type %s. Please check the handler is properly configured.", key));
LOGGER.warn(String.format("Failed to create external link handler of type %s. Please check the handler is properly configured.", key));
return Optional.empty();
}
}
Expand Down
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