Skip to main content
summaryrefslogtreecommitdiffstats
blob: d2642d5d1c738742b2b326f51231384f4b6e6bcc (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*******************************************************************************
 * 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.impl.internal.workitem;

import java.util.ArrayList;
import java.util.Collection;
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.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
import org.eclipse.osee.ats.core.config.TeamDefinitions;
import org.eclipse.osee.ats.core.model.impl.AtsConfigObject;
import org.eclipse.osee.ats.impl.IAtsServer;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.ArtifactReadable;

/**
 * @author Donald G Dunne
 */
public class ActionableItem extends AtsConfigObject implements IAtsActionableItem {

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

   @Override
   public Collection<IAtsActionableItem> getChildrenActionableItems() {
      Set<IAtsActionableItem> children = new HashSet<IAtsActionableItem>();
      try {
         for (ArtifactReadable childArt : getArtifact().getRelated(CoreRelationTypes.Default_Hierarchical__Child)) {
            IAtsActionableItem childTeamDef = atsServices.getConfigItemFactory().getActionableItem(childArt);
            children.add(childTeamDef);
         }
      } catch (OseeCoreException ex) {
         getLogger().error(ex, "Error getting Children Actionable Items");
      }
      return children;
   }

   private ArtifactReadable getArtifact() {
      return (ArtifactReadable) artifact;
   }

   @Override
   public IAtsActionableItem getParentActionableItem() {
      IAtsActionableItem parent = null;
      try {
         ResultSet<ArtifactReadable> related = getArtifact().getRelated(CoreRelationTypes.Default_Hierarchical__Parent);
         if (!related.isEmpty()) {
            parent = atsServices.getConfigItemFactory().getActionableItem(related.iterator().next());
         }
      } catch (OseeCoreException ex) {
         getLogger().error(ex, "Error getParentActionableItem");
      }
      return parent;
   }

   @Override
   public IAtsTeamDefinition getTeamDefinition() {
      IAtsTeamDefinition teamDef = null;
      try {
         ResultSet<ArtifactReadable> related = getArtifact().getRelated(AtsRelationTypes.TeamActionableItem_Team);
         if (!related.isEmpty()) {
            teamDef = atsServices.getConfigItemFactory().getTeamDef(related.iterator().next());
         }
      } catch (OseeCoreException ex) {
         getLogger().error(ex, "Error getTeamDefinition");
      }
      return teamDef;
   }

   @Override
   public IAtsTeamDefinition getTeamDefinitionInherited() {
      return TeamDefinitions.getImpactedTeamDef(this);
   }

   @Override
   public void setParentActionableItem(IAtsActionableItem parentActionableItem) {
      throw new UnsupportedOperationException("Error ActionableItem.setParentActionableItem not implemented");
   }

   @Override
   public void setTeamDefinition(IAtsTeamDefinition teamDef) {
      throw new UnsupportedOperationException("Error ActionableItem.setTeamDefinition not implemented");
   }

   @Override
   public void setActionable(boolean actionable) {
      throw new UnsupportedOperationException("Error ActionableItem.setActionable not implemented");
   }

   @Override
   public void setActive(boolean active) {
      throw new UnsupportedOperationException("Error ActionableItem.setActive not implemented");
   }

   @Override
   public String getTypeName() {
      return "Actionable Item";
   }

   @Override
   public boolean isAllowUserActionCreation() {
      return getArtifact().getSoleAttributeValue(AtsAttributeTypes.AllowUserActionCreation, true);
   }

   @Override
   public void setAllowUserActionCreation(boolean allowUserActionCreation) {
      throw new UnsupportedOperationException("Error ActionableItem.setAllowUserActionCreation not implemented");
   }

   @Override
   public void addRule(String rule) {
      throw new UnsupportedOperationException("ActionableItem.addRule not implemented");
   }

   @Override
   public Collection<String> getRules() {
      Collection<String> rules = new ArrayList<String>();
      try {
         rules = getArtifact().getAttributeValues(AtsAttributeTypes.RuleDefinition);
      } catch (OseeCoreException ex) {
         getLogger().error(ex, "Error getting rules");
      }
      return rules;
   }

   @Override
   public boolean hasRule(String rule) {
      boolean result = false;
      for (String rule2 : getRules()) {
         if (rule.equals(rule2)) {
            result = true;
            break;
         }
      }
      return result;
   }

   @Override
   public void removeRule(String rule) {
      throw new UnsupportedOperationException("ActionableItem.setActionable not implemented");
   }

}

Back to the top