Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 29, 2025

When OSLC systems like DOORS send date values in xsd:date format (e.g., 2020-08-10) but annotated as xsd:dateTime, parsing fails with DatatypeFormatException. In non-strict mode, this incorrectly returned UnparseableLiteral instead of a Date.

Fix: In JenaModelHelper.handleExtendedPropertyValue(), when xsd:dateTime parsing fails in non-strict mode, attempt to parse as xsd:date before falling back to UnparseableLiteral.

// Before: date-only value with dateTime type → UnparseableLiteral
// After:  date-only value with dateTime type → Date object

Tests Added:

  • testDateOnlyValueWithDateTimeType(): Verifies that date-only values (e.g., 2020-08-10) with xsd:dateTime type are correctly parsed as Date objects
  • testFullDateTimeValueStillParsesCorrectly(): Ensures that full dateTime values with time components (e.g., 2020-08-10T14:30:45Z) are still correctly parsed, confirming the fix doesn't affect normal dateTime processing

Closes #242

Checklist

  • This PR adds an entry to the CHANGELOG. See https://keepachangelog.com/en/1.0.0/ for instructions. Minor edits are exempt.
  • This PR was tested on at least one Lyo OSLC server (comment @oslc-bot /test-all if not sure) or adds unit/integration tests.
  • This PR does NOT break the API
  • Lint checks pass (run mvn package org.openrewrite.maven:rewrite-maven-plugin:run spotless:apply -DskipTests -P'!enforcer' if not, commit & push)
Original prompt

This section details on the original issue you should resolve

<issue_title>Property #createdOn could not be parsed as datatype #dateTime</issue_title>
<issue_description>I have a slight issue when trying to read requirements from DOORS via DWA via OSLC via LYO. For most attribute values this works. However, for the dates, the following error is shown:

2020-08-10 09:59:32 WARN  org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper:1132 - Property http://jazz.net/ns/rm/doors/attribute#createdOn could not be parsed as datatype http://www.w3.org/2001/XMLSchema#dateTime
org.apache.jena.datatypes.DatatypeFormatException: Lexical form '2020-08-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class org.apache.jena.datatypes.xsd.XSDDateTime] Lexical form '2020-08-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class org.apache.jena.datatypes.xsd.XSDDateTime] during parse -org.apache.xerces.impl.dv.InvalidDatatypeValueException: cvc-datatype-valid.1.2.1: '2020-08-10' is not a valid value for 'dateTime'.
	at org.apache.jena.graph.impl.LiteralLabelImpl.getValue(LiteralLabelImpl.java:338)
	at org.apache.jena.graph.Node_Literal.getLiteralValue(Node_Literal.java:44)
	at org.apache.jena.rdf.model.impl.LiteralImpl.getValue(LiteralImpl.java:98)
	at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.handleExtendedPropertyValue(JenaModelHelper.java:1120)
	at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.fromResource(JenaModelHelper.java:637)
	at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.createObjectResultList(JenaModelHelper.java:507)
	at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.fromJenaModel(JenaModelHelper.java:391)
	at org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider.readFrom(AbstractOslcRdfXmlProvider.java:349)
	at org.eclipse.lyo.oslc4j.provider.jena.OslcRdfXmlProvider.readFrom(OslcRdfXmlProvider.java:271)
	at org.apache.wink.client.internal.handlers.ClientResponseImpl.readEntity(ClientResponseImpl.java:126)
	at org.apache.wink.client.internal.handlers.ClientResponseImpl.getEntity(ClientResponseImpl.java:65)
	at org.apache.wink.client.internal.handlers.ClientResponseImpl.getEntity(ClientResponseImpl.java:52)
	at doors.api.DoorsRequirementGetter.readRequirementFromDoorsDirectlyBy(DoorsRequirementGetter.java:112)
	at doors.api.DoorsRequirementGetterTest.readRequirementFromDoorsDirectlyByShouldReturnSpecObject(DoorsRequirementGetterTest.java:89)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:205)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:201)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
	at org.junit.platform.engine....

</details>

- Fixes eclipse-lyo/lyo#46

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/eclipse-lyo/lyo/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: berezovskyi <64734+berezovskyi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix parsing issue for createdOn dateTime property Fix parsing of date-only values with xsd:dateTime type Nov 29, 2025
Copilot AI requested a review from berezovskyi November 29, 2025 11:36
@berezovskyi
Copy link
Contributor

@copilot Also add a test that ensures that the correct dateTime processing is not affected by this change, i.e. when the datetime has the time.

…ng is not affected

Co-authored-by: berezovskyi <64734+berezovskyi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot Also add a test that ensures that the correct dateTime processing is not affected by this change, i.e. when the datetime has the time.

Added testFullDateTimeValueStillParsesCorrectly() test in commit 4f10984. It verifies that a full dateTime value with time component (e.g., 2020-08-10T14:30:45Z) is correctly parsed as a Date with the proper year, month, day, hour, minute, and second values.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/lyo/lyo/core/oslc4j-jena-provider org.codehaus.plexus.classworlds.launcher.Launcher test -Dtest=UnparseableLiteralTest (dns block)
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/lyo/lyo/core/oslc4j-core-build org.codehaus.plexus.classworlds.launcher.Launcher install -DskipTests -Dmaven.javadoc.skip=true -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@berezovskyi berezovskyi marked this pull request as ready for review November 29, 2025 12:45
@berezovskyi
Copy link
Contributor

@oslc-bot /test-all

@oslc-bot
Copy link

oslc-bot commented Nov 29, 2025

Downstream Build Status

Repository Lyo CI Job state Workflow
oslc-op/refimpl ✅ Pass completed Link
oslc/lyo-samples ✅ Pass completed Link
oslc/promcode-lyo-server ✅ Pass completed Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants