| 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 |
{
|
| 2151 |
ghuddy |
137 |
EA.Element tgt_ele = (EA.Element)Main.EA_Repository.GetElementByID( theConnector.SupplierID );
|
| 2141 |
ghuddy |
138 |
if (tgt_ele != null)
|
|
|
139 |
{
|
|
|
140 |
if (!tgt_ele.Type.StartsWith("Requirement"))
|
|
|
141 |
{
|
| 2155 |
ghuddy |
142 |
Main.WriteOutput(" --> " + tgt_ele.Name, tgt_ele.ElementID);
|
| 2141 |
ghuddy |
143 |
}
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
}
|
| 2155 |
ghuddy |
147 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
148 |
else if (parameters[1].StartsWith("Name"))
|
|
|
149 |
{
|
| 2155 |
ghuddy |
150 |
Main.WriteOutput(" Modified Name: " + ea_req.Name, ea_req.ElementID );
|
|
|
151 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
152 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
153 |
}
|
| 2155 |
ghuddy |
154 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
155 |
else if (parameters[1].StartsWith("Notes"))
|
|
|
156 |
{
|
| 2155 |
ghuddy |
157 |
Main.WriteOutput(" Modified Description: " + ea_req.Name, ea_req.ElementID );
|
|
|
158 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
159 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
160 |
}
|
| 2155 |
ghuddy |
161 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
162 |
else if (parameters[1].StartsWith("Difficulty"))
|
|
|
163 |
{
|
| 2155 |
ghuddy |
164 |
Main.WriteOutput(" Modified Difficulty: " + ea_req.Name, ea_req.ElementID );
|
|
|
165 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
166 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
167 |
}
|
| 2155 |
ghuddy |
168 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
169 |
else if (parameters[1].StartsWith("Priority"))
|
|
|
170 |
{
|
| 2155 |
ghuddy |
171 |
Main.WriteOutput(" Modified Priority: " + ea_req.Name, ea_req.ElementID );
|
|
|
172 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
173 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
174 |
}
|
| 2155 |
ghuddy |
175 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
176 |
else if (parameters[1].StartsWith("Version"))
|
|
|
177 |
{
|
| 2155 |
ghuddy |
178 |
Main.WriteOutput(" Modified Version: " + ea_req.Name, ea_req.ElementID );
|
|
|
179 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
180 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
181 |
}
|
| 2155 |
ghuddy |
182 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2141 |
ghuddy |
183 |
else if (parameters[1].StartsWith("Status"))
|
|
|
184 |
{
|
| 2155 |
ghuddy |
185 |
Main.WriteOutput(" Modified Status: " + ea_req.Name, ea_req.ElementID );
|
|
|
186 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
187 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
| 2141 |
ghuddy |
188 |
}
|
| 2155 |
ghuddy |
189 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
190 |
else if (parameters[1].StartsWith("Subsystem"))
|
|
|
191 |
{
|
|
|
192 |
Main.WriteOutput(" Modified Subsystem: " + ea_req.Name, ea_req.ElementID );
|
|
|
193 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
194 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
195 |
}
|
|
|
196 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
197 |
else if (parameters[1].StartsWith("Stability"))
|
|
|
198 |
{
|
|
|
199 |
Main.WriteOutput(" Modified Stability: " + ea_req.Name, ea_req.ElementID );
|
|
|
200 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
201 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
202 |
}
|
|
|
203 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
204 |
else if (parameters[1].StartsWith("ReqType"))
|
|
|
205 |
{
|
|
|
206 |
Main.WriteOutput(" Modified Type: " + ea_req.Name, ea_req.ElementID );
|
|
|
207 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
208 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
209 |
}
|
|
|
210 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
211 |
else if (parameters[1].StartsWith("SourceVersion"))
|
|
|
212 |
{
|
|
|
213 |
Main.WriteOutput(" Modified Type: " + ea_req.Name, ea_req.ElementID );
|
|
|
214 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
215 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
216 |
}
|
|
|
217 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
218 |
else if (parameters[1].StartsWith("SourceSection"))
|
|
|
219 |
{
|
|
|
220 |
Main.WriteOutput(" Modified Type: " + ea_req.Name, ea_req.ElementID );
|
|
|
221 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
222 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
223 |
}
|
|
|
224 |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
225 |
else if (parameters[1].StartsWith("Source"))
|
|
|
226 |
{
|
|
|
227 |
Main.WriteOutput(" Modified Type: " + ea_req.Name, ea_req.ElementID );
|
|
|
228 |
Main.WriteOutput(" <<< " + parameters[2], ea_req.ElementID);
|
|
|
229 |
Main.WriteOutput(" >>> " + parameters[3], ea_req.ElementID);
|
|
|
230 |
}
|
| 2141 |
ghuddy |
231 |
|
|
|
232 |
// accumulate good item into the newList
|
|
|
233 |
newList += trimmed_s + "\r\n";
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
catch
|
|
|
237 |
{
|
|
|
238 |
// do nothing - the newList accumulator will not have the GUID that caused the exception
|
|
|
239 |
// so the next time a display operation is attempted, the exception wont happen.
|
|
|
240 |
}
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
// Update the change log
|
|
|
244 |
changeLog.Notes = newList;
|
|
|
245 |
changeLog.Update();
|
|
|
246 |
}
|
|
|
247 |
|
| 2147 |
ghuddy |
248 |
|
|
|
249 |
/// <summary>
|
|
|
250 |
/// Rid a string of any : char because we use that as a delimiter in the change log and so we
|
|
|
251 |
/// do not want a users use of the character to confuse the change log display mechanism.
|
|
|
252 |
/// </summary>
|
|
|
253 |
/// <param name="s"></param>
|
|
|
254 |
/// <returns></returns>
|
|
|
255 |
private string NO_COLONS(string s)
|
|
|
256 |
{
|
|
|
257 |
string sc = s.Replace(':', ' ');
|
|
|
258 |
sc = sc.Replace('\r' , ' ');
|
|
|
259 |
sc = sc.Replace('\n' , ' ');
|
|
|
260 |
|
|
|
261 |
return sc;
|
|
|
262 |
}
|
| 2151 |
ghuddy |
263 |
|
| 2155 |
ghuddy |
264 |
/// <summary>
|
|
|
265 |
/// Get a new import package in which to store change log and new requirements from the import.
|
|
|
266 |
/// </summary>
|
|
|
267 |
/// <param name="parentPackage"></param>
|
|
|
268 |
/// <param name="importDateTime"></param>
|
|
|
269 |
/// <returns></returns>
|
|
|
270 |
private EA.Package createImportPackage(EA.Package parentPackage, string importDateTime)
|
|
|
271 |
{
|
|
|
272 |
EA.Package importPackage = null;
|
|
|
273 |
string importSubDir = EA_TaggedValues.Read(base.RQ_Element, Constants.TAG_IMPORT_SUB_DIR, "");
|
|
|
274 |
if (importSubDir != null && importSubDir.Length > 0)
|
|
|
275 |
{
|
|
|
276 |
importPackage = (EA.Package)parentPackage.Packages.GetByName(importSubDir);
|
|
|
277 |
if (importPackage != null)
|
|
|
278 |
{
|
|
|
279 |
parentPackage = importPackage;
|
|
|
280 |
}
|
|
|
281 |
else
|
|
|
282 |
{
|
|
|
283 |
// create a subdir and use it as the parent
|
|
|
284 |
parentPackage = (EA.Package )parentPackage.Packages.AddNew( importSubDir, "Package");
|
|
|
285 |
parentPackage.Update();
|
|
|
286 |
}
|
|
|
287 |
}
|
| 2151 |
ghuddy |
288 |
|
| 2155 |
ghuddy |
289 |
// create the import dir in the parent
|
|
|
290 |
importPackage = (EA.Package )parentPackage.Packages.AddNew( "import " + importDateTime, "Package");
|
|
|
291 |
importPackage.Update();
|
|
|
292 |
|
|
|
293 |
return importPackage;
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
|
| 2151 |
ghuddy |
298 |
/// <summary>
|
|
|
299 |
/// A method that imports requirements from a ReqPro database into EA for the purpose
|
|
|
300 |
/// of supporting requirement-to-design traceability.
|
|
|
301 |
/// </summary>
|
|
|
302 |
/// <param name="repository"></param>
|
| 2155 |
ghuddy |
303 |
private void ImportFromReqPro(string importDateTime)
|
| 2151 |
ghuddy |
304 |
{
|
|
|
305 |
try
|
|
|
306 |
{
|
|
|
307 |
// Get a list of EA requirements and their associated ReqPro GUIDs
|
|
|
308 |
ArrayList ea_reqs;
|
|
|
309 |
ArrayList ea_GUIDs = new ArrayList();
|
|
|
310 |
ArrayList ea_req_matched = new ArrayList();
|
|
|
311 |
|
|
|
312 |
// Obtain the EA parent package so that we can create under it an import package
|
|
|
313 |
// if need be, and scan for existing requirement elements.
|
|
|
314 |
EA.Package parentPackage = Main.EA_Repository.GetPackageByID( base.RQ_Element.PackageID );
|
|
|
315 |
|
|
|
316 |
ArrayList allowedElementTypes = new ArrayList();
|
|
|
317 |
allowedElementTypes.Add("Requirement");
|
|
|
318 |
allowedElementTypes.Add("UseCase");
|
|
|
319 |
|
| 2155 |
ghuddy |
320 |
Main.WriteOutput("Acquiring list of elements already in EA", -1);
|
| 2151 |
ghuddy |
321 |
ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
|
| 2153 |
ghuddy |
322 |
EA_Utilities.findAndProcessPackageElements( parentPackage, reqLister, true );
|
| 2151 |
ghuddy |
323 |
|
|
|
324 |
if (Main.mustAbort)
|
|
|
325 |
return;
|
|
|
326 |
|
|
|
327 |
ea_reqs = reqLister.Elements;
|
|
|
328 |
foreach (EA.Element ea_req in ea_reqs)
|
|
|
329 |
{
|
| 2155 |
ghuddy |
330 |
string GUID = EA_TaggedValues.Read(ea_req, Constants.TAG_GUID);
|
| 2151 |
ghuddy |
331 |
ea_GUIDs.Add(GUID);
|
|
|
332 |
ea_req_matched.Add(false);
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
if (Main.mustAbort)
|
|
|
336 |
return;
|
|
|
337 |
|
| 2155 |
ghuddy |
338 |
// Create an import package to store new requirements and the change log
|
|
|
339 |
EA.Package importPackage = createImportPackage(parentPackage, importDateTime);
|
| 2151 |
ghuddy |
340 |
|
| 2155 |
ghuddy |
341 |
// Create the change log element in the import package
|
| 2151 |
ghuddy |
342 |
EA.Element changeLog = (EA.Element)importPackage.Elements.AddNew("Change Log","InformationItem");
|
|
|
343 |
changeLog.Update();
|
|
|
344 |
|
|
|
345 |
// Get a flattened list of requirements from the hierarchical data the user has filtered
|
|
|
346 |
ArrayList rq_req_collection = new ArrayList();
|
|
|
347 |
get_rq_req_collection(ref rq_req_collection);
|
|
|
348 |
|
|
|
349 |
int newRequirementCount = 0;
|
|
|
350 |
int modifiedRequirementCount = 0;
|
|
|
351 |
int statusUpdatedRequirementCount = 0;
|
|
|
352 |
int orphanedCount = 0;
|
|
|
353 |
|
|
|
354 |
|
| 2155 |
ghuddy |
355 |
Main.WriteOutput("Merging ReqPro content to EA", -1);
|
| 2151 |
ghuddy |
356 |
// loop through all of the ReqPro requirements
|
|
|
357 |
foreach(ReqPro_object rq_obj in rq_req_collection)
|
|
|
358 |
{
|
|
|
359 |
if (Main.mustAbort)
|
|
|
360 |
break;
|
|
|
361 |
|
|
|
362 |
try
|
|
|
363 |
{
|
|
|
364 |
// Find which EA requirement element refers to the current ReqPro GUID
|
|
|
365 |
int i_ea_req;
|
|
|
366 |
i_ea_req = ea_GUIDs.IndexOf( rq_obj.guid );
|
|
|
367 |
|
|
|
368 |
// If EA element was found
|
|
|
369 |
if (0 <= i_ea_req)
|
|
|
370 |
{
|
|
|
371 |
ea_req_matched[i_ea_req] = true;
|
|
|
372 |
|
|
|
373 |
EA.Element ea_req = ((EA.Element)ea_reqs[i_ea_req]);
|
|
|
374 |
|
|
|
375 |
rq_obj.ea_element_ID = ea_req.ElementID;
|
|
|
376 |
|
| 2155 |
ghuddy |
377 |
// Only update the requirement if it was not mastered in EA, or
|
|
|
378 |
// unrestricted imports have been enabled
|
|
|
379 |
if ( (false == EA_TaggedValues.Read(ea_req, Constants.TAG_CREATED_IN_EA, Constants.DEFAULT_CREATED_IN_EA))
|
|
|
380 |
|| (true == EA_TaggedValues.Read(ea_req, Constants.TAG_UNRESTRICTED_IMPORTS, Constants.DEFAULT_UNRESTRICTED_IMPORTS)) )
|
|
|
381 |
{
|
|
|
382 |
// This ReqPro requirement already has a counterpart in EA, so we must simply
|
|
|
383 |
// update the counterpart. But, to aid the designer, we need to try to tell them
|
|
|
384 |
// how the requirement has changed, which could ofcoarse change the meaning
|
|
|
385 |
// of the requirement and require design changes to be done.
|
| 2151 |
ghuddy |
386 |
|
| 2155 |
ghuddy |
387 |
bool meaningMayHaveChanged = false;
|
|
|
388 |
bool statusMayHaveChanged = false;
|
| 2151 |
ghuddy |
389 |
|
| 2155 |
ghuddy |
390 |
string ea_req_name = rq_obj.tag + " " + rq_obj.name;
|
| 2151 |
ghuddy |
391 |
|
| 2155 |
ghuddy |
392 |
Main.WriteOutput("Updating: " + ea_req_name, rq_obj.ea_element_ID);
|
| 2151 |
ghuddy |
393 |
|
| 2155 |
ghuddy |
394 |
ea_req.Name = updated_property_value_if_changed(changeLog, ea_req, ea_req.Name, "Name", ea_req_name, ref meaningMayHaveChanged);
|
| 2151 |
ghuddy |
395 |
|
| 2155 |
ghuddy |
396 |
ea_req.Notes = updated_property_value_if_changed(changeLog, ea_req, ea_req.Notes, "Notes", rq_obj.text, ref meaningMayHaveChanged);
|
| 2151 |
ghuddy |
397 |
|
| 2155 |
ghuddy |
398 |
ea_req.Difficulty = updated_property_value_if_changed(changeLog, ea_req, ea_req.Difficulty, "Difficulty", rq_obj.difficulty, ref statusMayHaveChanged);
|
| 2151 |
ghuddy |
399 |
|
| 2155 |
ghuddy |
400 |
ea_req.Priority = updated_property_value_if_changed(changeLog, ea_req, ea_req.Priority, "Priority", rq_obj.priority, ref statusMayHaveChanged);
|
| 2151 |
ghuddy |
401 |
|
| 2155 |
ghuddy |
402 |
ea_req.Status = updated_property_value_if_changed(changeLog, ea_req, ea_req.Status, "Status", rq_obj.status, ref statusMayHaveChanged);
|
|
|
403 |
|
|
|
404 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE, "Source", rq_obj.source, ref statusMayHaveChanged);
|
|
|
405 |
|
|
|
406 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE_VERSION, "SourceVersion", rq_obj.sourceVersion, ref statusMayHaveChanged);
|
|
|
407 |
|
|
|
408 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SOURCE_SECTION, "SourceSection", rq_obj.sourceSection, ref statusMayHaveChanged);
|
|
|
409 |
|
|
|
410 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_SUBSYSTEM, "Subsystem", rq_obj.subsystem, ref statusMayHaveChanged);
|
|
|
411 |
|
|
|
412 |
if_tagged_value_changed_update_it(changeLog, ea_req, Constants.TAG_STABILITY, "Stability", rq_obj.stability, ref statusMayHaveChanged);
|
|
|
413 |
|
|
|
414 |
// Requirement Types are actually implemented using ordinary EA element stereotypes.
|
| 2157 |
ghuddy |
415 |
if (!ea_req.Stereotype.Equals(rq_obj.type))
|
| 2155 |
ghuddy |
416 |
{
|
|
|
417 |
changeLog.Notes += ea_req.ElementGUID + ":ReqType:" + ea_req.Stereotype + ":" + rq_obj.type + "\r\n";
|
|
|
418 |
changeLog.Update();
|
|
|
419 |
statusMayHaveChanged = true;
|
| 2157 |
ghuddy |
420 |
ea_req.StereotypeEx = rq_obj.type;
|
|
|
421 |
ea_req.Stereotype = rq_obj.type;
|
| 2155 |
ghuddy |
422 |
}
|
|
|
423 |
|
|
|
424 |
ea_req.Update();
|
|
|
425 |
|
|
|
426 |
if (meaningMayHaveChanged)
|
|
|
427 |
{
|
|
|
428 |
modifiedRequirementCount++;
|
|
|
429 |
}
|
| 2151 |
ghuddy |
430 |
|
| 2155 |
ghuddy |
431 |
if (statusMayHaveChanged)
|
|
|
432 |
{
|
|
|
433 |
statusUpdatedRequirementCount++;
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
totalRequirements++;
|
| 2151 |
ghuddy |
437 |
}
|
|
|
438 |
|
|
|
439 |
}
|
|
|
440 |
else
|
|
|
441 |
{
|
|
|
442 |
totalRequirements++;
|
|
|
443 |
|
|
|
444 |
// This ReqPro requirement does not have a counterpart in EA, so we must create
|
|
|
445 |
// a new one.
|
|
|
446 |
newRequirementCount++;
|
|
|
447 |
|
|
|
448 |
// create the new EA requirement in the import package
|
|
|
449 |
EA.Element ea_req = (EA.Element)importPackage.Elements.AddNew( rq_obj.tag + " " + rq_obj.name, "Requirement");
|
|
|
450 |
|
|
|
451 |
rq_obj.ea_element_ID = ea_req.ElementID;
|
|
|
452 |
|
| 2155 |
ghuddy |
453 |
CopyReqProDatabase.copyReq(ea_req, rq_obj);
|
| 2151 |
ghuddy |
454 |
|
| 2155 |
ghuddy |
455 |
ea_req.Notes = rq_obj.text;
|
|
|
456 |
|
| 2151 |
ghuddy |
457 |
ea_req.Update();
|
|
|
458 |
|
|
|
459 |
changeLog.Notes += ea_req.ElementGUID + ":Created:" + ea_req.Name + "\r\n";
|
|
|
460 |
changeLog.Update();
|
|
|
461 |
|
| 2155 |
ghuddy |
462 |
Main.WriteOutput("Created: " + ea_req.Name, ea_req.ElementID);
|
| 2151 |
ghuddy |
463 |
}
|
|
|
464 |
|
|
|
465 |
}
|
|
|
466 |
catch (Exception ex)
|
|
|
467 |
{
|
| 2155 |
ghuddy |
468 |
Main.WriteOutput("Exception (ImportFromReqPro), " + ex.Message + ", " + rq_obj.name, -1);
|
| 2151 |
ghuddy |
469 |
}
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
if (Main.mustAbort)
|
|
|
473 |
return;
|
|
|
474 |
|
| 2155 |
ghuddy |
475 |
Main.WriteOutput("Checking for orphaned requirements", -1);
|
| 2151 |
ghuddy |
476 |
// Now check for orphaned EA requirements
|
|
|
477 |
for (int i = 0; i < ea_GUIDs.Count; i++)
|
|
|
478 |
{
|
|
|
479 |
if (Main.mustAbort)
|
|
|
480 |
break;
|
|
|
481 |
|
|
|
482 |
string rq_GUID = (string)ea_GUIDs[i];
|
|
|
483 |
if (rq_GUID != "")
|
|
|
484 |
{
|
|
|
485 |
if ((bool)ea_req_matched[i] == false)
|
|
|
486 |
{
|
|
|
487 |
EA.Element ea_req = (EA.Element)ea_reqs[i];
|
|
|
488 |
|
|
|
489 |
orphanedCount++;
|
|
|
490 |
|
|
|
491 |
changeLog.Notes += ea_req.ElementGUID + ":Orphaned:" + ea_req.Name + "\r\n";
|
|
|
492 |
changeLog.Update();
|
|
|
493 |
}
|
|
|
494 |
}
|
|
|
495 |
}
|
|
|
496 |
|
| 2155 |
ghuddy |
497 |
bool changeLogDeleted = false;
|
|
|
498 |
if (changeLog.Notes != null && changeLog.Notes.Length > 0)
|
|
|
499 |
{
|
|
|
500 |
DialogResult dlgres = MessageBoxEx.Show("Display Change Log?", "Change Log", MessageBoxButtons.YesNo);
|
|
|
501 |
if (dlgres == DialogResult.Yes)
|
|
|
502 |
displayChangeLog(changeLog);
|
|
|
503 |
}
|
|
|
504 |
else
|
|
|
505 |
{
|
|
|
506 |
importPackage.Elements.Refresh();
|
|
|
507 |
if (importPackage.Elements.Count == 1)
|
|
|
508 |
{
|
|
|
509 |
EA_Utilities.deletePackage(importPackage);
|
|
|
510 |
changeLogDeleted = true;
|
|
|
511 |
}
|
|
|
512 |
}
|
| 2151 |
ghuddy |
513 |
|
|
|
514 |
Main.EA_Repository.RefreshModelView(parentPackage.PackageID);
|
|
|
515 |
|
| 2149 |
ghuddy |
516 |
// Setup the internal requirement to requirement connectivity. This is seperate from the browser
|
|
|
517 |
// organisation of elements in EA, but since in ReqPro, that organisation tells part of the story
|
|
|
518 |
// of requirement to requirement connectivity, it is mirrored in the internal connectivity, along
|
|
|
519 |
// with explicit trace relationships setup in ReqPro.
|
|
|
520 |
// The purpose of this internal connectivity is to support relationship matrix tables in documentation
|
|
|
521 |
// generated by EA_DocGen, or to support diagrammatic representations of the requirements in EA,
|
|
|
522 |
// where the connectivity will become apparent through links ajoining the requirement elements in the
|
|
|
523 |
// diagram.
|
| 2151 |
ghuddy |
524 |
write_traces(totalRequirements);
|
| 2141 |
ghuddy |
525 |
|
| 2151 |
ghuddy |
526 |
if (Main.mustAbort)
|
|
|
527 |
return;
|
| 2141 |
ghuddy |
528 |
|
| 2155 |
ghuddy |
529 |
writeDelayedMessages();
|
|
|
530 |
|
| 2151 |
ghuddy |
531 |
// display summary stats
|
| 2155 |
ghuddy |
532 |
Main.WriteOutput(newRequirementCount.ToString() + " new requirements", -1);
|
|
|
533 |
Main.WriteOutput(modifiedRequirementCount.ToString() + " requirements modified", -1);
|
|
|
534 |
Main.WriteOutput(statusUpdatedRequirementCount.ToString() + " requirements had status changes", -1);
|
|
|
535 |
Main.WriteOutput(orphanedCount.ToString() + " requirements were orphaned", -1);
|
| 2151 |
ghuddy |
536 |
|
| 2155 |
ghuddy |
537 |
if (changeLogDeleted)
|
|
|
538 |
{
|
|
|
539 |
Main.WriteOutput("NOTE: import package and change log deleted, since nothing changed in this import", -1);
|
|
|
540 |
}
|
| 2151 |
ghuddy |
541 |
|
| 2155 |
ghuddy |
542 |
Main.WriteOutput("Import Completed", -1);
|
|
|
543 |
MessageBoxEx.Show("Import Completed");
|
| 2151 |
ghuddy |
544 |
}
|
|
|
545 |
catch (Exception ex)
|
|
|
546 |
{
|
| 2153 |
ghuddy |
547 |
Main.MessageBoxException(ex, "Exception (ImportFromReqPro)");
|
| 2151 |
ghuddy |
548 |
}
|
|
|
549 |
}
|
|
|
550 |
|
| 2155 |
ghuddy |
551 |
private string updated_property_value_if_changed(EA.Element changeLog,
|
|
|
552 |
EA.Element ea_req,
|
|
|
553 |
string dest_value,
|
|
|
554 |
string changeLogName,
|
|
|
555 |
string source_value,
|
|
|
556 |
ref bool mayHaveChanged)
|
|
|
557 |
{
|
|
|
558 |
if (dest_value.CompareTo(source_value) != 0 )
|
|
|
559 |
{
|
|
|
560 |
changeLog.Notes += ea_req.ElementGUID + ":" + changeLogName+ ":" + NO_COLONS(dest_value) + ":" + NO_COLONS(source_value) + "\r\n";
|
|
|
561 |
changeLog.Update();
|
|
|
562 |
mayHaveChanged = true;
|
|
|
563 |
return source_value;
|
|
|
564 |
}
|
|
|
565 |
return dest_value;
|
|
|
566 |
}
|
| 2151 |
ghuddy |
567 |
|
| 2155 |
ghuddy |
568 |
private void if_tagged_value_changed_update_it(EA.Element changeLog,
|
|
|
569 |
EA.Element ea_req,
|
|
|
570 |
string tagname,
|
|
|
571 |
string changeLogName,
|
|
|
572 |
string source_value,
|
|
|
573 |
ref bool statusMayHaveChanged)
|
|
|
574 |
{
|
|
|
575 |
string value = EA_TaggedValues.Read(ea_req, tagname, "");
|
|
|
576 |
if ((source_value != null) && (false == source_value.Equals(value)))
|
|
|
577 |
{
|
|
|
578 |
changeLog.Notes += ea_req.ElementGUID + ":" + changeLogName + ":" + value + ":" + source_value + "\r\n";
|
|
|
579 |
changeLog.Update();
|
|
|
580 |
EA_TaggedValues.Write(ea_req, tagname, source_value);
|
|
|
581 |
statusMayHaveChanged = true;
|
|
|
582 |
}
|
|
|
583 |
}
|
| 2151 |
ghuddy |
584 |
|
|
|
585 |
|
| 2155 |
ghuddy |
586 |
|
|
|
587 |
|
| 2141 |
ghuddy |
588 |
/// <summary>
|
|
|
589 |
/// This method (along with its sibling overload) obtains a flattened view of the
|
|
|
590 |
/// hierarchical requirements obtained from the ReqPro database. This accumulation
|
|
|
591 |
/// takes account of the users filtering requests.
|
|
|
592 |
/// </summary>
|
|
|
593 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
594 |
private void get_rq_req_collection(ref ArrayList rq_req_collection)
|
| 2141 |
ghuddy |
595 |
{
|
|
|
596 |
foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
|
|
|
597 |
{
|
| 2151 |
ghuddy |
598 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2141 |
ghuddy |
599 |
}
|
|
|
600 |
}
|
|
|
601 |
|
| 2151 |
ghuddy |
602 |
private void get_rq_req_collection(ref ArrayList rq_req_collection,
|
| 2141 |
ghuddy |
603 |
ReqPro_object rq_obj )
|
|
|
604 |
{
|
|
|
605 |
if (rq_obj.isPackage)
|
|
|
606 |
{
|
| 2147 |
ghuddy |
607 |
// if the package is not filtered, or if we are allowed to dig beneath filtered
|
|
|
608 |
// packages...
|
|
|
609 |
if (rq_obj.filtered == false || base.allowPackageStructureFragments)
|
| 2141 |
ghuddy |
610 |
{
|
|
|
611 |
// Using recursion, scan this objects sub-objects
|
|
|
612 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
613 |
{
|
| 2147 |
ghuddy |
614 |
// if the sub-object is a package, always recurse to process it, else
|
|
|
615 |
// if the sub-object is a requirement, only recurse if the containing package
|
|
|
616 |
// is not filtered, so that requirements of filtered packages are themselves
|
|
|
617 |
// filtered out by virtue of their parent packages filtering state.
|
|
|
618 |
if ( sub_obj.isPackage
|
|
|
619 |
|| (sub_obj.isRequirement && rq_obj.filtered == false))
|
|
|
620 |
{
|
| 2151 |
ghuddy |
621 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2147 |
ghuddy |
622 |
}
|
| 2141 |
ghuddy |
623 |
}
|
|
|
624 |
}
|
|
|
625 |
}
|
|
|
626 |
else if (rq_obj.isRequirement)
|
|
|
627 |
{
|
|
|
628 |
if ( ! (reqTypeIsFiltered(rq_obj) || reqStatusTypeIsFiltered(rq_obj)) )
|
|
|
629 |
{
|
|
|
630 |
// Add this requirement to the flattened list we are accumulating
|
|
|
631 |
rq_req_collection.Add(rq_obj);
|
|
|
632 |
|
| 2149 |
ghuddy |
633 |
// In ReqPro, a requirement can be related to another requirement in several ways:
|
|
|
634 |
// 1. By virtue of its position relative to another in the browser display. That is,
|
|
|
635 |
// if you place a requirement beneath a parent requirement, you are establishing a
|
|
|
636 |
// parent-child relationship.
|
|
|
637 |
// 2. By virtue of a specific TraceTo relationship being made via the Traceability menu
|
|
|
638 |
// option.
|
|
|
639 |
// Interestingly, ReqPro prevents you creating a relationship of one of the above types,
|
|
|
640 |
// if a relationship of the other type already exists. This implies that the relationship
|
|
|
641 |
// between a parent and child requirement must be singular and is important regardless
|
|
|
642 |
// of the manner in which it was created or represented.
|
|
|
643 |
// The CopyReqProDatabaseToMemory base class will already have taken care of recording
|
|
|
644 |
// relationships detected from ReqPro made using method 2 above. What we need to do here is
|
|
|
645 |
// take care of those apparent from the browser based hierarchical organisation (ie. made
|
|
|
646 |
// in ReqPro using method 1).
|
|
|
647 |
// All we need to do is grab the parent object (if any) and add the GUID of the child to
|
|
|
648 |
// its list of trace-to's. Later on, the write_traces() class method will turn these into
|
|
|
649 |
// EA based connection objects that belong to the parent requirement elements.
|
|
|
650 |
if (rq_obj.parent != null)
|
|
|
651 |
{
|
|
|
652 |
rq_obj.parent.ReqPro_traces.Add(rq_obj.guid);
|
|
|
653 |
}
|
|
|
654 |
|
| 2147 |
ghuddy |
655 |
// Using recursion, scan this objects sub-objects, which in practise will all
|
|
|
656 |
// be requirement objects. At this time requirement objects cannot have packages
|
|
|
657 |
// as children.
|
| 2141 |
ghuddy |
658 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
659 |
{
|
| 2151 |
ghuddy |
660 |
get_rq_req_collection(ref rq_req_collection, sub_obj);
|
| 2141 |
ghuddy |
661 |
}
|
|
|
662 |
}
|
|
|
663 |
}
|
|
|
664 |
}
|
|
|
665 |
|
|
|
666 |
|
|
|
667 |
}
|
|
|
668 |
}
|