It's all about the answers!

Ask a question

How to get Project Area List using RTC Java API Server Side


Peterson dos Santos (4428) | asked Sep 30 '19, 3:19 p.m.

Hi Friends,

I would like to know if is there a way to get a list of all projects area using Java Api Server Side.

I know its possible using IProcessItemService.findAllProjectAreas() on client side, is there any option that i can use on server side?

I appreciate any help,
Regards.

One answer



permanent link
David Lafreniere (4.8k7) | answered Sep 30 '19, 8:39 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Try:
com.ibm.team.process.service.util.ProjectAreaUtils.getProjectAreas()

Comments
Peterson dos Santos commented Oct 03 '19, 2:00 p.m.

HI David,

Thank you for return,

I didn't find the package (com.ibm.team.process.service.util) on RTC SDK Sever 6.0.4.

Do you know other way?

Regards,


David Lafreniere commented Oct 03 '19, 3:46 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

getProjectAreas(IServerQueryService queryService, IRepositoryItemService itemService, UUID uuid)

    {
        ProjectAreaQueryModel queryModel = ProjectAreaQueryModel.ROOT;
        IItemQuery query = IItemQuery.FACTORY.newInstance(queryModel);
        IPredicate notArchivedPredicate = queryModel.archived()._eq(Boolean.FALSE);
        IPredicate predicate = uuid== null ? notArchivedPredicate : queryModel.itemId()._eq(projectAreaUUID)._and(notArchivedPredicate);
        query.filter(predicate);
        IItemHandle [] handles = queryService.queryItems(query, IServerQueryService.EMPTY_PARAMETERS).toHandleArray();
        return fetchItems(itemService, handles, IRepositoryItemService.COMPLETE, IProjectArea.class);
    }


Peterson dos Santos commented Oct 15 '19, 10:18 a.m. | edited Oct 15 '19, 1:09 p.m.

Hi Thank you for helping!

Could you say me where is the fetchItems method?

Regards,


David Lafreniere commented Oct 15 '19, 1:09 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

    private static <T> List<T> fetchItems(
            final IRepositoryItemService repoItemService,
            final List<IItemHandle> handles,
            final String [] properties,
            final Class<T> clazz) throws TeamRepositoryException {
        IItemHandle [] handleArray = handles.toArray(new IItemHandle [handles.size()]);
        IItem [] items = repoItemService.fetchItems(handleArray, properties);
        List<T> itemList = new ArrayList<>(items.length);
        for (IItem item : items) {
            itemList.add(clazz.cast(item));
        }
        return itemList;
    }

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.