Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to retrieve all items of a given itemtype

Hi,

is there an easy way to retrieve all items from a given class from the
repository?
For instance, if I want to get all elements of type "MyType" (which inherits
from SimpleIem), the tutorials suggest to do something like

MyTypeQueryModel queryModel =
BaseMyTypeMapQueryModel.MyTypeQueryModel.ROOT;
IItemQuery itemQuery = IItemQuery.FACTORY.newInstance(queryModel);
IItemQueryPage itemQueryPage = null;
try {
itemQueryPage = queryService.queryItems(itemQuery,
IQueryService.EMPTY_PARAMETERS,
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE);
} catch (TeamRepositoryException e) {
e.printStackTrace();
}

List handles = itemQueryPage.getItemHandles());

The codegen tool however only generates MyTypeQueryModel .java and
BaseMyTypeQueryModel.java if the storage model includes an queryableProperty
annotation for an attribute of the class MyType.
In my case, I do not need to query for a specifc value -- I always want to
get all items of this type from the repository.

Is there a way to get this without introducing a dummy attribute with an
queryableProperty annotation?

Many thanks,

--Tim

0 votes



One answer

Permanent link
Tim Schumann wrote:
Hi,

is there an easy way to retrieve all items from a given class from the
repository?
For instance, if I want to get all elements of type "MyType" (which inherits
from SimpleIem), the tutorials suggest to do something like

MyTypeQueryModel queryModel =
BaseMyTypeMapQueryModel.MyTypeQueryModel.ROOT;
IItemQuery itemQuery = IItemQuery.FACTORY.newInstance(queryModel);
IItemQueryPage itemQueryPage = null;
try {
itemQueryPage = queryService.queryItems(itemQuery,
IQueryService.EMPTY_PARAMETERS,
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE);
} catch (TeamRepositoryException e) {
e.printStackTrace();
}

List handles = itemQueryPage.getItemHandles());

The codegen tool however only generates MyTypeQueryModel .java and
BaseMyTypeQueryModel.java if the storage model includes an queryableProperty
annotation for an attribute of the class MyType.
In my case, I do not need to query for a specifc value -- I always want to
get all items of this type from the repository.

Is there a way to get this without introducing a dummy attribute with an
queryableProperty annotation?

Many thanks,

--Tim



Hi Tim,

I tried this and see the same behavior as you describe. You may want to
open a workitem for us to create a query model even if there are no
queryableProperties. A workaround, as you mention, is to apply
queryableProperty to some attribute or reference in the class.


--
Chris Daly
Jazz Component Development Team

0 votes

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,064

Question asked: Mar 28 '08, 9:54 a.m.

Question was seen: 7,243 times

Last updated: Mar 28 '08, 9:54 a.m.

Confirmation Cancel Confirm