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

knowledgepixels / nanodash / 17837235071

18 Sep 2025 05:58PM UTC coverage: 13.87%. Remained the same
17837235071

push

github

tkuhn
chore: Remove serialVersionUIDs

443 of 4022 branches covered (11.01%)

Branch coverage included in aggregate %.

1133 of 7341 relevant lines covered (15.43%)

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/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 ContextComponent component;
22
    private Value value;
23

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

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

79
        @Override
80
        protected void onUpdate(AjaxRequestTarget target) {
81
            // No actual action needed here; Ajax request alone ensures values are kept after refreshing.
82
        }
×
83

84
    }
85

86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    public void removeFromContext() {
91
        component.removeFromContext();
×
92
    }
×
93

94
    /**
95
     * {@inheritDoc}
96
     */
97
    @Override
98
    public boolean isUnifiableWith(Value v) {
99
        return component.isUnifiableWith(v);
×
100
    }
101

102
    /**
103
     * {@inheritDoc}
104
     */
105
    @Override
106
    public void unifyWith(Value v) throws UnificationException {
107
        component.unifyWith(v);
×
108
    }
×
109

110
    /**
111
     * {@inheritDoc}
112
     */
113
    @Override
114
    public void fillFinished() {
115
        component.fillFinished();
×
116
    }
×
117

118
    /**
119
     * {@inheritDoc}
120
     */
121
    @Override
122
    public void finalizeValues() {
123
        component.finalizeValues();
×
124
    }
×
125

126
    /**
127
     * Get the value represented by this ValueItem.
128
     *
129
     * @return the value
130
     */
131
    public Value getValue() {
132
        return value;
×
133
    }
134

135
    /**
136
     * Get the component that represents this ValueItem.
137
     *
138
     * @return the ContextComponent that represents this ValueItem
139
     */
140
    public ContextComponent getComponent() {
141
        return component;
×
142
    }
143

144
    /**
145
     * <p>toString.</p>
146
     *
147
     * @return a {@link java.lang.String} object
148
     */
149
    public String toString() {
150
        return component.toString();
×
151
    }
152

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