Pages

Monday, February 7, 2011

How to use TreeNode to navigate objects in the AOT

During a code merge into an environment managed by another company, I came across some tables with "UNKNOWN" delete actions in their production environment.  This worried me a little bit, so I whipped up a quick job to search every table for unknown delete actions to see what the real damage was.  This demonstrates how to use TreeNode to traverse the AOT.  The reason I used "subStr" for a portion of the code was I also searched for "DEL_" delete actions.



static void findTablesWithSpecificDeleteAction(Args _args)
{
    #AOT
    #Properties
    TreeNode    rootNode;
    TreeNode    childNode;
    TreeNode    tempNode;
    ;
    rootNode = infolog.findNode(#TablesPath).AOTfirstChild();
    while (rootNode)
    {
        childNode = rootNode.AOTfindChild('DeleteActions');
        if (childNode)
        {
            tempNode = childNode.AOTfirstChild();
            while (tempNode)
            {
                if (subStr(tempNode.AOTname(), 1, 3) == "UNK")
                {
                    info(tempNode.treeNodePath());
                }
                tempNode = tempNode.AOTnextSibling();
            }
        }
        rootNode = rootNode.AOTnextSibling();
    }
}

No comments:

Post a Comment