Migrate lyo-client-samples to oslc-domains#274
Migrate lyo-client-samples to oslc-domains#274google-labs-jules[bot] wants to merge 9 commits intomainfrom
Conversation
Updated lyo-client-samples to use domain classes from oslc-domains artifact instead of the legacy oslc-java-client-resources. Updated pom.xml to depend on oslc-domains. Modified samples to handle API changes: - Package changes for QM, CM, RM, Automation domains. - Set types handling (Set<Link> instead of arrays). - Added missing constants in IConstants.java. - Handled ParameterInstance type change in AutomationRequest (changed from array to Set<Link>). - Replaced getRdfTypes() with getTypes().iterator().next().
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
Updated lyo-client-samples to use domain classes from oslc-domains artifact instead of the legacy oslc-java-client-resources. Updated pom.xml to depend on oslc-domains. Modified samples to handle API changes: - Package changes for QM, CM, RM, Automation domains. - Set types handling (Set<Link> instead of arrays). - Added missing constants in IConstants.java. - Handled ParameterInstance type change in AutomationRequest (changed from array to Set<Link>). - Replaced getRdfTypes() with setting rdf:type via setTypes() and retrieving it via getTypes(). - Verified with mvn verify.
There was a problem hiding this comment.
Pull request overview
This PR migrates lyo-client-samples from the legacy oslc-java-client-resources artifact to the standard-compliant oslc-domains artifact. The migration addresses API differences where the new library uses Set<Link> for relationships instead of arrays, and requires explicit handling of extended properties for vendor-specific attributes.
- Updated Maven dependency from
oslc-java-client-resourcestooslc-domains - Migrated resource class imports to new package structure (e.g.,
org.eclipse.lyo.oslc.domains.cm.ChangeRequest) - Adapted code to handle
Set<Link>for relationships and state properties instead of URI arrays - Defined missing OSLC Automation constants that were previously in
AutomationConstants
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Updated Maven dependency to use oslc-domains instead of legacy oslc-java-client-resources |
| RMSample.java | Fixed incorrect use of setTitle() to setDescription() and updated Requirement import |
| CMSample.java | Fixed incorrect use of setTitle() to setDescription() and updated ChangeRequest import |
| IConstants.java | Added OSLC Automation constants previously available in removed AutomationConstants class |
| IAutomationRequestHandler.java | Updated imports for AutomationRequest and AutomationResult to new package |
| AutomationRequestCanceledException.java | Updated AutomationRequest import to new package |
| AutomationAdapter.java | Adapted to use Set<Link> for state/parameter properties, added defensive handling for dcterms:relation, and used newly defined constants |
| ETMAutomationSample.java | Updated to handle Set<Link> for input parameters and verdicts instead of arrays |
| EWMSample.java | Used extended properties for non-standard attributes and fully-qualified Collections.singleton() calls |
| ETMSample.java | Added setTypes() call for resource type and imported Collections |
| ERMSample.java | Defined Jazz-specific RM constants and adapted setInstanceShape() and collection methods to use Set<Link> |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lyo-client-samples/src/main/java/org/eclipse/lyo/samples/client/jazz/EWMSample.java
Outdated
Show resolved
Hide resolved
...les/src/main/java/org/eclipse/lyo/samples/client/jazz/automation/impl/AutomationAdapter.java
Outdated
Show resolved
Hide resolved
| // testedByTestCase is not part of standard OSLC CM 2.0 ChangeRequest, so we use extended properties. | ||
| // Note: In oslc-java-client-resources it was available, but in oslc-domains it is strict to spec. | ||
| // Jazz uses http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/testedByTestCase ? | ||
| // Actually, the original code used addTestedByTestCase(Link). | ||
| // We'll use the QName for it. | ||
| // However, the property name in Jazz might be "http://open-services.net/ns/cm#testedByTestCase" or similar | ||
| // if it was generated. | ||
| // The method name `addTestedByTestCase` suggests `testedByTestCase`. | ||
| // Let's assume it is in the oslc_cm namespace or rtc_cm namespace. | ||
| // Based on previous resources, it was often `oslc_cm:testedByTestCase`. |
There was a problem hiding this comment.
This verbose comment block contains speculative reasoning and uncertainty. Consider condensing to a single clear statement: 'testedByTestCase is a vendor-specific extension not in standard OSLC CM 2.0, stored in extended properties using the oslc_cm namespace.'
| // testedByTestCase is not part of standard OSLC CM 2.0 ChangeRequest, so we use extended properties. | |
| // Note: In oslc-java-client-resources it was available, but in oslc-domains it is strict to spec. | |
| // Jazz uses http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/testedByTestCase ? | |
| // Actually, the original code used addTestedByTestCase(Link). | |
| // We'll use the QName for it. | |
| // However, the property name in Jazz might be "http://open-services.net/ns/cm#testedByTestCase" or similar | |
| // if it was generated. | |
| // The method name `addTestedByTestCase` suggests `testedByTestCase`. | |
| // Let's assume it is in the oslc_cm namespace or rtc_cm namespace. | |
| // Based on previous resources, it was often `oslc_cm:testedByTestCase`. | |
| // testedByTestCase is a vendor-specific extension not in standard OSLC CM 2.0, stored in extended properties using the oslc_cm namespace. |
There was a problem hiding this comment.
| // Note: The new oslc-domains AutomationRequest maps inputParameter to Set<Link>. | ||
| // If the parameter is an inline resource (as is common in Automation), the Link might | ||
| // not contain the detailed properties (name, value) unless we fetch it or parse the model manually. | ||
| // For now, we log the link. |
There was a problem hiding this comment.
[nitpick] This comment clearly explains a limitation in the migration. However, consider adding a TODO or FIXME to indicate this is incomplete functionality that should be addressed in the future.
| // For now, we log the link. | |
| // TODO: For now, we log the link. Improve this to fetch or parse inline resource properties if needed. |
Updated lyo-client-samples to use domain classes from oslc-domains artifact instead of the legacy oslc-java-client-resources. Updated pom.xml to depend on oslc-domains. Refactored samples to: - Use oslc-domains classes (AutomationRequest, AutomationResult, etc.) - Use oslc-domains constants where available (Oslc_autoDomainConstants, Oslc_qmDomainConstants). - Handle API changes (e.g. Set<Link> for relationships). - Explicitly set rdf:type using setTypes() for CreationFactory lookups. - Ensure tests pass.
…mples-to-oslc-domains Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
…t/jazz/automation/impl/AutomationAdapter.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| serviceProviderUrl, | ||
| OSLCConstants.OSLC_CM_V2, | ||
| defect.getRdfTypes()[0].toString(), | ||
| defect.getTypes().iterator().next().toString(), |
There was a problem hiding this comment.
The code calls getTypes().iterator().next() without first checking if the Set is empty. If setTypes was never called or was called with an empty Set, this will throw a NoSuchElementException. Add a null/empty check before accessing the iterator, or ensure setTypes is always called with a non-empty Set.
| defect.getTypes().iterator().next().toString(), | |
| OSLCConstants.CM_CHANGE_REQUEST_TYPE, |
| assertNotCanceled(request); | ||
|
|
||
| request.setStates(new URI[] {URI.create(AutomationConstants.STATE_COMPLETE)}); | ||
| // oslc-domains AutomationRequest.setState uses Set<Link> |
There was a problem hiding this comment.
The comment references "oslc-domains AutomationRequest.setState uses Set<Link>" but doesn't mention that the old API used URI[]. While the comment is helpful, consider clarifying that this is a migration from the previous API (e.g., "The old API used URI[], but oslc-domains AutomationRequest.setState uses Set<Link>").
| // oslc-domains AutomationRequest.setState uses Set<Link> | |
| // Migration note: the old API used URI[], but oslc-domains AutomationRequest.setState now uses Set<Link> |
| // Constants for States and Verdicts are not in Oslc_autoDomainConstants, but defined in spec. | ||
| // We keep them here or use hardcoded strings if not available in domains library. | ||
| // The constants AUTOMATION_NAMSPACE is available. | ||
| String STATE_COMPLETE = Oslc_autoDomainConstants.AUTOMATION_NAMSPACE + "Complete"; |
There was a problem hiding this comment.
There's a typo in the constant name from the oslc-domains library: 'AUTOMATION_NAMSPACE' should be 'AUTOMATION_NAMESPACE' (missing 'E'). This appears to be an issue in the oslc-domains library itself, not this PR. The comment correctly notes this constant is available and being used. Consider filing an issue with the oslc-domains project to fix this typo in their constant names.
| serviceProviderUrl, OSLCConstants.OSLC_QM_V2, testcase.getRdfTypes()[0].toString()); | ||
| serviceProviderUrl, | ||
| OSLCConstants.OSLC_QM_V2, | ||
| testcase.getTypes().iterator().next().toString()); |
There was a problem hiding this comment.
The code calls getTypes().iterator().next() without first checking if the Set is empty. If setTypes was never called or was called with an empty Set, this will throw a NoSuchElementException. Add a null/empty check before accessing the iterator, or ensure setTypes is always called with a non-empty Set.
| testcase.getTypes().iterator().next().toString()); | |
| OSLCConstants.OSLC_QM_V2 + "TestCase"); |
| // PROPERTY_PARENT_FOLDER = new QName(JAZZ_RM_NAMESPACE, "parent") | ||
| // NAMESPACE_URI_XHTML = "http://www.w3.org/1999/xhtml" | ||
|
|
||
| public static final String JAZZ_RM_NAMESPACE = "http://jazz.net/ns/rm#"; |
There was a problem hiding this comment.
The JAZZ_RM_NAMESPACE has been changed from "http://jazz.net/xmlns/prod/jazz/rm/1.0/" to "http://jazz.net/ns/rm#". This is a significant namespace change that could break compatibility with existing IBM ERM deployments. The old namespace appears to be the vendor-specific Jazz/IBM namespace, while the new one appears different. Verify that this namespace change is intentional and correct for the migration to oslc-domains. If the old RmConstants used the vendor-specific namespace, this change might cause the properties (primaryText, parent) to not be recognized by the server.
| public static final String JAZZ_RM_NAMESPACE = "http://jazz.net/ns/rm#"; | |
| public static final String JAZZ_RM_NAMESPACE = "http://jazz.net/xmlns/prod/jazz/rm/1.0/"; |
| serviceProviderUrl, | ||
| OSLCConstants.OSLC_CM_V2, | ||
| task.getRdfTypes()[0].toString(), | ||
| task.getTypes().iterator().next().toString(), |
There was a problem hiding this comment.
The code calls getTypes().iterator().next() without first checking if the Set is empty. If setTypes was never called or was called with an empty Set, this will throw a NoSuchElementException. Add a null/empty check before accessing the iterator, or ensure setTypes is always called with a non-empty Set.
Migrate lyo-client-samples to use oslc-domains artifact instead of oslc-java-client-resources.
This involves updating imports, handling API differences (e.g., Set for relationships), and defining missing constants.
PR created automatically by Jules for task 12524346837297004216 started by @berezovskyi