Need help with Layout DXL and redline markup.

Hello,

I am trying to write layout DXL to show the history since the last baseline and I am have trouble getting the script not to repeat the history eveytime an update is made also I am having trouble with redline mark-ups. I would appreciate any help since I am new to DXL.

Thank you,
Jim

Buffer buff1 = create()
// print a brief report of the history record 
void print(History h) {
    HistoryType ht = h.type 
    buff1 += h.author "\t" h.date "\t" ht "\t" 
    if (ht == createType ||
        ht == modifyType ||
        ht == deleteType)  { // attribute type
        buff1 += h.typeName
    } else if (ht == createAttr ||
               ht == modifyAttr ||
               ht == deleteAttr)  {  
      // attribute definition
      buff1 += h.attrName 
    } else if (ht == createObject ||
               ht == clipCopyObject  ||
               ht == modifyObject) { // object
       buff1 += h.absNo "\t"
        if (ht==modifyObject) { 
        // means an attribute has changed 
            string oldV = h.oldValue 
            string newV = h.newValue 
           buff1 += " (" h.attrName ":" oldV " -> " newV ")"
        }
    }
    buff1 += "\n"
    displayRich( tempStringOf buff1)
} 
// Main program 
History h 
for h in obj do print h
delete buff1

SystemAdmin - Wed Oct 05 23:22:31 EDT 2011

Re: Need help with Layout DXL and redline markup.
llandale - Thu Oct 06 14:53:58 EDT 2011

Global buffer is effective, but when you WOULD have issued a create for it inside the function, you remember to erase it. In this case change "+=" to "=" line 5.

From    buff1 += h.author "\t" h.date "\t" ht "\t"
To      buff1  = h.author "\t" h.date "\t" ht "\t"


On a side note: I do what you just about half the time I use a global like this!

You don't need to check for the attrType history since an object cannot have any such History; modifying AttrType has nothing to do with any objects. Ditto for the create/delete/modify Attr.

History type CreateObject should have its own display elseif, as should clipCopyObject. I would say just don't care, display "createObject" generically like you do for all the history and be done with it.

Modify type is more difficult. You don't need to display absno since surely you are already display Object ID in a column.

use plainOldValue and plainNewValue if you figure to compare them.

Something like this may display redlined markups:

 

bufOld = h.plainOldValue
bufNew = h.plainNewValue
diff(bufOld, bufNew, bufDiff)
buff1 += bufDiff


When that fails, someone better at rich text markup will jump in here and save me.

 

 

  • Louie

 

Re: Need help with Layout DXL and redline markup.
llandale - Thu Oct 06 14:57:07 EDT 2011

This is a computational hog. Be sure to convert it to attrDXL when you are ready to deploy it; otherwise you will see your views slowing down to a crawl.

Re: Need help with Layout DXL and redline markup.
SystemAdmin - Fri Oct 07 01:55:41 EDT 2011

I found a better example to work from currently I am trying to print the link history but when I run the script I get an run-time error "-R-W- DXL: <Line:5> wrong history type deleteLink for Link Initial Name Backtrace:" any ideas how would you print the redline mark-up for the link history? Any ideas how to improve the current code for execution time?
 

  • Does anyone know of a good resource for DXL, I find the reference guide lacking in times and some function(s)that I see in sample code found on the internet sometime I cannot find them in the DXL reference guide.


Thank you,
Jim

 

 

void defaultDescribeEvent(Object o, string sAttribute, History h, Buffer b) 
{
    HistoryType ht = null; ht = h.type;
        Buffer v = create()
        Buffer old = create(); old = h.plainOldValue;
        Buffer new = create(); new = h.plainNewValue; 
        diff (v, old,new, "\\cf1\\strike ", "\\cf3\\ul ")
        if (ht == modifyObject)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += h.attrName "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }else if (ht == deleteLink || ht == createLink)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += goodStringOf(ht) "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }
 
        delete old
        delete new
        delete v
}
 
string getHistoryForAttributes(Object o, void describeEvent(Object, string, History, Buffer))
{
        History h = null
        Buffer b = create()
        for h in o do
        {
                if(h.readlocked)
                        continue
 
                string sAttribute = h.attrName
                describeEvent(o, sAttribute, h, b)
                
        }
        string sHistory = stringOf(b)
        delete b
        return sHistory 
}
 
displayRichWithColour getHistoryForAttributes(obj, defaultDescribeEvent)

 

 

Re: Need help with Layout DXL and redline markup.
SystemAdmin - Fri Oct 07 05:51:10 EDT 2011

SystemAdmin - Fri Oct 07 01:55:41 EDT 2011

I found a better example to work from currently I am trying to print the link history but when I run the script I get an run-time error "-R-W- DXL: <Line:5> wrong history type deleteLink for Link Initial Name Backtrace:" any ideas how would you print the redline mark-up for the link history? Any ideas how to improve the current code for execution time?
 

  • Does anyone know of a good resource for DXL, I find the reference guide lacking in times and some function(s)that I see in sample code found on the internet sometime I cannot find them in the DXL reference guide.


