Subversion Repositories DevTools

Rev

Rev 2153 | Rev 2157 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2153 Rev 2155
Line 29... Line 29...
29
      /// <summary>
29
      /// <summary>
30
      /// Method to parse a ReqPro database and copy it into an EA database.
30
      /// Method to parse a ReqPro database and copy it into an EA database.
31
      /// </summary>
31
      /// </summary>
32
      /// <param name="ea_repository"></param>
32
      /// <param name="ea_repository"></param>
33
      /// <returns></returns>
33
      /// <returns></returns>
34
      public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode)
34
      public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode, out bool cancelled)
35
      {
35
      {
-
 
36
         cancelled = false;
-
 
37
 
36
         try
38
         try
37
         {
39
         {
38
            // use the base classes parser to read the ReqPro database content and allow the user to
40
            // use the base classes parser to read the ReqPro database content and allow the user to
39
            // filter it.
41
            // filter it.
-
 
42
            base.structure_only = false;
-
 
43
 
-
 
44
            string importDateTime = System.DateTime.Now.ToString();
-
 
45
 
-
 
46
            Main.WriteOutput("EA Requirement import at " + importDateTime, -1 );
-
 
47
            Main.WriteOutput("",-1);
-
 
48
 
40
            if (true == base.prompt_and_parse(mode))
49
            if (true == base.prompt_and_parse(mode, out cancelled))
41
            {
50
            {
42
               if (Main.mustAbort)
51
               if (Main.mustAbort)
43
                  return false;
52
                  return false;
44
 
53
 
45
               try
54
               try
Line 56... Line 65...
56
 
65
 
57
                  // if there are existing requirement elements or sub-packages...
66
                  // if there are existing requirement elements or sub-packages...
58
                  if (reqElementsFound == true
67
                  if (reqElementsFound == true
59
                     || ea_rootPackage.Packages.Count > 0)
68
                     || ea_rootPackage.Packages.Count > 0)
60
                  {
69
                  {
-
 
70
                     DialogResult dlgRes = MessageBoxEx.Show(
61
                     DialogResult dlgRes = MessageBoxEx.Show("Package is not empty, delete existing content first?", "Confirm", MessageBoxButtons.YesNo);
71
                        "ReqPro import package is not empty. Delete existing content\n" + 
-
 
72
                        "first?\n\nNOTE:\n" +
-
 
73
                        "For DocModel imports, normally YES is the desired action here.\n" +
-
 
74
                        "All sub-packages within the ReqPro import package will be\n" +
-
 
75
                        "deleted along with any requirement elements found within the\n" +
-
 
76
                        "package itself, so that the import will begin with a clean sheet.\n" +
-
 
77
                        "If you have done any local modelling under the package, that work\n" + 
-
 
78
                        "will be lost. In future, do all such modelling elsewhere, and leave\n" +
-
 
79
                        "the ReqPro import package alone to be updated solely by the\n" +
-
 
80
                        "EA_ReqPro add-in's DocModel import operation.", 
-
 
81
                        "Confirm", 
-
 
82
                        MessageBoxButtons.YesNoCancel);
62
                     if (dlgRes == DialogResult.Yes)
83
                     if (dlgRes == DialogResult.Yes)
63
                     {
84
                     {
64
                        // Delete packages and requirement elements
85
                        // Delete packages and requirement elements
65
                        short i;
86
                        short i;
66
                        for(i=0; i < ea_rootPackage.Packages.Count; i++)
87
                        for(i=0; i < ea_rootPackage.Packages.Count; i++)
Line 76... Line 97...
76
                        }
97
                        }
77
                        ea_rootPackage.Packages.Refresh();
98
                        ea_rootPackage.Packages.Refresh();
78
                        // refresh project browser view
99
                        // refresh project browser view
79
                        Main.EA_Repository.RefreshModelView(ea_rootPackage.PackageID);
100
                        Main.EA_Repository.RefreshModelView(ea_rootPackage.PackageID);
80
                     }
101
                     }
-
 
102
                     else if (dlgRes == DialogResult.Cancel)
-
 
103
                     {
-
 
104
                        cancelled = true;
-
 
105
                        return false;
-
 
106
                     }
81
                  }
107
                  }
82
               }
108
               }
83
               catch (Exception ex)
109
               catch (Exception ex)
84
               {
110
               {
85
                  Main.MessageBoxException(ex, "Exception (CopyReqProDatabase)");
111
                  Main.MessageBoxException(ex, "Exception (CopyReqProDatabase)");
Line 100... Line 126...
100
               if (Main.mustAbort)
126
               if (Main.mustAbort)
101
                  return false;
127
                  return false;
102
 
128
 
103
               writeDelayedMessages();
129
               writeDelayedMessages();
104
 
130
 
105
               Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Import Completed", -1);
131
               Main.WriteOutput("Import Completed", -1);
106
               MessageBoxEx.Show("Import Completed", "Progress");
132
               MessageBoxEx.Show("Import Completed", "Progress");
107
               return true;
133
               return true;
108
            }
134
            }
109
         }
135
         }
