Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Merge / join objects with links
Topic Summary:
Created On: 22-Nov-2007 11:25
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Jon Martin, on Monday, November 26, 2007 12:29 PM

Answer:
Peter, I've try the kitchen but it didn't copy the incoming links

I have incoming links from several modules!

The script i used is:


//join.dxl

/*
Join selected objects on Object Text.
Also move links from deleted objects to joined object.

1. Select a set of contiguous objects.
(Only their object text will be retained.)
2. Run this script to replace the object text in
the first of these objects with the concatenation
of the object texts of the other objects, and then
delete those other objects.
*/

/*
Kitchen Tools for customizing DOORS with DXL V7.1
-------------------------------------------------
DISCLAIMER:

This programming tool has been thoroughly checked
and tested at all stages of its production.
Telelogic cannot accept any responsibility for
any loss, disruption or damage to your data or
your computer system that may occur while using
this script.

If you do not accept these conditions, do not use
this customised script.
-------------------------------------------------
*/

/* Modifications:

Date: Who: Description:
07 Oct 97 jd Creation.
08 Oct 97 wc Changed object text separator to "\n".
15 Oct 97 jd Added copying of links to preserve them.
07 Apr 98 jd Delete objects in reverse order so that children are deleted before parents.
22 Sep 98 jd Preserve rich text.
08 Feb 05 jd Use full paths names for link modules.
*/


#include <addins/kitchen/utensils/dbs.inc>

void moveLinks(Object fromObj, Object toObj) {
// move all incoming and outgoing links from
// one object to another

int linksNotCopied = 0

// scan outgoing links
Link l
for l in fromObj->"*" do {

// get link information
Module lnkMod = module l
string lnkModName = fullName(lnkMod)
string trgModName = target l
Object trgObj = target l

// if trgObj is null, it is because
// the target module is not open.
// So open it.
if ( null trgObj ) {
edit(trgModName, false)
trgObj = target l
}

// if still null, there is a problem.
// So skip it.
if ( null trgObj ) {
linksNotCopied++
continue
}

// create new link
Link newl = toObj->lnkModName->trgObj

// copy link attributes
string attrName
for attrName in lnkMod do {
if ( canWrite(lnkMod, attrName) ) {
newl.attrName = l.attrName ""
}
}

// delete old link
delete l

}

// scan incoming links
for l in fromObj<-"*" do {

// get link information
Module lnkMod = module l
string lnkModName = fullName(lnkMod)
string srcModName = source l
Object srcObj = source l

// if srcObj is null, it is because
// the source module is not open.
// So open it.
if ( null srcObj ) {
edit(srcModName, false)
srcObj = source l
}

// if still null, there is a problem.
// So skip it.
if ( null srcObj ) {
linksNotCopied++
continue
}

// create new link
Link newl = toObj<-lnkModName<-srcObj

// copy link attributes
string attrName
for attrName in lnkMod do {
if ( canWrite(lnkMod, attrName) ) {
newl.attrName = l.attrName ""
}
}

// delete old link
delete l

}

// show errors
if ( linksNotCopied > 0 ) {
ack linksNotCopied " links were not copied."
}

// flush out the deleted links
flushDeletions()
}


Skip toDelete = create()
Object firstObj = null
string objText = ""
int cellWdth = 0
bool hasOLE = false

int numObjs = 0
Object o
for o in current Module do
{
if ( !isSelected o ) continue

// accumlate object texts
objText = objText "\n" (richTextWithOle o."Object Text") ""

// accumulate cell widths
cellWdth += intOf o."TableCellWidth" ""

/*
// keep OLE
if ( oleIsObject(o) )
{ // this object has an OLE object

if ( hasOLE )
{ // already have an OLE object
ack "Cannot join two OLE objects."
break
}

hasOLE = true

if ( !null firstObj )
{ // move OLE to first object

oleCut(o)
olePaste(firstObj)
}
}
*/

if ( null firstObj ) {
// record first object
firstObj = o
} else {
// record which objects to delete
numObjs++
put(toDelete, numObjs, o)
}
}

if ( null firstObj || numObjs < 1 ) halt

// update first object
firstObj."Object Text" = richText objText[1:] // cut off leading "\n"
if ( cell(firstObj) ) setCellWidth(firstObj, cellWdth)

// copy links
for o in toDelete do moveLinks(o, firstObj)

// delete remaining objects
// in reverse order so that children are deleted before parents
for i in numObjs:1 by -1 do
{
if ( find(toDelete, i, o) )
{
softDelete(o)
flushDeletions()
}
}
 22-Nov-2007 11:25
User is offline View Users Profile Print this message


Jon Martin

Posts: 49
Joined: 22-Nov-2006

Hi All

Is it possible to merge objects that have In links in them?

Edited: 22-Nov-2007 at 11:27 by Jon Martin
Report this to a Moderator Report this to a Moderator
 22-Nov-2007 12:15
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

Hi,

as usual, there is a Kitchen script which does this: "Kitchen -> Objects -> Join seleceted Objects ..."

Regards,

Peter
Report this to a Moderator Report this to a Moderator
 22-Nov-2007 12:37
User is offline View Users Profile Print this message


Jon Martin

Posts: 49
Joined: 22-Nov-2006

