Skip to main content
summaryrefslogtreecommitdiffstats
blob: ece49f533a23c44f5e1423552796f433b912841e (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
/*******************************************************************************
 * Copyright (c) 2011 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.config.copy;

import java.util.List;
import org.eclipse.osee.ats.core.config.ActionableItemArtifact;
import org.eclipse.osee.ats.core.config.TeamDefinitionArtifact;
import org.eclipse.osee.ats.core.config.TeamDefinitionManager;
import org.eclipse.osee.ats.core.type.AtsRelationTypes;
import org.eclipse.osee.ats.core.workflow.ActionableItemManagerCore;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.XResultData;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

public class ConfigData {

   String searchStr;
   String replaceStr;
   TeamDefinitionArtifact teamDef;
   ActionableItemArtifact actionableItem;
   boolean retainTeamLeads;
   boolean persistChanges;

   public void validateData(XResultData resultData) {
      if (teamDef == null) {
         resultData.logError("Must Select Team Definition");
      }
      if (actionableItem == null) {
         resultData.logError("Must Select Actionable Item");
      }
      if (!Strings.isValid(searchStr)) {
         resultData.logError("Must Enter Search String");
      }
      if (!Strings.isValid(replaceStr)) {
         resultData.logError("Must Enter Replace String");
      }
      if (searchStr != null && replaceStr != null && searchStr.equals(replaceStr)) {
         resultData.logErrorWithFormat("Search string [%s] can't equal replace string [%s]", searchStr, replaceStr);
      }
   }

   public String getSearchStr() {
      return searchStr;
   }

   public void setSearchStr(String searchStr) {
      this.searchStr = searchStr;
   }

   public String getReplaceStr() {
      return replaceStr;
   }

   public void setReplaceStr(String replaceStr) {
      this.replaceStr = replaceStr;
   }

   public TeamDefinitionArtifact getTeamDef() {
      return teamDef;
   }

   public void setTeamDef(TeamDefinitionArtifact teamDef) {
      this.teamDef = teamDef;
   }

   public boolean isRetainTeamLeads() {
      return retainTeamLeads;
   }

   public void setRetainTeamLeads(boolean retainTeamLeads) {
      this.retainTeamLeads = retainTeamLeads;
   }

   public boolean isPersistChanges() {
      return persistChanges;
   }

   public void setPersistChanges(boolean persistChanges) {
      this.persistChanges = persistChanges;
   }

   public TeamDefinitionArtifact getParentTeamDef() throws OseeCoreException {
      TeamDefinitionArtifact parentTeamDef = null;
      if (teamDef.getParent() instanceof TeamDefinitionArtifact) {
         parentTeamDef = (TeamDefinitionArtifact) teamDef.getParent();
      } else {
         parentTeamDef = TeamDefinitionManager.getTopTeamDefinition();
      }
      return parentTeamDef;
   }

   public ActionableItemArtifact getParentActionableItem() throws OseeCoreException {
      ActionableItemArtifact parentActionableItem = null;
      // Determine parent actionable item if possible, otherwise use top actionable item
      List<Artifact> fromAias = teamDef.getRelatedArtifacts(AtsRelationTypes.TeamActionableItem_ActionableItem);
      if (fromAias.size() == 1) {
         parentActionableItem = (ActionableItemArtifact) fromAias.iterator().next().getParent();
      } else {
         parentActionableItem = ActionableItemManagerCore.getTopActionableItem();
      }
      return parentActionableItem;
   }

   public ActionableItemArtifact getActionableItem() {
      return actionableItem;
   }

   public void setActionableItem(ActionableItemArtifact actionableItem) {
      this.actionableItem = actionableItem;
   }

}

Back to the top