1
Bugs and Issues / Re: Document generation broken in v16.1
« on: July 25, 2025, 06:08:31 pm »
I use the latest available 17.1.1712 (x64)
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
/**
* Get the package ids of the given package tree (string = like #BRANCH# in search window).
*
* https://sparxsystems.com/forums/smf/index.php/topic,46180.msg270523.html#msg270523
* https://sparxsystems.com/forums/smf/index.php/topic,38987.msg259113.html#msg259113
*/
function GetPackageTreeIDArray(package /* : EA.Package */) // return: Array of descandant PackageIDs
{
if (package == null) return [];
// start with current package
var allPackages = [package.PackageID];
// get all child package IDs
return _GetChildPackageIDs(allPackages, allPackages);
}
function GetPackageTreeIDString(package /* : EA.Package */) // return: String of descandant PackageIDs like #branch#
{
var ids = GetPackageTreeIDArray(package)
return "" ? (ids.length == 0) : ids.join(",");
}
function _GetChildPackageIDs(allPackageIDs /* : Array of PackageIDs */, parentPackageIDs /* : Array of PackageIDs */) // return: Array of PackageIDs
{
// make sure there is at least a 0 is in
if (parentPackageIDs.length == 0)
{
parentPackageIDs.push(0);
}
// get all child package IDs (recursively)
var sqlQuery = "SELECT package.Package_ID FROM t_package package WHERE package.Parent_ID IN (" + parentPackageIDs.join(", ") + ")";
var queryResult = Repository.SQLQuery(sqlQuery);
var childPackageIDs = XMLGetNodeTextArray(XMLParseXML(queryResult), "//Row/Package_ID");
allPackageIDs = allPackageIDs.concat(childPackageIDs);
if ( childPackageIDs.length > 0)
{
allPackageIDs = _GetChildPackageIDs(allPackageIDs, childPackageIDs);
}
return allPackageIDs;
}
In the meantime I made better alternative, see github