Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2265b118a49855decde894d852ab2d6b2757ce63 (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
/*
 * 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.reports.split.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinition;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

/**
 * Class to compute states of the workflow and fill the map
 * 
 * @author Chandan Bandemutt
 */
public class StateDistributionEntry {

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

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

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

	/**
	 * Method to compute the states of the workflow and fill the map
	 * 
	 * @throws OseeCoreException
	 *             :
	 */
	public void computeStateSplit() throws OseeCoreException {
		for (AbstractWorkflowArtifact art : this.versionArtifact
				.getRelatedArtifactsOfType(
						AtsRelationTypes.TeamWorkflowTargetedForVersion_Workflow,
						TeamWorkFlowArtifact.class)) {
			IAtsWorkDefinition workDefinition = art.getWorkDefinition();
			List<IAtsStateDefinition> states = workDefinition.getStates();
			for (IAtsStateDefinition state : states) {
				double timeInState = 0;
				if (this.stateSplitMap.containsKey(state.getName())) {
					timeInState = getStateSplitMap().get(state.getName());
				}
				timeInState += art.getStateMgr().getHoursSpent(state.getName());
				this.stateSplitMap.put(state.getName(), timeInState);
			}
		}
	}

}

Back to the top