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

knowledgepixels / nanodash / 17855398223

19 Sep 2025 10:14AM UTC coverage: 13.734% (+0.05%) from 13.689%
17855398223

push

github

tkuhn
feat: Show start/end dates of spaces

436 of 4030 branches covered (10.82%)

Branch coverage included in aggregate %.

1123 of 7321 relevant lines covered (15.34%)

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.time.LocalDateTime;
4
import java.time.ZoneId;
5
import java.time.format.DateTimeFormatter;
6
import java.util.ArrayList;
7
import java.util.HashSet;
8
import java.util.List;
9
import java.util.Set;
10

11
import org.apache.commons.lang3.tuple.Pair;
12
import org.apache.wicket.Component;
13
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
14
import org.apache.wicket.markup.html.basic.Label;
15
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
16
import org.apache.wicket.markup.html.link.ExternalLink;
17
import org.apache.wicket.model.Model;
18
import org.apache.wicket.request.mapper.parameter.PageParameters;
19
import org.eclipse.rdf4j.model.IRI;
20
import org.nanopub.Nanopub;
21
import org.nanopub.extra.services.FailedApiCallException;
22

23
import com.knowledgepixels.nanodash.Space;
24
import com.knowledgepixels.nanodash.User;
25
import com.knowledgepixels.nanodash.Utils;
26
import com.knowledgepixels.nanodash.component.ItemListElement;
27
import com.knowledgepixels.nanodash.component.ItemListPanel;
28
import com.knowledgepixels.nanodash.component.PinGroupList;
29
import com.knowledgepixels.nanodash.component.TitleBar;
30
import com.knowledgepixels.nanodash.connector.ConnectorConfig;
31
import com.knowledgepixels.nanodash.connector.GenOverviewPage;
32

33

34

35
/**
36
 * The ProjectPage class represents a space page in the Nanodash application.
37
 */
38
public class SpacePage extends NanodashPage {
39

40
    /**
41
     * The mount path for this page.
42
     */
43
    public static final String MOUNT_PATH = "/space";
44

45
    /**
46
     * {@inheritDoc}
47
     */
48
    @Override
49
    public String getMountPath() {
50
        return MOUNT_PATH;
×
51
    }
52

53
    /**
54
     * Space object with the data shown on this page.
55
     */
56
    private Space space;
57

58
    private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
×
59

60
    /**
61
     * Constructor for the SpacePage.
62
     *
63
     * @param parameters the page parameters
64
     * @throws org.nanopub.extra.services.FailedApiCallException if the API call fails
65
     */
66
    public SpacePage(final PageParameters parameters) throws FailedApiCallException {
67
        super(parameters);
×
68

69
        space = Space.get(parameters.get("id").toString());
×
70
        Nanopub np = space.getRootNanopub();
×
71

72
        add(new TitleBar("titlebar", this, "connectors"));
×
73

74
        add(new Label("pagetitle", space.getLabel() + " (space) | nanodash"));
×
75
        add(new Label("spacename", space.getLabel()));
×
76
        add(new Label("spacetype", space.getTypeLabel()));
×
77
        add(new ExternalLink("id", space.getId(), space.getId()));
×
78
        add(new BookmarkablePageLink<Void>("np", ExplorePage.class, new PageParameters().add("id", np.getUri())));
×
79

80
        if (space.getStartDate() != null) {
×
81
            String dateString;
82
            LocalDateTime dt = LocalDateTime.ofInstant(space.getStartDate().toInstant(), ZoneId.systemDefault());
×
83
            dateString = dateTimeFormatter.format(dt);
×
84
            if (space.getEndDate() != null) {
×
85
                dt = LocalDateTime.ofInstant(space.getEndDate().toInstant(), ZoneId.systemDefault());
×
86
                String endDate = dateTimeFormatter.format(dt);
×
87
                if (!dateString.equals(endDate)) {
×
88
                    dateString += " - " + endDate;
×
89
                }
90
            }
91
            add(new Label("date", dateString));
×
92
        } else {
×
93
            add(new Label("date").setVisible(false));
×
94
        }
95

96
        add(new Label("description", "<span>" + Utils.sanitizeHtml(space.getDescription()) + "</span>").setEscapeModelStrings(false));
×
97

98
        if (space.isDataInitialized()) {
×
99
            add(new PinGroupList("pin-groups", space));
×
100
        } else {
101
            add(new AjaxLazyLoadPanel<Component>("pin-groups") {
×
102
    
103
                @Override
104
                public Component getLazyLoadComponent(String markupId) {
105
                    return new PinGroupList(markupId, space);
×
106
                }
107
    
108
                @Override
109
                protected boolean isContentReady() {
110
                    return space.isDataInitialized();
×
111
                }
112
    
113
            });
114
        }
115

116
        add(new ItemListPanel<Pair<IRI, String>>(
×
117
                "members",
118
                "Members",
119
                () -> space.isDataInitialized(),
×
120
                () -> {
121
                        List<Pair<IRI, String>> members = new ArrayList<>();
×
122
                        Set<IRI> adminSet = new HashSet<>(space.getAdmins());
×
123
                        for (IRI admin : space.getAdmins()) members.add(Pair.of(admin, "(admin)"));
×
124
                        for (IRI member : space.getMembers()) {
×
125
                            if (adminSet.contains(member)) continue;
×
126
                            members.add(Pair.of(member, ""));
×
127
                        }
×
128
                        return members;
×
129
                    },
130
                (p) -> new ItemListElement("item", UserPage.class, new PageParameters().add("id", p.getLeft()), User.getShortDisplayName(p.getLeft()), p.getRight())
×
131
            ));
132

133
        add(new ItemListPanel<Space>(
×
134
                "superspaces",
135
                "Part of",
136
                space.getSuperspaces(),
×
137
                (space) -> new ItemListElement("item", SpacePage.class, new PageParameters().add("id", space), space.getLabel(), "(" + space.getTypeLabel() + ")")
×
138
            ));
139

140
        addSubspacePanel("Group");
×
141
        addSubspacePanel("Project");
×
142
        addSubspacePanel("Program");
×
143
        addSubspacePanel("Initiative");
×
144
        addSubspacePanel("Outlet");
×
145
        addSubspacePanel("Campaign");
×
146
        addSubspacePanel("Community");
×
147
        addSubspacePanel("Event");
×
148

149
        String shortId = space.getId().replace("https://w3id.org/spaces/", "");
×
150
        ConnectorConfig cc = ConnectorConfig.get(shortId);
×
151
        if (cc != null) {
×
152
            add(new BookmarkablePageLink<Void>("content-button", GenOverviewPage.class, new PageParameters().add("journal", shortId)).setBody(Model.of("Nanopublication Submissions")));
×
153
        } else {
154
            add(new Label("content-button").setVisible(false));
×
155
        }
156
    }
×
157

158
    private void addSubspacePanel(String type) {
159
        String typePl = type + "s";
×
160
        typePl = typePl.replaceFirst("ys$", "ies");
×
161

162
        add(new ItemListPanel<Space>(
×
163
                typePl.toLowerCase(),
×
164
                typePl,
165
                space.getSubspaces("https://w3id.org/kpxl/gen/terms/" + type),
×
166
                (space) -> new ItemListElement("item", SpacePage.class, new PageParameters().add("id", space), space.getLabel())
×
167
            ));
168
    }
×
169

170
    /**
171
     * Checks if auto-refresh is enabled for this page.
172
     *
173
     * @return true if auto-refresh is enabled, false otherwise
174
     */
175
    protected boolean hasAutoRefreshEnabled() {
176
        return true;
×
177
    }
178

179
}
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