Naveen.S
Naveen.S

Reputation: 750

Pass field/attributes values from java to RTC using JAZZ API's

I am trying to create work item in RTC through java application using the jazz api's.

My connection to the repository is successful. Now i need to set all the required fields through java code in order to save/run the workitem. Really dont know how to set those values in below codes.

   String repositoryURI= args[0];
        String userId= args[1];
        String password= args[2];
        String projectAreaName= args[3];
        String typeIdentifier= args[4];
        String summary= args[5];
        String categoryName= args[6];

        ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
        teamRepository.registerLoginHandler(new LoginHandler(userId, password));
        teamRepository.login(null);

        IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
        IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
        IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

        URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
        IProjectAreaHandle projectArea= (IProjectAreaHandle) processClient.findProcessArea(uri, null, null);
        //IProjectAreaHandle projectArea = teamArea.getProjectArea();
        if (projectArea == null) {
            System.out.println("Project area not found.");
            return false;
        }
        //IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor);
        IWorkItemType workItemType= workItemClient.findWorkItemType((IProjectAreaHandle) projectArea, typeIdentifier, null);
              //  findWorkItemType(projectArea, typeIdentifier, null);
        if (workItemType == null) {
            System.out.println("Work item type not found.");
            return false;
        }
        System.out.println("Category not found.: " + categoryName );

        List path= Arrays.asList(categoryName.split("/"));

        System.out.println("Category not found.: " + path );
        ICategoryHandle category= workItemClient.findCategoryByNamePath((IProjectAreaHandle) projectArea, path, null);
        //ICategoryHandle category= 
        if (category == null) {
            System.out.println("Category not found.: " + category );
            return false;
        }


        WorkItemInitialization operation= new WorkItemInitialization(summary, category);


        IWorkItemHandle handle= operation.run(workItemType, null);

        IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);

        System.out.println("Created work item " + workItem.getId() + ".");

        teamRepository.logout();

While running the codes i am receiving the below errors. Because of mandatory fields are not assigned. Can any one help me to pass the attribute values (Contact Phone) from java to jazz. ERROR received:

Severity: ERROR Summary: Attribute 'Contact Phone #' not set Description: The 'Contact Phone #' attribute needs to be set (work item <09:13:03>).

Upvotes: 1

Views: 581

Answers (0)

Related Questions