Book a Demo

Author Topic: ApplyUserLockRecursive  (Read 5105 times)

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
ApplyUserLockRecursive
« on: November 13, 2018, 11:27:56 pm »
Hello,

we wanted to automate the transfer of a small package from one EA model to another one via XMI-export/import.

The target model has security enabled, therefore we lock the according target package via ApplyUserLockRecursive(true, true, true).
But we found the XMI import into the target model is failing because it seems not all elements within the target package got locked.

When analyzing we came across that apparently ApplyUserLockRecursive (via EA13.5 API) doesn't lock diagram elements like note-elements or text-elements which are part of diagrams. But then this seems to make it impossible to import a XMI file to the according package via automation API.

Anyone knows a solution / different approach to this?

Thank you
Markus

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: ApplyUserLockRecursive
« Reply #1 on: November 13, 2018, 11:36:06 pm »
Can't you simply call ApplyUserLock on each element and do that recursively?

Or are notes etc not present in the .Elements collections?

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: ApplyUserLockRecursive
« Reply #2 on: November 14, 2018, 10:37:55 am »
Hi Markus,

We gave up on API based locking.  Instead, as part of our overnight processing, we run queries to reset the security on all necessary objects to the correct value.  Since then we've only had security and locking problems extremely rarely (and typically caused by people leaving a livelock on an element by not exiting the product overnight).

If you need help with the queries, let me know.  They're pretty straightforward.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: ApplyUserLockRecursive
« Reply #3 on: November 14, 2018, 05:17:18 pm »
Hi Paolo and Geert,

thanks for your replies.

It seems that calling ApplyUserLock on Diagram objects does lock all elements, so seems we have to implement ApplyUserLockRecursive by ourselves.

Paolo, would it be possible to share some further details with respect the queries you run?

Thanks again.
Markus

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: ApplyUserLockRecursive
« Reply #4 on: November 16, 2018, 12:03:39 pm »
Hi Markus,

here's a couple of the queries we use.  They are ANSI-92 MS Access, but you should be able to convert (if necessary).

FIX_IncorrectlyLockedItemsInPackage
Code: [Select]
UPDATE t_seclocks AS PL INNER JOIN ((t_seclocks AS OL INNER JOIN t_object AS O ON OL.EntityID = O.ea_guid) INNER JOIN t_package AS P ON O.Package_ID = P.Package_ID) ON PL.EntityID = P.ea_guid SET OL.GroupID = [PL].[GroupID], OL.UserID = [PL].[UserID]
WHERE (((OL.GroupID)<>[PL].[GroupID]));

FIX_IncorrectlyLockedDiagramsInPackage
Code: [Select]
UPDATE (t_secgroup AS OG INNER JOIN t_seclocks AS OL ON OG.GroupID = OL.GroupID) INNER JOIN (((t_secgroup AS PG INNER JOIN t_seclocks AS PL ON PG.GroupID = PL.GroupID) INNER JOIN t_package AS P ON PL.EntityID = P.ea_guid) INNER JOIN t_diagram AS D ON P.Package_ID = D.Package_ID) ON OL.EntityID = D.ea_guid SET OL.GroupID = [PL].[GroupID], OL.UserID = [PL].[UserID]
WHERE (((OL.GroupID)<>[PL].[GroupID]));

They are part of a larger MS Access macro that also reports on locking errors etc.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!