How to retrieve Stories and Defects in one query using Java SDK

453 views
Skip to first unread message

Anjum Naseer

unread,
Apr 10, 2012, 8:46:13 AM4/10/12
to version...@googlegroups.com

Hi,

 

I am trying to retrieve both Stories and Defects from a particular sprint in one query and want them returned ordered by the Order field.

 

I have successfully managed to retrieve just Stories using the Java API but cannot work out how to construct a query that will return both Stories AND Defects in one go.

 

Thanks.

 

Anjum.

 

PS: I am using the latest Enterprise release of V1 (12.0.1.2915) and the latest Java SDK (VersionOne.JavaSDK-12.0).

ibuchanan

unread,
Apr 10, 2012, 9:13:15 AM4/10/12
to version...@googlegroups.com
Anjum,
 
The trick is that both Stories and Defects are PrimaryWorkitems. You didn't mention which layer of the SDK you are using (API Client or Object Model).
 
Assuming API Client, you can follow the approach to get multiple assets:
 
Just change the asset type to PrimaryWorkitem:
IAssetType storyType = metaModel.GetAssetType("PrimaryWorkitem");
 
(Note: ideally, you also rename the variable to primaryWorkitemType but the above makes it simple for copy/paste.)
 
Yours truly,
Ian Buchanan
Product Manager for Platform and Integrations

Saxon, Will

unread,
Apr 10, 2012, 9:48:43 AM4/10/12
to version...@googlegroups.com
I have a followup question to this, because I am working on a similar problem.

I am not using the Java SDK but rather interfacing directly w/ the API over HTTP. I have custom fields defined on PrimaryWorkitems, Stories and Defects. If I want to get all the Stories and Defects with a particular PWI custom value - e.g. a 'ready for export' flag at the PWI level - I can do that, but then I have to query each individual PWI again to collect the Story- or Defect-specific custom field values. If I query for PrimaryWorkitems and specify a Story- or Defect-specific field in the 'sel=' parameter, I get an error.

This makes sense, but I am wondering if there is a way around it so that I can query 1 time for all Backlog items and get each one with their type-specific custom fields.

Thanks,

-Will

> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/versionone-dev/-/gX2hTHigoEMJ.
> To post to this group, send email to version...@googlegroups.com.
> To unsubscribe from this group, send email to versionone-
> dev+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/versionone-dev?hl=en.


ibuchanan

unread,
Apr 10, 2012, 10:22:55 AM4/10/12
to version...@googlegroups.com
Will,
 
You might be able to use downcasting. See:
 
That said, I'm not sure it will let you select on both Story- and Defect-specific fields at once. You might need to do something with Custom Columns. Can you explain a little more about why you want different attributes to come back in the same query?
 
Ian

Thanks,

-Will

> To post to this group, send email to versionone-dev@googlegroups.com.


> To unsubscribe from this group, send email to versionone-

> dev+unsubscribe@googlegroups.com.

Saxon, Will

unread,
Apr 10, 2012, 10:54:25 AM4/10/12
to version...@googlegroups.com
We have a legacy defect tracking system which we want to auto-populate w/ V1 Stories and Defects. There are item-specific required attributes which match up with the custom fields in V1. So ideally, we'd get all the PWIs ready for export, loop through each one, build the corresponding legacy object, submit that and then update the V1 item to clear the export flag. Instead we're having to get all the PWIs, issue separate queries to get the Story- or Defect-specific attributes, then build/submit/update.

This is just one example. There has been discussion about dropping the legacy system in favor of a 100% V1-based workflow, but anytime we want to work with a backlog item that has Story- or Defect-specific fields we have to issue two queries. Since we're using the hosted solution, the added latency is a concern for us.

-Will

> -----Original Message-----
> From: version...@googlegroups.com [mailto:versionone-
> d...@googlegroups.com] On Behalf Of ibuchanan
> Sent: Tuesday, April 10, 2012 10:23 AM
> To: version...@googlegroups.com
> Subject: Re: How to retrieve Stories and Defects in one query using Java
> SDK
>

> <http://community.versionone.com/sdk/DetailedDocumentation/SDK%20.Net/apic
> l>

> <https://groups.google.com/d/msg/versionone-dev/-/gX2hTHigoEMJ> .


> > To post to this group, send email to versionone-

> d...@googlegroups.com <mailto:version...@googlegroups.com> .


> > To unsubscribe from this group, send email to versionone-

> > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com> .


> > For more options, visit this group at
> > http://groups.google.com/group/versionone-dev?hl=en

> <http://groups.google.com/group/versionone-dev?hl=en> .


>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ.
> To post to this group, send email to version...@googlegroups.com.


> To unsubscribe from this group, send email to versionone-

> dev+uns...@googlegroups.com.

Anjum Naseer

unread,
Apr 10, 2012, 10:52:02 AM4/10/12
to version...@googlegroups.com

Ian,

 

Thanks for the pointers. One question – once I retrieve the Primary Workitems, what is the best way to determine if each one represents a Story or a Defect?

 

I thought maybe I should use asset.getAssetType.isA(...) – is this the best way?

 

Thanks again,

 

Anjum.

 

From: version...@googlegroups.com [mailto:version...@googlegroups.com] On Behalf Of ibuchanan
Sent: 10 April 2012 14:13
To: version...@googlegroups.com
Subject: Re: How to retrieve Stories and Defects in one query using Java SDK

 

Anjum,

--

You received this message because you are subscribed to the Google Groups "VersionOne-dev" group.

To view this discussion on the web visit https://groups.google.com/d/msg/versionone-dev/-/gX2hTHigoEMJ.


To post to this group, send email to version...@googlegroups.com.

To unsubscribe from this group, send email to versionone-de...@googlegroups.com.

ibuchanan

unread,
Apr 10, 2012, 11:18:50 AM4/10/12
to version...@googlegroups.com
Anjum,
 
That would work. It might be easier use asset.getAssetType().getDisplayName(). Working with a string is a simpler interface than constructing an instance of the AssetType just to do comparison.
 
Ian

To post to this group, send email to versionone-dev@googlegroups.com.
To unsubscribe from this group, send email to versionone-dev+unsubscribe@googlegroups.com.

ibuchanan

unread,
Apr 10, 2012, 11:32:40 AM4/10/12
to version...@googlegroups.com
Will,
 
I understand better now. You can get custom fields that are unique to each Story and Defect using attribute selection syntax. For example:
username: admin
password: admin
 
If you check meta, you'll notice Value is unique to Story and Resolution is unique to Defect.
 
Hope that helps.
 
Ian

-Will

> d...@googlegroups.com <mailto:versionone-dev@googlegroups.com> .


>         > To unsubscribe from this group, send email to versionone-

>         > dev+unsubscribe@googlegroups.com
> <mailto:dev%2Bunsubscribe@googlegroups.com> .


>         > For more options, visit this group at
>         > http://groups.google.com/group/versionone-dev?hl=en
> <http://groups.google.com/group/versionone-dev?hl=en> .
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "VersionOne-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/versionone-dev/-/dlnufBp0ZYoJ.

> To post to this group, send email to versionone-dev@googlegroups.com.


> To unsubscribe from this group, send email to versionone-

> dev+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages