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

knowledgepixels / nanodash / 27831881428

19 Jun 2026 02:34PM UTC coverage: 26.652% (+0.07%) from 26.583%
27831881428

push

github

web-flow
Merge pull request #489 from knowledgepixels/feat/per-type-preset-templates

feat: per-type "add preset" templates (type-filtered preset choice)

1553 of 6847 branches covered (22.68%)

Branch coverage included in aggregate %.

3421 of 11816 relevant lines covered (28.95%)

4.26 hits per line

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

0.0
src/main/java/com/knowledgepixels/nanodash/component/AboutPartPanel.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.QueryApiAccess;
4
import com.google.common.collect.ArrayListMultimap;
5
import com.google.common.collect.Multimap;
6
import com.knowledgepixels.nanodash.Utils;
7
import com.knowledgepixels.nanodash.View;
8
import com.knowledgepixels.nanodash.ViewDisplay;
9
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
10
import com.knowledgepixels.nanodash.domain.User;
11
import org.apache.wicket.markup.html.panel.Panel;
12
import org.eclipse.rdf4j.model.IRI;
13
import org.nanopub.extra.services.QueryRef;
14

15
import java.util.Set;
16

17
/**
18
 * The "About" tab body for a resource part: an "ℹ️ Info" table (the part's type,
19
 * owning resource, and defining nanopub), the presets assigned to the part's
20
 * owning resource, and that resource's configured view displays each flagged
21
 * (displayed_here) for this specific part (issue #302). The presets and view displays
22
 * are inherited from the owning resource (a part has none of its own); the view
23
 * displays are managed on the owning resource, where part-level views live.
24
 */
25
public class AboutPartPanel extends Panel {
26

27
    /**
28
     * The "ℹ️ Info" view for a part: a key-value table (Type / Belongs to / Defined
29
     * in) sourced from the part's defining nanopub, found among the owning resource's
30
     * space members' pubkeys (as on the part page itself).
31
     */
32
    public static final String PART_INFO_VIEW = "https://w3id.org/np/RAKMu5L23lMUfZe-DSGopJTRFHBh-drfvazSDC6ZocxhU/part-info-view";
33

34
    /**
35
     * The "⬜ View displays" view for a part: the owning resource's view displays,
36
     * each flagged for this specific part via the partid/partclass parameters.
37
     */
38
    public static final String PART_VIEW_DISPLAYS_VIEW = "https://w3id.org/np/RACcSq7Rz961_1pIB0FYGRbVHAUiVCeXcJsqlCLs0TxpE/part-view-displays-view";
39

40
    /**
41
     * @param id          the Wicket markup id
42
     * @param context     the part's owning resource (maintained resource, space, or user)
43
     * @param partId      the part IRI
44
     * @param partClasses the part's own RDF types (used to flag which of the owning
45
     *                    resource's views are shown on this part)
46
     */
47
    public AboutPartPanel(String id, AbstractResourceWithProfile context, String partId, Set<IRI> partClasses) {
48
        super(id);
×
49

50
        // Info: the part's type / owning resource / defining nanopub, read from the
51
        // part's defining nanopub. As on the part page, the definition is looked up
52
        // among the owning resource's space members' pubkeys (or the owning user's).
53
        View infoView = View.get(PART_INFO_VIEW);
×
54
        Multimap<String, String> infoParams = ArrayListMultimap.create();
×
55
        infoParams.put("partid", partId);
×
56
        infoParams.put("context", context.getId());
×
57
        if (context.getSpace() != null) {
×
58
            for (IRI userIri : context.getSpace().getUsers()) {
×
59
                for (String pubkey : User.getUserData().getPubkeyHashes(userIri, true)) {
×
60
                    infoParams.put("pubkey", pubkey);
×
61
                }
×
62
            }
×
63
        } else {
64
            for (String pubkey : User.getUserData().getPubkeyHashes(Utils.vf.createIRI(context.getId()), true)) {
×
65
                infoParams.put("pubkey", pubkey);
×
66
            }
×
67
        }
68
        add(QueryResultTableBuilder.create("info", new QueryRef(infoView.getQuery().getQueryId(), infoParams), new ViewDisplay(infoView)).resourceWithProfile(context).id(context.getId()).contextId(context.getId()).build());
×
69

70
        // Presets are assigned to the owning resource (a part has none of its own),
71
        // so this lists the owning resource's presets. Uses the maintained-resource preset
72
        // view, so the "add preset" action links the maintained-resource template and
73
        // pre-fills the owning resource IRI (id = context), not the part.
74
        View presetsView = View.get(AboutResourcePanel.MAINTAINED_RESOURCE_PRESET_ASSIGNMENTS_VIEW);
×
75
        add(QueryResultTableBuilder.create("presets", new QueryRef(presetsView.getQuery().getQueryId(), "resource", context.getId()), new ViewDisplay(presetsView)).resourceWithProfile(context).id(context.getId()).contextId(context.getId()).build());
×
76

77
        // View displays: the owning resource's displays (resource = context, for the
78
        // display set + admin/maintainer auth), with displayed_here computed for THIS part
79
        // (partid + the part's classes). id = context so the view's "add view display"
80
        // action creates a display on the owning resource (where part-level views live,
81
        // and so the new display appears in this list).
82
        View vdView = View.get(PART_VIEW_DISPLAYS_VIEW);
×
83
        Multimap<String, String> vdParams = ArrayListMultimap.create();
×
84
        vdParams.put("resource", context.getId());
×
85
        vdParams.put("partid", partId);
×
86
        for (IRI partClass : partClasses) {
×
87
            vdParams.put("partclass", partClass.stringValue());
×
88
        }
×
89
        add(QueryResultTableBuilder.create("viewdisplays", new QueryRef(QueryApiAccess.LIST_PART_VIEW_DISPLAYS, vdParams), new ViewDisplay(vdView)).resourceWithProfile(context).id(context.getId()).contextId(context.getId()).build());
×
90
    }
×
91

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