| 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 |
namespace EA_ReqPro
|
|
|
9 |
{
|
|
|
10 |
/// <summary>
|
| 2151 |
ghuddy |
11 |
/// CopyReqProDatabase is a specialisation of CopyReqProDatabaseToMemory, designed to copy the
|
| 2141 |
ghuddy |
12 |
/// ReqPro database content into an EA database, maintaining the structure of
|
|
|
13 |
/// and hierarchy of packages and requirements found in the ReqPro database.
|
|
|
14 |
/// </summary>
|
|
|
15 |
public class CopyReqProDatabase : CopyReqProDatabaseToMemory
|
|
|
16 |
{
|
| 2151 |
ghuddy |
17 |
private int totalRequirements = 0;
|
|
|
18 |
|
| 2141 |
ghuddy |
19 |
/// <summary>
|
|
|
20 |
/// Construct the object
|
|
|
21 |
/// </summary>
|
|
|
22 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
23 |
public CopyReqProDatabase(): base()
|
| 2141 |
ghuddy |
24 |
{
|
| 2151 |
ghuddy |
25 |
totalRequirements = 0;
|
| 2141 |
ghuddy |
26 |
}
|
| 2151 |
ghuddy |
27 |
|
|
|
28 |
|
| 2141 |
ghuddy |
29 |
/// <summary>
|
|
|
30 |
/// Method to parse a ReqPro database and copy it into an EA database.
|
|
|
31 |
/// </summary>
|
|
|
32 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
33 |
/// <returns></returns>
|
|
|
34 |
public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode)
|
|
|
35 |
{
|
|
|
36 |
try
|
|
|
37 |
{
|
|
|
38 |
// use the base classes parser to read the ReqPro database content and allow the user to
|
|
|
39 |
// filter it.
|
|
|
40 |
if (true == base.prompt_and_parse(mode))
|
|
|
41 |
{
|
|
|
42 |
if (Main.mustAbort)
|
|
|
43 |
return false;
|
|
|
44 |
|
| 2145 |
ghuddy |
45 |
try
|
|
|
46 |
{
|
|
|
47 |
// Look for existing requirement elements
|
|
|
48 |
bool reqElementsFound = false;
|
| 2151 |
ghuddy |
49 |
for(short i=0; i < ea_rootPackage.Elements.Count; i++)
|
|
|
50 |
{
|
|
|
51 |
if ( ((EA.Element)ea_rootPackage.Elements.GetAt(i)).Type.StartsWith("Requirement") )
|
|
|
52 |
{
|
|
|
53 |
reqElementsFound = true;
|
|
|
54 |
}
|
| 2145 |
ghuddy |
55 |
}
|
|
|
56 |
|
|
|
57 |
// if there are existing requirement elements or sub-packages...
|
| 2151 |
ghuddy |
58 |
if (reqElementsFound == true
|
|
|
59 |
|| ea_rootPackage.Packages.Count > 0)
|
|
|
60 |
{
|
|
|
61 |
DialogResult dlgRes = MessageBoxEx.Show("Package is not empty, delete existing content first?", "Confirm", MessageBoxButtons.YesNo);
|
|
|
62 |
if (dlgRes == DialogResult.Yes)
|
|
|
63 |
{
|
|
|
64 |
// Delete packages and requirement elements
|
|
|
65 |
short i;
|
|
|
66 |
for(i=0; i < ea_rootPackage.Packages.Count; i++)
|
|
|
67 |
{
|
|
|
68 |
ea_rootPackage.Packages.Delete(i);
|
|
|
69 |
}
|
|
|
70 |
for(i=0; i < ea_rootPackage.Elements.Count; i++)
|
|
|
71 |
{
|
|
|
72 |
if ( ((EA.Element)ea_rootPackage.Elements.GetAt(i)).Type.StartsWith("Requirement") )
|
|
|
73 |
{
|
|
|
74 |
ea_rootPackage.Elements.Delete(i);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
ea_rootPackage.Packages.Refresh();
|
| 2145 |
ghuddy |
78 |
// refresh project browser view
|
| 2151 |
ghuddy |
79 |
Main.EA_Repository.RefreshModelView(ea_rootPackage.PackageID);
|
|
|
80 |
}
|
|
|
81 |
}
|
| 2145 |
ghuddy |
82 |
}
|
| 2151 |
ghuddy |
83 |
catch (Exception ex)
|
|
|
84 |
{
|
| 2153 |
ghuddy |
85 |
Main.MessageBoxException(ex, "Exception (CopyReqProDatabase)");
|
| 2151 |
ghuddy |
86 |
}
|
|
|
87 |
|
|
|
88 |
Main.EA_Repository.EnsureOutputVisible(Main.GUI_OUTPUT_TAB_NAME);
|
|
|
89 |
|
|
|
90 |
if (Main.mustAbort)
|
|
|
91 |
return false;
|
|
|
92 |
|
|
|
93 |
// write the captured info from reqpro, into the ea database, obeying the filter
|
|
|
94 |
// settings the user has specified.
|
|
|
95 |
write_ea_database();
|
|
|
96 |
|
|
|
97 |
// Configure the ReqProDB artifact as a document model artifact
|
|
|
98 |
RQ_Artifact.set_doc_model_mode(RQ_Element);
|
|
|
99 |
|
|
|
100 |
if (Main.mustAbort)
|
|
|
101 |
return false;
|
|
|
102 |
|
|
|
103 |
writeDelayedMessages();
|
|
|
104 |
|
|
|
105 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Import Completed", -1);
|
| 2153 |
ghuddy |
106 |
MessageBoxEx.Show("Import Completed", "Progress");
|
| 2151 |
ghuddy |
107 |
return true;
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
catch (Exception ex)
|
|
|
111 |
{
|
| 2153 |
ghuddy |
112 |
Main.MessageBoxException(ex, "Exception (parse)");
|
| 2151 |
ghuddy |
113 |
}
|
|
|
114 |
return false;
|
|
|
115 |
}
|
| 2149 |
ghuddy |
116 |
|
| 2141 |
ghuddy |
117 |
|
| 2151 |
ghuddy |
118 |
|
| 2149 |
ghuddy |
119 |
|
| 2141 |
ghuddy |
120 |
|
| 2151 |
ghuddy |
121 |
|
| 2143 |
ghuddy |
122 |
|
|
|
123 |
|
| 2151 |
ghuddy |
124 |
|
| 2143 |
ghuddy |
125 |
/// <summary>
|
| 2141 |
ghuddy |
126 |
/// This method (along with its sibling overloads) perform the copy operation once
|
|
|
127 |
/// the ReqPro database content has been acquired, and the user has submitted their
|
|
|
128 |
/// filtering requirements. This method begins the copy operation, but the real nitty
|
|
|
129 |
/// gritty of it occurs in the other overloaded method.
|
|
|
130 |
/// </summary>
|
|
|
131 |
/// <param name="ea_repository"></param>
|
| 2151 |
ghuddy |
132 |
private void write_ea_database()
|
| 2141 |
ghuddy |
133 |
{
|
| 2151 |
ghuddy |
134 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Copying ReqPro Database Content to EA", -1);
|
| 2141 |
ghuddy |
135 |
|
|
|
136 |
foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
|
|
|
137 |
{
|
| 2151 |
ghuddy |
138 |
if (Main.mustAbort)
|
|
|
139 |
break;
|
|
|
140 |
|
|
|
141 |
write_ea_database(ea_rootPackage, null, sub_obj);
|
| 2141 |
ghuddy |
142 |
}
|
|
|
143 |
|
| 2151 |
ghuddy |
144 |
ea_rootPackage.Packages.Refresh();
|
| 2141 |
ghuddy |
145 |
// refresh project browser view
|
| 2151 |
ghuddy |
146 |
Main.EA_Repository.RefreshModelView(ea_rootPackage.PackageID);
|
| 2143 |
ghuddy |
147 |
|
| 2151 |
ghuddy |
148 |
if (Main.mustAbort)
|
|
|
149 |
return;
|
|
|
150 |
|
| 2143 |
ghuddy |
151 |
// Setup the internal requirement to requirement connectivity. This is seperate from the browser
|
|
|
152 |
// organisation of elements in EA, but since in ReqPro, that organisation tells part of the story
|
|
|
153 |
// of requirement to requirement connectivity, it is mirrored in the internal connectivity, along
|
|
|
154 |
// with explicit trace relationships setup in ReqPro.
|
|
|
155 |
// The purpose of this internal connectivity is to support relationship matrix tables in documentation
|
|
|
156 |
// generated by EA_DocGen, or to support diagrammatic representations of the requirements in EA,
|
|
|
157 |
// where the connectivity will become apparent through links ajoining the requirement elements in the
|
|
|
158 |
// diagram.
|
| 2151 |
ghuddy |
159 |
write_traces(totalRequirements);
|
| 2141 |
ghuddy |
160 |
}
|
|
|
161 |
|
| 2151 |
ghuddy |
162 |
private void write_ea_database(EA.Package ea_parent_package,
|
| 2141 |
ghuddy |
163 |
EA.Element ea_parent_element,
|
|
|
164 |
ReqPro_object rq_obj )
|
|
|
165 |
{
|
| 2151 |
ghuddy |
166 |
if (Main.mustAbort)
|
|
|
167 |
return;
|
|
|
168 |
|
| 2141 |
ghuddy |
169 |
if (rq_obj.isPackage)
|
|
|
170 |
{
|
|
|
171 |
if (rq_obj.filtered == false)
|
|
|
172 |
{
|
|
|
173 |
if (ea_parent_package != null)
|
|
|
174 |
{
|
|
|
175 |
// create a representative package in EA
|
| 2153 |
ghuddy |
176 |
EA.Package new_ea_package = EA_Utilities.createPackage(ea_parent_package, rq_obj.name, rq_obj.treePos);
|
| 2143 |
ghuddy |
177 |
rq_obj.ea_element_ID = new_ea_package.PackageID;
|
| 2151 |
ghuddy |
178 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Package : " + rq_obj.name, new_ea_package.PackageID );
|
| 2141 |
ghuddy |
179 |
|
|
|
180 |
// Using recursion, scan this objects sub-objects
|
|
|
181 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
182 |
{
|
| 2151 |
ghuddy |
183 |
if (Main.mustAbort)
|
|
|
184 |
break;
|
|
|
185 |
|
| 2153 |
ghuddy |
186 |
write_ea_database(new_ea_package, null, sub_obj); //recurse
|
| 2141 |
ghuddy |
187 |
}
|
|
|
188 |
}
|
|
|
189 |
else
|
|
|
190 |
{
|
| 2143 |
ghuddy |
191 |
// should never get here - I have never seen it happen so far.
|
| 2151 |
ghuddy |
192 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ERROR,write_ea_database, parent package was null", -1);
|
| 2141 |
ghuddy |
193 |
}
|
|
|
194 |
}
|
|
|
195 |
else if (base.allowPackageStructureFragments)
|
|
|
196 |
{
|
|
|
197 |
// Using recursion, scan this objects sub-objects
|
|
|
198 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
199 |
{
|
| 2151 |
ghuddy |
200 |
if (Main.mustAbort)
|
|
|
201 |
break;
|
|
|
202 |
|
| 2141 |
ghuddy |
203 |
if (sub_obj.isPackage)
|
| 2153 |
ghuddy |
204 |
write_ea_database(ea_parent_package, null, sub_obj); // recurse
|
| 2141 |
ghuddy |
205 |
}
|
|
|
206 |
}
|
|
|
207 |
}
|
|
|
208 |
else if (rq_obj.isRequirement)
|
|
|
209 |
{
|
|
|
210 |
if ( ! (reqTypeIsFiltered(rq_obj) || reqStatusTypeIsFiltered(rq_obj)))
|
|
|
211 |
{
|
| 2143 |
ghuddy |
212 |
string rq_obj_name = rq_obj.tag + " " + rq_obj.name;
|
|
|
213 |
|
|
|
214 |
// If needed, create the requirement element as a child of a parent element
|
| 2141 |
ghuddy |
215 |
if (ea_parent_element != null)
|
|
|
216 |
{
|
| 2151 |
ghuddy |
217 |
totalRequirements++;
|
|
|
218 |
|
| 2141 |
ghuddy |
219 |
// create a representative element in EA
|
| 2143 |
ghuddy |
220 |
EA.Element new_ea_element = (EA.Element)ea_parent_element.Elements.AddNew(rq_obj_name, "Requirement");
|
|
|
221 |
rq_obj.ea_element_ID = new_ea_element.ElementID;
|
| 2151 |
ghuddy |
222 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Element : " + rq_obj_name, new_ea_element.ElementID );
|
| 2141 |
ghuddy |
223 |
|
| 2143 |
ghuddy |
224 |
// In ReqPro, a requirement can be related to another requirement in several ways:
|
|
|
225 |
// 1. By virtue of its position relative to another in the browser display. That is,
|
|
|
226 |
// if you place a requirement beneath a parent requirement, you are establishing a
|
|
|
227 |
// parent-child relationship.
|
|
|
228 |
// 2. By virtue of a specific TraceTo relationship being made via the Traceability menu
|
|
|
229 |
// option.
|
|
|
230 |
// Interestingly, ReqPro prevents you creating a relationship of one of the above types,
|
|
|
231 |
// if a relationship of the other type already exists. This implies that the relationship
|
|
|
232 |
// between a parent and child requirement must be singular and is important regardless
|
|
|
233 |
// of the manner in which it was created or represented.
|
|
|
234 |
// The CopyReqProDatabaseToMemory base class will already have taken care of recording
|
|
|
235 |
// relationships detected from ReqPro made using method 2 above. What we need to do here is
|
|
|
236 |
// take care of those apparent from the browser based hierarchical organisation (ie. made
|
|
|
237 |
// in ReqPro using method 1).
|
|
|
238 |
// All we need to do is grab the parent object (if any) and add the GUID of the child to
|
|
|
239 |
// its list of trace-to's. Later on, the write_traces() class method will turn these into
|
|
|
240 |
// EA based connection objects that belong to the parent requirement elements.
|
|
|
241 |
if (rq_obj.parent != null)
|
|
|
242 |
{
|
|
|
243 |
rq_obj.parent.ReqPro_traces.Add(rq_obj.guid);
|
|
|
244 |
}
|
|
|
245 |
|
| 2141 |
ghuddy |
246 |
// If the ReqPro requirements detailed text is more than what the name already contains (allowing for it
|
|
|
247 |
// to have a stop character that the name may not have) then copy it over, otherwise ignore it. This
|
|
|
248 |
// prevents the same text appearing twice in any generated document made using EA_DocGen.
|
|
|
249 |
if (!rq_obj.text.StartsWith(rq_obj.name) || (rq_obj.text.Length > (rq_obj.name.Length + 1)))
|
|
|
250 |
new_ea_element.Notes = rq_obj.text;
|
|
|
251 |
|
|
|
252 |
new_ea_element.TreePos = rq_obj.treePos;
|
| 2151 |
ghuddy |
253 |
new_ea_element.Status = rq_obj.status;
|
| 2141 |
ghuddy |
254 |
new_ea_element.Update();
|
|
|
255 |
|
| 2143 |
ghuddy |
256 |
// Write EA tag information exactly as is done for the import for traceability use. This
|
|
|
257 |
// opens up the possibility that a document model import could be converted into a traceability
|
|
|
258 |
// use model in some future update to EA_ReqPro addin.
|
| 2153 |
ghuddy |
259 |
EA_Utilities.WriteTag(new_ea_element, "GUID", rq_obj.guid);
|
|
|
260 |
EA_Utilities.WriteTag(new_ea_element, "TAG", rq_obj.tag);
|
| 2143 |
ghuddy |
261 |
|
| 2153 |
ghuddy |
262 |
if (rq_obj.source != null)
|
|
|
263 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE", rq_obj.source);
|
|
|
264 |
if (rq_obj.sourceVersion != null)
|
|
|
265 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE_VERSION", rq_obj.sourceVersion);
|
|
|
266 |
if (rq_obj.sourceSection != null)
|
|
|
267 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE_SECTION", rq_obj.sourceSection);
|
|
|
268 |
|
| 2141 |
ghuddy |
269 |
// Using recursion, scan this objects sub-objects
|
|
|
270 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
271 |
{
|
| 2151 |
ghuddy |
272 |
if (Main.mustAbort)
|
|
|
273 |
break;
|
|
|
274 |
|
| 2153 |
ghuddy |
275 |
write_ea_database(null, new_ea_element, sub_obj); // recurse
|
| 2141 |
ghuddy |
276 |
}
|
|
|
277 |
}
|
| 2143 |
ghuddy |
278 |
// else create the requirement element as a child of a parent package
|
| 2141 |
ghuddy |
279 |
else if (ea_parent_package != null)
|
|
|
280 |
{
|
| 2151 |
ghuddy |
281 |
totalRequirements++;
|
|
|
282 |
|
| 2141 |
ghuddy |
283 |
// create a representative element in EA
|
| 2143 |
ghuddy |
284 |
EA.Element new_ea_element = (EA.Element)ea_parent_package.Elements.AddNew(rq_obj_name, "Requirement");
|
|
|
285 |
rq_obj.ea_element_ID = new_ea_element.ElementID;
|
| 2151 |
ghuddy |
286 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Element : " + rq_obj_name, new_ea_element.ElementID );
|
| 2141 |
ghuddy |
287 |
|
|
|
288 |
// If the ReqPro requirements detailed text is more than what the name already contains (allowing for it
|
|
|
289 |
// to have a stop character that the name may not have) then copy it over, otherwise ignore it. This
|
|
|
290 |
// prevents the same text appearing twice in any generated document made using EA_DocGen.
|
|
|
291 |
if (!rq_obj.text.StartsWith(rq_obj.name) || (rq_obj.text.Length > (rq_obj.name.Length + 1)))
|
|
|
292 |
new_ea_element.Notes = rq_obj.text;
|
|
|
293 |
|
|
|
294 |
new_ea_element.TreePos = rq_obj.treePos;
|
| 2151 |
ghuddy |
295 |
new_ea_element.Status = rq_obj.status;
|
| 2141 |
ghuddy |
296 |
new_ea_element.Update();
|
|
|
297 |
|
| 2143 |
ghuddy |
298 |
// Write EA tag information exactly as is done for the import for traceability use. This
|
|
|
299 |
// opens up the possibility that a document model import could be converted into a traceability
|
|
|
300 |
// use model in some future update to EA_ReqPro addin.
|
| 2153 |
ghuddy |
301 |
EA_Utilities.WriteTag(new_ea_element, "GUID", rq_obj.guid);
|
|
|
302 |
EA_Utilities.WriteTag(new_ea_element, "TAG", rq_obj.tag);
|
| 2143 |
ghuddy |
303 |
|
| 2153 |
ghuddy |
304 |
if (rq_obj.source != null)
|
|
|
305 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE", rq_obj.source);
|
|
|
306 |
if (rq_obj.sourceVersion != null)
|
|
|
307 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE_VERSION", rq_obj.sourceVersion);
|
|
|
308 |
if (rq_obj.sourceSection != null)
|
|
|
309 |
EA_Utilities.WriteTag(new_ea_element,"SOURCE_SECTION", rq_obj.sourceSection);
|
|
|
310 |
|
| 2141 |
ghuddy |
311 |
// Using recursion, scan this objects sub-objects
|
| 2151 |
ghuddy |
312 |
|
| 2141 |
ghuddy |
313 |
foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
|
|
|
314 |
{
|
| 2151 |
ghuddy |
315 |
if (Main.mustAbort)
|
|
|
316 |
break;
|
|
|
317 |
|
| 2153 |
ghuddy |
318 |
write_ea_database(null, new_ea_element, sub_obj); // recurse
|
| 2141 |
ghuddy |
319 |
}
|
|
|
320 |
}
|
|
|
321 |
else
|
|
|
322 |
{
|
| 2143 |
ghuddy |
323 |
// should never get here - I have never seen it happen so far.
|
| 2151 |
ghuddy |
324 |
Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ERROR,write_ea_database, parent package was null", -1);
|
| 2141 |
ghuddy |
325 |
}
|
|
|
326 |
}
|
|
|
327 |
}
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
}
|