Is it possible through script to move objects within a module and rearrange them based on the outlink object number? Reasoning behind this is the following. I have multiple modules(I'll call them Tier 3), most with anywhere from 200-500 objects that have been linked to other modules (Tier 2) during requirement decomposition. During the decomposition process, heading structures were not consistently created across the various modules, so now requirements in Tier 3 may be under section 4, while in Tier 2 they are in section 3. The object identifier in the outlink in the Tier 3 module shows me the in Tier 2 it is in section 3. I want to use that object identifier shown in the outlink information in the Tier 3 module, and move\rearrange the objects in ascending value.
RCB319 - Fri Nov 17 08:51:52 EST 2017 |
Re: Rearrange objects based on outlink object number Well, yes, it is possible. The question is, which information do you need in order to write such a script? I am not sure whether you really mean the object identifier that tells you about the destination chapter, I rather think that it is the object number you are interested in (like "3.1.1.0-1" for the first text object below heading 3.1.1). This number you can get with the perm number(obj). "obj" will be the object of the link target, see the code generated by the analysis wizard on how to get this object. There are move commands, see "move(object)" in the DXL manual, you will always move one object after or below another one, so your task will be to find the correct "parent" object and move the object in question below the parent. |
Re: Rearrange objects based on outlink object number Object number is what I am referencing - thank you for correcting that. I'm new to this (DOORs in general, and definitely working with dxl). I've got the DXL manual, so will start there. I've also got the code generated by the Wizard and have been looking at how that is grabbing the link target and object number. I'll dive into it and see if I can get it to work.
|
Re: Rearrange objects based on outlink object number RCB319 - Fri Nov 17 10:01:32 EST 2017 Object number is what I am referencing - thank you for correcting that. I'm new to this (DOORs in general, and definitely working with dxl). I've got the DXL manual, so will start there. I've also got the code generated by the Wizard and have been looking at how that is grabbing the link target and object number. I'll dive into it and see if I can get it to work.
good luck. that's quite a topic for beginning with DXL.. -> remember to work in a test database with disposable data, archive your test data and restore it every time you invalidated it with a test run of the script. If possible, use an account that has almost no access rights to modules outside your test project. |
Re: Rearrange objects based on outlink object number Mike.Scharnow - Fri Nov 17 10:32:14 EST 2017 good luck. that's quite a topic for beginning with DXL.. -> remember to work in a test database with disposable data, archive your test data and restore it every time you invalidated it with a test run of the script. If possible, use an account that has almost no access rights to modules outside your test project. I've got a test sandbox to play in for this. And yes, it is a bit overwhelming for someone that has never done it before :-)
|
Re: Rearrange objects based on outlink object number Another question regarding this, and if necessary I can start a new thread. I've been able to get display a column showing the Object Number for my outlinked objects (by use of some scripting that I already had available here and some minor work in showing the necessary attributes) and can sort those numerically. When sorted, they all get moved to the bottom of the module, but are in numeric order. Code for that is the following:
// Sort Objects in Module
string ATTR = "DXL for Out-links at depth 1"
Skip objects = createString
Module m = current Module
Object o = null
Object p = null
p = current Object
for o in m do
{
if (o.ATTR "" == "") continue
if (!find(objects, o.ATTR ""))
{
put(objects, o.ATTR "", o)
}
else
{
print("duplicate: " identifier(o) "\n")
}
}
for o in objects do
{
if (o == last(m)) continue
noError
move(o, last(m))
lastError
}
While I can deal with them being sorted and at the bottom of the module, ideally I would now like to include the Object Number for the Headings that were already included in the module, and sort/move the other objects in relation to those. That would eliminate the need for me to move sorted objects manually.
Any suggestions on how to modify the above code to accomplish this?
From the manual:
string number(Object o) returns the hierarchical object number (for example 2.1.1-0.1) of object o as a string.
How would I go about including this in the sorting of the two combined Object Numbers?
Best regards!
|
Re: Rearrange objects based on outlink object number RCB319 - Mon Nov 20 09:16:46 EST 2017 Another question regarding this, and if necessary I can start a new thread. I've been able to get display a column showing the Object Number for my outlinked objects (by use of some scripting that I already had available here and some minor work in showing the necessary attributes) and can sort those numerically. When sorted, they all get moved to the bottom of the module, but are in numeric order. Code for that is the following:
// Sort Objects in Module
string ATTR = "DXL for Out-links at depth 1"
Skip objects = createString
Module m = current Module
Object o = null
Object p = null
p = current Object
for o in m do
{
if (o.ATTR "" == "") continue
if (!find(objects, o.ATTR ""))
{
put(objects, o.ATTR "", o)
}
else
{
print("duplicate: " identifier(o) "\n")
}
}
for o in objects do
{
if (o == last(m)) continue
noError
move(o, last(m))
lastError
}
While I can deal with them being sorted and at the bottom of the module, ideally I would now like to include the Object Number for the Headings that were already included in the module, and sort/move the other objects in relation to those. That would eliminate the need for me to move sorted objects manually.
Any suggestions on how to modify the above code to accomplish this?
From the manual:
string number(Object o) returns the hierarchical object number (for example 2.1.1-0.1) of object o as a string.
How would I go about including this in the sorting of the two combined Object Numbers?
Best regards!
this is just an idea / an excerpt, most probably there are a lot of typos.
// cache all objects in skip so that a move of an object will not destroy the for loop
Skip skObjectsToBeMoved = create()
for o in m do put (skObjectsToBeMoved, o, o)
for o in skObjectsToBeMoved do {
// find linked object by following the link, set oLinkedObect
[…]
string sPositionInLinkedModule= number (oLinkedObject) // e.g.: "2.1.1-0.1"
int offset
int length
if (! findPlainText (sPositionInLinkedModule, "-", offset, length, false)) {
print "could not find position for object " (o."Absolute Number""")
} else {
string sChapterNumber = sPositionInLinkedModule [ 0 : (offset-1) ]
print "object will be moved inside chapter " sChapterNumber "\n"
Object oDestination
bool bFound = false
for oDestination in m do {
if (number(oDestination) == sChapterNumber) { // 2.1.1 matches 2.1.1
print "found the chapter\n"
bFound = true
move (o, last(below(oDestination)))
}
}
if (! bFound) { print "could not find destination for " o."Absolute Number"""}
}
}
|
Re: Rearrange objects based on outlink object number - REOPENED (
Hmm ... perhaps ... the simpliest way is to use a sort ... Sort s = ascending "Absolute Number" sorting on set s refresh current Module Of course you have to filter on the linked oulink information instead of the absolute number, but may be you don't need to do more ;) Have fun ! ) |