0
public class CreateWorkItem {
    
    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;
        }
    }
    
    private static class WorkItemInitialization extends WorkItemOperation {
        
        private String fSummary;
        private ICategoryHandle fCategory;
        
        public WorkItemInitialization(String summary, ICategoryHandle category) {
            super("Initializing Work Item");
            fSummary= summary;
            fCategory= category;
        }
        
        @Override
        protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
            IWorkItem workItem= workingCopy.getWorkItem();
            workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary));
            workItem.setCategory(fCategory);
        }
    }
    
    public static void main(String[] args) {
        
        boolean result;
        TeamPlatform.startup();
        try {
            result= run(args);
        } catch (TeamRepositoryException x) {
            x.printStackTrace();
            result= false;
        } finally {
            TeamPlatform.shutdown();
        }
        
        if (!result)
            System.exit(1);
        
    }
    
    private static boolean run(String[] args) throws TeamRepositoryException {
        
        if (args.length != 7) {
            System.out.println("Usage: CreateWorkItem  <repositoryURI> <userId> <password> <projectArea> <workItemType> <summary> <category>");
            return false;
        }
        
        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"));
        IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
        if (projectArea == null) {
            System.out.println("Project area not found.");
            return false;
        }
        
        IWorkItemType workItemType= workItemClient.findWorkItemType(projectArea, typeIdentifier, null);
        if (workItemType == null) {
            System.out.println("Work item type not found.");
            return false;
        }
        
        List path= Arrays.asList(categoryName.split("/"));
        ICategoryHandle category= workItemClient.findCategoryByNamePath(projectArea, path, null);
        if (category == null) {
            System.out.println("Category not found.");
            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();
        
        return true;
    }
}

**This is jazz.net' offical sample code. My question is how can I set value to "categoryName" in "private static boolean run(String[] args) throws TeamRepositoryException" function.In the Main fuction,there is nothing describing the "arg[]".Who can give me a sample to initial "categoryName" argument. **

Siddharth Kaul
  • 871
  • 10
  • 20
Li Lu
  • 9
  • 1
  • run()'s args array is passed from main(..) (which is a standard Java program entry point) and thus taken from command line arguments of the program, is that what you meant? You can specify command line arguments in IDE class run configuration or in "java" run command separating them using space. – Deinlandel Jul 08 '20 at 15:26
  • I meams: what value can I put into "categoryName". In "run" function. String repositoryURI= args[0];//value is https://localhost:9443/ccm ; String categoryName= args[6];//what value can I put here ; – Li Lu Jul 09 '20 at 01:51

1 Answers1

0

The category name argument is something that is defined in the RTC CCM project against the timeline or the project. A sample for this is shown below. These are the values that are expected in the Category Name Argument.

You can look into your project settings to get this information.

Example Categories

Siddharth Kaul
  • 871
  • 10
  • 20