Subversion Repositories DevTools

Rev

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

Rev 2145 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.Collections.Specialized;
5
using System.Windows.Forms;
6
using System.Windows.Forms;
6
using ReqPro40;
7
using ReqPro40;
7
 
8
 
8
 
9
 
9
namespace EA_ReqPro
10
namespace EA_ReqPro
10
{
11
{
Line 14... Line 15...
14
	/// to a client with sufficient information to allow it to build a model of that ReqPro
15
	/// to a client with sufficient information to allow it to build a model of that ReqPro
15
	/// database content in memory, maintaining the hierarchy and ordering of objects found.
16
	/// database content in memory, maintaining the hierarchy and ordering of objects found.
16
	/// </summary>
17
	/// </summary>
17
	public class ReqProParser
18
	public class ReqProParser
18
	{
19
	{
-
 
20
      // lists of meta-data in the ReqPro database
-
 
21
      protected ArrayList rq_req_types;
-
 
22
      protected ArrayList rq_req_status_types;
-
 
23
      protected ArrayList delayedMessages;
-
 
24
 
-
 
25
      // constructor
19
		public ReqProParser()
26
		public ReqProParser()
20
		{
27
		{
-
 
28
         delayedMessages = new ArrayList();
21
		}
29
		}
22
 
30
 
23
      /// <summary>
31
      /// <summary>
24
      /// The parser will call this virtual method when it has opened a ReqPro project
32
      /// The parser will call this virtual method when it has opened a ReqPro project
25
      /// </summary>
33
      /// </summary>
Line 37... Line 45...
37
      /// </summary>
45
      /// </summary>
38
      /// <param name="level"></param>
46
      /// <param name="level"></param>
39
      /// <param name="ea_repository"></param>
47
      /// <param name="ea_repository"></param>
40
      /// <param name="rq_project"></param>
48
      /// <param name="rq_project"></param>
41
      /// <param name="rq_Package"></param>
49
      /// <param name="rq_Package"></param>
42
      protected virtual void processPackage(int level,
50
      protected virtual void processPackage(int level,
43
                                            EA.Repository ea_repository, 
-
 
44
                                            ReqPro40.Project rq_project, 
51
                                            ReqPro40.Project rq_project, 
45
                                            ReqPro40.Package rq_package)
52
                                            ReqPro40.Package rq_package)
46
      {
53
      {
47
      }
54
      }
48
 
55
 
49
      /// <summary>
56
      /// <summary>
Line 53... Line 60...
53
      /// <param name="level"></param>
60
      /// <param name="level"></param>
54
      /// <param name="ea_repository"></param>
61
      /// <param name="ea_repository"></param>
55
      /// <param name="rq_project"></param>
62
      /// <param name="rq_project"></param>
56
      /// <param name="rq_Package"></param>
63
      /// <param name="rq_Package"></param>
57
      /// <param name="rq_Requirement"></param>
64
      /// <param name="rq_Requirement"></param>
58
      protected virtual void processRequirement(int level,
65
      protected virtual void processRequirement(int level,
59
                                                EA.Repository ea_repository, 
-
 
60
                                                ReqPro40.Project rq_project, 
66
                                                ReqPro40.Project rq_project, 
61
                                                ReqPro40.Package rq_package,
67
                                                ReqPro40.Package rq_package,
62
                                                ReqPro40.Requirement rq_requirement)
68
                                                ReqPro40.Requirement rq_requirement)
63
      {
69
      {
64
      }
70
      }
65
 
71
 
Line 70... Line 76...
70
      /// <param name="level"></param>
76
      /// <param name="level"></param>
71
      /// <param name="ea_repository"></param>
77
      /// <param name="ea_repository"></param>
72
      /// <param name="rq_project"></param>
78
      /// <param name="rq_project"></param>
73
      /// <param name="rq_Package"></param>
79
      /// <param name="rq_Package"></param>
74
      /// <param name="rq_Requirement"></param>
80
      /// <param name="rq_Requirement"></param>
75
      protected virtual void processObject(int level,
81
      protected virtual void processObject(int level,
76
                                           EA.Repository ea_repository, 
-
 
77
                                           ReqPro40.Project rq_project, 
82
                                           ReqPro40.Project rq_project, 
78
                                           ReqPro40.Package rq_package,
83
                                           ReqPro40.Package rq_package,
79
                                           ReqPro40.Requirement rq_requirement)
84
                                           ReqPro40.Requirement rq_requirement)
80
      {
85
      {
81
      }
86
      }
82
 
87
 
-
 
88
      protected void writeDelayedMessages()
-
 
89
      {
-
 
90
         foreach(string s in delayedMessages)
-
 
91
         {
-
 
92
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, s, -1);
-
 
93
         }
-
 
94
      }
-
 
95
 
-
 
96
      #region Requirement Type methods
-
 
97
 
-
 
98
      /// <summary>
-
 
99
      /// Get the requirement types from the ReqPro database, into a simple list, where each element
-
 
100
      /// describes the requirement type and whether it is filtered or not. This list can be given to 
-
 
101
      /// the ReqProFilterForm to capture the users requirement type filtering decisions. 
-
 
102
      /// </summary>
-
 
103
      protected void get_rq_req_types_from_database(ReqPro40.Project RQ_project)
-
 
104
      {
-
 
105
         rq_req_types = new ArrayList();
-
 
106
 
-
 
107
         ReqPro40.ReqTypes rqtypes = RQ_project.ReqTypes;
-
 
108
         foreach (ReqPro40.ReqType rq_type in rqtypes)
-
 
109
         {
-
 
110
            ReqPro_ReqType new_req_type = new ReqPro_ReqType(rq_type);
-
 
111
            new_req_type.name     = rq_type.Name;
-
 
112
            new_req_type.prefix   = rq_type.ReqPrefix;
-
 
113
            rq_req_types.Add(new_req_type);
-
 
114
         }
-
 
115
      }
-
 
116
 
-
 
117
      /// <summary>
-
 
118
      /// Examine the requirement type list to see if the requirement type of the specified object
-
 
119
      /// has been filtered or not.
-
 
120
      /// </summary>
-
 
121
      /// <param name="rq_obj"></param>
-
 
122
      /// <returns></returns>
-
 
123
      protected bool reqTypeIsFiltered(ReqPro_object rq_obj)
-
 
124
      {
-
 
125
         return ((ReqPro_ReqType)rq_req_types[rq_obj.tag_enum]).filtered;
-
 
126
      }
-
 
127
 
-
 
128
      protected bool reqTypeHasOneOrMoreAttrs(ReqPro_object rq_obj, ref bool hasStatus, ref bool hasDiff, ref bool hasPrio)
-
 
129
      {
-
 
130
         foreach (ReqPro_ReqType rp_rt in rq_req_types)
-
 
131
         {
-
 
132
            if (rq_obj.tag.StartsWith(rp_rt.prefix))
-
 
133
            {
-
 
134
               hasStatus = rp_rt.hasStatus;
-
 
135
               hasDiff = rp_rt.hasDifficulty;
-
 
136
               hasPrio = rp_rt.hasPriority;
-
 
137
               return hasStatus | hasDiff | hasPrio;
-
 
138
            }
-
 
139
         }
-
 
140
 
-
 
141
         return false;
-
 
142
      }
-
 
143
 
-
 
144
      #endregion
-
 
145
 
-
 
146
      #region Requirement Status Type methods
-
 
147
 
-
 
148
      /// <summary>
-
 
149
      /// Get the requirement status types from the ReqPro database, into a simple list, where each element
-
 
150
      /// describes the requirement status type and whether it is filtered or not. This list can be given to 
-
 
151
      /// the ReqProFilterForm to capture the users requirement status type filtering decisions. 
-
 
152
      /// </summary>
-
 
153
      protected void get_rq_req_status_types_from_database(ReqPro40.Project RQ_project)
-
 
154
      {
-
 
155
         StringCollection status_values = new StringCollection();
-
 
156
 
-
 
157
         // Each requirement type can have its own unique list of status attribute values
-
 
158
         // so we have to go through each requirement type and find the set of status values
-
 
159
         // that each one has and add them to out string collection, if the collection does
-
 
160
         // not already have the strings ofcoarse. So, we are merging together all the status
-
 
161
         // values in the ReqPro database, into one set.
-
 
162
         foreach (ReqPro_ReqType rp_rt in rq_req_types)
-
 
163
         {
-
 
164
            try 
-
 
165
            {
-
 
166
               ReqPro40.Attr attr = rp_rt.rq_type.get_Attr("Status", ReqPro40.enumAttrLookups.eAttrLookups_Label);
-
 
167
               rp_rt.hasStatus = true;
-
 
168
 
-
 
169
               foreach (ReqPro40.ListItem listItem in attr.ListItems)
-
 
170
               {
-
 
171
                  if (!status_values.Contains(listItem.Text))
-
 
172
                  {
-
 
173
                     status_values.Add(listItem.Text);
-
 
174
                  }
-
 
175
               }
-
 
176
            }
-
 
177
            catch 
-
 
178
            {
-
 
179
               delayedMessages.Add( string.Format("WARNING, ReqPro requirement type ({0}) has no Status attribute", rp_rt.prefix) );
-
 
180
            }
-
 
181
            // Also check if this requirement type has any of the other attributes we might import. This is
-
 
182
            // a little off topic for this function but this is a convenient place to do this until another
-
 
183
            // function is written.
-
 
184
            try 
-
 
185
            {
-
 
186
               ReqPro40.Attr attr = rp_rt.rq_type.get_Attr("Difficulty", ReqPro40.enumAttrLookups.eAttrLookups_Label);
-
 
187
               rp_rt.hasDifficulty = true;
-
 
188
            }
-
 
189
            catch 
-
 
190
            {
-
 
191
               delayedMessages.Add( string.Format("WARNING, ReqPro requirement type ({0}) has no Difficulty attribute", rp_rt.prefix) );
-
 
192
            };
-
 
193
 
-
 
194
            try 
-
 
195
            {
-
 
196
               ReqPro40.Attr attr = rp_rt.rq_type.get_Attr("Priority", ReqPro40.enumAttrLookups.eAttrLookups_Label);
-
 
197
               rp_rt.hasPriority = true;
-
 
198
            }
-
 
199
            catch 
-
 
200
            {
-
 
201
               delayedMessages.Add( string.Format("WARNING, ReqPro requirement type ({0}) has no Priority attribute", rp_rt.prefix) );
-
 
202
            };
-
 
203
         }
-
 
204
 
-
 
205
         // if reqpro had no status values, then add a dummy one
-
 
206
         if (status_values.Count == 0)
-
 
207
         {
-
 
208
            status_values.Add("Approved");
-
 
209
         }
-
 
210
 
-
 
211
         // With our merged set of status values, create a list of ReqPro_ReqStatus objects.
-
 
212
         rq_req_status_types = new ArrayList();
-
 
213
         foreach (string s in status_values)
-
 
214
         {
-
 
215
            ReqPro_ReqStatus new_ReqPro_ReqStatus = new ReqPro_ReqStatus();
-
 
216
            new_ReqPro_ReqStatus.filtered = false;
-
 
217
            new_ReqPro_ReqStatus.status_value = s;
-
 
218
            rq_req_status_types.Add(new_ReqPro_ReqStatus);
-
 
219
         }
-
 
220
      }
-
 
221
 
-
 
222
      /// <summary>
-
 
223
      /// Examine the requirement status type list to see if the requirement status type of 
-
 
224
      /// the specified object has been filtered or not.
-
 
225
      /// </summary>
-
 
226
      /// <param name="rq_obj"></param>
-
 
227
      /// <returns></returns>
-
 
228
      protected bool reqStatusTypeIsFiltered(ReqPro_object rq_obj)
-
 
229
      {
-
 
230
         foreach (ReqPro_ReqStatus rqs in rq_req_status_types)
-
 
231
         {
-
 
232
            if (0 == rqs.status_value.CompareTo(rq_obj.status))
-
 
233
            {
-
 
234
               return rqs.filtered;
-
 
235
            }
-
 
236
         }
-
 
237
         return false;
-
 
238
      }
-
 
239
 
-
 
240
      #endregion
83
 
241
 
84
 
242
 
85
 
-
 
86
      /// <summary>
243
      /// <summary>
87
      /// Initiates a ReqPro database parsing operation using a prompted reqpro database open operation
244
      /// Initiates a ReqPro database parsing operation using a prompted reqpro database open operation
88
      /// </summary>
245
      /// </summary>
89
      /// <param name="ea_repository"></param>
246
      /// <param name="ea_repository"></param>
90
      /// <returns></returns>
247
      /// <returns></returns>
91
      public virtual bool prompt_and_parse(EA.Repository ea_repository, ReqProDB_Artifact.MODE mode)
248
      public virtual bool prompt_and_parse(ReqProDB_Artifact.MODE mode)
92
      {
249
      {
93
         ReqPro40.Application rq_app = null;
250
         ReqPro40.Application rq_app = null;
94
         ReqPro40.Project rq_project = null;
251
         ReqPro40.Project rq_project = null;
95
 
252
 
96
         try
253
         try
97
         {
254
         {
98
            // If we can find a ReqProDB artifact in the package, use it to logon to the ReqPro database
255
            // If we can find a ReqProDB artifact in the package, use it to logon to the ReqPro database
99
            ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();
256
            ReqProDB_Artifact RQ_Artifact = new ReqProDB_Artifact();
100
            EA.Element RQ_Element = RQ_Artifact.get_rq_artifact(ea_repository);
257
            EA.Element RQ_Element = RQ_Artifact.get_rq_artifact();
101
            if (RQ_Element != null)
258
            if (RQ_Element != null)
102
            {
259
            {
103
               // check to see if the ReqProDB element has the same mode as that specified by parameter
260
               // check to see if the ReqProDB element has the same mode as that specified by parameter
104
               ReqProDB_Artifact.MODE rq_art_mode = RQ_Artifact.get_mode(ea_repository, RQ_Element);
261
               ReqProDB_Artifact.MODE rq_art_mode = RQ_Artifact.get_mode(RQ_Element);
105
               if (rq_art_mode != ReqProDB_Artifact.MODE.UNDEFINED)
262
               if (rq_art_mode != ReqProDB_Artifact.MODE.UNDEFINED)
106
               {
263
               {
107
                  if (rq_art_mode != mode)
264
                  if (rq_art_mode != mode)
108
                  {
265
                  {
109
                     DialogResult dlgRes = MessageBox.Show("You are attempting to use a ReqProDB element\n" +
266
                     DialogResult dlgRes = MessageBoxEx.Show("You are attempting to use a ReqProDB element " +
110
                        "for a different purpose than that which was\n" +
267
                        "for a different purpose than that which was " +
111
                        "specified when the element was first created.\n" +
268
                        "specified when the element was first created. " +
112
                        "Continue Anyway?", "Confirm", MessageBoxButtons.YesNo);
269
                        "Continue Anyway?", "Confirm", MessageBoxButtons.YesNo);
113
                     if (dlgRes != DialogResult.Yes)
270
                     if (dlgRes != DialogResult.Yes)
114
                     {
271
                     {
115
                        return false;
272
                        return false;
116
                     }
273
                     }
117
                  }
274
                  }
118
               }
275
               }
-
 
276
 
-
 
277
               if (Main.mustAbort)
-
 
278
                  return false;
119
 
279
 
120
               rq_project = RQ_Artifact.OpenReqProProject(ea_repository, RQ_Element);
280
               rq_project = RQ_Artifact.OpenReqProProject(RQ_Element);
121
               if (rq_project != null)
281
               if (rq_project != null)
122
                  rq_app = RQ_Artifact.RQ_app;
282
                  rq_app = RQ_Artifact.RQ_app;
123
            }
283
            }
124
            
284
            
-
 
285
            if (Main.mustAbort)
-
 
286
               return false;
-
 
287
 
125
            // If no ReqProDB artifact found, prompt user to logon to the ReqPro database
288
            // If no ReqProDB artifact found, prompt user to logon to the ReqPro database
126
            if (rq_project == null)
289
            if (rq_project == null)
127
            {
290
            {
128
               // let user select the ReqPro database file name
291
               // let user select the ReqPro database file name
129
               OpenFileDialog ofd = new OpenFileDialog();
292
               OpenFileDialog ofd = new OpenFileDialog();
130
               ofd.Title = "Select Requisite Pro project file";
293
               ofd.Title = "Select Requisite Pro project file";
131
               ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
294
               ofd.Filter = "ReqPro files (*.rqs)|*.rqs|All files (*.*)|*.*";
132
               DialogResult dlgRes = ofd.ShowDialog();
295
               DialogResult dlgRes = ofd.ShowDialog();
133
               if (dlgRes != DialogResult.OK)
296
               if (dlgRes != DialogResult.OK)
-
 
297
                  return false;
-
 
298
 
-
 
299
               if (Main.mustAbort)
134
                  return false;
300
                  return false;
135
 
301
 
136
               // let user specifiy username/password
302
               // let user specifiy username/password
137
               Logon logon = new Logon("");
303
               Logon logon = new Logon("");
138
               dlgRes = logon.ShowDialog();
304
               dlgRes = logon.ShowDialog();
139
               if (dlgRes != DialogResult.OK)
305
               if (dlgRes != DialogResult.OK)
-
 
306
                  return false;
-
 
307
 
-
 
308
               if (Main.mustAbort)
140
                  return false;
309
                  return false;
141
 
310
 
142
               string username = logon.ebUserName.Text;
311
               string username = logon.ebUserName.Text;
143
               string password = logon.ebPassword.Text;
312
               string password = logon.ebPassword.Text;
144
 
313
 
145
               // Connect to the ReqPro database using the ReqPro extensibility mechanism
314
               // Connect to the ReqPro database using the ReqPro extensibility mechanism
146
               rq_app = new ReqPro40.ApplicationClass();
315
               rq_app = new ReqPro40.ApplicationClass();
147
 
316
 
148
               rq_project = 
317
               rq_project = 
149
                  rq_app.OpenProject(ofd.FileName,
318
                  rq_app.OpenProject(ofd.FileName,
150
                  ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
319
                  ReqPro40.enumOpenProjectOptions.eOpenProjOpt_RQSFile,
151
                  username,
320
                  username,
152
                  password, 
321
                  password, 
153
                  enumProjectFlags.eProjFlag_Normal,
322
                  enumProjectFlags.eProjFlag_Normal,
154
                  enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
323
                  enumRelatedProjectOptions.eRelatedProjOption_ConnectAsSpecified);
-
 
324
 
-
 
325
               if (Main.mustAbort)
-
 
326
                  return false;
155
 
327
 
156
               // if we do not currently have a ReqProDB artifact, create one
328
               // if we do not currently have a ReqProDB artifact, create one
157
               if (RQ_Element == null)
329
               if (RQ_Element == null)
158
               {
330
               {
159
                  EA_Utilities EA_Utils = new EA_Utilities(ea_repository);
331
                  EA_Utilities EA_Utils = new EA_Utilities();
160
 
332
 
161
                  RQ_Element = RQ_Artifact.create_rq_artifact( ea_repository, 
333
                  RQ_Element = RQ_Artifact.create_rq_artifact(
162
                     EA_Utils.get_selected_package(), 
334
                     EA_Utils.get_selected_package(), 
163
                     rq_project.Name, 
335
                     rq_project.Name, 
164
                     rq_project.Description, 
336
                     rq_project.Description, 
165
                     logon.ebUserName.Text, 
337
                     logon.ebUserName.Text, 
166
                     ofd.FileName, 
338
                     ofd.FileName, 
167
                     rq_project.GUID);
339
                     rq_project.GUID);
168
               }
340
               }
-
 
341
               if (Main.mustAbort)
-
 
342
                  return false;
169
            }
343
            }
170
 
-
 
171
 
344
 
-
 
345
            if (Main.mustAbort)
-
 
346
               return false;
172
 
347
 
173
            // Now do the parsing of the ReqPro database
348
            // Now do the parsing of the ReqPro database
174
            if (rq_project != null)
349
            if (rq_project != null)
175
            {
350
            {
176
               // give req pro project object to user of this class
351
               // give req pro project object to user of this class
177
               provideReqProDatabaseInfo(rq_app, rq_project, RQ_Artifact, RQ_Element);
352
               provideReqProDatabaseInfo(rq_app, rq_project, RQ_Artifact, RQ_Element);
-
 
353
 
-
 
354
               // get the requirement types from the req pro project
-
 
355
               get_rq_req_types_from_database(rq_project);
-
 
356
 
-
 
357
               get_rq_req_status_types_from_database(rq_project);
178
 
358
 
179
               // Get the ReqPro root package and parse it
359
               // Get the ReqPro root package and parse it
-
 
360
               Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Acquiring ReqPro Database", -1);
180
               ReqPro40.RootPackage rq_rootPackage = rq_project.GetRootPackage(true);
361
               ReqPro40.RootPackage rq_rootPackage = rq_project.GetRootPackage(true);
181
 
362
 
182
               parseRootPackage(0, ea_repository, rq_project, rq_rootPackage);
363
               parseRootPackage(0, rq_project, rq_rootPackage);
-
 
364
 
-
 
365
               if (Main.mustAbort)
-
 
366
                  return false;
-
 
367
 
183
               return true;
368
               return true;
184
            }
369
            }
185
         }
370
         }
186
         catch (Exception ex)
371
         catch (Exception ex)
187
         {
372
         {
188
            MessageBox.Show(ex.Message, "Error (ReqProParser::prompt_and_parse)", MessageBoxButtons.OK);
373
            MessageBoxEx.Show(ex.Message, "Error (prompt_and_parse)", MessageBoxButtons.OK);
189
            if (rq_project != null)
374
            if (rq_project != null)
190
               rq_project.CloseProject();
375
               rq_project.CloseProject();
191
         }  
376
         }  
192
         return false;
377
         return false;
193
      }
378
      }
194
 
379
 
195
      /// <summary>
380
      /// <summary>
196
      /// This method handles the parsing of the root package in the ReqPro database.
381
      /// This method handles the parsing of the root package in the ReqPro database.
197
      /// The method is almost identical to the parsePackage method, except that this
382
      /// The method is almost identical to the parsePackage method, except that this
198
      /// deals with a ReqPro40.RootPackage object, whereas the latter deals with a
383
      /// deals with a ReqPro40.RootPackage object, whereas the latter deals with a
199
      /// ReqPro40.Package object. Perhaps the two functions could be combined into 
384
      /// ReqPro40.Package object. Perhaps the two functions could be combined into 
200
      /// one if we move to .NET 2 where c# has some support for generic (template)
385
      /// one if we move to .NET 2 where c# has some support for generic (template)
201
      /// programming.
386
      /// programming.
202
      /// </summary>
387
      /// </summary>
203
      /// <param name="repository"></param>
388
      /// <param name="repository"></param>
204
      /// <param name="rq_project"></param>
389
      /// <param name="rq_project"></param>
205
      /// <param name="thisPackage"></param>
390
      /// <param name="thisPackage"></param>
206
      private void parseRootPackage(int level,
391
      private void parseRootPackage(int level,
207
                                    EA.Repository ea_repository, 
-
 
208
                                    ReqPro40.Project rq_project, 
392
                                    ReqPro40.Project rq_project, 
209
                                    ReqPro40.RootPackage thisPackage)
393
                                    ReqPro40.RootPackage thisPackage)
210
      {
394
      {
211
         // Scan through the sub-packages of the root package
395
         // Scan through the sub-packages of the root package
212
         int limit_packageCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Package);
396
         int limit_packageCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Package);
213
         if (limit_packageCount > 0)
397
         if (limit_packageCount > 0)
214
         {
398
         {
215
            int i_packageCount;
399
            int i_packageCount;
216
            thisPackage.MoveFirst();
400
            thisPackage.MoveFirst();
217
            for (i_packageCount = 0; i_packageCount < limit_packageCount; i_packageCount++)
401
            for (i_packageCount = 0; i_packageCount < limit_packageCount; i_packageCount++)
218
            {
402
            {
-
 
403
               if (Main.mustAbort)
-
 
404
                  break;
-
 
405
 
219
               // Read the sub-package and parse it
406
               // Read the sub-package and parse it
220
               ReqPro40.Package subPackage = (ReqPro40.Package)thisPackage.GetCurrentElement();
407
               ReqPro40.Package subPackage = (ReqPro40.Package)thisPackage.GetCurrentElement();
221
               parsePackage(level+1, ea_repository, rq_project, subPackage);
408
               parsePackage(level+1, "", rq_project, subPackage);
222
               thisPackage.MoveNext();
409
               thisPackage.MoveNext();
223
            }
410
            }
224
         }
411
         }
-
 
412
 
-
 
413
         if (Main.mustAbort)
-
 
414
            return;
225
 
415
 
226
         // Scan through the requirements directly beneath the root package
416
         // Scan through the requirements directly beneath the root package
227
         int limit_reqCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Requirement);
417
         int limit_reqCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Requirement);
228
         if (limit_reqCount > 0)
418
         if (limit_reqCount > 0)
229
         {
419
         {
230
            // Obtain the requirement element key list from the root package and scan through each entry
420
            // Obtain the requirement element key list from the root package and scan through each entry
231
            int i_reqCount;
421
            int i_reqCount;
232
            System.Object[,] keyList = (System.Object[,])thisPackage.KeyList(ReqPro40.enumElementTypes.eElemType_Requirement);
422
            System.Object[,] keyList = (System.Object[,])thisPackage.KeyList(ReqPro40.enumElementTypes.eElemType_Requirement);
233
            for (i_reqCount = 0; i_reqCount < limit_reqCount; i_reqCount++)
423
            for (i_reqCount = 0; i_reqCount < limit_reqCount; i_reqCount++)
234
            {
424
            {
-
 
425
               if (Main.mustAbort)
-
 
426
                  break;
-
 
427
 
235
               // Obtain the ReqPro requirement from its key, and parse it
428
               // Obtain the ReqPro requirement from its key, and parse it
236
               ReqPro40.Requirement thisRequirement = 
429
               ReqPro40.Requirement thisRequirement = 
237
                  rq_project.GetRequirement(keyList[0,i_reqCount],
430
                  rq_project.GetRequirement(keyList[0,i_reqCount],
238
                                            ReqPro40.enumRequirementLookups.eReqLookup_Key,
431
                                            ReqPro40.enumRequirementLookups.eReqLookup_Key,
239
                                            ReqPro40.enumRequirementsWeights.eReqWeight_Heavy,
432
                                            ReqPro40.enumRequirementsWeights.eReqWeight_Heavy,
240
                                            ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
433
                                            ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
241
 
434
 
242
               if (thisRequirement != null)
435
               if (thisRequirement != null)
243
               {
436
               {
244
                  parseRequirement(level+1, ea_repository, rq_project, null, thisRequirement);                  
437
                  parseRequirement(level+1, rq_project, null, thisRequirement);                  
245
               }
438
               }
246
            }
439
            }
247
         }
440
         }
248
      }
441
      }
249
 
442
 
250
      /// <summary>
443
      /// <summary>
251
      /// This method handles the parsing of each package beneath the root package
444
      /// This method handles the parsing of each package beneath the root package
252
      /// in the ReqPro database.
445
      /// in the ReqPro database.
253
      /// The method is almost identical to the parseRootPackage method, except that 
446
      /// The method is almost identical to the parseRootPackage method, except that 
254
      /// this deals with a ReqPro40.Package object, whereas the latter deals with a
447
      /// this deals with a ReqPro40.Package object, whereas the latter deals with a
Line 256... Line 449...
256
      /// one if we move to .NET 2 where c# has some support for generic (template)
449
      /// one if we move to .NET 2 where c# has some support for generic (template)
257
      /// programming.      
450
      /// programming.      
258
      /// </summary>
451
      /// </summary>
259
      /// <param name="repository"></param>
452
      /// <param name="repository"></param>
260
      /// <param name="rq_project"></param>
453
      /// <param name="rq_project"></param>
261
      /// <param name="thisPackage"></param>
454
      /// <param name="thisPackage"></param>
262
      private void parsePackage(int level,
455
      private void parsePackage(int level,
263
                                EA.Repository ea_repository, 
456
                                string prefix,
264
                                ReqPro40.Project rq_project, 
457
                                ReqPro40.Project rq_project, 
265
                                ReqPro40.Package thisPackage)
458
                                ReqPro40.Package thisPackage)
266
      {
459
      {
-
 
460
         if (Main.mustAbort)
-
 
461
            return;
-
 
462
 
-
 
463
         Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, prefix + thisPackage.Name, -1);
-
 
464
 
267
         // call user defined functions
465
         // call user defined functions
268
         processPackage(level, ea_repository, rq_project, thisPackage);
466
         processPackage(level, rq_project, thisPackage);
269
         processObject(level, ea_repository, rq_project, thisPackage, null);
467
         processObject(level, rq_project, thisPackage, null);
270
 
468
 
271
         // Scan through the sub-packages of this package
469
         // Scan through the sub-packages of this package
272
         int limit_packageCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Package);
470
         int limit_packageCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Package);
273
         if (limit_packageCount > 0)
471
         if (limit_packageCount > 0)
274
         {
472
         {
275
            int i_packageCount;
473
            int i_packageCount;
276
            thisPackage.MoveFirst();
474
            thisPackage.MoveFirst();
277
            for (i_packageCount = 0; i_packageCount < limit_packageCount; i_packageCount++)
475
            for (i_packageCount = 0; i_packageCount < limit_packageCount; i_packageCount++)
278
            {
476
            {
-
 
477
               if (Main.mustAbort)
-
 
478
                  break;
-
 
479
 
279
               // Read the sub-package and parse it
480
               // Read the sub-package and parse it
280
               ReqPro40.Package subPackage = (ReqPro40.Package)thisPackage.GetCurrentElement();
481
               ReqPro40.Package subPackage = (ReqPro40.Package)thisPackage.GetCurrentElement();
281
               parsePackage(level+1, ea_repository, rq_project, subPackage);
482
               parsePackage(level+1, prefix + "    ", rq_project, subPackage);
282
               thisPackage.MoveNext();
483
               thisPackage.MoveNext();
283
            }
484
            }
284
         }
485
         }
-
 
486
 
-
 
487
         if (Main.mustAbort)
-
 
488
            return;
285
 
489
 
286
         // Scan through the requirements directly beneath this package
490
         // Scan through the requirements directly beneath this package
287
         int limit_reqCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Requirement);
