It's all about the answers!

Ask a question

Retrieve links from files under scm via API


Julian Hemm (58416) | asked Nov 05 '20, 5:30 a.m.

 Hi,


is there a way to retrieve the metadata, in particular the links from a file in scm pointing to QM testcases, using the plain Java or OSLC API?

Thank you!

Accepted answer


permanent link
Michael Valenta (3.7k3) | answered Nov 23 '20, 8:42 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Julian,

The following service call on the IScmService which can be invoked from plain java will give you all the links associated with one or more SCM files:

    /**
     * Get related artifacts for the specified versionable states.
     *
     * @param itemStateHandles
     *      Versionable item handles including the state. Must not be {@code null} and
     *      all elements must not be {@code null} and have a state ID.
     * @param gcURL
     *      The URL of the global configuration in which the results should be resolved.
     *      if this field is {@code null}, this method will only return outgoing links
     *      and the related artifact URIs may not point to a concrete resource.
     * @param options
     *      Options; See {@link #LINK_FETCH_OPTIONS} for all options.
     * @param monitor
     *      Progress monitor.
     * @return
     *      An array with an element for each handle in {@code itemStateHandles}. The value of each element
     *      contains all of the related artifacts for the corresponding state handle.
     * @throws TeamRepositoryException
     *      If the operation fails.
     * @since 0.11.0.4 (RTC 6.0.4)
     */
    public RelatedArtifactsDTO[] getRelatedArtifacts(IVersionableHandle[] itemStateHandles,
            String gcURL, String[] options,
            IRepositoryProgressMonitorHandle monitor)
            throws TeamRepositoryException;

If you have any further questions, let me know.
Michael
Julian Hemm selected this answer as the correct answer

Comments
Julian Hemm commented Nov 23 '20, 8:57 a.m.

Thank you Michael, that works pretty well.

I did not find an option to add a new RelatedArtifact using the ScmService, which would be my next use-case.
I would appreciate if you could give some hint on this as well.
Thanks a lot! 

Your answer


Register or 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.