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

knowledgepixels / nanodash / 18653097879

20 Oct 2025 01:11PM UTC coverage: 13.053% (-0.5%) from 13.583%
18653097879

push

github

web-flow
Merge pull request #265 from knowledgepixels/252-datetime-picker-datetime-literal-placeholders

Add date pickers for date/datetime literal placeholders

450 of 4316 branches covered (10.43%)

Branch coverage included in aggregate %.

1157 of 7995 relevant lines covered (14.47%)

0.65 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.eclipse.rdf4j.model.vocabulary.XSD;
15
import org.nanopub.vocabulary.NTEMPLATE;
16

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

22
    private ContextComponent component;
23
    private Value value;
24

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

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

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

92
    }
93

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

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

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

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

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

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

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

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

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