Book a Demo

Author Topic: Copy element "as new" should keep the li  (Read 5045 times)

deefer

  • EA User
  • **
  • Posts: 98
  • Karma: +0/-0
    • View Profile
Copy element "as new" should keep the li
« on: July 15, 2011, 07:27:09 pm »
Hi
when copying a package with elements into a new one, all the newly created elements in the new package keep the original package's elements links.

Why not to do it also for a single element's copy (as new)? Or, at least, I would give the option to perform it and let the user decide.

Example:
I have a number of packages containing test cases; the test cases are linked to their requirements/use cases elements.

I decide to do a test run, so I create a new package for the test run and now I want to copy in it the test cases that will be tested in this run.

Unfortunately, the test cases in the run will loose the links to the requirements (because I have to do the paste as new), hence loosing the traceability reqs-tests.

Please let me know what you think.
Davide
« Last Edit: July 15, 2011, 09:19:51 pm by davideferrari »

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Copy element "as new" should keep the li
« Reply #1 on: July 15, 2011, 09:36:56 pm »
The following VB Script allows you to select the element to clone in the project browser, run the script, and obtain a cloned element that maintains the same relationships as the original one.

Here is the VB Script code (copy and paste it in the script editor window):



option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name:
' Author:
' Purpose:
' Date:
'
sub main
      Dim OriginalPackage
      Dim TempPackage
      Dim SubPackage
      Dim ElementToClone
      Dim i
      Dim Finished
      
      Set ElementToClone = Repository.GetTreeSelectedObject()
      Set OriginalPackage = Repository.GetPackageByID(ElementToClone.PackageID)
      Set TempPackage = OriginalPackage.Packages.AddNew("Cloned Element", "Nothing")
      TempPackage.Update()
      OriginalPackage.Packages.Refresh()
      OriginalPackage.Update()
      ElementToClone.PackageID = TempPackage.PackageID
      ElementToClone.Update()
      TempPackage.Elements.Refresh()
      TempPackage.Update()
      TempPackage.Clone()
      ElementToClone.PackageID = OriginalPackage.PackageID
      ElementToClone.Update()
      OriginalPackage.Elements.Refresh()
      OriginalPackage.Update()
      Finished = false
      i = 0
      While i < OriginalPackage.Packages.Count And Not Finished
            Set SubPackage = OriginalPackage.Packages.GetAt(i)
            If SubPackage.PackageID = TempPackage.PackageID Then
                  OriginalPackage.Packages.DeleteAt i, false
                  Finished = true
            End If
            i = i + 1
      Wend
      OriginalPackage.Packages.Refresh()
      OriginalPackage.Update()
      Repository.RefreshModelView(OriginalPackage.PackageID)
end sub

main

deefer

  • EA User
  • **
  • Posts: 98
  • Karma: +0/-0
    • View Profile
Re: Copy element "as new" should keep the li
« Reply #2 on: July 15, 2011, 10:21:03 pm »
Thanx a lot for the script.

I think this should be a feature included by default in EA user interface.

Cheers,
Davide