}
internal async void _set_structured_name (Folks.Persona persona,
- StructuredName sname)
+ StructuredName? sname)
{
- const string query_t = "DELETE { " +
+ const string query_d = "DELETE { " +
" ?p " + Trf.OntologyDefs.NCO_FAMILY + " ?family . " +
" ?p " + Trf.OntologyDefs.NCO_GIVEN + " ?given . " +
" ?p " + Trf.OntologyDefs.NCO_ADDITIONAL + " ?adi . " +
" OPTIONAL { ?p " + Trf.OntologyDefs.NCO_PREFIX + " ?prefix } . " +
" OPTIONAL { ?p " + Trf.OntologyDefs.NCO_SUFFIX + " ?suffix } . " +
" FILTER (tracker:id(?p) = %s) " +
- "} " +
- "INSERT { " +
+ "} ";
+ const string query_i = "INSERT { " +
" ?p " + Trf.OntologyDefs.NCO_FAMILY + " '%s'; " +
" " + Trf.OntologyDefs.NCO_GIVEN + " '%s'; " +
" " + Trf.OntologyDefs.NCO_ADDITIONAL + " '%s'; " +
"} ";
var p_id = ((Trf.Persona) persona).tracker_id ();
- string query = query_t.printf (p_id, sname.family_name, sname.given_name,
- sname.additional_names, sname.prefixes, sname.suffixes, p_id);
+
+ string query = query_d.printf (p_id);
+ if (sname != null)
+ {
+ query = query_i.printf (sname.family_name, sname.given_name,
+ sname.additional_names, sname.prefixes, sname.suffixes, p_id);
+ }
+
yield this._tracker_update (query, "_set_structured_name");
}
yield ((Trf.PersonaStore) this.store)._set_avatar (this, avatar);
}
- private StructuredName _structured_name;
+ private StructuredName? _structured_name = null;
/**
* {@inheritDoc}
*/
- public StructuredName structured_name
+ public StructuredName? structured_name
{
get { return this._structured_name; }
public set
this._gender = Gender.UNSPECIFIED;
this._full_name = fullname;
this._tracker_id = tracker_id;
- this._structured_name = new StructuredName (null, null, null, null, null);
+ this._structured_name = null;
this._phone_numbers = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
{
if (family_name != null)
{
- this._structured_name.family_name = family_name;
+ if (this._structured_name == null)
+ {
+ this._structured_name =
+ new StructuredName (family_name, null, null, null, null);
+ }
+ else
+ {
+ this._structured_name.family_name = family_name;
+ }
+
this.notify_property ("structured-name");
}
}
{
if (given_name != null)
{
- this._structured_name.given_name = given_name;
+ if (this._structured_name == null)
+ {
+ this._structured_name =
+ new StructuredName (null, given_name, null, null, null);
+ }
+ else
+ {
+ this._structured_name.given_name = given_name;
+ }
+
this.notify_property ("structured-name");
}
}
{
if (additional_names != null)
{
- this._structured_name.additional_names = additional_names;
+ if (this._structured_name == null)
+ {
+ this._structured_name =
+ new StructuredName (null, null, additional_names, null, null);
+ }
+ else
+ {
+ this._structured_name.additional_names = additional_names;
+ }
+
this.notify_property ("structured-name");
}
}
{
if (prefixes != null)
{
- this._structured_name.prefixes = prefixes;
+ if (this._structured_name == null)
+ {
+ this._structured_name =
+ new StructuredName (null, null, null, prefixes, null);
+ }
+ else
+ {
+ this._structured_name.prefixes = prefixes;
+ }
+
this.notify_property ("structured-name");
}
}
{
if (suffixes != null)
{
- this._structured_name.suffixes = suffixes;
+ if (this._structured_name == null)
+ {
+ this._structured_name =
+ new StructuredName (null, null, null, null, suffixes);
+ }
+ else
+ {
+ this._structured_name.suffixes = suffixes;
+ }
+
this.notify_property ("structured-name");
}
}