Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Associating Work Items with Change Sets in RTC: A Java API Approach

To associate a work item with a change set using the Java Plain API in IBM Rational Team Concert (RTC), you can follow these steps based on the provided search results. Here's a concise guide to help you achieve this:

Steps to Associate a Work Item with a Change Set

  1. Set Up Your RTC Environment: Ensure that you have the RTC SDK set up in your Java environment. You will need access to the necessary libraries and classes.
  2. Obtain References: You will need to get references to the relevant services, including the  ILinkManager  and  IWorkItemServer .
  3. Create a Link Between Change Set and Work Item:
    • Use the  ILinkManager  to create a link between your change set and the work item.
    • You can create a reference to the work item using its handle.
  4. Code Example:
    Here’s a simple code snippet demonstrating how to associate a work item with a change set:
    java
    import com.ibm.team.repository.common.TeamRepositoryException; import com.ibm.team.scm.common.IChangeSetHandle; import com.ibm.team.scm.common.IChangeSet; import com.ibm.team.scm.client.IChangeSetClient; import com.ibm.team.workitem.common.model.IWorkItemHandle; import com.ibm.team.workitem.common.model.IWorkItem; // Assuming 'repository' is your connected repository and 'changeSetHandle' is your change set IChangeSetClient changeSetClient = (IChangeSetClient) repository.getClientLibrary(IChangeSetClient.class); IWorkItemServer workItemServer = (IWorkItemServer) repository.getClientLibrary(IWorkItemServer.class); try { // Fetch the change set IChangeSet changeSet = changeSetClient.resolve(changeSetHandle, null);
    // Create a reference to the work item IWorkItemHandle workItemHandle = workItemServer.findWorkItemById(workItemId, null);
    // Associate the work item with the change set changeSetClient.linkChangeSetToWorkItem(changeSet, workItemHandle);
    System.out.println("Successfully associated change set with work item."); } catch (TeamRepositoryException e) { e.printStackTrace(); System.out.println("Failed to associate change set with work item: " + e.getMessage()); }
    <button aria-label="Copy Code" class="sc-blHHSb fdjstX" style="border-width: 0px; border-style: solid; border-color: rgb(229, 231, 235); scrollbar-color: auto; scrollbar-width: auto; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; font-family: inherit; font-feature-settings: inherit; font-variation-settings: inherit; font-size: 14px; font-weight: inherit; line-height: inherit; letter-spacing: inherit; margin: 0.15rem 0px 0px; padding: 0.25rem; appearance: button; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; cursor: pointer; position: absolute; top: 0.5em; right: 0.75em; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; border-radius: 0.25rem; max-height: 2rem; max-width: 2rem;" type="button"><svg class="icon" fill="#4d4d4c" height="16pt" viewbox="0 0 384 512" width="16pt"><path d="M280 240H168c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8zm0 96H168c-4.4 0-8 3.6-8 8v16c0 4.4 3.6 8 8 8h112c4.4 0 8-3.6 8-8v-16c0-4.4-3.6-8-8-8zM112 232c-13.3 0-24 10.7-24 24s10.7 24 24 24 24-10.7 24-24-10.7-24-24-24zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24 24-10.7 24-24-10.7-24-24-24zM336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 48c8.8 0 16 7.2 16 16s-7.2 16-16 16-16-7.2-16-16 7.2-16 16-16zm144 408c0 4.4-3.6 8-8 8H56c-4.4 0-8-3.6-8-8V120c0-4.4 3.6-8 8-8h40v32c0 8.8 7.2 16 16 16h160c8.8 0 16-7.2 16-16v-32h40c4.4 0 8 3.6 8 8v336z"></path></svg></button>

            </pre>
        </div>
        </span><span style="--tw-backdrop-blur:; --tw-backdrop-brightness:; --tw-backdrop-contrast:; --tw-backdrop-grayscale:; --tw-backdrop-hue-rotate:; --tw-backdrop-invert:; --tw-backdrop-opacity:; --tw-backdrop-saturate:; --tw-backdrop-sepia:; --tw-blur:; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-brightness:; --tw-contain-layout:; --tw-contain-paint:; --tw-contain-size:; --tw-contain-style:; --tw-contrast:; --tw-drop-shadow:; --tw-gradient-from-position:; --tw-gradient-to-position:; --tw-gradient-via-position:; --tw-grayscale:; --tw-hue-rotate:; --tw-invert:; --tw-numeric-figure:; --tw-numeric-fraction:; --tw-numeric-spacing:; --tw-ordinal:; --tw-pan-x:; --tw-pan-y:; --tw-pinch-zoom:; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-inset:; --tw-ring-offset-color: #fff; --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-offset-width: 0px; --tw-ring-shadow: 0 0 #0000; --tw-rotate: 0; --tw-saturate:; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-sepia:; --tw-shadow-colored: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-skew-x: 0; --tw-skew-y: 0; --tw-slashed-zero:; --tw-translate-x: 0; --tw-translate-y: 0; border: 0px solid rgb(229, 231, 235); box-sizing: border-box; scrollbar-color: auto; scrollbar-width: auto;"></span>
    </li>
    

Important Notes

  • Error Handling: Always implement error handling to manage exceptions that may arise during API calls.
  • Permissions: Ensure you have the necessary permissions to modify change sets and work items in your RTC environment.
  • Documentation: Refer to the official RTC API documentation for more details on methods and classes available for use.
By following these steps and utilizing the provided code snippet, you should be able to successfully associate a work item with a change set using the Java Plain API in IBM Rational Team Concert.

0 votes

Comments

If you want to do this correctly, I would suggest to

  1. Ask a question e.g. "How can I associate Work Items with Change Sets in RTC using the Plain Java Client libraries"
  2. In the answer provide the information you provided in the question here.
That way would allow to accept the question as answered. 


Be the first one to answer this question!

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 2,357
× 411

Question asked: Sep 20 '24, 2:29 p.m.

Question was seen: 208 times

Last updated: Sep 23 '24, 3:03 a.m.

Confirmation Cancel Confirm