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

Is there a Project Area Id? (PlainJavaAPI)

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?

0 votes



5 answers

Permanent link
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 :)

0 votes


Permanent link
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 ...

0 votes


Permanent link
If your code is in client side, you can use
ITeamRepository.itemManager().fetchCompleteItem(handle, ...)

0 votes


Permanent link
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

0 votes


Permanent link
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...

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
× 10,938

Question asked: Dec 03 '10, 10:09 a.m.

Question was seen: 6,368 times

Last updated: Dec 03 '10, 10:09 a.m.

Confirmation Cancel Confirm