@Test public void testYear() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.eventDate.qualifiedName(), "1879"); ExtendedRecord er = ExtendedRecord.newBuilder().setId("1").setCoreTerms(map).build(); TemporalRecord tr = TemporalRecord.newBuilder().setId("1").build(); TemporalInterpreter interpreter = TemporalInterpreter.builder().create(); interpreter.interpretTemporal(er, tr); assertEquals("1879", tr.getEventDate().getGte()); assertNull(tr.getEventDate().getLte()); assertEquals(1879, tr.getYear().intValue()); assertNull(tr.getMonth()); assertNull(tr.getDay()); assertEquals(0, tr.getIssues().getIssueList().size()); }
public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); }
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } }
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private  TemporalInterpreter(
      List<DateComponentOrdering> orderings,
      SerializableFunction<String, String> preprocessDateFn); }
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private  TemporalInterpreter(
      List<DateComponentOrdering> orderings,
      SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr); }
TemporalInterpreter implements Serializable { public void interpretTemporal(ExtendedRecord er, TemporalRecord tr) { String year = extractValue(er, DwcTerm.year); String month = extractValue(er, DwcTerm.month); String day = extractValue(er, DwcTerm.day); String eventDate = extractValue(er, DwcTerm.eventDate); String normalizedEventDate = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(eventDate)).orElse(eventDate); EventRange eventRange = temporalRangeParser.parse(year, month, day, normalizedEventDate); eventRange .getFrom() .map(AtomizedLocalDate::fromTemporalAccessor) .ifPresent( ald -> { tr.setYear(ald.getYear()); tr.setMonth(ald.getMonth()); tr.setDay(ald.getDay()); }); EventDate ed = new EventDate(); eventRange.getFrom().map(TemporalAccessor::toString).ifPresent(ed::setGte); eventRange.getTo().map(TemporalAccessor::toString).ifPresent(ed::setLte); tr.setEventDate(ed); addIssueSet(tr, eventRange.getIssues()); } @Builder(buildMethodName = "create") private  TemporalInterpreter(
      List<DateComponentOrdering> orderings,
      SerializableFunction<String, String> preprocessDateFn); void interpretTemporal(ExtendedRecord er, TemporalRecord tr); void interpretModified(ExtendedRecord er, TemporalRecord tr); void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr);  }