491
         int limit_reqCount = thisPackage.get_Count(ReqPro40.enumElementTypes.eElemType_Requirement);
288
         if (limit_reqCount > 0)
492
         if (limit_reqCount > 0)
289
         {
493
         {
290
            // Obtain the requirement element key list from this package and scan through each entry
494
            // Obtain the requirement element key list from this package and scan through each entry
291
            int i_reqCount;
495
            int i_reqCount;
292
            System.Object[,] keyList = (System.Object[,])thisPackage.KeyList(ReqPro40.enumElementTypes.eElemType_Requirement);
496
            System.Object[,] keyList = (System.Object[,])thisPackage.KeyList(ReqPro40.enumElementTypes.eElemType_Requirement);
293
            for (i_reqCount = 0; i_reqCount < limit_reqCount; i_reqCount++)
497
            for (i_reqCount = 0; i_reqCount < limit_reqCount; i_reqCount++)
294
            {
498
            {
-
 
499
               if (Main.mustAbort)
-
 
500
                  break;
-
 
501
 
295
               // Obtain the ReqPro requirement from its key, and parse it
502
               // Obtain the ReqPro requirement from its key, and parse it
296
               ReqPro40.Requirement thisRequirement = 
503
               ReqPro40.Requirement thisRequirement = 
297
                  rq_project.GetRequirement(keyList[0,i_reqCount],
504
                  rq_project.GetRequirement(keyList[0,i_reqCount],
298
                                            ReqPro40.enumRequirementLookups.eReqLookup_Key,
505
                                            ReqPro40.enumRequirementLookups.eReqLookup_Key,
299
                                            ReqPro40.enumRequirementsWeights.eReqWeight_Heavy,
506
                                            ReqPro40.enumRequirementsWeights.eReqWeight_Heavy,
300
                                            ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
507
                                            ReqPro40.enumRequirementFlags.eReqFlag_RetainHierarchy);
301
               if (thisRequirement != null)
508
               if (thisRequirement != null)
302
               {
509
               {
303
                  parseRequirement(level+1, ea_repository, rq_project, thisPackage, thisRequirement);                  
510
                  parseRequirement(level+1, rq_project, thisPackage, thisRequirement);                  
304
               }
511
               }
305
            }
512
            }
306
         }
513
         }
307
      }
