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

knowledgepixels / nanodash / 18939026354

30 Oct 2025 11:24AM UTC coverage: 14.184% (-0.1%) from 14.315%
18939026354

push

github

ashleycaselli
Merge branch 'master' of github.com:knowledgepixels/nanodash

507 of 4504 branches covered (11.26%)

Branch coverage included in aggregate %.

1322 of 8391 relevant lines covered (15.75%)

0.71 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.eclipse.rdf4j.model.IRI;
11
import org.eclipse.rdf4j.model.Literal;
12
import org.eclipse.rdf4j.model.Value;
13
import org.eclipse.rdf4j.model.vocabulary.XSD;
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 AbstractContextComponent {
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, rg.getContext());
×
34
        this.value = value;
×
35
        final Template template = this.context.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, this.context);
×
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, statementPartId, rg);
×
43
            } else if (this.context.isReadOnly()) {
×
44
                if (template.isPlaceholder(iri) || template.isIntroducedResource(iri) || template.isEmbeddedResource(iri)) {
×
45
                    component = new ReadonlyItem("value", id, iri, 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(), this.context);
×
51
            } else if (template.isAgentPlaceholder(iri)) {
×
52
                component = new AgentChoiceItem("value", id, iri, rg.isOptional(), this.context);
×
53
            } else if (template.isGuidedChoicePlaceholder(iri)) {
×
54
                component = new GuidedChoiceItem("value", id, iri, rg.isOptional(), this.context);
×
55
            } else if (template.isIntroducedResource(iri) && this.context.getFillMode() == FillMode.SUPERSEDE) {
×
56
                component = new ReadonlyItem("value", id, iri, statementPartId, rg);
×
57
            } else if (template.isUriPlaceholder(iri)) {
×
58
                component = new IriTextfieldItem("value", id, iri, rg.isOptional(), this.context);
×
59
            } else if (template.isLongLiteralPlaceholder(iri)) {
×
60
                component = new LiteralTextareaItem("value", iri, rg.isOptional(), this.context);
×
61
            } else if (template.isLiteralPlaceholder(iri)) {
×
62
                // TODO add all date time types
63
                if (XSD.DATE.equals(template.getDatatype(iri))) {
×
64
                    component = new LiteralDateItem("value", iri, rg.isOptional(), this.context);
×
65
                } else if (XSD.DATETIME.equals(template.getDatatype(iri))) {
×
66
                    component = new LiteralDateTimeItem("value", iri, rg.isOptional(), this.context);
×
67
                } else {
68
                    component = new LiteralTextfieldItem("value", iri, rg.isOptional(), this.context);
×
69
                }
70
            } else if (template.isPlaceholder(iri)) {
×
71
                component = new ValueTextfieldItem("value", id, iri, rg.isOptional(), this.context);
×
72
            } else {
73
                component = new IriItem("value", id, iri, id.equals("obj"), statementPartId, rg);
×
74
            }
75
        } else {
×
76
            component = new LiteralItem("value", id, (Literal) value, rg);
×
77
        }
78
        add((Component) component);
×
79
    }
×
80

81
    /**
82
     * OnChangeAjaxBehavior that keeps the value after a refresh.
83
     */
84
    public static class KeepValueAfterRefreshBehavior extends OnChangeAjaxBehavior {
×
85

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

91
    }
92

93
    /**
94
     * {@inheritDoc}
95
     */
96
    @Override
97
    public void removeFromContext() {
98
        component.removeFromContext();
×
99
    }
×
100

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

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

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

125
    /**
126
     * {@inheritDoc}
127
     */
128
    @Override
129
    public void finalizeValues() {
130
        component.finalizeValues();
×
131
    }
×
132

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

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

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

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