Thank you,
Jim

 

 

void defaultDescribeEvent(Object o, string sAttribute, History h, Buffer b) 
{
    HistoryType ht = null; ht = h.type;
        Buffer v = create()
        Buffer old = create(); old = h.plainOldValue;
        Buffer new = create(); new = h.plainNewValue; 
        diff (v, old,new, "\\cf1\\strike ", "\\cf3\\ul ")
        if (ht == modifyObject)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += h.attrName "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }else if (ht == deleteLink || ht == createLink)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += goodStringOf(ht) "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }
 
        delete old
        delete new
        delete v
}
 
string getHistoryForAttributes(Object o, void describeEvent(Object, string, History, Buffer))
{
        History h = null
        Buffer b = create()
        for h in o do
        {
                if(h.readlocked)
                        continue
 
                string sAttribute = h.attrName
                describeEvent(o, sAttribute, h, b)
                
        }
        string sHistory = stringOf(b)
        delete b
        return sHistory 
}
 
displayRichWithColour getHistoryForAttributes(obj, defaultDescribeEvent)

 

 

Copying my post from the LinkedIn DOORS group:

No books available for DOORS DXL, sorry. The only booklike thing is the DXL Help / DXL Reference manual supplied along with DOORS.

Websites:
http://www.smartdxl.com/ - Excellent collection of scripts and a small, not so active forum

http://www.baselinesinc.com/ - see DXL Tutorial http://www.baselinesinc.com/?p=9&cpage=1, also has a small collection of scripts

http://www.ibm.com/developerworks/forums/forum.jspa?forumID=1527 - most active DXL forum by IBM

http://easyweb.easynet.co.uk/~iany/consultancy/papers.htm - some white papers on getting started with DXL

http://www.galactic-solutions.com/GalacticWhitePapers.htm - advanced DXL stuff and excellent collection of scripts

Re: Need help with Layout DXL and redline markup.
llandale - Fri Oct 07 13:33:43 EDT 2011

SystemAdmin - Fri Oct 07 01:55:41 EDT 2011

I found a better example to work from currently I am trying to print the link history but when I run the script I get an run-time error "-R-W- DXL: <Line:5> wrong history type deleteLink for Link Initial Name Backtrace:" any ideas how would you print the redline mark-up for the link history? Any ideas how to improve the current code for execution time?
 

  • Does anyone know of a good resource for DXL, I find the reference guide lacking in times and some function(s)that I see in sample code found on the internet sometime I cannot find them in the DXL reference guide.


Thank you,
Jim

 

 

void defaultDescribeEvent(Object o, string sAttribute, History h, Buffer b) 
{
    HistoryType ht = null; ht = h.type;
        Buffer v = create()
        Buffer old = create(); old = h.plainOldValue;
        Buffer new = create(); new = h.plainNewValue; 
        diff (v, old,new, "\\cf1\\strike ", "\\cf3\\ul ")
        if (ht == modifyObject)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += h.attrName "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }else if (ht == deleteLink || ht == createLink)
        {
                b += "{\\b On }"
                Date d = h.date
                b += d ""
                b += " {\\b "
                b += h.author ""
                b += "} "
                // object modification has old and new values
                b += " {\\b " 
                b += goodStringOf(ht) "} "
                b += " \\par " 
                b += v
                b += " \\par "
        }
 
        delete old
        delete new
        delete v
}
 
string getHistoryForAttributes(Object o, void describeEvent(Object, string, History, Buffer))
{
        History h = null
        Buffer b = create()
        for h in o do
        {
                if(h.readlocked)
                        continue
 
                string sAttribute = h.attrName
                describeEvent(o, sAttribute, h, b)
                
        }
        string sHistory = stringOf(b)
        delete b
        return sHistory 
}
 
displayRichWithColour getHistoryForAttributes(obj, defaultDescribeEvent)

 

 

Each HistoryType uses only some of the History properties. When you query a property for a HistoryType that doesn't use that property you get your DXL errors. For example you get a dxl error querying h.attrName for type "createObject" history. I suspect also "plainOldValue" for type "CreateObject" such as at the top of your function below.

Also, in a strange twist of reality, the linkInitialName and targetInitialName properties are only readable by the Administrator.

However, I have found you can always trap such h.property query errors with noError() and lastError(). So if you initialize your variables with null values when you declare them, then have all your functions put noError() at the top and lastError() at the bottom, at least your code will come to a graceful end even if you don't get the information you are seeking.

  • Louie

I actually wrote a big script that searched my database for all History, and when I encountered a new History Type I'd query it with all the Properties, and keep track of which ones were illegal for which HistoryType. Took that information and coded it into my various functions, but alas then lost it the original list.

