It's all about the answers!

Ask a question

Getting files of a Baselin


Lorena Cortés (2654) | asked Jun 21 '12, 5:33 p.m.
edited Jun 21 '12, 5:34 p.m.
Hi

I'm using the jazz API (SDK)

I need to get the files in a certain baseline.

Currently I have a code that gets all the files in a component, but I only need to get the baseline's files.

Thanks

9 answers



permanent link
Matt Lennon (61225) | answered Jun 26 '12, 9:44 a.m.
JAZZ DEVELOPER
Hi Lorena.

To answer your original question about getting the files in a particular baseline, here is some sample code based on the Jazz Java client API. Given a baseline handle, this code prints the files in the baseline, including file type, uuid, and path.

Is this what you had in mind?

    -Matt
==============================
    
    /**
     * Print the specified baseline
     */
    private static void printBaseline(IBaselineHandle handle, IProgressMonitor monitor) throws TeamRepositoryException {
        IBaselineConnection blConn = SCMPlatform.getWorkspaceManager(repo).getBaselineConnection(handle, monitor);
        IConfiguration config = blConn.changeHistory().configuration();
        IFolderHandle rootFolder = config.rootFolderHandle(monitor);
        printFolder(blConn.getName(), rootFolder, config, monitor);
    }
    
    /**
     * Recursively print the specified repository folder and its file contents.
     * Print the path and UUID of each entry.
     */
    @SuppressWarnings("unchecked")
    private static void printFolder(String path, IFolderHandle folder, IConfiguration config, IProgressMonitor monitor) throws TeamRepositoryException {
        printEntry(path, folder);
        Map<String,IVersionableHandle> kids = config.childEntries(folder, monitor);
        for (Entry<String, IVersionableHandle> folderEntry : kids.entrySet()) {
            path = path + "/" + folderEntry.getKey();
            IVersionableHandle child = folderEntry.getValue();
            if (child instanceof IFolderHandle) {
                printFolder(path, (IFolderHandle) child, config, monitor);
            } else {
                printEntry(path, child);
            }
        }
    }
    
    /**
     * Print a single repository file's type, UUID, and path.
     */
    private static void printEntry(String path, IVersionableHandle vh) throws TeamRepositoryException {
        if (firstTimeThrough) {
            System.out.format("File Type,UUID,Path\n");
            firstTimeThrough = false;
        }
        System.out.format("%s,%s,%s\n", vh.getItemType().getName(), vh.getStateId().getUuidValue(), path);
    }

permanent link
Michele Pegoraro (1.8k14119103) | answered Jun 22 '12, 6:42 a.m.
Hi, you can't take directly the files from a baseline. You need to compare the baseline to a workspace or a stream in order to get the change-sets (and then the files) you want find.

Best regards,
Michele

permanent link
VK L (8177157159) | answered Jun 22 '12, 7:21 a.m.
Hi Michele (or) Lorena,
                                      Is it possible to get such lists using Calculated value script to retrieve values into an enumeration attribute?

Thanks.

permanent link
Ralph Schoon (63.7k33648) | answered Jun 22 '12, 8:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Valli,

https://jazz.net/wiki/bin/view/Main/AttributeCustomization states what is possible and as far as i am aware what you want to do is not doable using JavaScript.



permanent link
VK L (8177157159) | answered Jun 22 '12, 8:52 a.m.
Thanks Ralph. Can operation advisor provide an equivalent of what i am trying to do?
My req. is: Based on project area, i want a drop-down of streams available,
based on selected stream,, i want a drop-down of baselines available

Its kind of dependent enumeration concept - but i need to automate the values in the enumeration list. Is this possible using operation advisor plugin?

permanent link
Ralph Schoon (63.7k33648) | answered Jun 22 '12, 9:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

i think you want to create an AttributeValueProvider (see https://jazz.net/wiki/bin/view/Main/AttributeValueProviders ) and possibly an attribute presentation (see https://jazz.net/wiki/bin/view/Main/ContributingAttributePresentationsV2 ) to allows selecting the values.

An operation advisor would be required to make sure some precondition is met.

permanent link
Ralph Schoon (63.7k33648) | answered Jun 22 '12, 9:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Having said that and even if I have looked into extending the tools, I rather try to avoid complex extensions like the ones mentioned above if at all possible. Keep it simple.

If you make work item usage too complex all users will start to hate it and you loose time etc. We have seen excessive customizations in the past with other tools and the ill effect it has.

There also seems a universal law that more stuff is added to work items, but it is almost never removed, even if it is not necessary anymore.  8-D

permanent link
VK L (8177157159) | answered Jun 22 '12, 10:47 a.m.
Hi Ralph,             
                 This is the calculated value script that i asked previously about...I am not sure of how to retrieve streams, baselines etc using dojo providers. I have not tried it relating to SCM at all.Please advise.

Thanks.

permanent link
Ralph Schoon (63.7k33648) | answered Jun 22 '12, 10:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Valli,

please follow the links in https://jazz.net/forum/questions/79881/getting-files-of-a-baselin/79959 .

Since I haven't implemented anything like that myself, I can't provide more. The only think that I am pretty sure of is that you can't access that kind of data in a JavaScript based attribute customization.

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.