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

knowledgepixels / nanodash / 17302137193

28 Aug 2025 04:35PM UTC coverage: 11.965% (-0.4%) from 12.355%
17302137193

Pull #244

github

web-flow
Merge 4e969b0ee into 3323a35f1
Pull Request #244: Use vocabularies with latest version of `nanopub-java`

331 of 3840 branches covered (8.62%)

Branch coverage included in aggregate %.

943 of 6808 relevant lines covered (13.85%)

0.61 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/ValueItem.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.component.PublishForm.FillMode;
4
import com.knowledgepixels.nanodash.component.StatementItem.RepetitionGroup;
5
import com.knowledgepixels.nanodash.template.Template;
6
import com.knowledgepixels.nanodash.template.UnificationException;
7
import org.apache.wicket.Component;
8
import org.apache.wicket.ajax.AjaxRequestTarget;
9
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
10
import org.apache.wicket.markup.html.panel.Panel;
11
import org.eclipse.rdf4j.model.IRI;
12
import org.eclipse.rdf4j.model.Literal;
13
import org.eclipse.rdf4j.model.Value;
14
import org.nanopub.vocabulary.NTEMPLATE;
15

16
/**
17
 * ValueItem is a panel that represents a single value in a statement.
18
 */
19
public class ValueItem extends Panel implements ContextComponent {
20

21
    private static final long serialVersionUID = 1L;
22

23
    private ContextComponent component;
24
    private Value value;
25

26
    /**
27
     * Constructor for ValueItem.
28
     *
29
     * @param id              the component id
30
     * @param value           the value to be represented
31
     * @param statementPartId the IRI of the statement part this value belongs to
32
     * @param rg              the repetition group this value is part of
33
     */
34
    public ValueItem(String id, Value value, IRI statementPartId, RepetitionGroup rg) {
35
        super(id);
×
36
        this.value = value;
×
37
        final Template template = rg.getContext().getTemplate();
×
38
        if (value instanceof IRI) {
×
39
            IRI iri = (IRI) value;
×
40
            if (template.isSequenceElementPlaceholder(iri)) {
×
41
                component = new SequenceElementItem("value", iri, rg.getRepeatIndex() + 1, rg.getContext());
×
42
            } else if (iri.equals(NTEMPLATE.CREATOR_PLACEHOLDER)) {
×
43
                // This is a special placeholder that is always read-only
44
                component = new ReadonlyItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
45
            } else if (rg.getContext().isReadOnly()) {
×
46
                if (template.isPlaceholder(iri)) {
×
47
                    component = new ReadonlyItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
48
                } else {
49
                    component = new IriItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
50
                }
51
            } else if (template.isRestrictedChoicePlaceholder(iri)) {
×
52
                component = new RestrictedChoiceItem("value", id, iri, rg.isOptional(), rg.getContext());
×
53
            } else if (template.isAgentPlaceholder(iri)) {
×
54
                component = new AgentChoiceItem("value", id, iri, rg.isOptional(), rg.getContext());
×
55
            } else if (template.isGuidedChoicePlaceholder(iri)) {
×
56
                component = new GuidedChoiceItem("value", id, iri, rg.isOptional(), rg.getContext());
×
57
            } else if (template.isIntroducedResource(iri) && rg.getContext().getFillMode() == FillMode.SUPERSEDE) {
×
58
                component = new ReadonlyItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
59
            } else if (template.isUriPlaceholder(iri)) {
×
60
                component = new IriTextfieldItem("value", id, iri, rg.isOptional(), rg.getContext());
×
61
            } else if (template.isLongLiteralPlaceholder(iri)) {
×
62
                component = new LiteralTextareaItem("value", iri, rg.isOptional(), rg.getContext());
×
63
            } else if (template.isLiteralPlaceholder(iri)) {
×
64
                component = new LiteralTextfieldItem("value", iri, rg.isOptional(), rg.getContext());
×
65
            } else if (template.isPlaceholder(iri)) {
×
66
                component = new ValueTextfieldItem("value", id, iri, rg.isOptional(), rg.getContext());
×
67
            } else {
68
                component = new IriItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
69
            }
70
        } else {
×
71
            component = new LiteralItem("value", id, (Literal) value, rg);
×
72
        }
73
        add((Component) component);
×
74
    }
×
75

76
    /**
77
     * OnChangeAjaxBehavior that keeps the value after a refresh.
78
     */
79
    public static class KeepValueAfterRefreshBehavior extends OnChangeAjaxBehavior {
×
80

81
        private static final long serialVersionUID = 1L;
82

83
        @Override
84
        protected void onUpdate(AjaxRequestTarget target) {
85
            // No actual action needed here; Ajax request alone ensures values are kept after refreshing.
86
        }
×
87

88
    }
89

90
    /**
91
     * {@inheritDoc}
92
     */
93
    @Override
94
    public void removeFromContext() {
95
        component.removeFromContext();
×
96
    }
×
97

98
    /**
99
     * {@inheritDoc}
100
     */
101
    @Override
102
    public boolean isUnifiableWith(Value v) {
103
        return component.isUnifiableWith(v);
×
104
    }
105

106
    /**
107
     * {@inheritDoc}
108
     */
109
    @Override
110
    public void unifyWith(Value v) throws UnificationException {
111
        component.unifyWith(v);
×
112
    }
×
113

114
    /**
115
     * {@inheritDoc}
116
     */
117
    @Override
118
    public void fillFinished() {
119
        component.fillFinished();
×
120
    }
×
121

122
    /**
123
     * {@inheritDoc}
124
     */
125
    @Override
126
    public void finalizeValues() {
127
        component.finalizeValues();
×
128
    }
×
129

130
    /**
131
     * Get the value represented by this ValueItem.
132
     *
133
     * @return the value
134
     */
135
    public Value getValue() {
136
        return value;
×
137
    }
138

139
    /**
140
     * Get the component that represents this ValueItem.
141
     *
142
     * @return the ContextComponent that represents this ValueItem
143
     */
144
    public ContextComponent getComponent() {
145
        return component;
×
146
    }
147

148
    /**
149
     * <p>toString.</p>
150
     *
151
     * @return a {@link java.lang.String} object
152
     */
153
    public String toString() {
154
        return component.toString();
×
155
    }
156

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