Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1a56d5e5e02257bd447041ea8f5e30e9b84b91f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2013 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.core.internal.column;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
import org.eclipse.osee.ats.api.review.IAtsReviewService;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.api.workflow.IAtsWorkItemService;
import org.eclipse.osee.ats.core.column.IAtsColumnUtility;
import org.eclipse.osee.ats.core.internal.column.ev.AtsColumnUtilities;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Strings;

/**
 * @author Donald G. Dunne
 */
public class TeamColumnUtility implements IAtsColumnUtility {

   private final IAtsWorkItemService workItemService;
   private final IAtsReviewService reviewService;

   public TeamColumnUtility(IAtsWorkItemService workItemService, IAtsReviewService reviewService) {
      this.workItemService = workItemService;
      this.reviewService = reviewService;
   }

   @Override
   public String getColumnText(IAtsObject atsObject) {
      String result = "";
      try {
         if (atsObject instanceof IAtsTeamWorkflow) {
            result = ((IAtsTeamWorkflow) atsObject).getTeamDefinition().getName();
         } else if (atsObject instanceof IAtsWorkItem) {
            result = getColumnText(((IAtsWorkItem) atsObject).getParentTeamWorkflow());
         }
         if (!Strings.isValid(result) && (atsObject instanceof IAtsAbstractReview)) {
            IAtsAbstractReview review = (IAtsAbstractReview) atsObject;
            if (reviewService.isStandAloneReview(review)) {
               List<IAtsTeamDefinition> teams = new ArrayList<IAtsTeamDefinition>();
               for (IAtsActionableItem ai : review.getActionableItems()) {
                  if (ai.getTeamDefinitionInherited() != null) {
                     teams.add(ai.getTeamDefinition());
                  }
               }
               if (!teams.isEmpty()) {
                  result = Collections.toString(", ", teams);
               }
            }
         }
      } catch (OseeCoreException ex) {
         return AtsColumnUtilities.CELL_ERROR_PREFIX + " - " + ex.getLocalizedMessage();
      }
      return result;
   }

   @Override
   public String getDescription() {
      return "Team that has been assigned to work this Action";
   }

}

Back to the top