It's all about the answers!

Ask a question

Time sheet data pull not updating when refreshed.

William Hunsicker (4058) | asked May 22 '13, 8:19 a.m.

I have a Plain Java API web based application that displays time sheet information from RTC to the user for the work items they have open or that have closed within the last 7 days.  When the application first comes up, the timesheet information is pulled from the RTC Repository just fine with the code below.  If the user then goes into RTC and updates one of the timesheet elements (lets say to add some hours, and yes they save the hours), and then refreshes the web application, the new hours added do not show up on the display.

In testing, I have gone so far as to close the browser and come back in, and refreshed in every way I can think of, but the data still shows the original pull.  If I stop and restart the web server, then the data is refreshed.  Does anyone know how I can direct the data to refresh?  I have traced the code, and every time the getReferences() method is called, it returns only the first timesheet entry, not the newly added one.



 public List<RTCTaskEntries> getActiveTimeSheets (RTCClient client, String username, Date startDate) throws Exception {
  // Declaration section for reusable objects/variables
  if (!TeamPlatform.isStarted()) {
  service = TeamPlatform.getTeamRepositoryService();
  teamRepository = service.getTeamRepository(client.getBaseURL());
  teamRepository.registerLoginHandler(new LoginHandler(client.username, client.password));
  itemManager = teamRepository.itemManager();
  processClient = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
  uri = URI.create(client.projectName.replaceAll(" ", "%20"));
  projectArea = (IProjectArea) processClient.findProcessArea(uri, null, null);
  queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
  wicService = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
  wcm = wicService.getWorkItemWorkingCopyManager();
  try {
   IWorkItemHandle wiHandle = null;
   IWorkItem wi = null;
   WorkItemWorkingCopy wc = null;
   ITimeSheetEntry tseRec; // Not able to initialize to null due to object type.
   IItemHandle refItem = null;
   // Query where clause parameters
   //Limit Project
   IQueryableAttribute projectAttribute = findAttribute(teamRepository, projectArea, IWorkItem.PROJECT_AREA_PROPERTY, null);
   Expression projectExpression = new AttributeExpression(projectAttribute, AttributeOperation.EQUALS, projectArea);
   //Limit Owner
   IQueryableAttribute ownerAttribute = findAttribute(teamRepository, projectArea, IWorkItem.OWNER_PROPERTY, null);
   Expression ownerExpression = new AttributeExpression(ownerAttribute, AttributeOperation.EQUALS, getOwner(username, teamRepository));
   //Limit to TASKs
   IQueryableAttribute typeAttribute = findAttribute(teamRepository, projectArea, IWorkItem.TYPE_PROPERTY, null);
   Expression typeExpression = new AttributeExpression(typeAttribute, AttributeOperation.EQUALS, "task");
   // Set up the where clause object
   Term term = new Term(Operator.AND);
   IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);
   while (results.hasNext(monitor)) {
    wi =;
    IWorkflowInfo wfi = wicService.findWorkflowInfo(wi, monitor);
    int workFlowState = -1;
    if (wfi != null) {
     workFlowState = wfi.getStateGroup(wi.getState2());
    if (((workFlowState == IWorkflowInfo.OPEN_STATES) || (workFlowState == IWorkflowInfo.IN_PROGRESS_STATES)) ||  // All Open Tasks
     ((workFlowState == IWorkflowInfo.CLOSED_STATES) && (wi.getResolutionDate().after(cutoffForClosedTasks))))  // Closed tasks which were closed 7 days before this period
     // Create and populate a DTO object with work item data needed for display
     wiHandle = (IWorkItemHandle) wi.getItemHandle();
     wcm.connect(wiHandle, IWorkItem.FULL_PROFILE, monitor);
     wc = wicService.getWorkItemWorkingCopyManager().getWorkingCopy(wiHandle);
     IWorkItemReferences itemReference = wc.getReferences();
     List<IReference> times = itemReference.getReferences(WorkItemEndPoints.WORK_TIME);
     for (IReference workTimes : times) {
      if (workTimes.isItemReference()) {
       refItem = ((IItemReference) workTimes).getReferencedItem();
       if (refItem instanceof ITimeSheetEntryHandle) {
        tseRec = (ITimeSheetEntry) itemManager.fetchCompleteItem(refItem, IItemManager.REFRESH, monitor);
        IContributor creator = (IContributor) itemManager.fetchCompleteItem(tseRec.getCreator(), IItemManager.REFRESH, monitor);
        if (wiCreator.equals(creator)) {
         // Create and populate a time sheet DTO for dispaly
  catch (Exception ex) {
   throw ex;
  finally {
   wcm = null;
   wicService = null;
   queryClient = null;
   projectArea = null;
   uri = null;
   processClient = null;
   itemManager = null;
   teamRepository = null;
   service = null;

Be the first one to answer this question!

Register or to post your answer.