514
      }
308
 
515
 
309
 
516
 
310
 
517
 
311
      /// <summary>
518
      /// <summary>
312
      /// This method parses a requirement and any sub-requirements found in the 
519
      /// This method parses a requirement and any sub-requirements found in the 
313
      /// ReqPro database by the package/root package parsers.
520
      /// ReqPro database by the package/root package parsers.
314
      /// NOTE that when called from the parseRootPackage method, the thisPackage
521
      /// NOTE that when called from the parseRootPackage method, the thisPackage
315
      /// parameter will be null.
522
      /// parameter will be null.
316
      /// </summary>
523
      /// </summary>
317
      /// <param name="repository"></param>
524
      /// <param name="repository"></param>
318
      /// <param name="rq_project"></param>
525
      /// <param name="rq_project"></param>
319
      /// <param name="thisPackage"></param>
526
      /// <param name="thisPackage"></param>
320
      /// <param name="thisRequirement"></param>
527
      /// <param name="thisRequirement"></param>
321
      private void parseRequirement(int level,
528
      private void parseRequirement(int level,
322
                                    EA.Repository ea_repository, 
-
 
323
                                    ReqPro40.Project rq_project, 
529
                                    ReqPro40.Project rq_project, 
324
                                    ReqPro40.Package thisPackage, 
530
                                    ReqPro40.Package thisPackage, 
325
                                    ReqPro40.Requirement thisRequirement)
531
                                    ReqPro40.Requirement thisRequirement)
