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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*******************************************************************************
* 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.client.internal.ev;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.ats.api.IAtsConfigObject;
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.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.ev.IAtsEarnedValueService;
import org.eclipse.osee.ats.api.ev.IAtsWorkPackage;
import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.core.client.ev.WorkPackageArtifact;
import org.eclipse.osee.ats.core.client.internal.AtsClientService;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
* @author Donald G. Dunne
*/
public class AtsEarnedValueImpl implements IAtsEarnedValueService {
@Override
public String getWorkPackageId(IAtsWorkItem workItem) {
String guid = null;
Artifact artifact = AtsClientService.get().getArtifact(workItem);
Conditions.checkNotNull(artifact, "workItem", "Can't Find Work Package matching %s", workItem.toStringWithId());
if (artifact instanceof AbstractWorkflowArtifact) {
AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) artifact;
guid = awa.getSoleAttributeValue(AtsAttributeTypes.WorkPackageGuid, null);
}
return guid;
}
@Override
public IAtsWorkPackage getWorkPackage(IAtsWorkItem workItem) throws OseeCoreException {
WorkPackageArtifact wpa = null;
String workPackageGuid = getWorkPackageId(workItem);
if (Strings.isValid(workPackageGuid)) {
Artifact workPkgArt = ArtifactQuery.getArtifactFromId(workPackageGuid, AtsUtilCore.getAtsBranch());
return new WorkPackageArtifact(workPkgArt);
}
return wpa;
}
@Override
public Collection<IAtsWorkPackage> getWorkPackageOptions(IAtsObject object) throws OseeCoreException {
List<IAtsWorkPackage> workPackageOptions = new ArrayList<>();
getWorkPackageOptions(object, workPackageOptions);
return workPackageOptions;
}
public Collection<IAtsWorkPackage> getWorkPackageOptions(IAtsObject object, List<IAtsWorkPackage> workPackageOptions) throws OseeCoreException {
// Config objects get work package options from related work package artifacts
if (object instanceof IAtsConfigObject) {
IAtsConfigObject configObj = (IAtsConfigObject) object;
Artifact artifact = AtsClientService.get().getArtifact(configObj);
if (artifact != null) {
for (Artifact workPackageArt : artifact.getRelatedArtifacts(AtsRelationTypes.WorkPackage_WorkPackage)) {
workPackageOptions.add(new WorkPackageArtifact(workPackageArt));
}
}
}
// Team Wf get work package options of Ais and Team Definition
else if (object instanceof IAtsTeamWorkflow) {
IAtsTeamWorkflow teamWf = (IAtsTeamWorkflow) object;
getWorkPackageOptions(teamWf.getTeamDefinition(), workPackageOptions);
for (IAtsActionableItem ai : teamWf.getActionableItems()) {
getWorkPackageOptions(ai, workPackageOptions);
}
}
// Children work items inherit the work packages options of their parent team workflow
else if (object instanceof IAtsWorkItem) {
IAtsWorkItem workItem = (IAtsWorkItem) object;
// Work Items related to Team Wf get their options from Team Wf
IAtsTeamWorkflow teamWf = workItem.getParentTeamWorkflow();
if (teamWf != null) {
getWorkPackageOptions(teamWf, workPackageOptions);
}
// Stand-alone reviews get their options from related AIs and Team Defs
else if (workItem instanceof IAtsAbstractReview) {
IAtsAbstractReview review = (IAtsAbstractReview) workItem;
for (IAtsActionableItem ai : review.getActionableItems()) {
getWorkPackageOptions(ai, workPackageOptions);
if (ai.getTeamDefinition() != null) {
getWorkPackageOptions(ai.getTeamDefinition(), workPackageOptions);
}
}
}
}
return workPackageOptions;
}
}
|