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.Collections.Specialized;
5
using System.Collections.Specialized;
6
using System.Windows.Forms;
6
using System.Windows.Forms;
7
using ReqPro40;
7
using ReqPro40;
8
 
8
 
9
namespace EA_ReqPro
9
namespace EA_ReqPro
10
{
10
{
11
	/// <summary>
11
	/// <summary>
Line 32... Line 32...
32
      protected int lastLevel;                    // Allows us to determine if we have gone down/up in the hierarchy
32
      protected int lastLevel;                    // Allows us to determine if we have gone down/up in the hierarchy
33
 
33
 
34
      // Collector for the results of the parsing
34
      // Collector for the results of the parsing
35
      protected ReqPro_object rq_root_package;
35
      protected ReqPro_object rq_root_package;
36
 
36
 
37
      protected ArrayList rq_req_types;
-
 
38
      protected ArrayList rq_req_status_types;
37
      private int writeTracesModulo = 100;
39
 
-
 
40
 
38
 
41
      /// <summary>
39
      /// <summary>
42
      /// Constructor logic
40
      /// Constructor logic
43
      /// </summary>
41
      /// </summary>
44
      /// <param name="ea_repository"></param>
42
      /// <param name="ea_repository"></param>
45
		public CopyReqProDatabaseToMemory(EA.Repository ea_repository): base()
43
		public CopyReqProDatabaseToMemory(): base()
46
		{
44
		{
47
         try
45
         try
48
         {
46
         {
49
            // create an EA_Utilities object
47
            // create an EA_Utilities object
50
            EA_Utils = new EA_Utilities(ea_repository);
48
            EA_Utils = new EA_Utilities();
51
 
49
 
52
            // figure out where in the EA database we will place the results of parsing
50
            // figure out where in the EA database we will place the results of parsing
53
            object o;
51
            object o;
54
            EA.ObjectType type;
52
            EA.ObjectType type;
55
            type = ea_repository.GetTreeSelectedItem(out o);
53
            type = Main.EA_Repository.GetTreeSelectedItem(out o);
56
            if (type == EA.ObjectType.otElement)
54
            if (type == EA.ObjectType.otElement)
57
            {
55
            {
58
               ea_rootPackage = ea_repository.GetPackageByID( ((EA.Element)o).PackageID );
56
               ea_rootPackage = Main.EA_Repository.GetPackageByID( ((EA.Element)o).PackageID );
59
            }
57
            }
60
            else if (type == EA.ObjectType.otPackage)
58
            else if (type == EA.ObjectType.otPackage)
61
            {
59
            {
62
               ea_rootPackage = (EA.Package)o;
60
               ea_rootPackage = (EA.Package)o;
63
            }
61
            }
64
            else
62
            else
65
            {
63
            {
66
               Exception e = new Exception("No Root Package given");
64
               Exception e = new Exception("No Root Package given");
67
               throw e;
65
               throw e;
68
            }
66
            }
69
         }
67
         }
70
         catch (Exception ex)
68
         catch (Exception ex)
71
         {
69
         {
72
            MessageBox.Show(ex.Message, "Error (CopyReqProDatabaseToMemory::CopyReqProDatabaseToMemory)", MessageBoxButtons.OK);
70
            MessageBoxEx.Show(ex.Message, "Error (CopyReqProDatabaseToMemory)", MessageBoxButtons.OK);
73
         }    
71
         }    
74
		}
72
		}
75
 
73
 
76
 
74
 
77
 
-
 
78
      #region Requirement Status Type methods
-
 
79
 
-
 
80
      /// <summary>
-
 
81
      /// Get the requirement status types from the ReqPro database, into a simple list, where each element
-
 
82
      /// describes the requirement status type and whether it is filtered or not. This list can be given to 
-
 
83
      /// the ReqProFilterForm to capture the users requirement status type filtering decisions. 
-
 
84
      /// </summary>
-
 
85
      private void get_rq_req_status_types_from_database()
-
 
86
      {
-
 
87
         StringCollection status_values = new StringCollection();
-
 
88
 
-
 
89
         // Each requirement type can have its own unique list of status attribute values
-
 
90
         // so we have to go through each requirement type and find the set of status values
-
 
91
         // that each one has and add them to out string collection, if the collection does
-
 
92
         // not already have the strings ofcoarse. So, we are merging together all the status
-
 
93
         // values in the ReqPro database, into one set.
-
 
94
         ReqPro40.ReqTypes rqtypes = RQ_project.ReqTypes;
-
 
95
         foreach (ReqPro40.ReqType rq_type in rqtypes)
-
 
96
         {
-
 
97
            ReqPro40.Attr attr = rq_type.get_Attr("Status", ReqPro40.enumAttrLookups.eAttrLookups_Label);
-
 
98
            foreach (ReqPro40.ListItem listItem in attr.ListItems)
-
 
99
            {
-
 
100
               if (!status_values.Contains(listItem.Text))
-
 
101
               {
-
 
102
                  status_values.Add(listItem.Text);
-
 
103
               }
-
 
104
            }
-
 
105
         }
-
 
106
 
-
 
107
         // With our merged set of status values, create a list of ReqPro_ReqStatus objects.
-
 
108
         rq_req_status_types = new ArrayList();
-
 
109
         foreach (string s in status_values)
-
 
110
         {
-
 
111
            ReqPro_ReqStatus new_ReqPro_ReqStatus = new ReqPro_ReqStatus();
-
 
112
            new_ReqPro_ReqStatus.filtered = false;
-
 
113
            new_ReqPro_ReqStatus.status_value = s;
-
 
114
            rq_req_status_types.Add(new_ReqPro_ReqStatus);
-
 
115
         }
-
 
116
      }
-
 
117
 
-
 
118
      /// <summary>
-
 
119
      /// Examine the requirement status type list to see if the requirement status type of 
-
 
120
      /// the specified object has been filtered or not.
-
 
121
      /// </summary>
-
 
122
      /// <param name="rq_obj"></param>
-
 
123
      /// <returns></returns>
-
 
124
      protected bool reqStatusTypeIsFiltered(ReqPro_object rq_obj)
-
 
125
      {
-
 
126
         foreach (ReqPro_ReqStatus rqs in rq_req_status_types)
-
 
127
         {
-
 
128
            if (0 == rqs.status_value.CompareTo(rq_obj.status))
-
 
129
            {
-
 
130
               return rqs.filtered;
-
 
131
            }
-
 
132
         }
-
 
133
         return false;
-
 
134
      }
-
 
135
 
-
 
136
      #endregion
-
 
137
 
75
 
138
      #region Requirement Type methods
76
      #region Requirement Type methods
139
      /// <summary>
77
      /// <summary>
140
      /// Recursively set the requirement type enum in each requirement object read
78
      /// Recursively set the requirement type enum in each requirement object read
141
      /// from the ReqPro database. The enum give fast indication of the requirement type.
79
      /// from the ReqPro database. The enum give fast indication of the requirement type.
142
      /// If we didnt do this, each time the requirement type needs to be evaluated, a string 
80
      /// If we didnt do this, each time the requirement type needs to be evaluated, a string 
143
      /// compare needs to be done. Here, we do them all up-front so that down the track a simple
81
      /// compare needs to be done. Here, we do them all up-front so that down the track a simple
144
      /// integer access is all that is required.
82
      /// integer access is all that is required.
145
      /// </summary>
83
      /// </summary>
146
      /// <param name="rq_obj"></param>
84
      /// <param name="rq_obj"></param>
147
      private void set_rq_req_types_in_copied_data( ReqPro_object rq_obj )
85
      private void set_rq_req_types_in_copied_data( ReqPro_object rq_obj )
148
         {
86
         {
149
            if (rq_obj.isRequirement)
87
            if (rq_obj.isRequirement)
150
            {
88
            {
151
               int i = 0;
89
               int i = 0;
152
               foreach (ReqPro_ReqType req_type in rq_req_types)
90
               foreach (ReqPro_ReqType req_type in rq_req_types)
153
               {
91
               {
154
                  if (rq_obj.tag.StartsWith(req_type.prefix))
92
                  if (rq_obj.tag.StartsWith(req_type.prefix))
155
                  {
93
                  {
156
                     rq_obj.tag_enum = i;
94
                     rq_obj.tag_enum = i;
157
                  }
95
                  }
158
                  i++;
96
                  i++;
159
               }
97
               }
160
            }
98
            }
161
 
99
 
162
            foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
100
            foreach( ReqPro_object sub_obj in rq_obj.ReqPro_objects )
163
            {
101
            {
164
               // recurse
102
               // recurse
165
               set_rq_req_types_in_copied_data(sub_obj);
103
               set_rq_req_types_in_copied_data(sub_obj);
166
            }
104
            }
167
         }
105
         }
168
 
-
 
169
      /// <summary>
-
 
170
      /// Get the requirement types from the ReqPro database, into a simple list, where each element
-
 
171
      /// describes the requirement type and whether it is filtered or not. This list can be given to 
-
 
172
      /// the ReqProFilterForm to capture the users requirement type filtering decisions. 
-
 
173
      /// </summary>
-
 
174
      private void get_rq_req_types_from_database()
-
 
175
      {
-
 
176
         rq_req_types = new ArrayList();
-
 
177
 
-
 
178
         ReqPro40.ReqTypes rqtypes = RQ_project.ReqTypes;
-
 
179
         foreach (ReqPro40.ReqType rq_type in rqtypes)
-
 
180
         {
-
 
181
            ReqPro_ReqType new_req_type = new ReqPro_ReqType();
-
 
182
            new_req_type.name     = rq_type.Name;
-
 
183
            new_req_type.prefix   = rq_type.ReqPrefix;
-
 
184
            new_req_type.filtered = false;
-
 
185
            rq_req_types.Add(new_req_type);
-
 
186
         }
-
 
187
      }
-
 
188
 
106
 
189
      /// <summary>
-
 
190
      /// Examine the requirement type list to see if the requirement type of the specified object
-
 
191
      /// has been filtered or not.
-
 
192
      /// </summary>
-
 
193
      /// <param name="rq_obj"></param>
-
 
194
      /// <returns></returns>
-
 
195
      protected bool reqTypeIsFiltered(ReqPro_object rq_obj)
-
 
196
      {
-
 
197
         return ((ReqPro_ReqType)rq_req_types[rq_obj.tag_enum]).filtered;
-
 
198
      }
-
 
199
 
107
 
200
      #endregion
108
      #endregion
201
 
109
 
202
      #region ReqProParser (base class) overrides
110
      #region ReqProParser (base class) overrides
203
      /// <summary>
111
      /// <summary>
204
      /// This method is designed to prompt the user to select the ReqPro database file
112
      /// This method is designed to prompt the user to select the ReqPro database file
205
      /// before opening and parsing it. Once parsed, the user is offered a chance to setup
113
      /// before opening and parsing it. Once parsed, the user is offered a chance to setup
206
      /// the filter controls.
114
      /// the filter controls.
207
      /// </summary>
115
      /// </summary>
208
      /// <param name="ea_repository"></param>
116
      /// <param name="ea_repository"></param>
209
      /// <returns></returns>
117
      /// <returns></returns>
210
      public override bool prompt_and_parse(EA.Repository ea_repository, ReqProDB_Artifact.MODE mode)
118
      public override bool prompt_and_parse(ReqProDB_Artifact.MODE mode)
211
      {
119
      {
212
         try
120
         try
213
         {
121
         {
214
 
122
 
215
            pre_parsing();
123
            pre_parsing();
216
            if (true == base.prompt_and_parse(ea_repository, mode))
124
            if (true == base.prompt_and_parse(mode))
217
            {
125
            {
218
               // obtain the requirement types from the reqpro database (need these for
126
               // make sure all imported requirements have the correct requirement type enumeration
219
               // the filter dialog)
127
               // (converted from the string name of the tag)
220
               get_rq_req_types_from_database();
-
 
221
               set_rq_req_types_in_copied_data(rq_root_package);
128
               set_rq_req_types_in_copied_data(rq_root_package);
222
 
-
 
223
               get_rq_req_status_types_from_database();
-
 
224
 
129
 
225
               // bring up the filter dialog to allow user to specify exactly what gets copied
130
               // bring up the filter dialog to allow user to specify exactly what gets copied
226
               ReqProFilterForm rq_filter = new ReqProFilterForm(mode == ReqProDB_Artifact.MODE.TRACEABILITY);
131
               ReqProFilterForm rq_filter = new ReqProFilterForm(mode == ReqProDB_Artifact.MODE.TRACEABILITY);
227
               rq_filter.populate(rq_root_package, rq_req_types, rq_req_status_types);
132
               rq_filter.populate(rq_root_package, rq_req_types, rq_req_status_types);
228
 
133
 
229
               // Setup the filter based on the saved filter settings in the ReqProDB element (if any)
134
               // Setup the filter based on the saved filter settings in the ReqProDB element (if any)
230
               if (RQ_Element != null)
135
               if (RQ_Element != null)
231
               {
136
               {
232
                  rq_filter.loadFilterSettings(RQ_Element.Notes);
137
                  rq_filter.loadFilterSettings(RQ_Element.Notes);
233
               }
138
               }
234
 
139
 
235
               DialogResult dlgRes = rq_filter.ShowDialog();
140
               DialogResult dlgRes = rq_filter.ShowDialog();
236
               if (dlgRes == DialogResult.OK)
141
               if (dlgRes == DialogResult.OK)
237
               {
142
               {
238
                  allowPackageStructureFragments = rq_filter.allowPackageStructureFragments;
143
                  allowPackageStructureFragments = rq_filter.allowPackageStructureFragments;
239
                  RQ_project.CloseProject();
144
                  RQ_project.CloseProject();
240
 
145
 
241
                  // Save filter settings to the ReqProDB element if it is available
146
                  // Save filter settings to the ReqProDB element if it is available
242
                  if (RQ_Element != null)
147
                  if (RQ_Element != null)
243
                  {
148
                  {
244
                     RQ_Element.Notes = rq_filter.saveFilterSettings();
149
                     RQ_Element.Notes = rq_filter.saveFilterSettings();
245
                     RQ_Element.Update();
150
                     RQ_Element.Update();
246
                  }
151
                  }
247
 
152
 
248
                  return true;
153
                  return true;
249
               }
154
               }
250
               RQ_project.CloseProject();
155
               RQ_project.CloseProject();
251
            }
156
            }
252
         }
157
         }
253
         catch (Exception ex)
158
         catch (Exception ex)
254
         {
159
         {
255
            MessageBox.Show(ex.Message, "Error (CopyReqProDatabaseToMemory::parse)", MessageBoxButtons.OK);
160
            MessageBoxEx.Show(ex.Message, "Error (parse)", MessageBoxButtons.OK);
256
         }      
161
         }      
257
         return false;
162
         return false;
258
      }
163
      }
259
 
164
 
260
 
165
 
261
 
166
 
262
      /// <summary>
167
      /// <summary>
263
      /// This method will be called by the base class parser when it has obtained a ReqPro
168
      /// This method will be called by the base class parser when it has obtained a ReqPro
264
      /// project object. We capture that object here so we can interrogate the ReqPro database
169
      /// project object. We capture that object here so we can interrogate the ReqPro database
265
      /// ourselves, if we need to. We wont do that for package/requirement reading, but we may
170
      /// ourselves, if we need to. We wont do that for package/requirement reading, but we may
266
      /// do it for meta-data such as requirement types, etc.
171
      /// do it for meta-data such as requirement types, etc.
267
      /// </summary>
172
      /// </summary>
268
      /// <param name="reqpro_project"></param>
173
      /// <param name="reqpro_project"></param>
269
      protected override void provideReqProDatabaseInfo(ReqPro40.Application rq_app, 
174
      protected override void provideReqProDatabaseInfo(ReqPro40.Application rq_app, 
270
         ReqPro40.Project rq_project, 
175
         ReqPro40.Project rq_project, 
271
         ReqProDB_Artifact rq_artifact,
176
         ReqProDB_Artifact rq_artifact,
272
         EA.Element rq_element)
177
         EA.Element rq_element)
273
      {
178
      {
274
         RQ_app = rq_app;
179
         RQ_app = rq_app;
275
         RQ_project = rq_project;
180
         RQ_project = rq_project;
276
         RQ_Artifact = rq_artifact;
181
         RQ_Artifact = rq_artifact;
277
         RQ_Element = rq_element;
182
         RQ_Element = rq_element;
278
      }
183
      }
279
 
184
 
280
      /// <summary>
185
      /// <summary>
281
      /// This method will be called by the base class parser whenever a package or requirement object
186
      /// This method will be called by the base class parser whenever a package or requirement object
282
      /// is found in the ReqPro database. The method collects important information from the object 
187
      /// is found in the ReqPro database. The method collects important information from the object 
283
      /// into a structure that begins with the ea_rootPackage object. The structure is highly dynamic
188
      /// into a structure that begins with the ea_rootPackage object. The structure is highly dynamic
284
      /// with each object able to hold a list of other objects. This naturally allows for the ReqPro
189
      /// with each object able to hold a list of other objects. This naturally allows for the ReqPro
Line 289... Line 194...
289
      /// </summary>
194
      /// </summary>
290
      /// <param name="level"></param>
195
      /// <param name="level"></param>
291
      /// <param name="ea_repository"></param>
196
      /// <param name="ea_repository"></param>
292
      /// <param name="rq_project"></param>
197
      /// <param name="rq_project"></param>
293
      /// <param name="rq_package"></param>
198
      /// <param name="rq_package"></param>
294
      /// <param name="rq_requirement"></param>
199
      /// <param name="rq_requirement"></param>
295
      protected override void processObject(int level,
200
      protected override void processObject(int level,
296
                                            EA.Repository ea_repository, 
-
 
297
                                            ReqPro40.Project rq_project, 
201
                                            ReqPro40.Project rq_project, 
298
                                            ReqPro40.Package rq_package,
202
                                            ReqPro40.Package rq_package,
299
                                            ReqPro40.Requirement rq_requirement)
203
                                            ReqPro40.Requirement rq_requirement)
300
      {
204
      {
301
         // If we are still at the same level as the previous package, then pop the previous object 
205
         // If we are still at the same level as the previous package, then pop the previous object 
302
         // in readiness for pushing the one we are now dealing with.
206
         // in readiness for pushing the one we are now dealing with.
303
         if (level == lastLevel)
207
         if (level == lastLevel)
304
         {
208
         {
305
            rq_objs.Pop();
209
            rq_objs.Pop();
306
            ea_treePos.Pop();
210
            ea_treePos.Pop();
307
         }
211
         }
308
            // but if we are beneath the previous level, pop all objects that are above us because
212
            // but if we are beneath the previous level, pop all objects that are above us because
309
            // we no longer need them in our hierarchy reference data.
213
            // we no longer need them in our hierarchy reference data.
310
         else if (level < lastLevel)
214
         else if (level < lastLevel)
311
         {
215
         {
312
            while (lastLevel >= level)
216
            while (lastLevel >= level)
313
            {
217
            {
314
               rq_objs.Pop();
218
               rq_objs.Pop();
315
               ea_treePos.Pop();
219
               ea_treePos.Pop();
316
               lastLevel--;
220
               lastLevel--;
317
            }
221
            }
318
         }
222
         }
319
 
223
 
320
         // bump the tree position at this level (controls display position in the EA project browser)
224
         // bump the tree position at this level (controls display position in the EA project browser)
321
         int treePos = (int)ea_treePos.Pop();
225
         int treePos = (int)ea_treePos.Pop();
322
         treePos++;
226
         treePos++;
323
         ea_treePos.Push(treePos);
227
         ea_treePos.Push(treePos);
324
 
228
 
325
         // create the new requirement or package
229
         // create the new requirement or package
326
         ReqPro_object new_rq_obj = new ReqPro_object();
230
         ReqPro_object new_rq_obj = new ReqPro_object();
327
         if (rq_requirement != null)
231
         if (rq_requirement != null)
328
         {
232
         {
329
            new_rq_obj.isRequirement = true;
233
            new_rq_obj.isRequirement = true;
330
            new_rq_obj.name   = rq_requirement.Name;
234
            new_rq_obj.name   = rq_requirement.Name;
331
            new_rq_obj.text   = rq_requirement.Text;
235
            new_rq_obj.text   = rq_requirement.Text;
332
            new_rq_obj.guid   = rq_requirement.GUID;
236
            new_rq_obj.guid   = rq_requirement.GUID;
333
            new_rq_obj.tag    = rq_requirement.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
237
            new_rq_obj.tag    = rq_requirement.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
334
 
238
 
-
 
239
            bool hasStatus = false;
-
 
240
            bool hasDifficulty = false;
-
 
241
            bool hasPriority = false;
-
 
242
            if (reqTypeHasOneOrMoreAttrs(new_rq_obj, ref hasStatus, ref hasDifficulty, ref hasPriority))
-
 
243
            {
-
 
244
               if (hasStatus)
-
 
245
               {
335
            new_rq_obj.status     = rq_requirement.AttrValues["Status", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
246
                  new_rq_obj.status = rq_requirement.AttrValues["Status", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
-
 
247
               }
-
 
248
               if (hasDifficulty)
-
 
249
               {
336
            new_rq_obj.difficulty = rq_requirement.AttrValues["Difficulty", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
250
                  new_rq_obj.difficulty = rq_requirement.AttrValues["Difficulty", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
-
 
251
               }
-
 
252
               if (hasPriority)
-
 
253
               {
337
            new_rq_obj.priority   = rq_requirement.AttrValues["Priority", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
254
                  new_rq_obj.priority = rq_requirement.AttrValues["Priority", ReqPro40.enumAttrValueLookups.eAttrValueLookup_Label].Text;
-
 
255
               }
-
 
256
            }
-
 
257
 
338
            new_rq_obj.version    = rq_requirement.VersionNumber;
258
            new_rq_obj.version    = rq_requirement.VersionNumber;
339
            new_rq_obj.versionDateTime = rq_requirement.VersionDateTime;
259
            new_rq_obj.versionDateTime = rq_requirement.VersionDateTime;
340
 
260
 
341
 
261
 
342
            // requirements can trace to other requirements, so we have to find those in order to re-construct
262
            // requirements can trace to other requirements, so we have to find those in order to re-construct
343
            // that traceability later on. Currently, we only process TracesTo relationships from ReqPro.
263
            // that traceability later on. Currently, we only process TracesTo relationships from ReqPro.
344
            int limit_numberOfTracesTo = 0;
264
            int limit_numberOfTracesTo = 0;
345
            if (true == rq_requirement.get_HasTracesTo(ref limit_numberOfTracesTo))
265
            if (true == rq_requirement.get_HasTracesTo(ref limit_numberOfTracesTo))
346
            {
266
            {
347
               // scan through the TracesTo relationships
267
               // scan through the TracesTo relationships
348
               ReqPro40.Relationships theseRelationships = (ReqPro40.Relationships)rq_requirement.TracesTo;
268
               ReqPro40.Relationships theseRelationships = (ReqPro40.Relationships)rq_requirement.TracesTo;
349
 
269
 
350
               int i_numberOfTracesTo;
270
               int i_numberOfTracesTo;
351
               theseRelationships.MoveFirst();
271
               theseRelationships.MoveFirst();
352
               for (i_numberOfTracesTo = 0; i_numberOfTracesTo < limit_numberOfTracesTo; i_numberOfTracesTo++)
272
               for (i_numberOfTracesTo = 0; i_numberOfTracesTo < limit_numberOfTracesTo; i_numberOfTracesTo++)
353
               {
273
               {
354
                  // Obtain the traced-to requirement from the relationship, and parse it
274
                  // Obtain the traced-to requirement from the relationship, and parse it
355
                  ReqPro40.Relationship thisRelationship = theseRelationships.GetCurrentRelationship();
275
                  ReqPro40.Relationship thisRelationship = theseRelationships.GetCurrentRelationship();
356
 
276
 
357
                  ReqPro40.Requirement tracedToRequirement = 
277
                  ReqPro40.Requirement tracedToRequirement = 
358
                     thisRelationship.get_DestinationRequirement(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
278
                     thisRelationship.get_DestinationRequirement(ReqPro40.enumRequirementsWeights.eReqWeight_Heavy);
359
 
279
 
360
                  if (tracedToRequirement != null)
280
                  if (tracedToRequirement != null)
361
                  {
281
                  {
362
                     // Add the GUID of the traced-to requirement to the relevant list within the
282
                     // Add the GUID of the traced-to requirement to the relevant list within the
363
                     // object representing the traced-from requirement (ie. parent requirement).
283
                     // object representing the traced-from requirement (ie. parent requirement).
364
                     new_rq_obj.ReqPro_traces.Add(tracedToRequirement.GUID);
284
                     new_rq_obj.ReqPro_traces.Add(tracedToRequirement.GUID);
365
                  }
285
                  }
366
 
286
 
367
                  theseRelationships.MoveNext();
287
                  theseRelationships.MoveNext();
368
               }
288
               }
369
            }
289
            }
370
 
290
 
371
         }
291
         }
372
         else if (rq_package != null)
292
         else if (rq_package != null)
373
         {
293
         {
374
            new_rq_obj.isPackage = true;
294
            new_rq_obj.isPackage = true;
375
 
295
 
376
            // Packages in ReqPro may be prefixed by a number to force ReqPro's alphanumeric sorting
296
            // Packages in ReqPro may be prefixed by a number to force ReqPro's alphanumeric sorting
377
            // algorithm to order the packages in the way the user wants, as dictated by the actual 
297
            // algorithm to order the packages in the way the user wants, as dictated by the actual 
378
            // numbers used. EA does not have this problem because it uses a tree position number to
298
            // numbers used. EA does not have this problem because it uses a tree position number to
379
            // control a package/element's position in the project browser. So, strip off any leading
299
            // control a package/element's position in the project browser. So, strip off any leading
380
            // numeric from the ReqPro packages.
300
            // numeric from the ReqPro packages.
381
            string trimstring = " 0123456789";
301
            string trimstring = " 0123456789";
382
            char[] trimmer = trimstring.ToCharArray();
302
            char[] trimmer = trimstring.ToCharArray();
383
            string filtered_name = rq_package.Name.TrimStart(trimmer);
303
            string filtered_name = rq_package.Name.TrimStart(trimmer);
384
 
304
 
385
            new_rq_obj.name = filtered_name;
305
            new_rq_obj.name = filtered_name;
386
            new_rq_obj.guid = rq_package.GUID;
306
            new_rq_obj.guid = rq_package.GUID;
387
         }
307
         }
388
 
308
 
389
         new_rq_obj.level = level;
309
         new_rq_obj.level = level;
390
         new_rq_obj.treePos = treePos;
310
         new_rq_obj.treePos = treePos;
391
 
311
 
392
         // attach it to its parent object
312
         // attach it to its parent object
393
         ReqPro_object parent_rq_obj = (ReqPro_object)rq_objs.Peek();
313
         ReqPro_object parent_rq_obj = (ReqPro_object)rq_objs.Peek();
394
         parent_rq_obj.ReqPro_objects.Add( new_rq_obj );
314
         parent_rq_obj.ReqPro_objects.Add( new_rq_obj );
395
         new_rq_obj.parent = parent_rq_obj;
315
         new_rq_obj.parent = parent_rq_obj;
396
 
316
 
397
         // keep a count of the number of requirements the object has beneath it
317
         // keep a count of the number of requirements the object has beneath it
398
         if (true == new_rq_obj.isRequirement)
318
         if (true == new_rq_obj.isRequirement)
399
            parent_rq_obj.numberOfRequirements++;
319
            parent_rq_obj.numberOfRequirements++;
400
 
320
 
401
         // push the new object onto the stack, ready for any sub-objects that may belong to it.
321
         // push the new object onto the stack, ready for any sub-objects that may belong to it.
402
         // If, the next time we enter this method, the level is the same, this will get popped off.
322
         // If, the next time we enter this method, the level is the same, this will get popped off.
403
         // If, the next time we enter this method, the level is lower, this and possibly more will
323
         // If, the next time we enter this method, the level is lower, this and possibly more will
404
         // get popped off.
324
         // get popped off.
405
         rq_objs.Push(new_rq_obj);
325
         rq_objs.Push(new_rq_obj);
406
         ea_treePos.Push(0);
326
         ea_treePos.Push(0);
407
 
327
 
408
         // capture what the hierarchy level is for the object just processed.
328
         // capture what the hierarchy level is for the object just processed.
409
         lastLevel = level;
329
         lastLevel = level;
410
      }
330
      }
411
      
331
      
412
      #endregion
332
      #endregion
413
 
333
 
414
 
334
 
415
      /// <summary>
335
      /// <summary>
416
      /// Finds and returns the ReqPro_object instance that contains the specified GUID. The
336
      /// Finds and returns the ReqPro_object instance that contains the specified GUID. The
417
      /// GUID is that of the originating ReqPro requirement, which is copied into a ReqPro_object
337
      /// GUID is that of the originating ReqPro requirement, which is copied into a ReqPro_object
418
      /// instance when it is created. This find operation supports the ability to resolve object to
338
      /// instance when it is created. This find operation supports the ability to resolve object to
419
      /// object trace relationships mirrored from the ReqPro database during the construction
339
      /// object trace relationships mirrored from the ReqPro database during the construction
420
      /// of the ReqPro_object hierarchy.
340
      /// of the ReqPro_object hierarchy.
421
      /// </summary>
341
      /// </summary>
422
      /// <param name="rq_obj"></param>
342
      /// <param name="rq_obj"></param>
423
      /// <param name="ReqProGUID"></param>
343
      /// <param name="ReqProGUID"></param>
424
      /// <returns></returns>
344
      /// <returns></returns>
425
      protected ReqPro_object findReqPro_object_byReqProGUID(ReqPro_object rq_obj, string ReqProGUID)
345
      protected ReqPro_object findReqPro_object_byReqProGUID(ReqPro_object rq_obj, string ReqProGUID)
426
      {
346
      {
427
         if (rq_obj.guid.CompareTo(ReqProGUID) == 0)
347
         if (rq_obj.guid.CompareTo(ReqProGUID) == 0)
428
         {
348
         {
429
            return rq_obj;
349
            return rq_obj;
430
         }
350
         }
431
 
351
 
432
         foreach (ReqPro_object sub_rq_obj in rq_obj.ReqPro_objects)
352
         foreach (ReqPro_object sub_rq_obj in rq_obj.ReqPro_objects)
433
         {
353
         {
434
            ReqPro_object tgt_obj = findReqPro_object_byReqProGUID(sub_rq_obj, ReqProGUID);
354
            ReqPro_object tgt_obj = findReqPro_object_byReqProGUID(sub_rq_obj, ReqProGUID);
435
            if (tgt_obj != null)
355
            if (tgt_obj != null)
436
               return tgt_obj;
356
               return tgt_obj;
437
         }
357
         }
438
 
358
 
439
         return null;
359
         return null;
-
 
360
      }
-
 
361
 
-
 
362
      protected int write_traces(int totalRequirements)
-
 
363
      {
-
 
364
         Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "Writing Trace Information", -1);
-
 
365
         int numberWritten = 0;
-
 
366
 
-
 
367
         // adjust modulo for logging purposes so that the number of output messages is restricted
-
 
368
         // for larger and larger numbers of requirements
-
 
369
         if (totalRequirements > 1000)
-
 
370
            writeTracesModulo = 100;
-
 
371
         else if (totalRequirements > 500)
-
 
372
            writeTracesModulo = 50;
-
 
373
         else if (totalRequirements > 100)
-
 
374
            writeTracesModulo = 20;
-
 
375
         else if (totalRequirements > 50)
-
 
376
            writeTracesModulo = 10;
-
 
377
         else if (totalRequirements > 20)
-
 
378
            writeTracesModulo = 5;
-
 
379
         else // 10 or less 
-
 
380
            writeTracesModulo = 1;
-
 
381
 
-
 
382
         foreach( ReqPro_object sub_obj in rq_root_package.ReqPro_objects )
-
 
383
         {
-
 
384
            if (Main.mustAbort)
-
 
385
               return numberWritten;
-
 
386
 
-
 
387
            numberWritten = write_traces(sub_obj, numberWritten, totalRequirements);
-
 
388
         }
-
 
389
 
-
 
390
         Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, "Traces Completed", -1);
-
 
391
 
-
 
392
         return numberWritten;
440
      }
393
      }
441
 
394
 
442
      /// <summary>
395
      /// <summary>
443
      /// This method examines all of the ReqPro_object trace relationships and mirrors them in 
396
      /// This method examines all of the ReqPro_object trace relationships and mirrors them in 
444
      /// the EA requirement elements that have been formed from each un-filtered ReqPro_objects.
397
      /// the EA requirement elements that have been formed from each un-filtered ReqPro_objects.
445
      /// </summary>
398
      /// </summary>
446
      /// <param name="ea_repository"></param>
399
      /// <param name="ea_repository"></param>
447
      /// <param name="rq_obj"></param>
400
      /// <param name="rq_obj"></param>
448
      protected void write_traces(EA.Repository ea_repository, ReqPro_object rq_obj)
401
      private int write_traces(ReqPro_object rq_obj, int numberWritten, int totalRequirements)
449
      {
402
      {
-
 
403
         if (Main.mustAbort)
-
 
404
            return numberWritten;
-
 
405
 
450
         if (rq_obj.isRequirement)
406
         if (rq_obj.isRequirement)
451
         {
407
         {
452
            // if this object had an EA element made for it during the write_ea_database() process...
408
            // if this object had an EA element made for it during the write_ea_database() process...
453
            if (rq_obj.ea_element_ID != -1)
409
            if (rq_obj.ea_element_ID != -1)
454
            {
410
            {
-
 
411
               numberWritten++;
-
 
412
               if ((numberWritten % writeTracesModulo) == 0)
-
 
413
               {
-
 
414
                  Main.EA_Repository.WriteOutput(Main.GUI_OUTPUT_TAB_NAME, string.Format("   {0} of {1}", numberWritten, totalRequirements), -1);
-
 
415
               }
-
 
416
 
455
               EA.Element ea_rq_obj = ea_repository.GetElementByID(rq_obj.ea_element_ID);
417
               EA.Element ea_rq_obj = Main.EA_Repository.GetElementByID(rq_obj.ea_element_ID);
456
               if (ea_rq_obj != null)
418
               if (ea_rq_obj != null)
457
               {
419
               {
458
                  foreach(string s in rq_obj.ReqPro_traces)
420
                  foreach(string s in rq_obj.ReqPro_traces)
459
                  {
421
                  {
460
                     ReqPro_object tgt_obj = findReqPro_object_byReqProGUID(rq_root_package,s);
422
                     ReqPro_object tgt_obj = findReqPro_object_byReqProGUID(rq_root_package,s);
461
                     if (tgt_obj != null)
423
                     if (tgt_obj != null)
462
                     {
424
                     {
463
                        if (tgt_obj.ea_element_ID != -1)
425
                        if (tgt_obj.ea_element_ID != -1)
464
                        {
426
                        {
465
                           EA.Element ea_tgt_obj = ea_repository.GetElementByID(tgt_obj.ea_element_ID);
427
                           EA.Element ea_tgt_obj = Main.EA_Repository.GetElementByID(tgt_obj.ea_element_ID);
466
                           if (ea_tgt_obj != null)
428
                           if (ea_tgt_obj != null)
467
                           {
429
                           {
468
                              add_connection(ea_repository, ea_rq_obj, ea_tgt_obj);
430
                              add_connection(ea_rq_obj, ea_tgt_obj);
469
                           }
431
                           }
470
                        }
432
                        }
471
                     }
433
                     }
472
                  }
434
                  }
473
               }
435
               }
Line 475... Line 437...
475
         }
437
         }
476
 
438
 
477
         // recurse to ensure we examine the entire hiearchy
439
         // recurse to ensure we examine the entire hiearchy
478
         foreach(ReqPro_object sub_obj in rq_obj.ReqPro_objects)
440
         foreach(ReqPro_object sub_obj in rq_obj.ReqPro_objects)
479
         {
441
         {
480
            write_traces(ea_repository, sub_obj);
442
            if (Main.mustAbort)
-
 
443
               break;
-
 
444
 
-
 
445
            numberWritten = write_traces(sub_obj, numberWritten, totalRequirements);
481
         }
446
         }
-
 
447
         return numberWritten;
482
      }
448
      }
483
 
449
 
484
      /// <summary>
450
      /// <summary>
485
      /// Adds a connection between one EA element and another
451
      /// Adds a connection between one EA element and another
486
      /// </summary>
452
      /// </summary>
487
      /// <param name="repository"></param>
453
      /// <param name="repository"></param>
488
      /// <param name="rq_artifact"></param>
454
      /// <param name="rq_artifact"></param>
489
      /// <param name="ea_req"></param>
455
      /// <param name="ea_req"></param>
490
      protected void add_connection(EA.Repository ea_repository, EA.Element src_element, EA.Element dest_element)
456
      protected void add_connection(EA.Element src_element, EA.Element dest_element)
491
      {
457
      {
492
         // Add the new requirement to the src_element
458
         // Add the new requirement to the src_element
493
         EA.Connector c = (EA.Connector)src_element.Connectors.AddNew("", "Relationship");
459
         EA.Connector c = (EA.Connector)src_element.Connectors.AddNew("", "Dependency");
494
         c.SupplierID = dest_element.ElementID;
460
         c.SupplierID = dest_element.ElementID;
495
         //c.Stereotype = "trace";
461
         //c.Stereotype = "trace";
496
         c.Direction = "Source -> Destination";
462
         c.Direction = "Source -> Destination";
497
         if (false == c.Update())
463
         if (false == c.Update())
498
         {
464
         {
499
            ea_repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "New Connector Error : " + c.GetLastError(), dest_element.ElementID );
465
            Main.EA_Repository.WriteOutput( Main.GUI_OUTPUT_TAB_NAME, "New Connector Error : " + c.GetLastError(), dest_element.ElementID );
500
         }
466
         }
501
         src_element.Connectors.Refresh();
467
         src_element.Connectors.Refresh();
502
      }
468
      }
503
      
469
      
504
      /// <summary>
470
      /// <summary>
505
      /// A method to contain common pre-parsing steps.
471
      /// A method to contain common pre-parsing steps.
506
      /// </summary>
472
      /// </summary>
507
      private void pre_parsing()
473
      private void pre_parsing()
508
      {
474
      {
509
         // create an object to represent the root of the database so that we can collect
475
         // create an object to represent the root of the database so that we can collect
510
         // sub-objects (packages or requirements) underneath it.
476
         // sub-objects (packages or requirements) underneath it.
511
         rq_root_package = new ReqPro_object();
477
         rq_root_package = new ReqPro_object();
512
         rq_root_package.name = "ROOT";
478
         rq_root_package.name = "ROOT";
513
 
479
 
514
         // initialise the ReqPro database hierarchy tracking data
480
         // initialise the ReqPro database hierarchy tracking data
515
         rq_objs.Clear();
481
         rq_objs.Clear();
516
         rq_objs.Push(rq_root_package);
482
         rq_objs.Push(rq_root_package);
517
         ea_treePos.Clear();
483
         ea_treePos.Clear();
518
         ea_treePos.Push(0);
484
         ea_treePos.Push(0);
519
         lastLevel = 0;
485
         lastLevel = 0;
520
      }
486
      }
521
 
487
 
522
 
488
 
523
                         
489
                         
524
 
490