* Add AbstractFieldDetails.id to identify instances of details
* Deprecate PostalAddress.uid in favor of AbstractFieldDetails.id
* Deprecate NoteFieldDetails.uid in favor of AbstractFieldDetails.id
+* Deprecate Role.uid in favor of AbstractFieldDetails.id
Behavior changes:
* PostalAddress.equal() now ignores PostalAddress.uid
var title = r_info[Trf.RoleFields.TITLE];
var organisation = r_info[Trf.RoleFields.DEPARTMENT];
- var new_role = new Role (title, organisation, tracker_id);
+ var new_role = new Role (title, organisation, null);
new_role.role = role;
var role_fd = new RoleFieldDetails (new_role);
+ role_fd.id = tracker_id;
role_fds.add (role_fd);
}
internal bool _add_role (string tracker_id, string? role, string? title, string? org)
{
- var new_role = new Role (title, org, tracker_id);
+ var new_role = new Role (title, org, null);
new_role.role = role;
var role_fd = new RoleFieldDetails (new_role);
+ role_fd.id = tracker_id;
if (this._roles.add (role_fd))
{
this.notify_property ("roles");
{
foreach (var role_fd in this._roles)
{
- if (role_fd.value.uid == tracker_id)
+ if (role_fd.id == tracker_id)
{
this._roles.remove (role_fd);
this.notify_property ("roles");
set { this._role = (value != null ? value : ""); }
}
+ private string _uid;
/**
* The UID that distinguishes this role.
*/
+ [Deprecated (since = "UNRELEASED", replacement = "AbstractFieldDetails.id")]
public string uid
{
get { return _uid; }
*/
public class Folks.RoleFieldDetails : AbstractFieldDetails<Role>
{
+ private string _id;
+ /**
+ * {@inheritDoc}
+ */
+ public override string id
+ {
+ get { return this._id; }
+ set
+ {
+ this._id = (value != null ? value : "");
+
+ /* Keep the Role.uid sync'd from our id */
+ if (this._id != this.value.uid)
+ this.value.uid = this._id;
+ }
+ }
+
/**
* Create a new RoleFieldDetails.
*
this.value = value;
if (parameters != null)
this.parameters = parameters;
+
+ /* We keep these sync'd both directions */
+ this.id = this.value.uid;
+
+ /* Keep the Role.uid sync'd to our id */
+ this.value.notify["uid"].connect ((s, p) =>
+ {
+ if (this.id != this.value.uid)
+ this.id = this.value.uid;
+ });
}
/**
var role_expected = new Role ("boss", "Company");
role_expected.role = "Role";
var role_fd_expected = new RoleFieldDetails (role_expected);
+
+ /* We copy the tracker_id - we don't know it.
+ * We could get it from the 1st personas iid but there is no
+ * real need. */
+ role_fd_expected.id = role_fd.id;
+
if (role_fd.equal (role_fd_expected))
{
+ /* Ensure that setting the Role uid directly (which is
+ * deprecated) is equivalent to setting the id on a
+ * RoleFieldDetails directly */
+ var role_2 = new Role (
+ role_expected.title,
+ role_expected.organisation_name,
+ role_fd.id);
+ role_2.role = role_expected.role;
+ var role_fd_2 = new RoleFieldDetails (role_2);
+ assert (role_fd.equal (role_fd_2));
+ assert (role_fd.id == role_fd_2.id);
+
this._found_role = true;
this._main_loop.quit ();
}