Skip to main content
summaryrefslogtreecommitdiffstats
blob: adf72aad4cdcb7f0354c3a83d45d69f9984dc30d (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*******************************************************************************
 * 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 org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.agile.IAgileBacklog;
import org.eclipse.osee.ats.api.agile.IAgileItem;
import org.eclipse.osee.ats.api.agile.IAgileSprint;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
import org.eclipse.osee.ats.api.team.IAtsWorkItemFactory;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsGoal;
import org.eclipse.osee.ats.api.workflow.IAtsTask;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.impl.IAtsServer;
import org.eclipse.osee.ats.impl.internal.action.Action;
import org.eclipse.osee.ats.impl.internal.agile.AgileBacklog;
import org.eclipse.osee.ats.impl.internal.agile.AgileSprint;
import org.eclipse.osee.framework.core.data.ArtifactId;
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 WorkItemFactory implements IAtsWorkItemFactory {

   private final Log logger;
   private final IAtsServer atsServer;

   public WorkItemFactory(Log logger, IAtsServer atsServer) {
      this.logger = logger;
      this.atsServer = atsServer;
   }

   @Override
   public IAtsTeamWorkflow getTeamWf(ArtifactId artifact) throws OseeCoreException {
      IAtsTeamWorkflow team = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.TeamWorkflow)) {
            team = new TeamWorkflow(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return team;
   }

   @Override
   public IAtsWorkItem getWorkItem(ArtifactId artifact) {
      IAtsWorkItem workItem = null;
      try {
         if (artifact instanceof ArtifactReadable) {
            ArtifactReadable artRead = (ArtifactReadable) artifact;
            if (artRead.isOfType(AtsArtifactTypes.TeamWorkflow)) {
               workItem = getTeamWf(artifact);
            } else if (artRead.isOfType(AtsArtifactTypes.PeerToPeerReview) || artRead.isOfType(AtsArtifactTypes.DecisionReview)) {
               workItem = getReview(artRead);
            } else if (artRead.isOfType(AtsArtifactTypes.Task)) {
               workItem = getTask(artRead);
            } else if (artRead.isOfType(AtsArtifactTypes.Goal)) {
               workItem = getGoal(artRead);
            } else if (artRead.isOfType(AtsArtifactTypes.AgileSprint)) {
               workItem = getAgileSprint(artRead);
            }
         }
      } catch (OseeCoreException ex) {
         logger.error(ex, "Error getting work item for [%s]", artifact);
      }
      return workItem;
   }

   @Override
   public IAtsGoal getGoal(ArtifactId artifact) throws OseeCoreException {
      IAtsGoal goal = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.Goal)) {
            goal = new Goal(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return goal;
   }

   @Override
   public IAgileSprint getAgileSprint(ArtifactId artifact) throws OseeCoreException {
      IAgileSprint sprint = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.AgileSprint)) {
            sprint = new AgileSprint(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return sprint;
   }

   @Override
   public IAgileItem getAgileItem(ArtifactId artifact) {
      IAgileItem item = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.AbstractWorkflowArtifact)) {
            item =
               new org.eclipse.osee.ats.impl.internal.agile.AgileItem(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return item;
   }

   @Override
   public IAgileBacklog getAgileBacklog(ArtifactId artifact) throws OseeCoreException {
      IAgileBacklog backlog = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.Goal)) {
            backlog = new AgileBacklog(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return backlog;
   }

   @Override
   public IAtsTask getTask(ArtifactId artifact) throws OseeCoreException {
      IAtsTask task = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.Task)) {
            task = new Task(logger, atsServer, (ArtifactReadable) artifact);
         }
      }
      return task;
   }

   @Override
   public IAtsAbstractReview getReview(ArtifactId artifact) throws OseeCoreException {
      IAtsAbstractReview review = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.PeerToPeerReview)) {
            review = new PeerToPeerReview(logger, atsServer, artRead);
         } else {
            review = new DecisionReview(logger, atsServer, artRead);
         }
      }
      return review;
   }

   @Override
   public IAtsAction getAction(ArtifactId artifact) {
      IAtsAction action = null;
      if (artifact instanceof ArtifactReadable) {
         ArtifactReadable artRead = (ArtifactReadable) artifact;
         if (artRead.isOfType(AtsArtifactTypes.Action)) {
            action = new Action(atsServer, artRead);
         }
      }
      return action;
   }

   @Override
   public IAtsWorkItem getWorkItemByAtsId(String atsId) {
      ArtifactReadable artifact = atsServer.getQuery().and(AtsAttributeTypes.AtsId, atsId).getResults().getOneOrNull();
      return getWorkItem(artifact);
   }

}

Back to the top