@@ -317,10 +317,10 @@ public void setValue(PathogenTestDto newFieldValue) throws ReadOnlyException, Co
317317 }
318318 typingIdField .setValue (newFieldValue .getTypingId ());
319319 specieField .setValue (newFieldValue .getSpecie ());
320- if (!genoTypingCB .isReadOnly ()) {
320+ if (!genoTypingCB .isReadOnly ()) {
321321 genoTypingCB .setValue (newFieldValue .getGenoTypeResult ());
322322 // We only set the genotyping result text if the genotyping result is not read only
323- if (!genoTypingResultTextTF .isReadOnly ()) {
323+ if (!genoTypingResultTextTF .isReadOnly ()) {
324324 genoTypingResultTextTF .setValue (newFieldValue .getGenoTypeResultText ());
325325 }
326326 }
@@ -362,22 +362,27 @@ protected void addFields() {
362362 I18nProperties .getPrefixCaption (SampleDto .I18N_PREFIX , SampleDto .SAMPLE_DATE_TIME ),
363363 DateFormatHelper .formatDate (getSampleDate ()))));
364364 testDateField .addValueChangeListener (e -> {
365- boolean hasTime = !getSampleDate ().toInstant ().atZone (ZoneId .systemDefault ()).toLocalDate ().equals (LocalTime .MIDNIGHT );
366- if (hasTime ) {
367- testDateField .removeAllValidators ();
368- testDateField .addValidator (
369- new DateComparisonValidator (
370- testDateField ,
371- this ::getSampleDate ,
372- false ,
373- false ,
374- false ,
375- I18nProperties .getValidationError (
376- Validations .afterDateWithDate ,
377- testDateField .getCaption (),
378- I18nProperties .getPrefixCaption (SampleDto .I18N_PREFIX , SampleDto .SAMPLE_DATE_TIME ),
379- DateFormatHelper .formatLocalDateTime (getSampleDate ()))));
365+ boolean hasTime =
366+ getSampleDate () != null && !getSampleDate ().toInstant ().atZone (ZoneId .systemDefault ()).toLocalDate ().equals (LocalTime .MIDNIGHT );
367+
368+ if (!hasTime ) {
369+ return ;
380370 }
371+
372+ testDateField .removeAllValidators ();
373+ testDateField .addValidator (
374+ new DateComparisonValidator (
375+ testDateField ,
376+ this ::getSampleDate ,
377+ false ,
378+ false ,
379+ false ,
380+ I18nProperties .getValidationError (
381+ Validations .afterDateWithDate ,
382+ testDateField .getCaption (),
383+ I18nProperties .getPrefixCaption (SampleDto .I18N_PREFIX , SampleDto .SAMPLE_DATE_TIME ),
384+ DateFormatHelper .formatLocalDateTime (getSampleDate ()))));
385+
381386 });
382387 ComboBox lab = addInfrastructureField (PathogenTestDto .LAB );
383388 lab .addItems (FacadeProvider .getFacilityFacade ().getAllActiveLaboratories (true ));
0 commit comments