Querying for User Story revisions in Rally

依然范特西╮ 提交于 2020-01-04 04:36:07

问题


I would like to retrieve the JSON object for the revision log using the URL associated with the User Story. I have accomplished this with jQuery using the following code, although I would rather do it with built in tools in the Rally SDK. I haven't had any luck with Ext.Ajax or Ext.data.JsonP requests, although I feel that is the correct approach. Any help would be appreciated.

$.ajax({
    url: URL,
    dataType: 'jsonp',
    jsonp: 'jsonp',
    success: function(response) {
        $.each(response.RevisionHistory.Revisions, function(key, rev) {
            //Parse Revision Log
        });
    }
});

回答1:


This is relatively straightforward with the App SDK 2.0. The following examples in the documentation should be helpful to you:

http://developer.rallydev.com/apps/2.0p4/doc/#!/guide/appsdk_20_data_models

http://developer.rallydev.com/apps/2.0p4/doc/#!/guide/appsdk_20_data_stores

Here's a quick little code snippet to get the revision history of a specific story:

Rally.data.ModelFactory.getModel({
    type: 'UserStory',
    success: function(storyModel) {
        var storyRef = 'https://rally1.rallydev.com/slm/webservice/1.37/hierarchicalrequirement/12345.js';
        var storyID = Rally.util.Ref.getOidFromRef(storyRef);
        storyModel.load(storyID, {
            fetch: ['Name', 'FormattedID', 'Description', 'RevisionHistory', 'Revisions'],
            callback: function(story, operation) {
                if(story && story.get('RevisionHistory') && story.get('RevisionHistory').Revisions) {
                    Ext.Array.each(story.get('RevisionHistory').Revisions, function(revision) {
                        //Parse revision log
                    });
                }
            }
        });
    }
});

The nice thing with using the SDK is that it will automatically do ajax vs. jsonp requests depending on how you are running the app. The example above works great for a single story. If you would like to parse through multiple stories you'd want to use a store instead of model.load:

Ext.create('Rally.data.WsapiDataStore', {
    model: 'UserStory',
    autoLoad: true,
    fetch: ['Name', 'FormattedID', 'Description', 'RevisionHistory', 'Revisions'],    
    listeners: {
        load: function(store, stories) {
            Ext.Array.each(stories, function(story) { 
                if(story && story.get('RevisionHistory') && story.get('RevisionHistory').Revisions) {
                    Ext.Array.each(story.get('RevisionHistory').Revisions, function(revision) {
                        //Parse revision log
                    });
                }
            });
        }
    } 
});


来源:https://stackoverflow.com/questions/12694644/querying-for-user-story-revisions-in-rally

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!