Repository navigation
Conversation
mswiderski
left a comment
There was a problem hiding this comment.
nice work, especially around the Resolver
7668b6b to
41b2343
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The immutable image list breaks descriptor generation, and valid input structures can produce missing or incorrect resource paths.
5 open issues
Keep descriptor image list mutable during image collection · New Escape non-identifier JSON property names in generated paths · New Preserve generic type arguments during model traversal · New Traverse wildcard upper bounds when resolving resource IDs · New Resolve Jackson annotations from complete property accessors · New
What changed in this PR
This PR adds unique-resource metadata to service model descriptors. It derives resource types and JSONPath expressions from model-input annotations for downstream resource reporting.
Changes:
- Adds
@UniqueResourceIdand descriptor storage for resource types and paths. - Integrates build-time path discovery into Quarkus descriptor generation.
- Adds resolver tests and an end-to-end descriptor test.
| File | Description |
|---|---|
service/definition/src/main/java/ai/timefold/solver/service/definition/api/ModelDescriptor.java |
Stores and copies resource metadata; changes collection defaults. |
service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResourceId.java |
Defines the resource-ID annotation. |
service/definition/src/main/java/ai/timefold/solver/service/definition/internal/descriptor/usage/UniqueResource.java |
Pairs a resource type with its JSONPath. |
service/quarkus/deployment/src/main/java/ai/timefold/solver/service/quarkus/deployment/TimefoldModelDescriptorProcessor.java |
Adds resource metadata during descriptor generation. |
service/quarkus/deployment/src/main/java/ai/timefold/solver/service/quarkus/deployment/descriptor/ResourceIdPathResolver.java |
Traverses indexed input fields to derive resource paths. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/ModelDescriptorUniqueResourcesTest.java |
Checks generated descriptor resource entries. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/descriptor/UniqueResourceIdPathResolverTest.java |
Tests traversal, field annotations, and blank resource types. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataVisit.java |
Provides an annotated visit ID. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataVehicle.java |
Provides an annotated vehicle ID and nested visits. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataSolution.java |
Provides the test model input structure. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataRest.java |
Supplies the test model REST interface. |
service/quarkus/deployment/src/test/java/ai/timefold/solver/service/quarkus/deployment/testdata/uniqueresource/TestdataConstraintProvider.java |
Supplies a constraint for the test deployment. |
Review effort: Balanced
| private static String jsonName(FieldInfo field) { | ||
| var jsonProperty = field.declaredAnnotation(JSON_PROPERTY); |
There was a problem hiding this comment.
This and other problems. E.g. handling @JsonBackReference and other Jackson advanced features.
Also, we don't check the super classes or interfaces where the user can define the ID.
Given these complications, I am not sure if I like it more than the original proposal @mswiderski .
There was a problem hiding this comment.
let's not over-engineer this - it is only for our models and we know we can do it reliably.
|
This pull request, as it stands, would leave the Solver documentation stale in the places below. An automated check found them and can be wrong.
[#uniqueResourceIds]
== Unique resource IDs
Annotate each resource identifier that must be unique within its resource type with `@UniqueResourceId` from `ai.timefold.solver.service.definition.api.usage`.
[source,java]
----
@UniqueResourceId(type = "vehicle")
private String id;
----
The service uses the annotation to report the resource type and the JSONPath to the identifier in the model input.
The generated model descriptor exposes these resources through `uniqueResources`.
Each entry contains `resourceType` and `resourceIdJsonPath`, such as `vehicle` and `$.vehicles[*].id`.The fix goes into this
|
41b2343 to
060e71e
Compare
| private static void visitType(IndexView index, Type type, String path, Set<DotName> visitingSet, | ||
| List<UniqueResource> resourceList) { | ||
| switch (type.kind()) { | ||
| case ARRAY -> visitType(index, type.asArrayType().elementType(), path + "[*]", visitingSet, resourceList); |


Fixes https://github.com/TimefoldAI/timefold-solver-enterprise/issues/930.
An alternative to #2769.