• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 17666363500

12 Sep 2025 06:20AM UTC coverage: 13.781% (+0.03%) from 13.751%
17666363500

push

github

tkuhn
feat: Identify sub-spaces based on ID hierarchy, and show them

433 of 3974 branches covered (10.9%)

Branch coverage included in aggregate %.

1111 of 7230 relevant lines covered (15.37%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/page/SpacePage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.List;
6

7
import org.apache.commons.lang3.tuple.Pair;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
10
import org.apache.wicket.markup.html.link.ExternalLink;
11
import org.apache.wicket.markup.repeater.Item;
12
import org.apache.wicket.markup.repeater.data.DataView;
13
import org.apache.wicket.markup.repeater.data.ListDataProvider;
14
import org.apache.wicket.request.mapper.parameter.PageParameters;
15
import org.eclipse.rdf4j.model.IRI;
16
import org.nanopub.Nanopub;
17
import org.nanopub.extra.services.FailedApiCallException;
18

19
import com.knowledgepixels.nanodash.QueryApiAccess;
20
import com.knowledgepixels.nanodash.Space;
21
import com.knowledgepixels.nanodash.User;
22
import com.knowledgepixels.nanodash.Utils;
23
import com.knowledgepixels.nanodash.component.ItemListElement;
24
import com.knowledgepixels.nanodash.component.ItemListPanel;
25
import com.knowledgepixels.nanodash.component.QueryResultTable;
26
import com.knowledgepixels.nanodash.component.TemplateItem;
27
import com.knowledgepixels.nanodash.component.TitleBar;
28
import com.knowledgepixels.nanodash.template.Template;
29

30
/**
31
 * The ProjectPage class represents a space page in the Nanodash application.
32
 */
33
public class SpacePage extends NanodashPage {
34

35
    /**
36
     * The mount path for this page.
37
     */
38
    public static final String MOUNT_PATH = "/space";
39

40
    /**
41
     * {@inheritDoc}
42
     */
43
    @Override
44
    public String getMountPath() {
45
        return MOUNT_PATH;
×
46
    }
47

48
    /**
49
     * Space object with the data shown on this page.
50
     */
51
    private Space space;
52

53
    /**
54
     * Constructor for the SpacePage.
55
     *
56
     * @param parameters the page parameters
57
     * @throws org.nanopub.extra.services.FailedApiCallException if the API call fails
58
     */
59
    public SpacePage(final PageParameters parameters) throws FailedApiCallException {
60
        super(parameters);
×
61

62
        space = Space.get(parameters.get("id").toString());
×
63
        Nanopub np = space.getRootNanopub();
×
64

65
        add(new TitleBar("titlebar", this, "connectors"));
×
66

67
        add(new Label("pagetitle", space.getLabel() + " (space) | nanodash"));
×
68
        add(new Label("spacename", space.getLabel()));
×
69
        add(new ExternalLink("id", space.getId(), space.getId()));
×
70
        add(new BookmarkablePageLink<Void>("np", ExplorePage.class, new PageParameters().add("id", np.getUri())));
×
71
        add(new Label("description", "<span>" + Utils.sanitizeHtml(space.getDescription()) + "</span>").setEscapeModelStrings(false));
×
72

73
        final PageParameters params = new PageParameters();
×
74
        if (space.getDefaultProvenance() != null) {
×
75
            params.add("prtemplate", space.getDefaultProvenance().stringValue());
×
76
        }
77
        List<Pair<String, List<Template>>> templateLists = new ArrayList<>();
×
78
        List<String> templateTagList = new ArrayList<>(space.getTemplateTags());
×
79
        Collections.sort(templateTagList);
×
80
        List<Template> templates = new ArrayList<>(space.getTemplates());
×
81
        for (String tag : templateTagList) {
×
82
            for (Template t : space.getTemplatesPerTag().get(tag)) {
×
83
                if (templates.contains(t)) templates.remove(t);
×
84
            }
×
85
            templateLists.add(Pair.of(tag, space.getTemplatesPerTag().get(tag)));
×
86
        }
×
87
        if (!templates.isEmpty()) {
×
88
            String l = templateLists.isEmpty() ? "Templates" : "Other Templates";
×
89
            templateLists.add(Pair.of(l, templates));
×
90
        }
91
        add(new DataView<Pair<String, List<Template>>>("template-lists", new ListDataProvider<>(templateLists)) {
×
92

93
            @Override
94
            protected void populateItem(Item<Pair<String, List<Template>>> item) {
95
                item.add(new ItemListPanel<Template>(
×
96
                        "templates",
97
                        item.getModelObject().getLeft(),
×
98
                        item.getModelObject().getRight(),
×
99
                        (template) -> new TemplateItem("item", template, params)
×
100
                    ));
101
            }
×
102

103
        });
104

105
        add(new ItemListPanel<Template>(
×
106
                "templates",
107
                "Templates",
108
                () -> space.isDataInitialized(),
×
109
                () -> space.getTemplates(),
×
110
                (template) -> new TemplateItem("item", template, params)
×
111
            ));
112

113
        add(new ItemListPanel<IRI>(
×
114
                "owner-users",
115
                "Owners",
116
                () -> space.isDataInitialized(),
×
117
                () -> space.getOwners(),
×
118
                (userIri) -> new ItemListElement("item", UserPage.class, new PageParameters().add("id", userIri), User.getShortDisplayName(userIri))
×
119
            ));
120

121
        add(new ItemListPanel<IRI>(
×
122
                "member-users",
123
                "Members",
124
                () -> space.isDataInitialized(),
×
125
                () -> space.getMembers(),
×
126
                (userIri) -> new ItemListElement("item", UserPage.class, new PageParameters().add("id", userIri), User.getShortDisplayName(userIri))
×
127
            ));
128

129
        add(new ItemListPanel<Space>(
×
130
                "subspaces",
131
                "Sub-Spaces",
132
                space.getSubspaces(),
×
133
                (space) -> new ItemListElement("item", SpacePage.class, new PageParameters().add("id", space), space.getLabel())
×
134
            ));
135

136
        add(new DataView<IRI>("queries", new ListDataProvider<IRI>(space.getQueryIds())) {
×
137

138
            @Override
139
            protected void populateItem(Item<IRI> item) {
140
                String queryId = QueryApiAccess.getQueryId(item.getModelObject());
×
141
                item.add(QueryResultTable.createComponent("query", queryId, false));
×
142
            }
×
143

144
        });
145
    }
×
146

147
    /**
148
     * Checks if auto-refresh is enabled for this page.
149
     *
150
     * @return true if auto-refresh is enabled, false otherwise
151
     */
152
    protected boolean hasAutoRefreshEnabled() {
153
        return true;
×
154
    }
155

156
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc