I would like to delete some packages from the Enterprise Architect data model with the Enterprise Architect Java API.
What is the behavior of the Enterprise Architect when I delete a package in the package collection?
Will I produce orphans, because I won´t delete the underlying packages (and other elements) explicitly?
My code to delete a specific package:
org.sparx.Package delPackage = repo.GetPackageByGuid(delPackageGUID);
org.sparx.Package supraPackage = repo.GetPackageByID(delPackage.GetParentID());
org.sparx.Collection<org.sparx.Package> packages = supraPackage.GetPackages();
Iterator<org.sparx.Package> packageIter = packages.iterator();
org.sparx.Package tempPackage;
short index = 0;
short foundIndex = -1;
packageLoop:
while (packageIter.hasNext())
{
tempPackage = packageIter.next();
if (tempPackage.GetPackageGUID().equals(delPackageGUID) == true)
{
foundIndex = index;
break packageLoop;
}
index++;
}
if (foundIndex < 0)
{
throw new Exception("some error message");
}
if (packages.GetAt(foundIndex).GetPackageGUID().equals(delPackageGUID) == false)
{
throw new Exception("some error message");
}
else
{
delPackage.ApplyUserLock();
delPackage.GetLastError();
packages.DeleteAt(foundIndex, false);
packages.GetLastError();
//Update
packages.Refresh();
}