Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0398b46335a594a1d17b499a16f5f52ed0dd9287 (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
/*
 * Copyright (c) 2012 Robert Bosch Engineering and Business Solutions Ltd India. 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
 */
package org.eclipse.osee.ats.reports.split.model;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.util.HoursSpentUtil;
import org.eclipse.osee.ats.reports.split.internal.AtsClientService;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

/**
 * Class to compute the work from work flow and fill the map
 * 
 * @author Chandan Bandemutt
 */
public class TeamDistributionEntry {

   private final Artifact versionArtifact;
   private final Map<String, Double> teamSplitMap;

   /**
    * Constructor to set the version artifact and to instantiate the map
    * 
    * @param verArtifact : sets the version artifact
    */
   public TeamDistributionEntry(final Artifact verArtifact) {
      this.versionArtifact = verArtifact;
      this.teamSplitMap = new HashMap<String, Double>();
   }

   /**
    * Method to compute the work from work flow and fill the map
    * 
    * @throws OseeCoreException :
    */
   public void computeTeamSplit() throws OseeCoreException {
      Collection<TeamWorkFlowArtifact> teamWorkflows =
         this.versionArtifact.getRelatedArtifactsOfType(AtsRelationTypes.TeamWorkflowTargetedForVersion_Workflow,
            TeamWorkFlowArtifact.class);
      for (TeamWorkFlowArtifact workflow : teamWorkflows) {
         double work = 0;
         String teamName = workflow.getTeamName();
         if (this.teamSplitMap.containsKey(teamName)) {
            work = this.teamSplitMap.get(teamName);
         }
         double hoursSpent = HoursSpentUtil.getHoursSpentTotal(workflow, AtsClientService.get().getServices());
         this.teamSplitMap.put(teamName, work + hoursSpent);
      }
   }

   /**
    * @return the map
    */
   public Map<String, Double> getTeamSplitMap() {
      return this.teamSplitMap;
   }

}

Back to the top