Subversion Repositories DevTools

Rev

Rev 2163 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2163 Rev 2169
Line 102... Line 102...
102
 
102
 
103
         m_ExportExtent = exportExtent;
103
         m_ExportExtent = exportExtent;
104
      }
104
      }
105
 
105
 
106
 
106
 
-
 
107
      /// <summary>
-
 
108
      /// Function to schedule and control the export sequence. Here is where the real work
-
 
109
      /// begins of exporting requirements and traceability from EA to RequisitePro.
-
 
110
      /// </summary>
-
 
111
      /// <param name="exportDateTime"></param>
-
 
112
      /// <param name="cancelled"></param>
107
      private void ExportToReqPro(string exportDateTime, out bool cancelled)
113
      private void ExportToReqPro(string exportDateTime, out bool cancelled)
108
      {
114
      {
109
         cancelled = false;
115
         cancelled = false;
110
 
116
 
111
         try
117
         try
Line 122... Line 128...
122
            #region DETERMINE PARENT PACKAGE
128
            #region DETERMINE PARENT PACKAGE
123
            // Obtain the EA parent package so that we can scan it for existing requirement elements.
129
            // Obtain the EA parent package so that we can scan it for existing requirement elements.
124
            EA.Package parentPackage;
130
            EA.Package parentPackage;
125
            if (m_ExportExtent == ExportForm.ExportExtent.PACKAGE_REQS)
131
            if (m_ExportExtent == ExportForm.ExportExtent.PACKAGE_REQS)
126
            {
132
            {
127
               parentPackage = EA_Utilities.get_selected_package();
133
               parentPackage = EA_ProjectBrowser.get_selected_package();
128
            }
134
            }
129
            else 
135
            else 
130
            {
136
            {
131
               // default to the ReqProDB container package. This is probably what most exports
137
               // default to the ReqProDB container package. This is probably what most exports
132
               // will use.
138
               // will use.
Line 144... Line 150...
144
 
150
 
145
            if (m_ExportExtent != ExportForm.ExportExtent.SINGLE_REQ)
151
            if (m_ExportExtent != ExportForm.ExportExtent.SINGLE_REQ)
146
            {
152
            {
147
               // create the element accumulator, and use it to find all the requirement
153
               // create the element accumulator, and use it to find all the requirement
148
               // elements in the container package
154
               // elements in the container package
149
               ElementAccumulator reqLister = new ElementAccumulator(allowedElementTypes);
155
               EA_ElementAccumulator reqLister = new EA_ElementAccumulator(allowedElementTypes);
150
               EA_Utilities.findAndProcessPackageElements( parentPackage, reqLister, true );
156
               EA_Parsing.findAndProcessPackageElementsInBrowserOrder( parentPackage, reqLister, true );
151
 
157
 
152
               if (Main.mustAbort)
158
               if (Main.mustAbort)
153
                  return;
159
                  return;
154
 
160
 
-
 
161
               // Sanity check the EA requirements
-
 
162
               Main.WriteOutput("Sanity checking requirement elements in EA", -1);
-
 
163
               if (false == sanity_check_requirements(reqLister.Elements))
-
 
164
               {
-
 
165
                  cancelled = true;
-
 
166
                  return;
-
 
167
               }
-
 
168
 
155
               // Remove requirements from the accumulated list if they have already been linked
169
               // Remove requirements from the accumulated list if they have already been linked
156
               // to ReqPro requirement elements, by virtue of them seeming to have a valid GUID
170
               // to ReqPro requirement elements, by virtue of them seeming to have a valid GUID
157
               // We dont actually validate the GUID, just check that one is present or not.
171
               // We dont actually validate the GUID, just check that one is present or not.
158
               ea_reqs = reqLister.Elements; 
172
               ea_reqs = reqLister.Elements; 
159
               int i_ea_reqs;
173
               int i_ea_reqs;
Line 186... Line 200...
186
               if (Main.mustAbort)
200
               if (Main.mustAbort)
187
                  return;
201
                  return;
188
            }
202
            }
189
            else // user wants to export a single selected requirement
203
            else // user wants to export a single selected requirement
190
            {
204
            {
191
               EA.Element ea_ele = EA_Utilities.get_selected_element(allowedElementTypes);
205
               EA.Element ea_ele = EA_ProjectBrowser.get_selected_element(allowedElementTypes);
192
               if (ea_ele == null)
206
               if (ea_ele == null)
193
               {
207
               {
194
                  MessageBoxEx.Show(
208
                  MessageBoxEx.Show(
195
                     "The export extent chosen (single requirement export)\n" +
209
                     "The export extent chosen (single requirement export)\n" +
196
                     "is not compatible with the item selected in the EA\n" +
210
                     "is not compatible with the item selected in the EA\n" +
Line 212... Line 226...
212
                  return;
226
                  return;
213
               }
227
               }
214
 
228
 
215
               ea_reqs = new ArrayList();
229
               ea_reqs = new ArrayList();
216
               ea_reqs.Add(ea_ele);
230
               ea_reqs.Add(ea_ele);
-
 
231
 
-
 
232
               // Sanity check the EA requirement
-
 
233
               Main.WriteOutput("Sanity checking requirement element in EA", -1);
-
 
234
               if (false == sanity_check_requirements(ea_reqs))
-
 
235
               {
-
 
236
                  cancelled = true;
-
 
237
                  return;
-
 
238
               }
217
            }
239
            }
218
            #endregion
240
            #endregion
219
 
241
 
220
            // Export newly mastered EA requirements to ReqPro
242
            // Export newly mastered EA requirements to ReqPro
221
            if (false == export_new_EA_mastered_requirements(ref ea_reqs, ref ea_mastered_reqs, ref ea_mastered_reqs_rp_guids, out cancelled))
243
            if (false == export_new_EA_mastered_requirements(ref ea_reqs, ref ea_mastered_reqs, ref ea_mastered_reqs_rp_guids, out cancelled))
Line 251... Line 273...
251
         {
273
         {
252
            Main.MessageBoxException(ex, "Exception (ExportToReqPro)");
274
            Main.MessageBoxException(ex, "Exception (ExportToReqPro)");
253
         }
275
         }
254
      }
276
      }
255
 
277
 
-
 
278
      /// <summary>
-
 
279
      /// sanity check a list of requirements to make sure they all meet ReqPro's constraints
-
 
280
      /// </summary>
-
 
281
      /// <param name="al"></param>
-
 
282
      /// <returns></returns>
-
 
283
      private bool sanity_check_requirements(ArrayList al)
-
 
284
      {
-
 
285
         int numBadRequirements = 0;
-
 
286
         foreach (EA.Element ele in al)
-
 
287
         {
-
 
288
            if (false == requirement_meets_reqpro_constraints(ele))
-
 
289
            {
-
 
290
               numBadRequirements++;
-
 
291
            }
-
 
292
 
-
 
293
            if (Main.mustAbort)
-
 
294
               return false;
-
 
295
         }
-
 
296
         if (numBadRequirements > 0)
-
 
297
         {
-
 
298
            MessageBoxEx.Show(
-
 
299
               "One or more EA requirement objects for export do not meet the constraints\n" +
-
 
300
               "imposed by RequisitePro - see EA_ReqPro output tab for the list of bad objects.",
-
 
301
               "Error");
-
 
302
            return false;
-
 
303
         }
-
 
304
         return true;
-
 
305
      }
-
 
306
 
-
 
307
 
-
 
308
      /// <summary>
-
 
309
      /// sanity check a requirement in EA to make sure it meets ReqPro's constraints
-
 
310
      /// and issue and message to the output tab if it does not.
-
 
311
      /// </summary>
-
 
312
      /// <param name="ele"></param>
-
 
313
      /// <returns></returns>
-
 
314
      private bool requirement_meets_reqpro_constraints(EA.Element ele)
-
 
315
      {
-
 
316
         string tag = null;
-
 
317
 
-
 
318
         if (ele.Name == null)
-
 
319
         {
-
 
320
            Main.WriteOutput("???", ele.ElementID);
-
 
321
            Main.WriteOutput("   Element has no name", ele.ElementID);
-
 
322
            return false;
-
 
323
         }
-
 
324
 
-
 
325
         string untagged_name = untaggedReqName(ele.Name, ref tag, false);
-
 
326
 
-
 
327
         if (untagged_name.Length > 128)
-
 
328
         {
-
 
329
            Main.WriteOutput(untagged_name, ele.ElementID);
-
 
330
            Main.WriteOutput(string.Format("   Element name exceeds 128 char limit - actual length is {0}", untagged_name.Length), ele.ElementID);
-
 
331
            return false;
-
 
332
         }
-
 
333
 
-
 
334
         if (untagged_name.IndexOfAny("\r\n".ToCharArray(), 0) >= 0)
-
 
335
         {
-
 
336
            Main.WriteOutput(untagged_name, ele.ElementID);
-
 
337
            Main.WriteOutput("   Element name contains carriage return or line feed", ele.ElementID);
-
 
338
            return false;
-
 
339
         }
-
 
340
 
-
 
341
         if (ele.Notes != null && ele.Notes.Length > 16000)
-
 
342
         {
-
 
343
            Main.WriteOutput(untagged_name, ele.ElementID);
-
 
344
            Main.WriteOutput(string.Format("   Element notes exceeds 16000 char limit - actual length is {0}", ele.Notes.Length), ele.ElementID);
-
 
345
            return false;
-
 
346
         }
-
 
347
 
-
 
348
         return true;   // requirement is good
-
 
349
      }
-
 
350
 
-
 
351
 
256
 
352
 
257
      /// <summary>
353
      /// <summary>
258
      /// Exports newly EA mastered requirements to ReqPro
354
      /// Exports newly EA mastered requirements to ReqPro
259
      /// </summary>
355
      /// </summary>
260
      /// <param name="ea_reqs"></param>
356
      /// <param name="ea_reqs"></param>
Line 307... Line 403...
307
               string tag = null;
403
               string tag = null;
308
               string ea_req_untagged_name = untaggedReqName(ea_req.Name, ref tag, false);
404
               string ea_req_untagged_name = untaggedReqName(ea_req.Name, ref tag, false);
309
 
405
 
310
               Main.WriteOutput("Exporting : " + ea_req.Name, ea_req.ElementID);
406
               Main.WriteOutput("Exporting : " + ea_req.Name, ea_req.ElementID);
311
 
407
 
-
 
408
               // If the EA requirement has a parent requirement, then in ReqPro we must organise it such 
-
 
409
               // that it has a parent-child hierarchical relationship
-
 
410
               ReqPro40.Requirement parent_rp_req = null;
-
 
411
               EA.Element parent_ea_req = null;
-
 
412
               if (ea_req.ParentID != 0)
-
 
413
               {
-
 
414
                  parent_ea_req = Main.EA_Repository.GetElementByID(ea_req.ParentID);
-
 
415
                  if (parent_ea_req != null)
-
 
416
                  {
-
 
417
                     // get GUID of ReqPro parent requirement
-
 
418
                     string parent_guid = EA_TaggedValues.Read(parent_ea_req, Constants.TAG_GUID);
-
 
419
                     if (parent_guid != null && parent_guid.Length > 0 && parent_guid.StartsWith("{"))
-
 
420
                     {
-
 
421
                        // Get the parent ReqPro requirement
-
 
422
                        parent_rp_req = ReqProDatabase.get_requirement_by_guid(parent_guid);
-
 
423
                     }
-
 
424
 
-
 
425
                     // Even though in EA, a parent-child relationship exists, we want to re-enforce that
-
 
426
                     // with a connection relationship too, so that when the parent and child exists on
-
 
427
                     // a diagram, they are shown linked together.
-
 
428
                     EA_Connectors.add(parent_ea_req, ea_req);
-
 
429
                  }
-
 
430
               }
-
 
431
 
-
 
432
 
312
               // Add the requirement to ReqPro requirement collection
433
               // Add the requirement to ReqPro requirement collection
-
 
434
               ReqPro40.Requirement rp_req = null;
-
 
435
 
-
 
436
               if (parent_rp_req != null)
-
 
437
                  rp_req = ReqProDatabase.add_requirement(req_collection, ea_req_untagged_name, ea_req.Notes, this.m_ReqType, parent_rp_req);
-
 
438
               else
313
               ReqPro40.Requirement rp_req = ReqProDatabase.add_requirement(req_collection, ea_req_untagged_name, ea_req.Notes, this.m_ReqType);
439
                  rp_req = ReqProDatabase.add_requirement(req_collection, ea_req_untagged_name, ea_req.Notes, this.m_ReqType);
-
 
440
 
314
               if (rp_req != null)
441
               if (rp_req != null)
315
               {
442
               {
316
                  // Get the tag for the new requirement from ReqPro and use it to form a new name for 
443
                  // Get the tag for the new requirement from ReqPro and use it to form a new name for 
317
                  // the EA requirement. Note that at this point in time the tag has a pending form. It
444
                  // the EA requirement. Note that at this point in time the tag has a pending form. It
318
                  // only becomes correct once we do a rq_req.Save() later on, so this update has to be
445
                  // only becomes correct once we do a rq_req.Save() later on, so this update has to be
Line 338... Line 465...
338
 
465
 
339
 
466
 
340
                  // Commit changes to ReqPro database
467
                  // Commit changes to ReqPro database
341
                  rp_req.Save();
468
                  rp_req.Save();
342
 
469
 
343
                  // Now locate the new requirement under the selected package in ReqPro
470
                  // Now locate the new requirement under the selected package in ReqPro, but we only need to do this if the
-
 
471
                  // requirement is a root level requirement that has no parent requirement.
344
                  if (rp_pkg != null)
472
                  if ((rp_pkg != null) && (parent_rp_req == null))
345
                  {
473
                  {
346
                     rp_pkg.AddElement(rp_req, ReqPro40.enumPackageLookups.ePackageLookup_Object, ReqPro40.enumElementTypes.eElemType_Requirement);
474
                     rp_pkg.AddElement(rp_req, ReqPro40.enumPackageLookups.ePackageLookup_Object, ReqPro40.enumElementTypes.eElemType_Requirement);
347
                  }
475
                  }
348
                     
476
                     
349
                  // If the EA requirement has a parent requirement, then in ReqPro we must organise it such 
-
 
350
                  // that it has a parent-child hierarchical relationship
-
 
351
                  if (ea_req.ParentID != 0)
-
 
352
                  {
-
 
353
                     EA.Element parent_ea_req = Main.EA_Repository.GetElementByID(ea_req.ParentID);
-
 
354
                     if (parent_ea_req != null)
-
 
355
                     {
-
 
356
                        // get GUID of ReqPro parent requirement
-
 
357
                        string parent_guid = EA_TaggedValues.Read(parent_ea_req, Constants.TAG_GUID);
-
 
358
                        if (parent_guid != null && parent_guid.Length > 0 && parent_guid.StartsWith("{"))
-
 
359
                        {
-
 
360
                           // Get the parent ReqPro requirement
-
 
361
                           ReqPro40.Requirement parent_rp_req = ReqProDatabase.get_requirement_by_guid(parent_guid);
-
 
362
                           if (parent_rp_req != null)
-
 
363
                           {
-
 
364
                              // Establish relationship in ReqPro
-
 
365
                              rp_req.AssignParent(parent_rp_req, ReqPro40.enumRequirementLookups.eReqLookup_Object);
-
 
366
 
477
 
367
                              // Even though in EA, a parent-child relationship exists, we want to re-enforce that
-
 
368
                              // with a connection relationship too, so that when the parent and child exists on
-
 
369
                              // a diagram, they are shown linked together.
-
 
370
                              EA_Utilities.add_connection(parent_ea_req, ea_req);
-
 
371
                           }
-
 
372
                        }
-
 
373
                     }
-
 
374
                  }
-
 
375
 
478
 
376
                  // Now re-acquire the tag, which should no longer be in a pending form but have a real number
479
                  // Now re-acquire the tag, which should no longer be in a pending form but have a real number
377
                  // assigned to it as a result of the commit we just did above.
480
                  // assigned to it as a result of the commit we just did above.
378
                  rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
481
                  rp_req_tag = rp_req.get_Tag(ReqPro40.enumTagFormat.eTagFormat_FullTag);
379
 
482