Re: Need help with Layout DXL and redline markup.
SystemAdmin - Sun Oct 09 16:29:19 EDT 2011

llandale - Fri Oct 07 13:33:43 EDT 2011
Each HistoryType uses only some of the History properties. When you query a property for a HistoryType that doesn't use that property you get your DXL errors. For example you get a dxl error querying h.attrName for type "createObject" history. I suspect also "plainOldValue" for type "CreateObject" such as at the top of your function below.

Also, in a strange twist of reality, the linkInitialName and targetInitialName properties are only readable by the Administrator.

However, I have found you can always trap such h.property query errors with noError() and lastError(). So if you initialize your variables with null values when you declare them, then have all your functions put noError() at the top and lastError() at the bottom, at least your code will come to a graceful end even if you don't get the information you are seeking.

  • Louie

I actually wrote a big script that searched my database for all History, and when I encountered a new History Type I'd query it with all the Properties, and keep track of which ones were illegal for which HistoryType. Took that information and coded it into my various functions, but alas then lost it the original list.

Hello,

I would like to get the in-link history is this even possible and how would I go about having the text change colors for the following " if (ht == createLink || ht == deleteLink) { b += " \\par " h.targetInitialName "/" h.targetAbsNo ""}" I would like to have the text be read on deletions and blue on the creation of links I know my logic would need to change but currently I cannot get the colors to change for my existing code.

Thank you,
Jim

Once again thank you for everyones input.

void defaultDescribeEvent(Object o, History h, Buffer b) 
{
    HistoryType ht = h.type 
    Date d = h.date
        b += "{\\b On }" d " {\\b " h.author "} " goodStringOf(ht) ""
        if (ht ==  createLink || ht == deleteLink) { b += " \\par " h.targetInitialName "/" h.targetAbsNo ""}
        // means an attribute has changed 
        if (ht == modifyObject) 
        { 
                Buffer v = create()
                Buffer old = create(); old = h.plainOldValue;
                Buffer new = create(); new = h.plainNewValue; 
                // redline markup
                diff (v, old, new, "\\cf1\\strike ", "\\cf3\\ul ")
 
                b += " {\\b " h.attrName "} " " \\par " v " \\par "
                
                delete old
                delete new
                delete v
          }
        else
        {
                b += " \\par "
        }
}
 
string getHistoryForAttributes(Object o, void describeEvent(Object, History, Buffer))
{
        History h = null
        Buffer b = create()
        for h in o do
        {
                if(h.readlocked)
                        continue
                        
                describeEvent(o, h, b)
        }
        string sHistory = stringOf(b)
        delete b
        return sHistory 
}
displayRichWithColour getHistoryForAttributes(obj, defaultDescribeEvent)

Re: Need help with Layout DXL and redline markup.
llandale - Mon Oct 10 12:37:51 EDT 2011

SystemAdmin - Sun Oct 09 16:29:19 EDT 2011

Hello,

I would like to get the in-link history is this even possible and how would I go about having the text change colors for the following " if (ht == createLink || ht == deleteLink) { b += " \\par " h.targetInitialName "/" h.targetAbsNo ""}" I would like to have the text be read on deletions and blue on the creation of links I know my logic would need to change but currently I cannot get the colors to change for my existing code.

Thank you,
Jim

Once again thank you for everyones input.

void defaultDescribeEvent(Object o, History h, Buffer b) 
{
    HistoryType ht = h.type 
    Date d = h.date
        b += "{\\b On }" d " {\\b " h.author "} " goodStringOf(ht) ""
        if (ht ==  createLink || ht == deleteLink) { b += " \\par " h.targetInitialName "/" h.targetAbsNo ""}
        // means an attribute has changed 
        if (ht == modifyObject) 
        { 
                Buffer v = create()
                Buffer old = create(); old = h.plainOldValue;
                Buffer new = create(); new = h.plainNewValue; 
                // redline markup
                diff (v, old, new, "\\cf1\\strike ", "\\cf3\\ul ")
 
                b += " {\\b " h.attrName "} " " \\par " v " \\par "
                
                delete old
                delete new
                delete v
          }
        else
        {
                b += " \\par "
        }
}
 
string getHistoryForAttributes(Object o, void describeEvent(Object, History, Buffer))
{
        History h = null
        Buffer b = create()
        for h in o do
        {
                if(h.readlocked)
                        continue
                        
                describeEvent(o, h, b)
        }
        string sHistory = stringOf(b)
        delete b
        return sHistory 
}
displayRichWithColour getHistoryForAttributes(obj, defaultDescribeEvent)

Don't recall getting the color to display in layouts, maybe someone can jump in here.

To get the "inlink" history you will need to go to the other object (source of links) and look for its outlink history, then the target of that history, and if it's your original object then display it.

Seems to me there are some problems with that, perhaps it's best if you just get the lnk."Created On" value and put that in your report.

  • Louie