Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: OpenIT Solutions on August 31, 2019, 01:01:41 am

Title: API to get username holding lock on element or package
Post by: OpenIT Solutions on August 31, 2019, 01:01:41 am
Hi,

Is there an API to get username or group holding lock on an element or package ?

Regards,

Jon.
Title: Re: API to get username holding lock on element or package
Post by: Geert Bellekens on August 31, 2019, 02:58:18 am
No. You'll have to get it using Repository.SQLQuery.

I did so many years ago in an add-in.

Geert
Title: Re: API to get username holding lock on element or package
Post by: OpenIT Solutions on September 04, 2019, 06:44:22 pm
Hi,

I wanted the username as I wanted to clone an element, this would fail if the package containing the element was locked to someone else. The easier solution I ended up using is below, this changes the elementid of the lock to a random guid, I can then clone and set the lock back. Works for my purpose - might help someone else...


guid = Left(CreateObject("Scriptlet.TypeLib").Guid,38)
Repository.Execute ("UPDATE t_seclocks set EntityID = '" & guid & "' WHERE EntityID = '" & thePackage.PackageGUID & "'")
set newElement = theElement.Clone
Repository.Execute ("UPDATE t_seclocks set EntityID = '" & thePackage.PackageGUID & "' WHERE EntityID = '" & guid & "'")