326
      {
532
      {
-
 
533
         if (Main.mustAbort)
-
 
534
            return;
-
 
535
 
327
         // call user defined functions
536
         // call user defined functions
328
         processRequirement(level, ea_repository, rq_project, thisPackage, thisRequirement);
537
         processRequirement(level, rq_project, thisPackage, thisRequirement);
329
         processObject(level, ea_repository, rq_project, thisPackage, thisRequirement);
538
         processObject(level, rq_project, thisPackage, thisRequirement);
330
 
539
 
331
         // requirements can have children that are requirements, so we have to find those
540
         // requirements can have children that are requirements, so we have to find those
332
         int limit_numberOfChildren = 0;
541
         int limit_numberOfChildren = 0;
333
         if (true == thisRequirement.get_HasChildren(ref limit_numberOfChildren))
542
         if (true == thisRequirement.get_HasChildren(ref limit_numberOfChildren))
334
         {
543
         {
335
            // scan through the child relationships
544
            // scan through the child relationships
336
            ReqPro40.Relationships theseRelationships = (ReqPro40.Relationships)thisRequirement.Children;
545
            ReqPro40.Relationships theseRelationships = (ReqPro40.Relationships)thisRequirement.Children;
337
 
546
 
338
            int i_numberOfChildren;
547
            int i_numberOfChildren;
339
            theseRelationships.MoveFirst();
548
            theseRelationships.MoveFirst();
340
            for (i_numberOfChildren = 0; i_numberOfChildren < limit_numberOfChildren; i_numberOfChildren++)
549
            for (i_numberOfChildren = 0; i_numberOfChildren < limit_numberOfChildren; i_numberOfChildren++)
341
            {
550
            {
-
 
551
               if (Main.mustAbort)
-
 
552
                  break;
-
 
553
 
342
               // Obtain the sub-requirement from the relationship, and parse it
554
               // Obtain the sub-requirement from the relationship, and parse it
343
               ReqPro40.Relationship thisRelationship = theseRelationships.GetCurrentRelationship();
555
               ReqPro40.Relationship thisRelationship = theseRelationships.GetCurrentRelationship();
344
 
556
 
345
               ReqPro40.Requirement subRequirement = 
557
               ReqPro40.Requirement subRequirement = 
346
                  thisRelationship.get_DestinationRequirement(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
558
                  thisRelationship.get_DestinationRequirement(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
347
 
559
 
348
               if (subRequirement != null)
560
               if (subRequirement != null)
349
               {
561
               {
350
                  parseRequirement(level+1, ea_repository, rq_project, thisPackage, subRequirement);
562
                  parseRequirement(level+1, rq_project, thisPackage, subRequirement);
351
               }
563
               }
352
 
564
 
353
               theseRelationships.MoveNext();
565
               theseRelationships.MoveNext();
354
            }
566
            }
355
         }
567
         }
356
      }
568
      }
357
 
569
 
358
	}
570
	}
-
 
571
 
359
}
572
}