Author Topic: EA.Element.Locked attribute  (Read 4029 times)

vladimir.liba

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
EA.Element.Locked attribute
« on: April 30, 2014, 12:14:30 am »
from documentation:
Locked
Boolean
Read/Write
Indicates if the element has been locked against further change.

But when i read this attribute, it returns me false for usecase, which was locked through UI (blue exclamation mark there), and returns true for usecase, which is not locked.

Anyone experienced this? Or I didn't understand that behaviour..

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: EA.Element.Locked attribute
« Reply #1 on: April 30, 2014, 12:46:06 am »
Not sure, but it depends on the setting of Require User Lock to Edit which reverses the meaning of a lock.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: EA.Element.Locked attribute
« Reply #2 on: April 30, 2014, 08:40:01 am »
At a guess, it works for the simple lock, not for security locks.

We could read all types of locks with this field, but then you still wouldn't be able to control the lock type when setting it.
« Last Edit: April 30, 2014, 08:44:29 am by simonm »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13274
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA.Element.Locked attribute
« Reply #3 on: April 30, 2014, 03:27:57 pm »
The .Locked attribute doesn't work (for that purpose anyway).

Here's the code I use:

Code: [Select]
/// <summary>
/// returns true if currently locked
/// </summary>
/// <returns>true if currently locked</returns>
public override bool isLocked()
{
      return (this.getLockedUser() != string.Empty);
}

Which uses
Code: [Select]
/// <summary>
/// returns the name of the user currently locking this element
/// </summary>
/// <returns>the name of the user currently locking this element</returns>
public override string getLockedUser()
{
      string lockedUser = string.Empty;
      //if (this.wrappedElement.Locked)
      //{
            string SQLQuery = @"select u.FirstName, u.Surname from t_seclocks s
                                          inner join t_secuser u on s.userID = u.userID
                                          where s.entityID = '" + this.wrappedElement.ElementGUID + "'";
            XmlDocument result = ((EAModel)this.model).SQLQuery(SQLQuery);
            XmlNode firstNameNode = result.SelectSingleNode("//FirstName");
            XmlNode lastNameNode = result.SelectSingleNode("//Surname");
            if (firstNameNode != null && lastNameNode != null)
            {
                  lockedUser = firstNameNode.InnerText + " " + lastNameNode.InnerText;
            }
      //}
      return lockedUser;
}

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: EA.Element.Locked attribute
« Reply #4 on: April 30, 2014, 05:11:32 pm »
Quote
The .Locked attribute doesn't work (for that purpose anyway).
As I said. Simple locks.

I'm not sure how you're trying to use your code, but EA will allow you to edit the element if you are the locking user or if you are a member of the group that holds the lock.

If there is no lock the behavior depends on the locking model. Require user lock to edit (locked until I hold a lock) or normal (unlocked unless someone else holds a lock)

Then there is version control still to take into account...