i know how to create links between two objects |
Re: delete links
You'll need to read the section on Link Management in the DOORS DXL Reference Manual (click here and download a copy - you need to look for the hyperlink though) Object o=current Module m=current int count=0 void deleteIncomingLinks(Object o) { Module modSrc=null Module sourceMod=null Link l bool allModsOpen = true ModuleVersion sourceModVersion = null // Open all modules that are the source of incoming links in edit mode ModName_ srcModRef string srcModName="" for srcModRef in o<-"*" do { srcModName=fullName(srcModRef) modSrc=edit(srcModName, false) if (null modSrc) { //provide a warning if a source cannot be opened in edit mode infoBox "Cannot open for Edit module: " srcModName allModsOpen = false } } // Delete all incoming links if(allModsOpen) { for l in o<-"*" do { Object objSrc=source l sourceModVersion = sourceVersion l srcModRef = module(sourceModVersion) modSrc=edit(fullName(srcModRef), false) count++ delete l flushDeletions save modSrc } } else print "Failed to get access to source module(s) \n" } //End of deleteIncomingLinks //***************** MAIN ******************** if(null o) { warningBox "No Object has been selected" halt } o = current if(!null o) { if(!confirm "Delete all incoming links to this object?") halt deleteIncomingLinks(o) infoBox "Deleted " count " links" save m } else { warningBox "No object selected" }
Paul Miller
|
Re: delete links SystemAdmin - Wed Feb 15 21:33:03 EST 2012
You'll need to read the section on Link Management in the DOORS DXL Reference Manual (click here and download a copy - you need to look for the hyperlink though) Object o=current Module m=current int count=0 void deleteIncomingLinks(Object o) { Module modSrc=null Module sourceMod=null Link l bool allModsOpen = true ModuleVersion sourceModVersion = null // Open all modules that are the source of incoming links in edit mode ModName_ srcModRef string srcModName="" for srcModRef in o<-"*" do { srcModName=fullName(srcModRef) modSrc=edit(srcModName, false) if (null modSrc) { //provide a warning if a source cannot be opened in edit mode infoBox "Cannot open for Edit module: " srcModName allModsOpen = false } } // Delete all incoming links if(allModsOpen) { for l in o<-"*" do { Object objSrc=source l sourceModVersion = sourceVersion l srcModRef = module(sourceModVersion) modSrc=edit(fullName(srcModRef), false) count++ delete l flushDeletions save modSrc } } else print "Failed to get access to source module(s) \n" } //End of deleteIncomingLinks //***************** MAIN ******************** if(null o) { warningBox "No Object has been selected" halt } o = current if(!null o) { if(!confirm "Delete all incoming links to this object?") halt deleteIncomingLinks(o) infoBox "Deleted " count " links" save m } else { warningBox "No object selected" }
Paul Miller
When using any of the numerous "for Handle1 in Handle2 do" loops in DOORS it's a big mistake to be deleting or adding any Handle1 entries for Handle2 as this messes up the loop. It's something like this, something all Coding 101 folks know not to do: for i = 0 to 99 { i = something else }
Skip skpLinksToDelete = create() // KEY and DATA both 'Link' for lnk in obj <-"*" do { if (I want to delete this link) then put(skpLinksToDelete, lnk, lnk) } // now delete the links: for lnk in skpLinksToDelete do { delete(lnk) } flushDeletions() delete(skpLinksToDelete)
|
Re: delete links llandale - Thu Feb 16 12:12:32 EST 2012 When using any of the numerous "for Handle1 in Handle2 do" loops in DOORS it's a big mistake to be deleting or adding any Handle1 entries for Handle2 as this messes up the loop. It's something like this, something all Coding 101 folks know not to do: for i = 0 to 99 { i = something else }
Skip skpLinksToDelete = create() // KEY and DATA both 'Link' for lnk in obj <-"*" do { if (I want to delete this link) then put(skpLinksToDelete, lnk, lnk) } // now delete the links: for lnk in skpLinksToDelete do { delete(lnk) } flushDeletions() delete(skpLinksToDelete)
Yep, good point, makes sense....but I'm scratching my head as to why does my 60 second late night hack utility script work then? My perspective (not saying I'm right, just want to know where it's wrong), once you're in the loop, a handle has been passed to the next link, the link is deleted which effectively kills the handle to that link, but why does the loop itself care at this point? I'm not attempting to use the same link handle again (maybe that's where I get away with it), the loop then just increments to the next link handle if one is there. Paul Miller Melbourne, Australia |
Re: delete links SystemAdmin - Thu Feb 16 18:47:59 EST 2012 Paul Miller Melbourne, Australia
Well the way those for a in b do loops in DXL work is dependent on the datatype. For columns its a prominent example, that: for col in mod do delete col
void ::do (Column &c, Module m, void codeBlock) { iCount = get_number_of_columns in current view of m for (i = 0; i < iCount; i++) do { c = get_column_nr i execute codeBlock } }
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: delete links SystemAdmin - Thu Feb 16 18:47:59 EST 2012 Paul Miller Melbourne, Australia I was scratching my own head as I wrote my retort, knowing you wouldn't have posted the code that you have not already proven to work. I specifically recall this being an issue with deleting links, but perhaps you don't have a problem because you are dealing with INcoming links, and this Object's list of incoming links is not adjusted when you indeed delete the underlying link. Perhaps incoming links are stored as LinkRef's which then point to a null Link. Anyway, maybe someone can prove me wrong using a script like your's but for outgoing links. And even if I'm wrong for "Link"s, what I said holds true for many other such loops. Its also very possible they have fixed this feature in v9, since my previous understanding was from v7 and perhaps v8. -Louie I'd be tempted to put the Handles of the SourceModules that have deleted links into a Skip list, and after your big loop then flushDeletions and plow through the Skip saving those modules (just once). |
Re: delete links SystemAdmin - Wed Feb 15 21:33:03 EST 2012
You'll need to read the section on Link Management in the DOORS DXL Reference Manual (click here and download a copy - you need to look for the hyperlink though) Object o=current Module m=current int count=0 void deleteIncomingLinks(Object o) { Module modSrc=null Module sourceMod=null Link l bool allModsOpen = true ModuleVersion sourceModVersion = null // Open all modules that are the source of incoming links in edit mode ModName_ srcModRef string srcModName="" for srcModRef in o<-"*" do { srcModName=fullName(srcModRef) modSrc=edit(srcModName, false) if (null modSrc) { //provide a warning if a source cannot be opened in edit mode infoBox "Cannot open for Edit module: " srcModName allModsOpen = false } } // Delete all incoming links if(allModsOpen) { for l in o<-"*" do { Object objSrc=source l sourceModVersion = sourceVersion l srcModRef = module(sourceModVersion) modSrc=edit(fullName(srcModRef), false) count++ delete l flushDeletions save modSrc } } else print "Failed to get access to source module(s) \n" } //End of deleteIncomingLinks //***************** MAIN ******************** if(null o) { warningBox "No Object has been selected" halt } o = current if(!null o) { if(!confirm "Delete all incoming links to this object?") halt deleteIncomingLinks(o) infoBox "Deleted " count " links" save m } else { warningBox "No object selected" }
Paul Miller
|
Re: delete links kavitharassou - Fri Jul 13 05:06:50 EDT 2012 Ken. Attachments attachment_14856393_Delete_Links.zip |
Re: delete links SystemAdmin - Wed Feb 15 21:33:03 EST 2012
You'll need to read the section on Link Management in the DOORS DXL Reference Manual (click here and download a copy - you need to look for the hyperlink though) Object o=current Module m=current int count=0 void deleteIncomingLinks(Object o) { Module modSrc=null Module sourceMod=null Link l bool allModsOpen = true ModuleVersion sourceModVersion = null // Open all modules that are the source of incoming links in edit mode ModName_ srcModRef string srcModName="" for srcModRef in o<-"*" do { srcModName=fullName(srcModRef) modSrc=edit(srcModName, false) if (null modSrc) { //provide a warning if a source cannot be opened in edit mode infoBox "Cannot open for Edit module: " srcModName allModsOpen = false } } // Delete all incoming links if(allModsOpen) { for l in o<-"*" do { Object objSrc=source l sourceModVersion = sourceVersion l srcModRef = module(sourceModVersion) modSrc=edit(fullName(srcModRef), false) count++ delete l flushDeletions save modSrc } } else print "Failed to get access to source module(s) \n" } //End of deleteIncomingLinks //***************** MAIN ******************** if(null o) { warningBox "No Object has been selected" halt } o = current if(!null o) { if(!confirm "Delete all incoming links to this object?") halt deleteIncomingLinks(o) infoBox "Deleted " count " links" save m } else { warningBox "No object selected" }
Paul Miller
hi paul, I tried to add a loop to your code to run through all objects in a module that have a status of 'deleted'. thats an enumerated type i use. im having issues getting it to run with my placement of the loop and my criteria. i've tried diff placements of the loop and criteria with no luck
for o in m do { string sstatus = probeAttr_(obj,"Status") if (sstatus == "Deleted") { } }
|