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

How can I programmatically get the list of Plans in an RTC Project Area using plain java client api and then access the workitems ?

 Our organization uses an RTC server to maintain all the work items. I need to develop a java client and connect to the jazz server [https://<OurOurganizationRTCWebSite>:9443/ccm/].I have done the login part but I need to retrieve the RTC plans from the project areas and then from the plans retrieve the work items.

Please help me.
Its urgent

0 votes



2 answers

Permanent link

There is no really supported Java Plan API. Plans are no longer supported in the Eclipse client either.  A plan is also really only a work item query. You should not try to work with the plans API, you should use the work item API.


Instead of trying to work with a plan use https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/ expressions and set the values such as planned for and the filed against. values. 

Pretty much all code needed for the work item API can be found in the work item command line, including tooling to get iterations from timelines etc.:   https://rsjazz.wordpress.com/2017/03/29/the-work-item-command-line-is-now-open-source/


 

0 votes

Comments

 Hi ralph,

Thanks ,but it would be better if you provide me the code for getting the timeline and  from timeline  iterations and then retrieve the workitems and its attributes.
I am in desire need .Please help me.

If you would be in dire need, you would basically look into the code provided on the links.

In addition, the code published in the blogs actually compiles which code pasted here does not.

 Thanks Ralph,

Can I get all work items id of a particular iteration from that particular iteration?If so, help me 

And along with with its attributes

Yes, you can use queries or expressions to do so. I provided you links with what you need to get started if you where interested. Expressions are harder, because you have to find the iteration objects in the database. The blog I am referring to provides pretty much all the API code you would need in examples. Additional examples can be found here in this forum if you know how to search. 


Good luck.

  


I have used the code below but i cannot get the name of the workitems and all its attributes .Also i need to get from which iteration the workitrem came. Please help me

showing 5 of 7 show 2 more comments

Permanent link

 

public class mRTC232 { 

    static String repository_address = "xxxxxx ";
    static String userId = "xxxxx"; 
    static String password = "xxxxx"; 
    static String projectAreaName = "xxxx"; 

    public static void main(String[] args) throws TeamRepositoryException { 

        System.out.println("Main runned"); 
        TeamPlatform.startup(); 
        ITeamRepository repository = TeamPlatform.getTeamRepositoryService() 
                .getTeamRepository(repository_address); 

        repository.registerLoginHandler(new ITeamRepository.ILoginHandler() { 
            public ILoginInfo challenge(ITeamRepository repository) { 
                return new ILoginInfo() { 
                    public String getUserId() { 
                        return userId; 
                    } 

                    public String getPassword() { 
                        return password; 
                    } 
                }; 
            } 
        }); 

        // IProgressMonitor monitor = new SysoutProgressMonitor(); 
        IProgressMonitor monitor = null; 
        try { 
            repository.login(null); 
        } catch (TeamRepositoryException e) { 
            e.printStackTrace(); 
        } 
        if (repository.getState() == 1) { 
            System.out.println("CONNECTED to: " + repository_address); 
        } 

        // -------------- 
        IWorkItemClient service = (IWorkItemClient) repository 
                .getClientLibrary(IWorkItemClient.class); 
        IQueryClient queryClient = (IQueryClient) repository 
                .getClientLibrary(IQueryClient.class); 
        IProcessClientService processClient = (IProcessClientService) repository 
                .getClientLibrary(IProcessClientService.class);
        
        // Replace
       / URI uri = URI.create(projectAreaName.replaceAll(" ", "%20")); 
        IProjectArea projectArea = (IProjectArea) processClient 
                .findProcessArea(uri, null, null);
        /
        
       
            
            IProcessItemService itemService = (IProcessItemService) repository
    .getClientLibrary(IProcessItemService.class);
    List pAreas = itemService.findAllProjectAreas(null, null);  
       
            
            for (Iterator iterator = pAreas.iterator(); iterator.hasNext();) {
IProjectArea projectAreas = (IProjectArea) iterator.next();
if(projectAreas.getName().equals("Tools"))
{
IAuditableClient iac = (IAuditableClient) repository.getClientLibrary(IAuditableClient.class); 
       
       // getting workitems 
       Term term = new Term(Operator.AND); 
       IQueryResult<IResolvedResult<IWorkItem>> result = queryClient 
               .getResolvedExpressionResults(projectAreas, term, 
                       IWorkItem.FULL_PROFILE); 

       for (int k = 0; result.hasNext(null); k++) { 
           System.out.println("WORKITEM------------------------------------------------"); 

           IResolvedResult<IWorkItem> resolved = result.next(null); 
System.out.println(resolved.getItem().toString());
}
}
            //Custom attributes 
           // WorkItem wi = new WorkItem(); 
           / if (!resolved.getItem().getCustomAttributes().isEmpty()) { 
                for (int i = 0; i < resolved.getItem().getCustomAttributes() 
                        .size(); i++) { 
                    com.ibm.team.workitem.common.model.IAttributeHandle handle = resolved 
                            .getItem().getCustomAttributes().get(i); 
                    com.ibm.team.workitem.common.model.IAttribute attribute = (IAttribute) repository 
                            .itemManager().fetchCompleteItem(handle, 
                                    IItemManager.DEFAULT, 
                                    new NullProgressMonitor()); // 
                    System.out.println("The attribute id: " 
                            + attribute.getIdentifier()); 
                    System.out.println("The attribute name: " 
                            + attribute.getDisplayName()); 
                   System.out.println(attribute.getOrigin()+"   "+attribute.getAttributeType()+" "+attribute.modified()+" "+attribute.getContextId()+" "+attribute.getModifiedBy());
                            printAttributes(resolved.getItem(), repository, iac, projectArea, monitor); 
                    try { 
                        
                    } catch (Exception e) { 
                        System.out.println("ASSERTION FAILED!!!!"); 
                    } /
               // } 
            
            //Builtin attributtes 
            
            List<IAttributeHandle> builtInAttributeHandles = service 
                    .findBuiltInAttributes(projectAreas, monitor); 
            IFetchResult builtIn = repository.itemManager() 
                    .fetchCompleteItemsPermissionAware(builtInAttributeHandles, 
                            IItemManager.REFRESH, monitor); 
            
            for (Iterator it = builtIn.getRetrievedItems().iterator(); it 
                    .hasNext();) { 
                com.ibm.team.workitem.common.model.IAttributeHandle handle = (IAttributeHandle) it 
                        .next(); 
                com.ibm.team.workitem.common.model.IAttribute attribute = (IAttribute) repository 
                        .itemManager() 
                        .fetchCompleteItem(handle, IItemManager.DEFAULT, 
                                new NullProgressMonitor()); 
                System.out.println("  Built In Attribute: " 
                        + attribute.getDisplayName()+ attribute.); 
                System.out.println(" Type: " + attribute.getAttributeType()); 
               / try { 
                    // wi.getAttributeValue(attribute, resolved.getItem()); 
                    System.out.println("  Value " 
                            + resolved.getItem().getValue(attribute)); 

                } catch (AssertionFailedException e) { 
                    System.out.println(e.toString()); 
                } /
            } 
            
        } 
        
        
    }
    
    
  

    static void printAttributes(IWorkItem workItem,ITeamRepository repository, 
            IAuditableClient auditableClient, IProjectArea projectArea, 
            org.eclipse.core.runtime.IProgressMonitor monitor) { 
        
        IWorkItemCommon workItemCommon = (IWorkItemCommon) repository.getClientLibrary(IWorkItemCommon.class); 
        
        try { 
            for (IAttribute ia : workItemCommon.findAttributes(projectArea, 
                    monitor)) { 

                if ((workItem.hasAttribute(ia))  && ! ia.isBuiltIn()) 
 { 
                    System.out.println("\t\t\tprocessing for variable=" 
                            + ia.getDisplayName() + " attrib type=" 
                            + ia.getAttributeType() + " kind=" 
                            + ia.getFullTextKind()); 
                    try { 
                        // this will throw exception if not enumeration 
                        IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>) workItemCommon 
                                .resolveEnumeration(ia, monitor); 
                        if (enumeration != null) { 
                            String[] iaval = ia 
                                    .getValue(auditableClient, workItem, 
                                            monitor).toString().split(":"); 
                            if (iaval.length > 1 && iaval[1] != null) { 
                                List<ILiteral> enumerationLiterals = enumeration 
                                        .getEnumerationLiterals(); 
                                for (ILiteral literal : enumerationLiterals) { 
                                    if (literal.getIdentifier2() 
                                            .getStringIdentifier() 
                                            .equalsIgnoreCase(iaval[1])) { 
                                        System.out 
                                                .println("\t\t\t\t --> attribute name=" 
                                                        + ia.getIdentifier() 
                                                        + ", type" 
                                                        + "=" 
                                                        + ia.getAttributeType() 
                                                        + " literal=" 
                                                        + literal 
                                                                .getIdentifier2() 
                                                                .getStringIdentifier() 
                                                        + " literal name=" 
                                                        + literal.getName()); 
                                        break; 
                                    } 
                                } 
                            } 
                        } 
                    } catch (Exception e) { 
                        System.out.println("\t\t\t\tattribute name=" 
                                + ia.getIdentifier() 
                                + ", type" 
                                + "=" 
                                + ia.getAttributeType() 
                                + " value=" 
                                + ia.getValue(auditableClient, workItem, 
                                        monitor)); 
                    } 
                } 
            } 
        } catch (Exception e) { 
            // TODO Auto-generated catch block 
            System.out.println("outer Exception=" + e.toString()); 
        } 
    } 

}// Main END 

0 votes

Comments

 I have used the code but i cannot get the name of the workitems and all its attributes .Also i need to get from which iteration the workitrem came. Please help me.urgent!!!

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,943

Question asked: Jun 06 '17, 7:27 a.m.

Question was seen: 2,504 times

Last updated: Jun 12 '17, 7:49 a.m.

Confirmation Cancel Confirm