It's all about the answers!

Ask a question

How to retrieve all items of a given itemtype


Tim Schumann (1464) | asked Mar 28 '08, 9:54 a.m.
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

One answer



permanent link
Chris Daly (61651) | answered Mar 31 '08, 7:12 p.m.
JAZZ DEVELOPER
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

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.