Answer Answer
Peter, I've try the kitchen but it didn't copy the incoming links

I have incoming links from several modules!

The script i used is:


//join.dxl

/*
Join selected objects on Object Text.
Also move links from deleted objects to joined object.

1. Select a set of contiguous objects.
(Only their object text will be retained.)
2. Run this script to replace the object text in
the first of these objects with the concatenation
of the object texts of the other objects, and then
delete those other objects.
*/

/*
Kitchen Tools for customizing DOORS with DXL V7.1
-------------------------------------------------
DISCLAIMER:

This programming tool has been thoroughly checked
and tested at all stages of its production.
Telelogic cannot accept any responsibility for
any loss, disruption or damage to your data or
your computer system that may occur while using
this script.

If you do not accept these conditions, do not use
this customised script.
-------------------------------------------------
*/

/* Modifications:

Date: Who: Description:
07 Oct 97 jd Creation.
08 Oct 97 wc Changed object text separator to "\n".
15 Oct 97 jd Added copying of links to preserve them.
07 Apr 98 jd Delete objects in reverse order so that children are deleted before parents.
22 Sep 98 jd Preserve rich text.
08 Feb 05 jd Use full paths names for link modules.
*/


#include <addins/kitchen/utensils/dbs.inc>

void moveLinks(Object fromObj, Object toObj) {
// move all incoming and outgoing links from
// one object to another

int linksNotCopied = 0

// scan outgoing links
Link l
for l in fromObj->"*" do {

// get link information
Module lnkMod = module l
string lnkModName = fullName(lnkMod)
string trgModName = target l
Object trgObj = target l

// if trgObj is null, it is because
// the target module is not open.
// So open it.
if ( null trgObj ) {
edit(trgModName, false)
trgObj = target l
}

// if still null, there is a problem.
// So skip it.
if ( null trgObj ) {
linksNotCopied++
continue
}

// create new link
Link newl = toObj->lnkModName->trgObj

// copy link attributes
string attrName
for attrName in lnkMod do {
if ( canWrite(lnkMod, attrName) ) {
newl.attrName = l.attrName ""
}
}

// delete old link
delete l

}

// scan incoming links
for l in fromObj<-"*" do {

// get link information
Module lnkMod = module l
string lnkModName = fullName(lnkMod)
string srcModName = source l
Object srcObj = source l

// if srcObj is null, it is because
// the source module is not open.
// So open it.
if ( null srcObj ) {
edit(srcModName, false)
srcObj = source l
}

// if still null, there is a problem.
// So skip it.
if ( null srcObj ) {
linksNotCopied++
continue
}

// create new link
Link newl = toObj<-lnkModName<-srcObj

// copy link attributes
string attrName
for attrName in lnkMod do {
if ( canWrite(lnkMod, attrName) ) {
newl.attrName = l.attrName ""
}
}

// delete old link
delete l

}

// show errors
if ( linksNotCopied > 0 ) {
ack linksNotCopied " links were not copied."
}

// flush out the deleted links
flushDeletions()
}


Skip toDelete = create()
Object firstObj = null
string objText = ""
int cellWdth = 0
bool hasOLE = false

int numObjs = 0
Object o
for o in current Module do
{
if ( !isSelected o ) continue

// accumlate object texts
objText = objText "\n" (richTextWithOle o."Object Text") ""

// accumulate cell widths
cellWdth += intOf o."TableCellWidth" ""

/*
// keep OLE
if ( oleIsObject(o) )
{ // this object has an OLE object

if ( hasOLE )
{ // already have an OLE object
ack "Cannot join two OLE objects."
break
}

hasOLE = true

if ( !null firstObj )
{ // move OLE to first object

oleCut(o)
olePaste(firstObj)
}
}
*/

if ( null firstObj ) {
// record first object
firstObj = o
} else {
// record which objects to delete
numObjs++
put(toDelete, numObjs, o)
}
}

if ( null firstObj || numObjs < 1 ) halt

// update first object
firstObj."Object Text" = richText objText[1:] // cut off leading "\n"
if ( cell(firstObj) ) setCellWidth(firstObj, cellWdth)

// copy links
for o in toDelete do moveLinks(o, firstObj)

// delete remaining objects
// in reverse order so that children are deleted before parents
for i in numObjs:1 by -1 do
{
if ( find(toDelete, i, o) )
{
softDelete(o)
flushDeletions()
}
}
Report this to a Moderator Report this to a Moderator
 23-Nov-2007 07:43
User is offline View Users Profile Print this message


Eric Piallat

Posts: 33
Joined: 26-Jan-2004

Hi,

This script works fine at my place, but keep in mind that links are stored by source.

That means you have to edit-open every source of link before launching the merging tool.

That can be done manually by following the links before merging, or you can open all linked modules before strating merging objects with:
ModName_ mn
Object o
for o in current Module do for mn in o <- "*" do edit fullName of mn


Alternately, you can modify the kitchen script, replacing:
// scan incoming links
for l in fromObj<-"*" do {
...

with:
// scan incoming links
ModName_ mn
for mn in fromObj <- "*" do edit fullName of mn
for l in fromObj<-"*" do {
...


-------------------------
E. Piallat
CeBeNetwork
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.