Subversion Repositories DevTools

Rev

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

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