0

I am using rally lookback api with java. I am trying to fetch historical data features, sample code that i am using is as shown below.

LookbackApi lookbackApi = new LookbackApi();

lookbackApi.setCredentials("username", "password");
lookbackApi.setWorkspace(47903209423);
lookbackApi.setServer("https://rally1.rallydev.com");
//lookbackApi.setWorkspace("90432948"); 

LookbackQuery query = lookbackApi.newSnapshotQuery();
query.addFindClause("_TypeHierarchy", "PortfolioItem/Feature");
query.setPagesize(200)                      // set pagesize to 200 instead of the default 20k
.setStart(200)                      // ask for the second page of data        
.requireFields("ScheduleState",     // A useful set of fields for defects, add any others you may want
               "ObjectID",
               "State",
               "Project",
               "PlanEstimate",
               "_ValidFrom",
               "_ValidTo")
.sortBy("_UnformattedID")        
.hydrateFields("ScheduleState","State", "PlanEstimate","Project");    // ScheduleState will come back as an OID if it doesn't get hydrated      

LookbackResult resultSet = query.execute();


int resultCount = resultSet.Results.size();
Map<String,Object> firstSnapshot = resultSet.Results.get(0);

Iterator<Map<String,Object>> iterator = resultSet.getResultsIterator();
while (iterator.hasNext()) {
    Map<String, Object> snapshot = iterator.next();
}

I need a way to put a condition so that it will fetch all the records from history which will have plan estimate changed,but will ignore other history for any feature and underlying user story. I need it this way so that we can track plan estimate change but, will be able to avoid fetching un-necessary data and reduce the time to do this.

nickm
  • 5,936
  • 1
  • 13
  • 14
Sagar
  • 173
  • 5
  • 8

2 Answers2

1

I'm not familiar with the java toolkit, but using the raw Lookback API, you would accomplish this with a filter clause like {"_PreviousValues.PlanEstimate": {"$exists": true}}.

Larry Maccherone
  • 9,393
  • 3
  • 27
  • 43
  • Thanks for the quick one, I can easily convert it for java API, I'll give it a try and update you. – Sagar Feb 26 '15 at 04:20
  • Initially I struggled to put it into java implementation. But after some trial and error it worked.Thanks. :) I will post snippet as answer so that it will be readable, incase some one is looking for the same. – Sagar Mar 02 '15 at 05:52
0
    Map ifExist = new HashMap();
    ifExist.put("$exists",  true); 
    // Note:- true is java boolean, be careful with this as string "true" will not work.
    query.addFindClause("_PreviousValues.PlanEstimate",ifExist);

Additinally one need to consider adding "_PreviousValues.PlanEstimate" into .requireFields() in case only "PlanEstimate" is required to hydrated

Sagar
  • 173
  • 5
  • 8