Revision f8fda7a9
Added by Andreas Kohlbecker about 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/data/validator/PartialCompletenesValidator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.data.validator; |
|
10 |
|
|
11 |
import org.joda.time.DateTimeFieldType; |
|
12 |
import org.joda.time.Partial; |
|
13 |
|
|
14 |
import com.vaadin.data.Validator; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author a.kohlbecker |
|
18 |
* @since Mar 27, 2019 |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class PartialCompletenesValidator implements Validator { |
|
22 |
|
|
23 |
private static final long serialVersionUID = -2739242148516872452L; |
|
24 |
|
|
25 |
@Override |
|
26 |
public void validate(Object value) throws InvalidValueException { |
|
27 |
if(value != null){ |
|
28 |
Partial partial = (Partial)value; |
|
29 |
|
|
30 |
if(partial.isSupported(DateTimeFieldType.monthOfYear()) |
|
31 |
&& !partial.isSupported(DateTimeFieldType.year()) |
|
32 |
){ |
|
33 |
throw new InvalidValueException("The Partial must support year if monthOfYear is set"); |
|
34 |
} |
|
35 |
if(partial.isSupported(DateTimeFieldType.dayOfMonth()) |
|
36 |
&& ! ( |
|
37 |
partial.isSupported(DateTimeFieldType.monthOfYear()) |
|
38 |
&& partial.isSupported(DateTimeFieldType.year()) |
|
39 |
) |
|
40 |
){ |
|
41 |
throw new InvalidValueException("The Partial must support monthOfYear and year if dayOfMonth is set"); |
|
42 |
} |
|
43 |
} |
|
44 |
} |
|
45 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/data/validator/TimePeriodCompletenesValidator.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.vaadin.data.validator; |
|
10 |
|
|
11 |
import com.vaadin.data.Validator; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author a.kohlbecker |
|
17 |
* @since Mar 27, 2019 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class TimePeriodCompletenesValidator implements Validator { |
|
21 |
|
|
22 |
private static final long serialVersionUID = 4651375734846907644L; |
|
23 |
|
|
24 |
PartialCompletenesValidator partialValidator = new PartialCompletenesValidator(); |
|
25 |
|
|
26 |
@Override |
|
27 |
public void validate(Object value) throws InvalidValueException { |
|
28 |
if(value != null){ |
|
29 |
TimePeriod timePeriod = (TimePeriod)value; |
|
30 |
if(timePeriod .getStart() != null){ |
|
31 |
partialValidator.validate(timePeriod.getEndDay()); |
|
32 |
} |
|
33 |
if(timePeriod.getEnd() != null){ |
|
34 |
partialValidator.validate(timePeriod.getEnd()); |
|
35 |
} |
|
36 |
} |
|
37 |
} |
|
38 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
40 | 40 |
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField; |
41 | 41 |
import eu.etaxonomy.cdm.vaadin.component.common.VerbatimTimePeriodField; |
42 | 42 |
import eu.etaxonomy.cdm.vaadin.data.validator.InReferenceTypeValidator; |
43 |
import eu.etaxonomy.cdm.vaadin.data.validator.TimePeriodCompletenesValidator; |
|
43 | 44 |
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction; |
44 | 45 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
45 | 46 |
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions; |
... | ... | |
151 | 152 |
*/ |
152 | 153 |
int row = 0; |
153 | 154 |
datePublishedField = new VerbatimTimePeriodField("Date published"); |
155 |
datePublishedField.addValidator(new TimePeriodCompletenesValidator()); |
|
154 | 156 |
addField(datePublishedField, "datePublished", 0, row, 1, row); |
155 | 157 |
typeSelect = new NativeSelect("Reference type"); |
156 | 158 |
typeSelect.addItems(referenceTypes); |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
478 | 478 |
} |
479 | 479 |
|
480 | 480 |
|
481 |
|
|
482 |
|
|
483 | 481 |
/** |
484 | 482 |
* Creates a new Registration for an exiting (previously published) name. |
485 | 483 |
* |
Also available in: Unified diff
fix #7968 validators for completeness of Partial and TimePeriod