110
         catch (Exception ex)
136
         catch (Exception ex)
111
         {
137
         {
112
            Main.MessageBoxException(ex, "Exception (parse)");
138
            Main.MessageBoxException(ex, "Exception (parse)");
113
         }      
139
         }  
-
 
140
    
114
         return false;
141
         return false;
115
      }
142
      }
116
 
143
 
117
 
144
 
118
   
145
   
Line 129... Line 156...
129
      /// gritty of it occurs in the other overloaded method.
156
      /// gritty of it occurs in the other overloaded method.
130
      /// </summary>
157
      /// </summary>
131
      /// <param name="ea_repository"></param>
158
      /// <param name="ea_repository"></param>
132
      private void write_ea_database()
159
      private void write_ea_database()
133
      {
160
      {
134
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Copying ReqPro Database Content to EA", -1);
161
         Main.WriteOutput("Copying ReqPro Database Content to EA", -1);
135
 
162
 
136
         foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
163
         foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
137
         {
164
         {
138
            if (Main.mustAbort)
165
            if (Main.mustAbort)
139
               break;
166
               break;
Line 173... Line 200...
173
               if (ea_parent_package != null)
200
               if (ea_parent_package != null)
174
               {
201
               {
175
                  // create a representative package in EA
202
                  // create a representative package in EA
176
                  EA.Package new_ea_package = EA_Utilities.createPackage(ea_parent_package, rq_obj.name, rq_obj.treePos);
203
                  EA.Package new_ea_package = EA_Utilities.createPackage(ea_parent_package, rq_obj.name, rq_obj.treePos);
177
                  rq_obj.ea_element_ID = new_ea_package.PackageID;
204
                  rq_obj.ea_element_ID = new_ea_package.PackageID;
178
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Package : " + rq_obj.name, new_ea_package.PackageID );
205
                  Main.WriteOutput("Created Package : " + rq_obj.name, new_ea_package.PackageID );
179
 
206
 
180
                  // Using recursion, scan this objects sub-objects
207
                  // Using recursion, scan this objects sub-objects
181
                  foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
208
                  foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
182
                  {
209
                  {
183
                     if (Main.mustAbort)
210
                     if (Main.mustAbort)
Line 187... Line 214...
187
                  }
214
                  }
188
               }
215
               }
189
               else
216
               else
190
               {
217
               {
191
                  // should never get here - I have never seen it happen so far.
218
                  // should never get here - I have never seen it happen so far.
192
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ERROR,write_ea_database, parent package was null", -1);
219
                  Main.WriteOutput("ERROR,write_ea_database, parent package was null", -1);
193
               }
220
               }
194
            }
221
            }
195
            else if (base.allowPackageStructureFragments)
222
            else if (base.allowPackageStructureFragments)
196
            {
223
            {
197
               // Using recursion, scan this objects sub-objects
224
               // Using recursion, scan this objects sub-objects
Line 209... Line 236...
209
         {
236
         {
210
            if ( ! (reqTypeIsFiltered(rq_obj) || reqStatusTypeIsFiltered(rq_obj)))
237
            if ( ! (reqTypeIsFiltered(rq_obj) || reqStatusTypeIsFiltered(rq_obj)))
211
            {
238
            {
212
               string rq_obj_name = rq_obj.tag + " " + rq_obj.name;
239
               string rq_obj_name = rq_obj.tag + " " + rq_obj.name;
213
 
240
 
-
 
241
               EA.Element new_ea_element = null;
-
 
242
 
214
               // If needed, create the requirement element as a child of a parent element
243
               // If needed, create the requirement element as a child of a parent element
215
               if (ea_parent_element != null)
244
               if (ea_parent_element != null)
216
               {
245
               {
217
                  totalRequirements++;
-
 
218
 
-
 
219
                  // create a representative element in EA
246
                  // create a representative element in EA
220
                  EA.Element new_ea_element = (EA.Element)ea_parent_element.Elements.AddNew(rq_obj_name, "Requirement");
247
                  new_ea_element = (EA.Element)ea_parent_element.Elements.AddNew(rq_obj_name, "Requirement");
221
                  rq_obj.ea_element_ID = new_ea_element.ElementID;
248
                  
222
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Element : " + rq_obj_name, new_ea_element.ElementID );
249
                  Main.WriteOutput("Created Element : " + rq_obj_name, new_ea_element.ElementID );
223
 
250
 
224
                  // In ReqPro, a requirement can be related to another requirement in several ways:
251
                  // 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, 
252
                  // 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 
253
                  //    if you place a requirement beneath a parent requirement, you are establishing a 
227
                  //    parent-child relationship.
254
                  //    parent-child relationship.
228
                  // 2. By virtue of a specific TraceTo relationship being made via the Traceability menu
255
                  // 2. By virtue of a specific TraceTo/TraceFrom relationship being made via the Traceability menu
229
                  //    option. 
256
                  //    option. 
230
                  // Interestingly, ReqPro prevents you creating a relationship of one of the above types,
257
                  // 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
258
                  // 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
259
                  // between a parent and child requirement must be singular and is important regardless
233
                  // of the manner in which it was created or represented.
260
                  // of the manner in which it was created or represented.
Line 235... Line 262...
235
                  // relationships detected from ReqPro made using method 2 above. What we need to do here is
262
                  // 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
263
                  // take care of those apparent from the browser based hierarchical organisation (ie. made
237
                  // in ReqPro using method 1).
264
                  // 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 
265
                  // 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
266
                  // 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.
267
                  // EA based connection objects
241
                  if (rq_obj.parent != null)
268
                  if (rq_obj.parent != null)
242
                  {
269
                  {
243
                     rq_obj.parent.ReqPro_traces.Add(rq_obj.guid);
270
                     rq_obj.parent.ReqPro_traces.Add(rq_obj.guid);
244
                  }
271
                  }
245
 
-
 
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;
-
 
253
                  new_ea_element.Status  = rq_obj.status;
-
 
254
                  new_ea_element.Update();
-
 
255
 
-
 
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.
-
 
259
                  EA_Utilities.WriteTag(new_ea_element, "GUID", rq_obj.guid);
-
 
260
                  EA_Utilities.WriteTag(new_ea_element, "TAG", rq_obj.tag);
-
 
261
 
-
 
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
 
-
 
269
                  // Using recursion, scan this objects sub-objects
-
 
270
                  foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
-
 
271
                  {
-
 
272
                     if (Main.mustAbort)
-
 
273
                        break;
-
 
274
 
-
 
275
                     write_ea_database(null, new_ea_element, sub_obj);  // recurse
-
 
276
                  }
-
 
277
               }
272
               }
278
               // else create the requirement element as a child of a parent package
273
               // else create the requirement element as a child of a parent package
279
               else if (ea_parent_package != null)
274
               else if (ea_parent_package != null)
280
               {
275
               {
-
 
276
                  // create a representative element in EA
-
 
277
                  new_ea_element = (EA.Element)ea_parent_package.Elements.AddNew(rq_obj_name, "Requirement");
-
 
278
                  
-
 
279
                  Main.WriteOutput("Created Element : " + rq_obj_name, new_ea_element.ElementID );
-
 
280
               }
-
 
281
               else
-
 
282
               {
-
 
283
                  // should never get here - I have never seen it happen so far.
-
 
284
                  Main.WriteOutput("ERROR, write_ea_database, parent package was null", -1);
-
 
285
               }
-
 
286
 
-
 
287
               if (new_ea_element != null)
-
 
288
               {
281
                  totalRequirements++;
289
                  totalRequirements++;
282
 
290
 
283
                  // create a representative element in EA
-
 
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;
291
                  rq_obj.ea_element_ID = new_ea_element.ElementID;
286
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Created Element : " + rq_obj_name, new_ea_element.ElementID );
-
 
287
 
292
 
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)))
293
                  new_ea_element.TreePos = rq_obj.treePos; // deliberately dont do TreePos in copyReq()
292
                     new_ea_element.Notes = rq_obj.text;
-
 
293
 
294
 
294
                  new_ea_element.TreePos = rq_obj.treePos;
-
 
295
                  new_ea_element.Status  = rq_obj.status;
-
 
296
                  new_ea_element.Update();
295
                  copyReq(new_ea_element, rq_obj);
297
 
296
 
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.
-
 
301
                  EA_Utilities.WriteTag(new_ea_element, "GUID", rq_obj.guid);
-
 
302
                  EA_Utilities.WriteTag(new_ea_element, "TAG", rq_obj.tag);
-
 
303
 
-
 
304
                  if (rq_obj.source != null)
297
                  new_ea_element.Update();
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
 
298
 
311
                  // Using recursion, scan this objects sub-objects
299
                  // Using recursion, scan this objects sub-objects
312
                  
-
 
313
                  foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
300
                  foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
314
                  {
301
                  {
315
                     if (Main.mustAbort)
302
                     if (Main.mustAbort)
316
                        break;
303
                        break;
317
 
304
 
318
                     write_ea_database(null, new_ea_element, sub_obj);  // recurse
305
                     write_ea_database(null, new_ea_element, sub_obj);  // recurse
319
                  }
306
                  }
320
               }
307
               }
321
               else
-
 
322
               {
-
 
323
                  // should never get here - I have never seen it happen so far.
-
 
324
                  Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "ERROR,write_ea_database, parent package was null", -1);
-
 
325
               }
-
 
326
            }
308
            }
327
         }
309
         }
