Skip to main content
summaryrefslogtreecommitdiffstats
blob: a09b0e3f973fb7e01a68024ee6c5c27d8b9f06b4 (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) 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.rest.internal.workitem.model;

import java.util.HashSet;
import java.util.Set;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.rest.IAtsServer;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.ArtifactReadable;

/**
 * @author Donald G. Dunne
 */
public class TeamWorkflow extends WorkItem implements IAtsTeamWorkflow {

   public TeamWorkflow(Log logger, IAtsServer atsServer, ArtifactReadable artifact) {
      super(logger, atsServer, artifact);
   }

   @Override
   public Set<IAtsActionableItem> getActionableItems() throws OseeCoreException {
      Set<IAtsActionableItem> ais = new HashSet<>();
      for (Object aiGuidObj : artifact.getAttributeValues(AtsAttributeTypes.ActionableItem)) {
         String aiGuid = (String) aiGuidObj;
         Long uuid = getAtsServer().getStoreService().getUuidFromGuid(aiGuid);
         if (uuid != null) {
            IAtsActionableItem ai = getAtsServer().getCache().getByUuid(uuid, IAtsActionableItem.class);
            if (ai == null) {
               ArtifactReadable aiArt = getAtsServer().getArtifactByGuid(aiGuid);
               ai = getAtsServer().getConfigItemFactory().getActionableItem(aiArt);
            }
            ais.add(ai);
         }
      }
      return ais;
   }

   @Override
   public IAtsTeamDefinition getTeamDefinition() throws OseeCoreException {
      IAtsTeamDefinition teamDef = null;
      String teamDefGuid = artifact.getSoleAttributeValue(AtsAttributeTypes.TeamDefinition);
      Long uuid = getAtsServer().getStoreService().getUuidFromGuid(teamDefGuid);
      if (uuid != null) {
         teamDef = getAtsServer().getCache().getByUuid(uuid, IAtsTeamDefinition.class);
         if (teamDef == null) {
            ArtifactReadable teamDefArt = getAtsServer().getArtifactByGuid(teamDefGuid);
            teamDef = getAtsServer().getConfigItemFactory().getTeamDef(teamDefArt);
         }
      }
      return teamDef;
   }
}

Back to the top