Querying with Plain Java Client API problem :(
![]()
Abraham Ayorinde (11●3)
| asked Jul 26 '16, 5:01 p.m.
edited Aug 01 '16, 12:41 p.m. by David Lafreniere (4.8k●7)
This line:
queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.SMALL_PROFILE);has raised the error
Argument must be an instance of IAuditableHandle, queryClient.getResolvedExpressionResults
The arguments should comply with the following specification:
The code section below provides more context.
|
4 answers
![]()
'term' is not an Expression..
you want either Expression1 or Expression2.. Comments I was hopeful, but I still receive the same error. :( Thanks anyway. ok, well, that only leaves 1 parameter left.. what is the definition of projectArea?>
My definition is as below.
IProjectArea projectArea = (IProjectArea)processClient.findProcessArea(uri,null,null);
ok, the api and the error say handle.
Yes. I'm developing in RTC (it's an eclipse based ide).
Perhaps you can direct me to information about all the API's and perhaps I can figure it out that way. That's been my biggest problem, I'm not even sure what is really what, so I am trying to make sense of everything by copying the code samples I find.
But I would still encourage everyone to try finding an explicit answer.
Some of the api is documented in the javadoc you can get from the download site..
Ralph Schoon can you help me? I know you can. :)
showing 5 of 7
show 2 more comments
|
![]()
Ralph Schoon (62.0k●3●36●43)
| answered Jul 28 '16, 2:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find examples here: https://rsjazz.wordpress.com/ , so help yourself. There is example code for querying. You have a debugger, you have instanceof. See what types you have. Looking at the code does not always help.
Comments How am I supposed to debug when I don't have the API source code? If I'm not mistaken, your query examples are for the server side of things. I'm looking for something on the client side. ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You should really really carefully follow https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ and do the Extensions Workshop. Then you could debug using the SDK. The SDK contains the API source code. If you can't, forget trying to write extensions.
|
![]()
I happened to have searched the board for some keywords and I see that this has been an existing problem, for some at least, since 2011. Ralph I believe you even suggested that the individual who first raised the problem create a work ticket because something is really wrong.
Anyway, the individual Zybnek Vavros discovered that if he adds a dependency to jaxen as the xml parser then the issue goes away.
(The original question can be found here: https://jazz.net/forum/questions/66113/server-problem-with-iauditableclient)
Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
No, the user reports that the error starts occurring if they use that XML parser and goes away if the XML parser gets removed from the dependencies or they use a newer version.
Actually he said that the error goes away when he uses version 1.0 FCS of jaxen.
So there's an issue with the xml parser nevertheless.
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
But that is not our parser it is some other parser he used.
|
![]()
so, here is my little sample, using your code.. works..
this took about 30 minutes to put together, using previous code I had (published here https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes a LONG time ago), ralphs blog, and hints from eclipse. I have never constructed a query before. takes repo url, userid, password, project name and user_name_to_find.. only does 'owner' package com.sd.tools; import java.net.URI; import com.ibm.team.process.client.IProcessClientService; import com.ibm.team.process.common.IProjectArea; import com.ibm.team.repository.client.ITeamRepository; import com.ibm.team.repository.client.TeamPlatform; import com.ibm.team.repository.client.ITeamRepository.ILoginHandler; import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo; import com.ibm.team.repository.common.IContributor; import com.ibm.team.repository.common.TeamRepositoryException; import com.ibm.team.workitem.client.IAuditableClient; import com.ibm.team.workitem.client.IQueryClient; import com.ibm.team.workitem.client.IWorkItemClient; import com.ibm.team.workitem.common.IAuditableCommon; import com.ibm.team.workitem.common.expression.AttributeExpression; import com.ibm.team.workitem.common.expression.Expression; import com.ibm.team.workitem.common.expression.IQueryableAttribute; import com.ibm.team.workitem.common.expression.QueryableAttributes; //import com.ibm.team.workitem.common.expression.Term; import com.ibm.team.workitem.common.model.AttributeOperation; import com.ibm.team.workitem.common.model.IWorkItem; import com.ibm.team.workitem.common.query.IQueryResult; public class QueryUser { private static class mylog implements org.eclipse.core.runtime.IProgressMonitor { public void beginTask(String arg0, int arg1) { // TODO Auto-generated method stub } public void done() { // TODO Auto-generated method stub } public void internalWorked(double arg0) { // TODO Auto-generated method stub } public boolean isCanceled() { // TODO Auto-generated method stub return false; } public void setCanceled(boolean arg0) { // TODO Auto-generated method stub } public void setTaskName(String arg0) { // TODO Auto-generated method stub } public void subTask(String arg0) { // TODO Auto-generated method stub } public void worked(int arg0) { // TODO Auto-generated method stub } } private static class LoginHandler implements ILoginHandler, ILoginInfo { private String fUserId; private String fPassword; private LoginHandler(String userId, String password) { fUserId = userId; fPassword = password; } public String getUserId() { return fUserId; } public String getPassword() { return fPassword; } public ILoginInfo challenge(ITeamRepository repository) { return this; } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub boolean debug = false; String repositoryURI = args[0]; String userId = args[1]; String password = args[2]; String projectAreaName = args[3]; String queryUserid = args[4]; mylog monitor = new mylog(); TeamPlatform.startup(); if (debug) System.out.println("platform started\n"); ITeamRepository teamRepository = TeamPlatform .getTeamRepositoryService().getTeamRepository(repositoryURI); if (debug) System.out.println("logging in\n"); teamRepository.registerLoginHandler(new LoginHandler(userId, password)); try { teamRepository.login(null); if (debug) System.out.println("logged in\n"); URI uri = URI.create(projectAreaName.replaceAll(" ", "%20")); IProjectArea projectArea = null; IProcessClientService processClient = (IProcessClientService) teamRepository .getClientLibrary(IProcessClientService.class); projectArea = (IProjectArea) processClient.findProcessArea(uri, null, null); IAuditableClient auditableClient = (IAuditableClient) teamRepository .getClientLibrary(IAuditableClient.class); IWorkItemClient workItemClient = (IWorkItemClient) teamRepository .getClientLibrary(IWorkItemClient.class); IQueryClient queryClient = workItemClient.getQueryClient(); IAuditableCommon auditableCommon = (IAuditableCommon) auditableClient.getTeamRepository().getClientLibrary(IAuditableCommon.class); IQueryableAttribute attribute = QueryableAttributes.getFactory( IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.OWNER_PROPERTY, auditableCommon, monitor); IContributor dude_user = teamRepository.contributorManager().fetchContributorByUserId(queryUserid, null); Expression isOwner = new AttributeExpression(attribute, AttributeOperation.EQUALS, dude_user); IQueryResult qr =queryClient.getResolvedExpressionResults(projectArea, isOwner, IWorkItem.SMALL_PROFILE); System.out.println("number of items returned="+qr.getResultSize(monitor).getTotalAvailable()); } catch (TeamRepositoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Comments ![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Thanks as always Sam. I had rather him fixing his environment for debugging. That is the bigger problem, I think.
I understand.. but this is SO easy.. make a user library for the plain javalibs. and one for the sdk libs, and a third for the planning libs (apt...)..
I only setup the SDK and create a user library for the plain Java API. As explained in my getting started. Then use a plugin to make PDE show the source for plain java.
|