328
      }
310
      }
329
 
311
 
-
 
312
      public static void copyReq(EA.Element new_ea_element, ReqPro_object rq_obj)
-
 
313
      {
-
 
314
         // If the ReqPro requirements detailed text is more than what the name already contains (allowing for it
-
 
315
         // to have a stop character that the name may not have) then copy it over, otherwise ignore it. This
-
 
316
         // prevents the same text appearing twice in any generated document made using EA_DocGen.
-
 
317
         if (!rq_obj.text.StartsWith(rq_obj.name) || (rq_obj.text.Length > (rq_obj.name.Length + 1)))
-
 
318
            new_ea_element.Notes = rq_obj.text;
-
 
319
 
-
 
320
         new_ea_element.Status     = rq_obj.status;
-
 
321
         new_ea_element.Difficulty = rq_obj.difficulty;
-
 
322
         new_ea_element.Priority   = rq_obj.priority;
-
 
323
         new_ea_element.Version    = rq_obj.version;
-
 
324
 
-
 
325
         // Write EA tag information exactly as is done for the import for traceability use. This 
-
 
326
         // opens up the possibility that a document model import could be converted into a traceability
-
 
327
         // use model in some future update to EA_ReqPro addin.
-
 
328
         EA_TaggedValues.Write(new_ea_element, Constants.TAG_GUID, rq_obj.guid);
-
 
329
         EA_TaggedValues.Write(new_ea_element, Constants.TAG_TAG, rq_obj.tag);
-
 
330
 
-
 
331
         if (rq_obj.source != null && rq_obj.source.Length > 0)
-
 
332
            EA_TaggedValues.Write(new_ea_element,Constants.TAG_SOURCE, rq_obj.source);
-
 
333
         if (rq_obj.sourceVersion != null && rq_obj.sourceVersion.Length > 0)
-
 
334
            EA_TaggedValues.Write(new_ea_element,Constants.TAG_SOURCE_VERSION, rq_obj.sourceVersion);
-
 
335
         if (rq_obj.sourceSection != null && rq_obj.sourceSection.Length > 0)
-
 
336
            EA_TaggedValues.Write(new_ea_element,Constants.TAG_SOURCE_SECTION, rq_obj.sourceSection);
-
 
337
 
-
 
338
         if (rq_obj.subsystem != null && rq_obj.subsystem.Length > 0)
-
 
339
            EA_TaggedValues.Write(new_ea_element,Constants.TAG_SUBSYSTEM, rq_obj.subsystem);
-
 
340
 
-
 
341
         if (rq_obj.stability != null && rq_obj.stability.Length > 0)
-
 
342
            EA_TaggedValues.Write(new_ea_element,Constants.TAG_STABILITY, rq_obj.stability);
330
 
343
 
-
 
344
         if (0 > new_ea_element.StereotypeEx.IndexOf(rq_obj.type))
-
 
345
         {
-
 
346
            if (new_ea_element.StereotypeEx.Length > 0)
-
 
347
               new_ea_element.StereotypeEx = rq_obj.type + "," + new_ea_element.StereotypeEx;
-
 
348
            else
-
 
349
               new_ea_element.StereotypeEx = rq_obj.type;
-
 
350
         }
-
 
351
         if (new_ea_element.Stereotype.Length == 0)
-
 
352
         {
-
 
353
            new_ea_element.Stereotype = new_ea_element.StereotypeEx.Split(",".ToCharArray())[0];
-
 
354
         }
-
 
355
 
-
 
356
      }
331
 
357
 
332
 
358
 
333
	}
359
	}
334
 
360
 
335
 
361