Book a Demo

Author Topic: Hierararchical Manage Locks for the love of...  (Read 9575 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Hierararchical Manage Locks for the love of...
« on: October 24, 2013, 05:48:43 pm »
Brrrring!

- EA Support, Uffe.
- Yes, hello, so-and-so is off sick today. Could you unlock such-and-such a package?
- I can release all so-and-so's locks, is that OK?
- No, just package such-and-such please.
- OK, give me a couple of hours.

Could we please get either a tree view in the Manage Locks dialog, or a button Unlock Recursive, or a pop-up "Do you wish to unlock child elements as well?"

I mean OK, fine, I'm a consultant, I get paid by the hour. But I'd rather be developing custom profiles or a cool Add-In than unravelling a flattened-out package hierarchy to unlock stuff selectively.
Hell, I'd rather be battling with the RTF template editor...!
My theories are always correct, just apply them to the right reality.

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Hierararchical Manage Locks for the love of...
« Reply #1 on: October 26, 2013, 06:31:08 pm »
Hi,

it would be something like that:

Code: [Select]
               //lockiteration from lockbreaker and exit
        public static bool lockiteration(EA.Package lockpackage, EA.Repository _Repo)
        {
            string lockbreaker = null;
            string lockbreaker_E = null;
            string lockbreaker_E_I = null;
            string lockbreaker_E_D = null;
            string lockbreaker_D = null;
            foreach (EA.Element element in lockpackage.Elements)
            {
                try
                {
                    lockbreaker_E = element.ElementGUID;
                    _Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker_E + "'");
                }
                catch
                {
                    MessageBox.Show("Element Lock could not be released", "Failure", MessageBoxButtons.OK);
                    return false;
                }
            }

            foreach (EA.Element element in lockpackage.Element.Elements)
            {
                try
                {
                    lockbreaker_E_I = element.ElementGUID;
                    _Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker_E_I + "'");
                }
                catch
                {
                    MessageBox.Show("Element Lock could not be released", "Failure", MessageBoxButtons.OK);
                    return false;
                }
            }
            foreach (EA.Diagram diagram in lockpackage.Element.Diagrams)
            {
                try
                {
                    lockbreaker_E_D = diagram.DiagramGUID;
                    _Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker_E_D + "'");
                }
                catch
                {
                    MessageBox.Show("Diagram lock could not be released", "Failure", MessageBoxButtons.OK);
                    return false;
                }
            }

            foreach (EA.Diagram diagram in lockpackage.Diagrams)
            {
                try
                {
                    lockbreaker_D = diagram.DiagramGUID;
                    _Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker_D + "'");
                }
                catch
                {
                    MessageBox.Show("Diagram lock could not be released", "Failure", MessageBoxButtons.OK);
                    return false;
                }
            }

            foreach (EA.Package package in lockpackage.Packages)
            {
                lockpackage = package;
                lockbreaker = lockpackage.PackageGUID;
                _Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker + "'");
                if (!lockiteration(lockpackage, _Repo))
                    return false;
            }
            return true;
        }

not complete but working for the elements
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Re: Hierararchical Manage Locks for the love of...
« Reply #2 on: November 12, 2013, 01:13:58 pm »
damn fine idea, must be pretty bad if you prefer using the RTF editor though
Orthogonality rules
Position and Team disestablished, thanks austerity.
Now itinerant.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hierararchical Manage Locks for the love of...
« Reply #3 on: November 14, 2013, 06:01:05 pm »
In one of my addins I actually implemented a "steal lock" function to avoid this type of issues.
Now my users can steal any lock they need with a push of a button.
I also implemented what I call "smart locking". When locking a diagram it also locks the parent element/package and all elements that are local to the diagram (but not everything else that is shown on the diagram).
When locking an operation it also locks the implementation diagram etc...

I now never have to unlock anything for anyone anymore.

Geert

PS. I also never battle RTF generator. I tried once, and then decided Id'd rather write my own document generator; which I did.

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Hierararchical Manage Locks for the love of...
« Reply #4 on: November 14, 2013, 06:26:21 pm »
That's what I did with the lockieration (code above)

Any User can force the whole package to be unlocked by the pressing of one button. To make it easier and more reproduceable

          
Code: [Select]
EA.IDualMailInterface Mailer = Repo.GetMailInterface();
          EA.Package lockpackage = Repo.GetTreeSelectedPackage();
          string lockpackagename = lockpackage.Name;
          string username = Repo.GetCurrentLoginUser();
          string subject = "Locked '" + lockpackagename + "' force-unlocked by " + username + "";
          string usernameGUID = ENARTalis_main.delxml(Repo.SQLQuery("Select UserID from t_secuser WHERE UserLogin ='" + username + "'"));
          string RecipientGUID = ENARTalis_main.delxml(Repo.SQLQuery("Select UserID from t_secuser WHERE UserLogin ='admin'"));
          string Message = "Lock removed by deleting lockinformation";
          try
          {
              Mailer.SendMailMessage(RecipientGUID, subject, EA.MessageFlag.mfPurple, Message);
              Mailer.SendMailMessage(usernameGUID, subject, EA.MessageFlag.mfPurple, Message);
          }
          catch (Exception)
          {
              MessageBox.Show("Mail has not been sent!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
              return;
          }
          bool success = true;
          string lockbreaker = null;
          lockbreaker = lockpackage.PackageGUID;
          Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + lockbreaker + "'");
          success = ea.ENARTalis_main.lockiteration(lockpackage, Repo);

The MailInterface was just for playing purpose (And a bit of statistic, how often it is really used)  :)

Additional at the Event EA_FileClose():

Code: [Select]
                   
string usernameGUID = Repo.GetCurrentLoginUser(true);
string lockeditemsfile = Repo.SQLQuery("Select EntityID from t_seclocks where UserID = '" + usernameGUID + "'");
string lockeditems = xmlnode(lockeditemsfile, "</EntityID>");
string[] split = lockeditems.Split(new Char[] { ',' });
foreach (string s in split)
                    {
                        Repo.Execute("DELETE FROM t_seclocks WHERE EntityID='" + s + "'");
                    }


Regards

Stefan

Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Hierararchical Manage Locks for the love of...
« Reply #5 on: November 14, 2013, 09:05:30 pm »
Yes, well and good, but my point is that this function should be in the admin GUI. It would surely be a very simple one for Sparx to implement, since there already are recursive lock/unlock functions.

Leaving aside the fact that allowing all users the option of stealing each others' locks defeats the purpose of having locks in the first place, there's way too much hacking required in order to effectively administer an EA project.
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Hierararchical Manage Locks for the love of...
« Reply #6 on: November 14, 2013, 09:12:28 pm »
Uffe,

I think we all support your request, just sharing the workarounds we developed over time to make up for the lack of usability in EA.

Geert

skiwi

  • EA Expert
  • ****
  • Posts: 2081
  • Karma: +46/-82
    • View Profile
Re: Hierararchical Manage Locks for the love of...
« Reply #7 on: April 24, 2019, 08:20:34 am »
Time to revive these suggestions?
Orthogonality rules
Position and Team disestablished, thanks austerity.
Now itinerant.