It's all about the answers!

Ask a question

Is there a Project Area Id? (PlainJavaAPI)


Eduardo Bello (4401922) | asked Dec 03 '10, 10:09 a.m.
I failed to find a function named "findProjectAreaById()" on PlainJavaAPI, so I decide to make one. If it already exists please read no further and just tell me where I get it :)

So, I'm trying to build a dynamic query, which I think it's faster (Am I right?). I build this piece of code:



private IProjectAreaHandle findProjectAreaById(UUID id) throws TeamRepositoryException {
ProjectAreaQueryModel pArea = ProjectAreaQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(pArea);

IPredicate predicate = pArea.itemId()._eq(query.newUUIDArg());
query.filter(predicate);
Object[] parameters= new Object[] { IProjectArea.ITEM_ID_PROPERTY, id };

ItemQueryIterator<IProjectAreaHandle> iterator = new ItemQueryIterator<IProjectAreaHandle>(getAuditableCommon(), query, parameters);
if (iterator.hasNext(null)) {
return iterator.next(null);
} else {
return null;
}
}


I call it on something like


IProjectAreaHandle projectHandler = findProjectAreaById(UUID.valueOf(areaId));



Where areaId is a string previously obtained with:
ProjectArea.getItemId().getUuidValue();

But I get "Incorrectly typed parameter submitted to query; Parameter 0 was class java.lang.String but com.ibm.team.repository.common.UUID was expected"


How is the UUID calculated?

I didn't found a way to convert com.ibm.team.repository.common.UUID into something standard and back to com.ibm.team.repository.common.UUID. Is the UUID generated from ProjectArea name?


I have found an ProjectAreaQueryModel.ROOT.uniqueName() that I could use on query, but I didn't found the associated IProjectArea property id.

Resuming, how can I store an unique identifier for a ProjectArea, and later recover that ProjectArea based on that unique identifier?

5 answers



permanent link
Eduardo Bello (4401922) | answered Dec 03 '10, 11:28 a.m.
Never mind... beginner mistake...

The error was at line:

Object[] parameters= new Object[] { IProjectArea.ITEM_ID_PROPERTY, id };

that obviously should be:

Object[] parameters= new Object[] { id };

--

I'd mixed two queries techniques :)

permanent link
Qiong Feng Huang (76911610) | answered Dec 05 '10, 9:14 p.m.
JAZZ DEVELOPER
You can try to use IRepositoryItemService to retrive the project area:
IProjectAreaHandle handle =
IProjectArea.ITEM_TYPE.createItemHandle(uuid, null);
IRepositoryItemService service = ... // get service
try {
service.fetchItem(handle, ...);
} catch ...

permanent link
Qiong Feng Huang (76911610) | answered Dec 05 '10, 9:20 p.m.
JAZZ DEVELOPER
If your code is in client side, you can use
ITeamRepository.itemManager().fetchCompleteItem(handle, ...)

permanent link
Jared Burns (4.5k29) | answered Dec 06 '10, 6:24 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Also, please note that any classes in a package with "internal" in the name are not API. The code snippet posted above is referencing the ProjectAreaQueryModel, which is just such a class.

This class is an internal implementation detail of the Process runtime and should not be accessed by third parties.

Jonathan's suggested path of using the IItemManager or IRepositoryItemService is the correct route.

- Jared

permanent link
Eduardo Bello (4401922) | answered Dec 07 '10, 6:32 a.m.
Also, please note that any classes in a package with "internal" in the name are not API. The code snippet posted above is referencing the ProjectAreaQueryModel, which is just such a class.

This class is an internal implementation detail of the Process runtime and should not be accessed by third parties.

Jonathan's suggested path of using the IItemManager or IRepositoryItemService is the correct route.

- Jared


If these type of query isn't API, why in jazz Wiki, "Developer's Guide to Querying Work Items https://jazz.net/wiki/bin/view/Main/QueryDevGuide". The JazzTeam says: "To illustrate another aspect of the Repository Query API, we use a dynamic query for this task"

Not only that but there they also said: "The dynamic query model is aimed at those occasions where a query needs to be created dynamically at runtime and only the attribute identifiers are known."

Which is exactly my case, once I only know the attribute identifier ItemID, but not the parameter.

The documentation isn't that great already, and if we couldn't trust what is written... Then we have troubles...

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.