| 2141 |
ghuddy |
1 |
using System;
|
| 2151 |
ghuddy |
2 |
using System.Text;
|
|
|
3 |
using System.Globalization;
|
|
|
4 |
using System.Collections;
|
|
|
5 |
using System.Windows.Forms;
|
| 2141 |
ghuddy |
6 |
using ReqPro40;
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
namespace EA_ReqPro
|
|
|
10 |
{
|
|
|
11 |
|
|
|
12 |
/// <summary>
|
| 2155 |
ghuddy |
13 |
/// ImportReqProDatabase is a specialisation of CopyReqProDatabaseToMemory, designed to copy the
|
|
|
14 |
/// ReqPro database content into an EA database, discarding the structure of and hierarchy of
|
|
|
15 |
/// packages, selecting just the requirements found in the ReqPro database for storage into EA,
|
|
|
16 |
/// where they will be used for design traceability purposes.
|
| 2141 |
ghuddy |
17 |
/// </summary>
|
| 2155 |
ghuddy |
18 |
public class ImportReqProDatabase : CopyReqProDatabaseToMemory
|
|
|
19 |
{
|
| 2151 |
ghuddy |
20 |
private int totalRequirements = 0;
|
|
|
21 |
|
| 2141 |
ghuddy |
22 |
/// <summary>
|
|
|
23 |
/// Constructor logic
|
|
|
24 |
/// </summary>
|
|
|
25 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
26 |
public ImportReqProDatabase(): base()
|
| 2155 |
ghuddy |
27 |
{
|
| 2151 |
ghuddy |
28 |
totalRequirements = 0;
|
| 2155 |
ghuddy |
29 |
}
|
| 2141 |
ghuddy |
30 |
|
|
|
31 |
|
|
|
32 |
/// <summary>
|
|
|
33 |
/// Method to parse a ReqPro database using the information in a ReqProDB artifact,
|
|
|
34 |
/// assumed to be selected in EA's project browser prior to the method call.
|
|
|
35 |
/// </summary>
|
|
|
36 |
/// <param name="ea_repository"></param>
|
|
|
37 |
/// <returns></returns>
|
| 2155 |
ghuddy |
38 |
public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode, out bool cancelled)
|
| 2151 |
ghuddy |
39 |
{
|
| 2155 |
ghuddy |
40 |
cancelled = false;
|
|
|
41 |
|
| 2151 |
ghuddy |
42 |
try
|
|
|
43 |
{
|
| 2155 |
ghuddy |
44 |
base.structure_only = false;
|
|
|
45 |
|
|
|
46 |
string importDateTime = System.DateTime.Now.ToString();
|
|
|
47 |
|
|
|
48 |
Main.WriteOutput("EA Requirement import at " + importDateTime, -1 );
|
|
|
49 |
Main.WriteOutput("",-1);
|
|
|
50 |
|
|
|
51 |
if (true == base.prompt_and_parse(mode, out cancelled))
|
| 2151 |
ghuddy |
52 |
{
|
|
|
53 |
if (Main.mustAbort)
|
|
|
54 |
return false;
|
|
|
55 |
|
|
|
56 |
Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
|
|
|
57 |
|
|
|
58 |
// Configure the ReqProDB artifact as a traceability artifact
|
|
|
59 |
RQ_Artifact.set_traceability_mode(RQ_Element);
|
|
|
60 |
|
| 2155 |
ghuddy |
61 |
ImportFromReqPro(importDateTime);
|
| 2151 |
ghuddy |
62 |
|
|
|
63 |
return true;
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
catch (Exception ex)
|
|
|
67 |
{
|
| 2153 |
ghuddy |
68 |
Main.MessageBoxException(ex, "Exception (parse)");
|
| 2151 |
ghuddy |
69 |
}
|
| 2155 |
ghuddy |
70 |
|
| 2151 |
ghuddy |
71 |
return false;
|
|
|
72 |
}
|
|
|
73 |
|
| 2141 |
ghuddy |
74 |
/// <summary>
|
|
|
75 |
/// Displays the content of the change log element to the output trace display. This method must
|
|
|
76 |
/// be kept in sync with the ImportFromReqPro method, obviously.
|
|
|
77 |
/// </summary>
|
|
|
78 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
79 |
/// <param name="changeLog"></param>
|
|
|
80 |
public void displayChangeLog(EA.Element changeLog)
|
| 2141 |
ghuddy |
81 |
{
|
|
|
82 |
// The change log element contains all the log in its notes section. Break it up into
|
|
|
83 |
// lines, because each line is a single log entry, so that we can process them one at
|
|
|
84 |
// a time.
|
|
|
85 |
string delimStr = "\n";
|
|
|
86 |
char [] delim = delimStr.ToCharArray();
|
|
|
87 |
string[] log_strings = changeLog.Notes.Split(delim,2000);
|
|
|
88 |
|
|
|
89 |
// Prepare a string to form an updated change log (needed to support the activity of orphaned
|
|
|
90 |
// requirement deletion).
|
|
|
91 |
string newList = "";
|
|
|
92 |
|
|
|
93 |
// modify delimiters to : character so that we can extract the parameters for each log entry
|
|
|
94 |
delimStr = ":";
|
|
|
95 |
delim = delimStr.ToCharArray();
|
|
|
96 |
|
| 2155 |
ghuddy |
97 |
Main.WriteOutput("Displaying Import Change Log", -1);
|
| 2141 |
ghuddy |
98 |
|
|
|
99 |
foreach(string s in log_strings)
|
|
|
100 |
{
|
| 2151 |
ghuddy |
101 |
if (Main.mustAbort)
|
|
|
102 |
break;
|
|
|
103 |
|
| 2141 |
ghuddy |
104 |
// over time, users may delete the orphaned requirements from the EA database, but their
|
|
|
105 |
// GUIDs will still exist in the change log. Use of such a GUID will cause
|
|
|
106 |
// an exception in the GetElementByGuid() function. What should we do? We can attempt
|
|
|
107 |
// to remove those GUIDs from the list. We can do this by accumulating a new list of GUIDs
|
|
|
108 |
// that is formed from the old list, where only good items from the old list find their
|
|
|
109 |
// way into the new list. Gradually, the list is wittled away as EA users delete orphaned
|
|
|
110 |
// requirements having first dealt with the design change impacts that resulted from their
|
|
|
111 |
// orphanage.
|
|
|
112 |
try
|
|
|
113 |
{
|
|
|
114 |
if (s.StartsWith("{"))
|
|
|
115 |
{
|
|
|
116 |
string trimmed_s = s.Trim();
|
|
|
117 |
|
|
|
118 |
// Get log entry;s parameters.
|
|
|
119 |
string[] parameters = trimmed_s.Split(delim, 10);
|
|
|
120 |
|
|
|
121 |
// The first parameter is the GUID so use it to get the requirement element
|
| 2151 |
ghuddy |
122 |
EA.Element ea_req = Main.EA_Repository.GetElementByGuid(parameters[0]);
|
| 2141 |
ghuddy |
123 |
|
|
|
124 |
// Now discriminate actions based on the second parameter
|
|
|
125 |
|
|
|
126 |
if (parameters[1].StartsWith("Created"))
|
|
|
127 |
{
|
| 2155 |
ghuddy |
128 |
Main.WriteOutput(" Created : " + ea_req.Name, ea_req.ElementID );
|
| 2141 |
ghuddy |
129 |
}
|
| 2155 |
ghuddy |
130 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
131 |
else if (parameters[1].StartsWith("Orphaned"))
|
|
|
132 |
{
|
| 2155 |
ghuddy |
133 |
Main.WriteOutput(" Orphaned : " + ea_req.Name, ea_req.ElementID );
|
| 2141 |
ghuddy |
134 |
|
|
|
135 |
foreach (EA.Connector theConnector in ea_req.Connectors)
|
|
|
136 |
{
|
| 2159 |
ghuddy |
137 |
int destId = -1;
|
|
|
138 |
|
|
|
139 |
// we dont care about direction of relationship, so test for both
|
|
|
140 |
if (theConnector.ClientID == ea_req.ElementID)
|
|
|
141 |
destId = theConnector.SupplierID;
|
|
|
142 |
else if (theConnector.SupplierID == ea_req.ElementID)
|
|
|
143 |
destId = theConnector.ClientID;
|
|
|
144 |
else
|
|
|
145 |
destId = theConnector.SupplierID;
|
|
|
146 |
|
|
|
147 |
// and make sure we filter out self-referential connectors
|
|
|
148 |
if (destId != ea_req.ElementID)
|
| 2141 |
ghuddy |
149 |
{
|
| 2159 |
ghuddy |
150 |
EA.Package tgt_pkg = (EA.Package)Main.EA_Repository.GetPackageByID( destId );
|
|
|
151 |
if (tgt_pkg != null)
|
| 2141 |
ghuddy |
152 |
{
|
| 2159 |
ghuddy |
153 |
Main.WriteOutput(" --> " + tgt_pkg.Name, tgt_pkg.PackageID);
|
| 2141 |
ghuddy |
154 |
}
|
| 2159 |
ghuddy |
155 |
else
|
|
|
156 |
{
|
|
|
157 |
EA.Element tgt_ele = (EA.Element)Main.EA_Repository.GetElementByID( destId );
|
|
|
158 |
if (tgt_ele != null)
|
|
|
159 |
{
|
|
|
160 |
//if (!tgt_ele.Type.StartsWith("Requirement"))
|
|
|
161 |
Main.WriteOutput(" --> " + tgt_ele.Name, tgt_ele.ElementID);
|
|
|
162 |
}
|
|
|
163 |
}
|
| 2141 |
ghuddy |
164 |
}
|
|
|
165 |
}
|
|
|
166 |
}
|
| 2155 |
ghuddy |
167 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
168 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_NAME))
|
| 2141 |
ghuddy |
169 |
{
|
| 2161 |
ghuddy |
170 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_NAME, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
171 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
172 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
173 |
}
|
| 2155 |
ghuddy |
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
175 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_NOTES)) // aka Description of the requirement
|
| 2141 |
ghuddy |
176 |
{
|
| 2161 |
ghuddy |
177 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", "Description", ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
178 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
179 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
180 |
}
|
| 2155 |
ghuddy |
181 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
182 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_DIFFICULTY))
|
| 2141 |
ghuddy |
183 |
{
|
| 2161 |
ghuddy |
184 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_DIFFICULTY, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
185 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
186 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
187 |
}
|
| 2155 |
ghuddy |
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
189 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_PRIORITY))
|
| 2141 |
ghuddy |
190 |
{
|
| 2161 |
ghuddy |
191 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_PRIORITY, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
192 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
193 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
194 |
}
|
| 2155 |
ghuddy |
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
196 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_VERSION))
|
| 2141 |
ghuddy |
197 |
{
|
| 2161 |
ghuddy |
198 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_VERSION, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
199 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
200 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
201 |
}
|
| 2155 |
ghuddy |
202 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
203 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_STATUS))
|
| 2141 |
ghuddy |
204 |
{
|
| 2161 |
ghuddy |
205 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_STATUS, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
206 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
207 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
208 |
}
|
| 2155 |
ghuddy |
209 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
210 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_SUBSYSTEM_TYPE))
|
| 2155 |
ghuddy |
211 |
{
|
| 2161 |
ghuddy |
212 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_SUBSYSTEM_TYPE, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
213 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
214 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
215 |
}
|
|
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
217 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_STABILITY))
|
| 2155 |
ghuddy |
218 |
{
|
| 2161 |
ghuddy |
219 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_STABILITY, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
220 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
221 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
222 |
}
|
|
|
223 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
224 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_REQ_TYPE))
|
| 2155 |
ghuddy |
225 |
{
|
| 2161 |
ghuddy |
226 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_REQ_TYPE, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
227 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
228 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
229 |
}
|
|
|
230 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
231 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_SOURCE_VERSION))
|
| 2155 |
ghuddy |
232 |
{
|
| 2161 |
ghuddy |
233 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_SOURCE_VERSION, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
234 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
235 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
236 |
}
|
|
|
237 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
238 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_SOURCE_SECTION))
|
| 2155 |
ghuddy |
239 |
{
|
| 2161 |
ghuddy |
240 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_SOURCE_SECTION, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
241 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
242 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
243 |
}
|
|
|
244 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2161 |
ghuddy |
245 |
else if (parameters[1].StartsWith(Constants.CHG_LOG_SOURCE))
|
| 2155 |
ghuddy |
246 |
{
|
| 2161 |
ghuddy |
247 |
Main.WriteOutput(string.Format(" Modified {0}: {1}", Constants.CHG_LOG_SOURCE, ea_req.Name), ea_req.ElementID );
|
| 2155 |
ghuddy |
248 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
249 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
250 |
}
|
| 2141 |
ghuddy |
251 |
|
|
|
252 |
// accumulate good item into the newList
|
|
|
253 |
newList += trimmed_s + "\r\n";
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
catch
|
|
|
257 |
{
|
|
|
258 |
// do nothing - the newList accumulator will not have the GUID that caused the exception
|
|
|
259 |
// so the next time a display operation is attempted, the exception wont happen.
|
|
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
// Update the change log
|
|
|
264 |
changeLog.Notes = newList;
|
|
|
265 |
changeLog.Update();
|
|
|
266 |
}
|
|
|
267 |
|
| 2147 |
ghuddy |
268 |
|
|
|
269 |
/// <summary>
|
|
|
270 |
/// Rid a string of any : char because we use that as a delimiter in the change log and so we
|
|
|
271 |
/// do not want a users use of the character to confuse the change log display mechanism.
|
|
|
272 |
/// </summary>
|
|
|
273 |
/// <param name="s"></param>
|
|
|
274 |
/// <returns></returns>
|
|
|
275 |
private string NO_COLONS(string s)
|
|
|
276 |
{
|
|
|
277 |
string sc = s.Replace(':', ' ');
|
|
|
278 |
sc = sc.Replace('\r' , ' ');
|
|
|
279 |
sc = sc.Replace('\n' , ' ');
|
|
|
280 |
|
|
|
281 |
return sc;
|
|
|
282 |
}
|
| 2151 |
ghuddy |
283 |
|
| 2155 |
ghuddy |
284 |
/// <summary>
|
|
|
285 |
/// Get a new import package in which to store change log and new requirements from the import.
|
|
|
286 |
/// </summary>
|
|
|
287 |
/// <param name="parentPackage"></param>
|
|
|
288 |
/// <param name="importDateTime"></param>
|
|
|
289 |
/// <returns></returns>
|
|
|
290 |
private EA.Package createImportPackage(EA.Package parentPackage, string importDateTime)
|
|
|
291 |
{
|
|
|
292 |
EA.Package importPackage = null;
|
|
|
293 |
string importSubDir = EA_TaggedValues.Read(base.RQ_Element, Constants.TAG_IMPORT_SUB_DIR, "");
|
|
|
294 |
if (importSubDir != null && importSubDir.Length > 0)
|
|
|
295 |
{
|
|
|
296 |
importPackage = (EA.Package)parentPackage.Packages.GetByName(importSubDir);
|
|
|
297 |
if (importPackage != null)
|
|
|
298 |
{
|
|
|
299 |
parentPackage = importPackage;
|
|
|
300 |
}
|
|
|
301 |
else
|
|
|
302 |
{
|
|
|
303 |
// create a subdir and use it as the parent
|
|
|
304 |
parentPackage = (EA.Package )parentPackage.Packages.AddNew( importSubDir, "Package");
|
|
|
305 |
parentPackage.Update();
|
|
|
306 |
}
|
|
|
307 |
}
|
| 2151 |
ghuddy |
308 |
|
| 2155 |
ghuddy |
309 |
// create the import dir in the parent
|
|
|
310 |
importPackage = (EA.Package )parentPackage.Packages.AddNew( "import " + importDateTime, "Package");
|
|
|
311 |
importPackage.Update();
|
|
|
312 |
|
|
|
313 |
return importPackage;
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
| 2151 |
ghuddy |
318 |
/// <summary>
|
|
|
319 |
/// A method that imports requirements from a ReqPro database into EA for the purpose
|
|
|
320 |
/// of supporting requirement-to-design traceability.
|
|
|
321 |
/// </summary>
|
|
|
322 |
/// <param name="repository"></param>
|
| 2155 |
ghuddy |
323 |
private void ImportFromReqPro(string importDateTime)
|
| 2151 |
ghuddy |
324 |
{
|
|
|
325 |
try
|
|
|
326 |
{
|
|
|
327 |
// Get a list of EA requirements and their associated ReqPro GUIDs
|
|
|
328 |
ArrayList ea_reqs;
|
|
|
329 |
ArrayList ea_GUIDs = new ArrayList();
|
|
|
330 |
ArrayList ea_req_matched = new ArrayList();
|
|
|
331 |
|
|
|
332 |
// Obtain the EA parent package so that we can create under it an import package
|
|
|
333 |
// if need be, and scan for existing requirement elements.
|
|
|
334 |
EA.Package parentPackage = Main.EA_Repository.GetPackageByID( base.RQ_Element.PackageID );
|
|
|
335 |
|
|
|
336 |
ArrayList allowedElementTypes = new ArrayList();
|
|
|
337 |
allowedElementTypes.Add("Requirement");
|
|
|
338 |
allowedElementTypes.Add("UseCase");
|
|
|
339 |
|
| 2155 |
ghuddy |
340 |
Main.WriteOutput("Acquiring list of elements already in EA", -1);
|
| 2151 |
ghuddy |
341 |
ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
|
| 2153 |
ghuddy |
342 |
EA_Utilities.findAndProcessPackageElements( parentPackage, reqLister, true );
|
| 2151 |
ghuddy |
343 |
|
|
|
344 |
if (Main.mustAbort)
|
|
|
345 |
return;
|
|
|
346 |
|
|
|
347 |
ea_reqs = reqLister.Elements;
|
|
|
348 |
foreach (EA.Element ea_req in ea_reqs)
|
|
|
349 |
{
|
| 2155 |
ghuddy |
350 |
string GUID = EA_TaggedValues.Read(ea_req, Constants.TAG_GUID);
|
| 2151 |
ghuddy |
351 |
ea_GUIDs.Add(GUID);
|
|
|
352 |
ea_req_matched.Add(false);
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
if (Main.mustAbort)
|
|
|
356 |
return;
|
|
|
357 |
|
| 2155 |
ghuddy |
358 |
// Create an import package to store new requirements and the change log
|
|
|
359 |
EA.Package importPackage = createImportPackage(parentPackage, importDateTime);
|
| 2151 |
ghuddy |
360 |
|
| 2155 |
ghuddy |
361 |
// Create the change log element in the import package
|
| 2151 |
ghuddy |
362 |
EA.Element changeLog = (EA.Element)importPackage.Elements.AddNew("Change Log","InformationItem");
|
|
|
363 |
changeLog.Update();
|
|
|
364 |
|
|
|
365 |
// Get a flattened list of requirements from the hierarchical data the user has filtered
|
|
|
366 |
ArrayList rq_req_collection = new ArrayList();
|
|
|
367 |
get_rq_req_collection(ref rq_req_collection);
|
|
|
368 |
|
|
|
369 |
int newRequirementCount = 0;
|
|
|
370 |
int modifiedRequirementCount = 0;
|
|
|
371 |
int statusUpdatedRequirementCount = 0;
|
|
|
372 |
int orphanedCount = 0;
|
|
|
373 |
|
|
|
374 |
|
| 2155 |
ghuddy |
375 |
Main.WriteOutput("Merging ReqPro content to EA", -1);
|
| 2151 |
ghuddy |
376 |
// loop through all of the ReqPro requirements
|
|
|
377 |
foreach(ReqPro_object rq_obj in rq_req_collection)
|
|
|
378 |
{
|
|
|
379 |
if (Main.mustAbort)
|
|
|
380 |
break;
|
|
|
381 |
|
|
|
382 |
try
|
|
|
383 |
{
|
|
|
384 |
// Find which EA requirement element refers to the current ReqPro GUID
|
|
|
385 |
int i_ea_req;
|
|
|
386 |
i_ea_req = ea_GUIDs.IndexOf( rq_obj.guid );
|
|
|
387 |
|
|
|
388 |
// If EA element was found
|
|
|
389 |
if (0 <= i_ea_req)
|
|
|
390 |
{
|
|
|
391 |
ea_req_matched[i_ea_req] = true;
|
|
|
392 |
|
|
|
393 |
EA.Element ea_req = ((EA.Element)ea_reqs[i_ea_req]);
|
|
|
394 |
|
|
|
395 |
rq_obj.ea_element_ID = ea_req.ElementID;
|
|
|
396 |
|
| 2155 |
ghuddy |
397 |
// Only update the requirement if it was not mastered in EA, or
|
|
|
398 |
// unrestricted imports have been enabled
|
|
|
399 |
if ( (false == EA_TaggedValues.Read(ea_req, Constants.TAG_CREATED_IN_EA, Constants.DEFAULT_CREATED_IN_EA))
|
|
|
400 |
|| (true == EA_TaggedValues.Read(ea_req, Constants.TAG_UNRESTRICTED_IMPORTS, Constants.DEFAULT_UNRESTRICTED_IMPORTS)) )
|
|
|
401 |
{
|
|
|
402 |
// This ReqPro requirement already has a counterpart in EA, so we must simply
|
|
|
403 |
// update the counterpart. But, to aid the designer, we need to try to tell them
|
|
|
404 |
// how the requirement has changed, which could ofcoarse change the meaning
|
|
|
405 |
// of the requirement and require design changes to be done.
|
| 2151 |
ghuddy |
406 |
|
| 2155 |
ghuddy |
407 |
bool meaningMayHaveChanged = false;
|
|
|
408 |
bool statusMayHaveChanged = false;
|
| 2151 |
ghuddy |
409 |
|
| 2155 |
ghuddy |
410 |
string ea_req_name = rq_obj.tag + " " + rq_obj.name;
|
| 2151 |
ghuddy |
411 |
|
| 2155 |
ghuddy |
412 |
Main.WriteOutput("Updating: " + ea_req_name, rq_obj.ea_element_ID);
|
| 2151 |
ghuddy |
413 |
|
| 2161 |
ghuddy |
414 |
ea_req.Name = updated_property_value_if_changed(changeLog, ea_req, ea_req.Name, Constants.CHG_LOG_NAME, ea_req_name, ref meaningMayHaveChanged);
|
| 2151 |
ghuddy |
415 |
|
| 2161 |
ghuddy |
416 |
ea_req.Notes = updated_property_value_if_changed(changeLog, ea_req, ea_req.Notes, Constants.CHG_LOG_NOTES, rq_obj.text, ref meaningMayHaveChanged);
|
| 2151 |
ghuddy |
417 |
|
| 2161 |
ghuddy |
418 |
ea_req.Difficulty = updated_property_value_if_changed(changeLog, ea_req, ea_req.Difficulty, Constants.CHG_LOG_DIFFICULTY, rq_obj.difficulty, ref statusMayHaveChanged);
|
| 2151 |
ghuddy |
419 |
|
| 2161 |
ghuddy |
420 |
ea_req.Priority = updated_property_value_if_changed(changeLog, ea_req, ea_req.Priority, Constants.CHG_LOG_PRIORITY, rq_obj.priority, ref statusMayHaveChanged);
|
| 2151 |
ghuddy |
421 |
|
| 2161 |
ghuddy |
422 |
ea_req.Status = updated_property_value_if_changed(changeLog, ea_req, ea_req.Status, Constants.CHG_LOG_STATUS, rq_obj.status, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
423 |
|
| 2161 |
ghuddy |
424 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE, Constants.CHG_LOG_SOURCE, rq_obj.source, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
425 |
|
| 2161 |
ghuddy |
426 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE_VERSION, Constants.CHG_LOG_SOURCE_VERSION, rq_obj.sourceVersion, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
427 |
|
| 2161 |
ghuddy |
428 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE_SECTION, Constants.CHG_LOG_SOURCE_SECTION, rq_obj.sourceSection, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
429 |
|
| 2161 |
ghuddy |
430 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SUBSYSTEM, Constants.CHG_LOG_SUBSYSTEM_TYPE, rq_obj.subsystem, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
431 |
|
| 2161 |
ghuddy |
432 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_STABILITY, Constants.CHG_LOG_STABILITY, rq_obj.stability, ref statusMayHaveChanged);
|
| 2155 |
ghuddy |
433 |
|
|
|
434 |
// Requirement Types are actually implemented using ordinary EA element stereotypes.
|
| 2161 |
ghuddy |
435 |
string[] sar = ea_req.StereotypeEx.Split(",".ToCharArray());
|
|
|
436 |
if (sar.Length > 0)
|
| 2155 |
ghuddy |
437 |
{
|
| 2161 |
ghuddy |
438 |
// The first item in the stereotype list is the one on display in the EA element properties and so is the one the user
|
|
|
439 |
// thinks is assigned to the requirement element, so check against that for changes
|
|
|
440 |
string sar0 = sar[0].Trim();
|
|
|
441 |
|
|
|
442 |
if (!sar0.Equals(rq_obj.type))
|
|
|
443 |
{
|
|
|
444 |
changeLog.Notes += ea_req.ElementGUID + ":" + Constants.CHG_LOG_REQ_TYPE + ":" + sar0 + ":" + rq_obj.type + "\r\n";
|
|
|
445 |
changeLog.Update();
|
|
|
446 |
statusMayHaveChanged = true;
|
|
|
447 |
ea_req.StereotypeEx = rq_obj.type;
|
|
|
448 |
ea_req.Stereotype = rq_obj.type;
|
|
|
449 |
}
|
|
|
450 |
}
|
|
|
451 |
else if (!ea_req.Stereotype.Equals(rq_obj.type))
|
|
|
452 |
{
|
|
|
453 |
changeLog.Notes += ea_req.ElementGUID + ":" + Constants.CHG_LOG_REQ_TYPE + ":" + ea_req.Stereotype + ":" + rq_obj.type + "\r\n";
|
| 2155 |
ghuddy |
454 |
changeLog.Update();
|
|
|
455 |
statusMayHaveChanged = true;
|
| 2157 |
ghuddy |
456 |
ea_req.StereotypeEx = rq_obj.type;
|
|
|
457 |
ea_req.Stereotype = rq_obj.type;
|
| 2155 |
ghuddy |
458 |
}
|
|
|
459 |
|
|
|
460 |
ea_req.Update();
|
|
|
461 |
|
|
|
462 |
if (meaningMayHaveChanged)
|
|
|
463 |
{
|
|
|
464 |
modifiedRequirementCount++;
|
|
|
465 |
}
|
| 2151 |
ghuddy |
466 |
|
| 2155 |
ghuddy |
467 |
if (statusMayHaveChanged)
|
|
|
468 |
{
|
|
|
469 |
statusUpdatedRequirementCount++;
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
totalRequirements++;
|
| 2151 |
ghuddy |
473 |
}
|
|
|
474 |
|
|
|
475 |
}
|
|
|
476 |
else
|
|
|
477 |
{
|
|
|
478 |
totalRequirements++;
|
|
|
479 |
|
|
|
480 |
// This ReqPro requirement does not have a counterpart in EA, so we must create
|
|
|
481 |
// a new one.
|
|
|
482 |
newRequirementCount++;
|
|
|
483 |
|
|
|
484 |
// create the new EA requirement in the import package
|
|
|
485 |
EA.Element ea_req = (EA.Element)importPackage.Elements.AddNew( rq_obj.tag + " " + rq_obj.name, "Requirement");
|
|
|
486 |
|
|
|
487 |
rq_obj.ea_element_ID = ea_req.ElementID;
|
|
|
488 |
|
| 2155 |
ghuddy |
489 |
CopyReqProDatabase.copyReq(ea_req, rq_obj);
|
| 2151 |
ghuddy |
490 |
|
| 2155 |
ghuddy |
491 |
ea_req.Notes = rq_obj.text;
|
|
|
492 |
|
| 2151 |
ghuddy |
493 |
ea_req.Update();
|
|
|
494 |
|
|
|
495 |
changeLog.Notes += ea_req.ElementGUID + ":Created:" + ea_req.Name + "\r\n";
|
|
|
496 |
changeLog.Update();
|
|
|
497 |
|
| 2155 |
ghuddy |
498 |
Main.WriteOutput("Created: " + ea_req.Name, ea_req.ElementID);
|
| 2151 |
ghuddy |
499 |
}
|
|
|
500 |
|
|
|
501 |
}
|
|
|
502 |
catch (Exception ex)
|
|
|
503 |
{
|
| 2155 |
ghuddy |
504 |
Main.WriteOutput("Exception (ImportFromReqPro), " + ex.Message + ", " + rq_obj.name, -1);
|
| 2151 |
ghuddy |
505 |
}
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
if (Main.mustAbort)
|
|
|
509 |
return;
|
|
|
510 |
|
| 2155 |
ghuddy |
511 |
Main.WriteOutput("Checking for orphaned requirements", -1);
|
| 2151 |
ghuddy |
512 |
// Now check for orphaned EA requirements
|
|
|
513 |
for (int i = 0; i < ea_GUIDs.Count; i++)
|
|
|
514 |
{
|
|
|
515 |
if (Main.mustAbort)
|
|
|
516 |
break;
|
|
|
517 |
|
|
|
518 |
string rq_GUID = (string)ea_GUIDs[i];
|
|
|
519 |
if (rq_GUID != "")
|
|
|
520 |
{
|
|
|
521 |
if ((bool)ea_req_matched[i] == false)
|
|
|
522 |
{
|
|
|
523 |
EA.Element ea_req = (EA.Element)ea_reqs[i];
|
|
|
524 |
|
|
|
525 |
orphanedCount++;
|
|
|
526 |
|
|
|
527 |
changeLog.Notes += ea_req.ElementGUID + ":Orphaned:" + ea_req.Name + "\r\n";
|
|
|
528 |
changeLog.Update();
|
|
|
529 |
}
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
|
| 2155 |
ghuddy |
533 |
bool changeLogDeleted = false;
|
|
|
534 |
if (changeLog.Notes != null && changeLog.Notes.Length > 0)
|
|
|
535 |
{
|
|
|
536 |
DialogResult dlgres = MessageBoxEx.Show("Display Change Log?", "Change Log", MessageBoxButtons.YesNo);
|
|
|
537 |
if (dlgres == DialogResult.Yes)
|
|
|
538 |
displayChangeLog(changeLog);
|
|
|
539 |
}
|
|
|
540 |
else
|
|
|
541 |
{
|
|
|
542 |
importPackage.Elements.Refresh();
|
|
|
543 |
if (importPackage.Elements.Count == 1)
|
|
|
544 |
{
|
|
|
545 |
EA_Utilities.deletePackage(importPackage);
|
|
|
546 |
changeLogDeleted = true;
|
|
|
547 |
}
|
|
|
548 |
}
|
| 2151 |
ghuddy |
549 |
|
|
|
550 |
Main.EA_Repository.RefreshModelView(parentPackage.PackageID);
|
|
|
551 |
|
| 2149 |
ghuddy |
552 |
// Setup the internal requirement to requirement connectivity. This is seperate from the browser
|
|
|
553 |
// organisation of elements in EA, but since in ReqPro, that organisation tells part of the story
|
|
|
554 |
// of requirement to requirement connectivity, it is mirrored in the internal connectivity, along
|
|
|
555 |
// with explicit trace relationships setup in ReqPro.
|
|
|
556 |
// The purpose of this internal connectivity is to support relationship matrix tables in documentation
|
|
|
557 |
// generated by EA_DocGen, or to support diagrammatic representations of the requirements in EA,
|
|
|
558 |
// where the connectivity will become apparent through links ajoining the requirement elements in the
|
|
|
559 |
// diagram.
|
| 2151 |
ghuddy |
560 |
write_traces(totalRequirements);
|
| 2141 |
ghuddy |
561 |
|
| 2151 |
ghuddy |
562 |
if (Main.mustAbort)
|
|
|
563 |
return;
|
| 2141 |
ghuddy |
564 |
|
| 2155 |
ghuddy |
565 |
writeDelayedMessages();
|
|
|
566 |
|
| 2151 |
ghuddy |
567 |
// display summary stats
|
| 2155 |
ghuddy |
568 |
Main.WriteOutput(newRequirementCount.ToString() + " new requirements", -1);
|
|
|
569 |
Main.WriteOutput(modifiedRequirementCount.ToString() + " requirements modified", -1);
|
|
|
570 |
Main.WriteOutput(statusUpdatedRequirementCount.ToString() + " requirements had status changes", -1);
|
|
|
571 |
Main.WriteOutput(orphanedCount.ToString() + " requirements were orphaned", -1);
|
| 2151 |
ghuddy |
572 |
|
| 2155 |
ghuddy |
573 |
if (changeLogDeleted)
|
|
|
574 |
{
|
|
|
575 |
Main.WriteOutput("NOTE: import package and change log deleted, since nothing changed in this import", -1);
|
|
|
576 |
}
|
| 2151 |
ghuddy |
577 |
|
| 2155 |
ghuddy |
578 |
Main.WriteOutput("Import Completed", -1);
|
|
|
579 |
MessageBoxEx.Show("Import Completed");
|
| 2151 |
ghuddy |
580 |
}
|
|
|
581 |
catch (Exception ex)
|
|
|
582 |
{
|
| 2153 |
ghuddy |
583 |
Main.MessageBoxException(ex, "Exception (ImportFromReqPro)");
|
| 2151 |
ghuddy |
584 |
}
|
|
|
585 |
}
|
|
|
586 |
|
| 2155 |
ghuddy |
587 |
private string updated_property_value_if_changed(EA.Element changeLog,
|
|
|
588 |
EA.Element ea_req,
|
|
|
589 |
string dest_value,
|
|
|
590 |
string changeLogName,
|
|
|
591 |
string source_value,
|
|
|
592 |
ref bool mayHaveChanged)
|
|
|
593 |
{
|
|
|
594 |
if (dest_value.CompareTo(source_value) != 0 )
|
|
|
595 |
{
|
|
|
596 |
changeLog.Notes += ea_req.ElementGUID + ":" + changeLogName+ ":" + NO_COLONS(dest_value) + ":" + NO_COLONS(source_value) + "\r\n";
|
|
|
597 |
changeLog.Update();
|
|
|
598 |
mayHaveChanged = true;
|
|
|
599 |
return source_value;
|
|
|
600 |
}
|
|
|
601 |
return dest_value;
|
|
|
602 |
}
|
| 2151 |
ghuddy |
603 |
|
| 2155 |
ghuddy |
604 |
private void if_tagged_value_changed_update_it(EA.Element changeLog,
|
|
|
605 |
EA.Element ea_req,
|
|
|
606 |
string tagname,
|
|
|
607 |
string changeLogName,
|
|
|
608 |
string source_value,
|
|
|
609 |
ref bool statusMayHaveChanged)
|
|
|
610 |
{
|
|
|
611 |
string value = EA_TaggedValues.Read(ea_req, tagname, "");
|
|
|
612 |
if ((source_value != null) && (false == source_value.Equals(value)))
|
|
|
613 |
{
|
|
|
614 |
changeLog.Notes += ea_req.ElementGUID + ":" + changeLogName + ":" + value + ":" + source_value + "\r\n";
|
|
|
615 |
changeLog.Update();
|
|
|
616 |
EA_TaggedValues.Write(ea_req, tagname, source_value);
|
|
|
617 |
statusMayHaveChanged = true;
|
|
|
618 |
}
|
|
|
619 |
}
|
| 2151 |
ghuddy |
620 |
|
|
|
621 |
|
| 2155 |
ghuddy |
622 |
|
|
|
623 |
|
| 2141 |
ghuddy |
624 |
/// <summary>
|
|
|
625 |
/// This method (along with its sibling overload) obtains a flattened view of the
|
|
|
626 |
/// hierarchical requirements obtained from the ReqPro database. This accumulation
|
|
|
627 |
/// takes account of the users filtering requests.
|
|
|
628 |
/// </summary>
|
|
|
629 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
630 |
private void get_rq_req_collection(ref ArrayList rq_req_collection)
|
| 2141 |
ghuddy |
631 |
{
|
|
|
632 |
foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
|
|
|
633 |
{
|
| 2151 |
ghuddy |
634 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2141 |
ghuddy |
635 |
}
|
|
|
636 |
}
|
|
|
637 |
|
| 2151 |
ghuddy |
638 |
private void get_rq_req_collection(ref ArrayList rq_req_collection,
|
| 2141 |
ghuddy |
639 |
ReqPro_object rq_obj )
|
|
|
640 |
{
|
|
|
641 |
if (rq_obj.isPackage)
|
|
|
642 |
{
|
| 2147 |
ghuddy |
643 |
// if the package is not filtered, or if we are allowed to dig beneath filtered
|
|
|
644 |
// packages...
|
|
|
645 |
if (rq_obj.filtered == false || base.allowPackageStructureFragments)
|
| 2141 |
ghuddy |
646 |
{
|
|
|
647 |
// Using recursion, scan this objects sub-objects
|
|
|
648 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
649 |
{
|
| 2147 |
ghuddy |
650 |
// if the sub-object is a package, always recurse to process it, else
|
|
|
651 |
// if the sub-object is a requirement, only recurse if the containing package
|
|
|
652 |
// is not filtered, so that requirements of filtered packages are themselves
|
|
|
653 |
// filtered out by virtue of their parent packages filtering state.
|
|
|
654 |
if ( sub_obj.isPackage
|
|
|
655 |
|| (sub_obj.isRequirement && rq_obj.filtered == false))
|
|
|
656 |
{
|
| 2151 |
ghuddy |
657 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2147 |
ghuddy |
658 |
}
|
| 2141 |
ghuddy |
659 |
}
|
|
|
660 |
}
|
|
|
661 |
}
|
|
|
662 |
else if (rq_obj.isRequirement)
|
|
|
663 |
{
|
|
|
664 |
if ( ! (reqTypeIsFiltered(rq_obj) || reqStatusTypeIsFiltered(rq_obj)) )
|
|
|
665 |
{
|
|
|
666 |
// Add this requirement to the flattened list we are accumulating
|
|
|
667 |
rq_req_collection.Add(rq_obj);
|
|
|
668 |
|
| 2149 |
ghuddy |
669 |
// In ReqPro, a requirement can be related to another requirement in several ways:
|
|
|
670 |
// 1. By virtue of its position relative to another in the browser display. That is,
|
|
|
671 |
// if you place a requirement beneath a parent requirement, you are establishing a
|
|
|
672 |
// parent-child relationship.
|
|
|
673 |
// 2. By virtue of a specific TraceTo relationship being made via the Traceability menu
|
|
|
674 |
// option.
|
|
|
675 |
// Interestingly, ReqPro prevents you creating a relationship of one of the above types,
|
|
|
676 |
// if a relationship of the other type already exists. This implies that the relationship
|
|
|
677 |
// between a parent and child requirement must be singular and is important regardless
|
|
|
678 |
// of the manner in which it was created or represented.
|
|
|
679 |
// The CopyReqProDatabaseToMemory base class will already have taken care of recording
|
|
|
680 |
// relationships detected from ReqPro made using method 2 above. What we need to do here is
|
|
|
681 |
// take care of those apparent from the browser based hierarchical organisation (ie. made
|
|
|
682 |
// in ReqPro using method 1).
|
|
|
683 |
// All we need to do is grab the parent object (if any) and add the GUID of the child to
|
|
|
684 |
// its list of trace-to's. Later on, the write_traces() class method will turn these into
|
|
|
685 |
// EA based connection objects that belong to the parent requirement elements.
|
|
|
686 |
if (rq_obj.parent != null)
|
|
|
687 |
{
|
|
|
688 |
rq_obj.parent.ReqPro_traces.Add(rq_obj.guid);
|
|
|
689 |
}
|
|
|
690 |
|
| 2147 |
ghuddy |
691 |
// Using recursion, scan this objects sub-objects, which in practise will all
|
|
|
692 |
// be requirement objects. At this time requirement objects cannot have packages
|
|
|
693 |
// as children.
|
| 2141 |
ghuddy |
694 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
695 |
{
|
| 2151 |
ghuddy |
696 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2141 |
ghuddy |
697 |
}
|
|
|
698 |
}
|
|
|
699 |
}
|
|
|
700 |
}
|
|
|
701 |
|
|
|
702 |
|
|
|
703 |
}
|
|
|
704 |
}
|