Support

Expand all | Collapse all

Batch Remove Relationships?

  • 1.  Batch Remove Relationships?

    Posted 04-15-2015 14:51
    Is there a way to remove relationships from several items all at once? I have the import relationships plugin enabled, so I can batch-add them, but is there a way to batch-remove them?


  • 2.  Re: Batch Remove Relationships?

    Posted 04-15-2015 15:50
    Currently I see no way in the GUI.

    Possible other ways would be SQL, SOAP, in future REST.

    If you want to strip off all up or down relationships of a document, then it could be done by a context sensitive velocity report that makes use of

    RelationshipDao.getRelationshipsForDocument
    with the flag you select up or downstream.

    Then put that list into that call:
    RelationshipDao.batchDeleteRelationships

    But this would be dangerous, as everybody that executes that report world delete the relationships.

    have not tried that, but I am pretty sure the following would work:

    #set($rlshpDao = $applicationContext.getBean("relationshipDao"))
    #foreach($vDoc in $documentList)
    ## delete up traces
    #set($rlshp = $rlshpDao.getRelationshipsForDocument($vDoc.document.id,false))
    #set($dummy = $rlshpDao.batchDeleteRelationships($rlshp))
    ## delete down traces
    #set($rlshp = $rlshpDao.getRelationshipsForDocument($vDoc.document.id,true))
    #set($dummy = $rlshpDao.batchDeleteRelationships($rlshp))
    #end

    could not resist, tested, works


  • 3.  RE: Re: Batch Remove Relationships?

    Posted 19 days ago
    Hello Harold,

    Thanks for posting this -- It saved my team a ton of manual cleanup work.  I was not able to get your script to work as is -- it appeared that the foreach loop was referencing an object variable that had not been defined: $documentList.  I inserted this bolded line before the foreach loop, and your script worked like a charm.  It removed all my relationships from currently selected project as well as relationships to items in other projects.  Thanks again!

    #set($rlshpDao = $applicationContext.getBean("relationshipDao"))
    #set( $documentList = $docDao.getActiveDocumentIdsInProject($mathTool.toInteger($project.id)))
    #foreach($vDoc in $documentList)

    ------------------------------
    Christopher Campbell
    Ivenix
    ------------------------------



  • 4.  Re: Batch Remove Relationships?

    Posted 04-17-2015 12:31
    Thanks for the help, Harald.  We currently do not use any other reporting methodology other than the standard Office exports (we're using Contour for instrument development), so we want to make the changes in the database directly.  I ended up deleting everything by hand, but will put this as a feature request in future versions, maybe for users with project admin capabilities only.

    Respectfully,

    Jen


  • 5.  Re: Batch Remove Relationships?

    Posted 04-17-2015 13:09
    Hi Jen,

    you have to add a velocity report in the admin section, call it batch relationship delete. 


    put the following:
    #set($rlshpDao = $applicationContext.getBean("relationshipDao"))
    #foreach($vDoc in $documentList)
    #set($rlshp = $rlshpDao.getRelationshipsForDocument($vDoc.document.id,false))
    #set($dummy = $rlshpDao.batchDeleteRelationships($rlshp))
    #set($rlshp = $rlshpDao.getRelationshipsForDocument($vDoc.document.id,true))
    #set($dummy = $rlshpDao.batchDeleteRelationships($rlshp))
    #end

    in a file you upload as a report file, and you have it.

    Import is that the conext sensitive checkbox is selected.

    When you have a list of items (filter) displayed where you want to get rid of the relationships, then goto export, office templates, then you will see this "report", after running this report, you get an empty page, and the realtionships are gone.

    Harald


  • 6.  Re: Batch Remove Relationships?

    Posted 04-20-2015 12:33
    Thanks for the detailed explanation, Harald.  I will certainly use this approach in the future if this comes up again.

    Jen


  • 7.  Re: Batch Remove Relationships?

    Posted 09-09-2015 16:45
    Hi Harald,

    Thanks for sharing this. I just installed and tested your Velocity on a sandbox on-premises server and deleted 10 relationships in a test project. It works great. I am asking another teammate to test before I install into production and delete 2000 relationships. This will save me at least 3 hours of manually deleting these relationships one-by-one. Thanks for sharing your expertise and knowledge. Have a great day.

    swoo


  • 8.  Re: Batch Remove Relationships?

    Posted 09-09-2015 17:45
    Edited by Kristina King 03-20-2017 17:11
    Whoa! A savings of 3 hours? That's awesome.

    Thanks for sharing, Harald! Thanks for confirming, Swoo!

    2017/03/20 edit: Note that the only supported scripts and reports are those posted by Jama official, so we cannot upload this report to a hosted instance, nor will we support the use of it on-premises.


  • 9.  Re: Batch Remove Relationships?

    Posted 09-10-2015 20:20
    I calculated that it will take my 5 seconds to find and delete one relationship and go onto another item. 5 * 2000 / 60 / 60 = 3 hours + re-work because I accidentally removed relationships that I did not want to :-) I appreciate  Harald's sharing and admire his expertise :-) swoo


  • 10.  Re: Batch Remove Relationships?

    Posted 10-29-2015 23:19
    This reply was created from a merged topic originally titled Testcase relating to the same Requirement multiple times. How best to cleanup..

    Hello Everyone,


    We were using a Custom Import to map Requirements to TestCases and the Custom Import timed out several times.

    As a result we now have Testcases mapped to the same Requirement several times (ie Test Case #1 maps to Requirement #1 four times).

    I know how to clean this up in the TestCase Relationship tab, but we have over 1000 Testcases that I have to check and potentially clean. =(

    Is there a better way to clean this up???

    Thanks!


  • 11.  Re: Batch Remove Relationships?

    Posted 02-05-2016 21:37
    Harald,

    The code that you listed, where do you put it?  Do you put it into a file and then select the file as the "Report File Name?"  Each time I try to save the velocity report, Jama gives me an error "Note: Only Velocity report files can be uploaded for Velocity Reports."  If I have not report file name entered, then Jama gives me the error "Format error converting number."

    --Rich


  • 12.  Re: Batch Remove Relationships?

    Posted 02-08-2016 13:26
    Rich,

    The code must be in a text file with the extension .vm.

    Then you choose that file in the file dialog that opens at choose file.

    regards
    Harald


  • 13.  Re: Batch Remove Relationships?

    Posted 03-08-2016 20:15
    This reply was created from a merged topic originally titled How to remove batch relationships.

    I am trying to remove all of the relationships in a module.  I see someone has created something about this, but I have no idea where they are entering their code for this.  


  • 14.  Re: Batch Remove Relationships?

    Posted 03-09-2016 20:22
    Mark,

    First, any user needs to create a text file with any name and extension ".vm".  Copy the code from the comment posted by Harald Hotz-Behofsits posted 11 months ago (sorry to future readers, but Jama's posting system doesn't display exact dates, only relative deltas from today's date).  Save the file.

    Second, a user with Admin rights needs to create the Velocity report as shown in the image in the comment posted by Harald Hotz-Behofsits posted 11 months ago.  In the report, select the <Report File Name> button and browse for the .vm file created in the previous step.

    Third, any user can execute the report following the instructions in Harald Hotz-Behofsits' paragraph that begins with, "When you have a list of items..."

    My experience is that Harald's code removes all relationships from the project regardless of whether or not the items appear in the filter.

    Harald,

    Do you have suggestions or advice on how to modify your code to only execute on items that appear in a filter?  Thank you!  P.S.  Your code/report worked great!


  • 15.  Re: Batch Remove Relationships?

    Posted 03-15-2016 12:07
    Have you checked the context sensitive box in report configuration?

    look at the screenshot some posts above.


  • 16.  RE: Re: Batch Remove Relationships?

    Posted 05-30-2018 10:35
    Thank you, Harold, for this solution.
    I'm not familiar with Velocity and am surprised that it is capable of manipulating data in the DB instead of just reporting out.

    I am dealing with a similar problem as described in: https://community.jamasoftware.com/communities/community-home/digestviewer/viewthread?GroupId=25&MessageKey=c8020b19-47b2-4fb9-8d9d-8f075d33513d&CommunityKey=c9d20d4c-5bb6-4f19-92eb-e7cee0942d51&tab=digestviewer&ReturnUrl=%2fcommunities%2fcommunity-home%2fdigestviewer%3fcommunitykey%3dc9d20d4c-5bb6-4f19-92eb-e7cee0942d51%26tab%3ddigestviewer

    The suggestion that you had for me at the time was to use the REST API. Unfortunately, we are running on JAMA 2015.5 and the API is not available in that version.

    So, I'd like to try the Velocity approach. My challenge is that I only want to delete certain relationships (those that link between two projects) and leave the rest intact.

    Is it possible to do such a thing using the Velocity method?

    ------------------------------
    Bob Hunt
    ------------------------------



  • 17.  RE: Re: Batch Remove Relationships?

    Posted 05-31-2018 13:37
    Hello Bob,
    Being on 2015.5 will require you to delete the relationships manually. I would recommend an upgrade to a supported version of Jama which will allow you to use the REST API and make this process less labor intensive.

    See our Standard channel (on-premises) Release Notes.

    If you are upgrading from a previous iteration of Jama 8.x, use this section of the user guide.

    If you are upgrading from a Jama version prior to 8, review our upgrade process for instructions on our new installation process. Notably, you will no longer download a Jama file; you will run a cURL command to pull the required elements. We also offer a complimentary one-hour pre-upgrade consultation. You can reply to this email and we will open a new request to start the process. Jama is a powerful tool and requires specific skills to properly administer. This guide will provide details on the skills required.

    With Jama 8.x, there are several changes to both our deployment model and supported software. Of important note, support for Windows servers and Oracle databases has ended.

    Note that with this release, we are not recommending the deployment of the most recent version of Docker and Replicated, but to instead install Docker 17.0.3 and Replicated 2.9.3 for all operating systems except Red Hat Enterprise Linux (RHEL). Servers using RHEL should utilize Docker 1.13.1 and Replicated 2.6.

    ------------------------------
    Dana Medhaug
    Technical Support Engineer
    Jama Software
    ------------------------------