It's all about the answers!

Ask a question

How to read details of all the Iterations in any RTC Project Area programatically.


Vaibhav S (106354) | asked Aug 30 '18, 2:09 a.m.

Hi,

How to read details of all the Iterations in any RTC Project Area programmatically.

If anyone has achieved this. please let me know.

Thanks
Vaibhav


One answer



permanent link
Vaibhav S (106354) | answered Aug 30 '18, 5:30 a.m.

Hi,

I found this code online. This does the required operation:


private void storeIterationVals(MigrationDetailsBean migDetailsBean, RTCServerConfig rtcServerConfig,
                     Object srcValue, IProgressMonitor monitor) throws TeamRepositoryException {
              PathHelper ph = new PathHelper(rtcServerConfig.getSrcRepo(), monitor);
              ph.calculateIterationPath((IterationHandle) srcValue);

              String paths = "IDPath: [" + ph.toIDPathString() + "] NamePath: (" + ph.toNamePathString() + ")";
              logger.info("Path to Iteration : " + ph.toIDPathString());

              DevelopmentLineHelper devLineUtil = new DevelopmentLineHelper(rtcServerConfig.getSrcRepo(), monitor);
              String iterationPath = ph.toNamePathString();
              IProjectAreaHandle targetPAHandle = migDetailsBean.getTargetProjArea().getProjectArea();
              List path = Arrays.asList(iterationPath.split("/"));

              // map by ID
              IIteration found = devLineUtil.findIteration(targetPAHandle, path, DevelopmentLineHelper.BYID);

              if (found == null) {
                     found = devLineUtil.findIteration(targetPAHandle, path, DevelopmentLineHelper.BYNAME);
              }

              // IIterationHandle found =
              // devLineUtil.fetchIterations(migDetailsBean.getTargetProjArea(), repo,
              // monitor, iterationPath);
              migDetailsBean.getTargetWI().setValue(migDetailsBean.getTargetAttribute(), found);
       }



public IIteration findIteration(IProjectAreaHandle iProjectAreaHandle,
                     List<String> path, Comparemode comparemode) throws TeamRepositoryException {
              fAuditableClient = (IAuditableClient) fTeamRepository
                           .getClientLibrary(IAuditableClient.class);
              IIteration foundIteration = null;
             
              IProjectArea projectArea = (IProjectArea) fTeamRepository.itemManager()
                           .fetchCompleteItem(iProjectAreaHandle, IItemManager.REFRESH,
                                         fMonitor);
              IDevelopmentLine developmentLine = findDevelopmentLine(projectArea,
                           path, comparemode);
              if (developmentLine != null) {
                     foundIteration = findIteration(developmentLine.getIterations(),
                                  path, 1, comparemode);
              }
              return foundIteration;
       }

public IDevelopmentLine findDevelopmentLine(IProjectArea projectArea,
                     List<String> path, Comparemode comparemode) throws TeamRepositoryException {
              int level = 0;
              String fookFor = path.get(level);
              IDevelopmentLineHandle[] developmentLineHandles = projectArea
                           .getDevelopmentLines();
              for (IDevelopmentLineHandle developmentLineHandle : developmentLineHandles) {
                     IDevelopmentLine developmentLine = fAuditableClient
                                  .resolveAuditable(developmentLineHandle,
                                                ItemProfile.DEVELOPMENT_LINE_DEFAULT, fMonitor);
                     String compare = "";
                     switch(comparemode){
                     case BYID:
                           compare = developmentLine.getId();
                           break;
                     case BYNAME:
                           compare = developmentLine.getName();
                           break;
                     case BYLABEL:
                           compare = developmentLine.getLabel();
                           break;
                     }
                     if (fookFor.equals(compare)) {
                           return developmentLine;
                     }
              }
              return null;
       }

      

Your answer


Register or 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.