Class: Org::Familysearch::Ws::Familytree::V2::Schema::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-fs-stack/enunciate/familytree.rb,
lib/ruby-fs-stack/familytree/person.rb

Overview

A Family Tree person.

Direct Known Subclasses

PedigreePerson, SearchPerson

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assertionsObject

A collection of assertions for this person.



3168
3169
3170
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3168

def assertions
  @assertions
end

#changesObject

A list of changes to the person



3178
3179
3180
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3178

def changes
  @changes
end

#discussionsObject

The discussions about this person.



3180
3181
3182
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3180

def discussions
  @discussions
end

#familiesObject

A collection of families for this person.



3170
3171
3172
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3170

def families
  @families
end

#idObject

The id of the person.



3158
3159
3160
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3158

def id
  @id
end

#identifiersObject

A collection of identifiers for this person.



3166
3167
3168
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3166

def identifiers
  @identifiers
end

#parentsObject

A collection of parents for this person.



3172
3173
3174
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3172

def parents
  @parents
end

#personasObject

A collection of persona references for this person.



3174
3175
3176
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3174

def personas
  @personas
end

#personIdObject

In the case of a persona, the id of the person of which this is a persona.



3160
3161
3162
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3160

def personId
  @personId
end

#propertiesObject

A collection of properties for this person.



3164
3165
3166
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3164

def properties
  @properties
end

#relationshipsObject

The relationships.



3176
3177
3178
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3176

def relationships
  @relationships
end

#requestedIdObject

The id of the person.



3154
3155
3156
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3154

def requestedId
  @requestedId
end

#tempIdObject

A temporary id for this person (e.g. for a person not persisted yet).



3162
3163
3164
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3162

def tempId
  @tempId
end

#versionObject

The version number for this person.



3156
3157
3158
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3156

def version
  @version
end

#watchesObject

The changes about this person.



3182
3183
3184
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3182

def watches
  @watches
end

Class Method Details

.from_json(o) ⇒ Object

constructs a Person from a (parsed) JSON hash



3262
3263
3264
3265
3266
3267
3268
3269
3270
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3262

def self.from_json(o)
  if o.nil?
    return nil
  else
    inst = new
    inst.init_jaxb_json_hash o
    return inst
  end
end

Instance Method Details

#add_baptism(options) ⇒ Object

Add a baptism ordinance

Params

  • options - accepts a :date, :place, and :temple option

Example

person.add_baptism :date => '14 Aug 2009', :temple => 'SGEOR', :place => 'Salt Lake City, Utah'


321
322
323
324
325
# File 'lib/ruby-fs-stack/familytree/person.rb', line 321

def add_baptism(options)
  add_assertions!
  options[:type] = 'Baptism'
  assertions.add_ordinance(options)
end

#add_birth(options) ⇒ Object

Add an event with type of Birth

Params

  • options - accepts a :date and :place option

Example

person.add_birth :date => '12 Aug 1902', :place => 'United States'


170
171
172
173
174
# File 'lib/ruby-fs-stack/familytree/person.rb', line 170

def add_birth(options)
  add_assertions!
  options[:type] = 'Birth'
  assertions.add_event(options)
end

#add_confirmation(options) ⇒ Object

Add a confirmation ordinance

Params

  • options - accepts a :date, :place, and :temple option

Example

person.add_confirmation :date => '14 Aug 2009', :temple => 'SGEOR', :place => 'Salt Lake City, Utah'


335
336
337
338
339
# File 'lib/ruby-fs-stack/familytree/person.rb', line 335

def add_confirmation(options)
  add_assertions!
  options[:type] = 'Confirmation'
  assertions.add_ordinance(options)
end

#add_death(options) ⇒ Object

Add an event with type of Birth

Params

  • options - accepts a :date and :place option

Example

person.add_birth :date => '12 Aug 1902', :place => 'United States'


201
202
203
204
205
# File 'lib/ruby-fs-stack/familytree/person.rb', line 201

def add_death(options)
  add_assertions!
  options[:type] = 'Death'
  assertions.add_event(options)
end

#add_endowment(options) ⇒ Object

Add a endowment ordinance

Params

  • options - accepts a :date, :place, and :temple option

Example

person.add_endowment :date => '14 Aug 2009', :temple => 'SGEOR', :place => 'Salt Lake City, Utah'


363
364
365
366
367
# File 'lib/ruby-fs-stack/familytree/person.rb', line 363

def add_endowment(options)
  add_assertions!
  options[:type] = 'Endowment'
  assertions.add_ordinance(options)
end

#add_gender(value) ⇒ Object

Convenience method for adding the gender.

Params

value - ‘Male’ or ‘Female’



91
92
93
94
# File 'lib/ruby-fs-stack/familytree/person.rb', line 91

def add_gender(value)
  add_assertions!
  assertions.add_gender(value)
end

#add_initiatory(options) ⇒ Object

Add a initiatory ordinance

Params

  • options - accepts a :date, :place, and :temple option

Example

person.add_initiatory :date => '14 Aug 2009', :temple => 'SGEOR', :place => 'Salt Lake City, Utah'


349
350
351
352
353
# File 'lib/ruby-fs-stack/familytree/person.rb', line 349

def add_initiatory(options)
  add_assertions!
  options[:type] = 'Initiatory'
  assertions.add_ordinance(options)
end

#add_name(value) ⇒ Object

Convenience method for adding a name. It fills in the necessary structure underneath to create the name.

Params

value - the name to be added

Example

person.add_name 'Parker Felch' # Sets the fullText to "Parker Felch"
person.add_name 'Parker Jones /Felch/' # Does not set the fullText, but sets the name pieces.


106
107
108
109
# File 'lib/ruby-fs-stack/familytree/person.rb', line 106

def add_name(value)
  add_assertions!
  assertions.add_name(value)
end

#add_sealing_to_parents(options) ⇒ Object

Add a sealing to parents ordinance

Params

  • options - accepts a :date, :place, :temple, :mother, and :father option

Example

person.add_sealing_to_parents :date => '14 Aug 2009', :temple => 'SGEOR', :place => 'Salt Lake City, Utah'

Raises:

  • (ArgumentError)


377
378
379
380
381
382
383
# File 'lib/ruby-fs-stack/familytree/person.rb', line 377

def add_sealing_to_parents(options)
  raise ArgumentError, ":mother option is required" if options[:mother].nil?
  raise ArgumentError, ":father option is required" if options[:father].nil?
  add_assertions!
  options[:type] = OrdinanceType::Sealing_to_Parents
  assertions.add_ordinance(options)
end

#baptismsObject



289
290
291
# File 'lib/ruby-fs-stack/familytree/person.rb', line 289

def baptisms
  select_ordinances('Baptism')
end

#birthObject

It should return the selected birth assertion unless it is not set in which case it will return the first



134
135
136
137
138
# File 'lib/ruby-fs-stack/familytree/person.rb', line 134

def birth
  birth = births.find{|b|!b.selected.nil?}
  birth ||= births[0]
  birth
end

#birthsObject



128
129
130
# File 'lib/ruby-fs-stack/familytree/person.rb', line 128

def births
  select_events('Birth')
end

#confirmationsObject



293
294
295
# File 'lib/ruby-fs-stack/familytree/person.rb', line 293

def confirmations
  select_ordinances('Confirmation')
end

#create_combine(persons) ⇒ Object

This method should only be called from FamilytreeV2::Communicator#combine

Params

  • persons - an array of person objects. All persons must have an id and version



404
405
406
407
408
409
410
411
412
# File 'lib/ruby-fs-stack/familytree/person.rb', line 404

def create_combine(persons)
  self.personas = Org::Familysearch::Ws::Familytree::V2::Schema::PersonPersonas.new
  self.personas.personas = persons.map do |person|
    persona = Org::Familysearch::Ws::Familytree::V2::Schema::PersonPersona.new
    persona.id = person.id
    persona.version = person.version
    persona
  end
end

#create_relationship(options) ⇒ Object

This method should really only be called from FamilytreeV2::Communicator#write_relationships

Params

  • options - requires the following:

    • :type - ‘parent’, ‘child’, ‘spouse’

    • :with - ID of the person with whom you are making the relationship

    • :lineage (optional) - ‘Biological’, ‘Adoptive’, etc.

    • :event - a hash with values => ‘Marriage’, :date => ‘15 Nov 2007’, :place => ‘Utah, United States’

Raises:

  • (ArgumentError)


393
394
395
396
397
398
# File 'lib/ruby-fs-stack/familytree/person.rb', line 393

def create_relationship(options)
  raise ArgumentError, ":type option is required" if options[:type].nil?
  raise ArgumentError, ":with option is required" if options[:with].nil?
  add_relationships!
  self.relationships.add_relationship(options)
end

#deathObject

It should return the selected death assertion unless it is not set in which case it will return the first



146
147
148
149
150
# File 'lib/ruby-fs-stack/familytree/person.rb', line 146

def death
  death = deaths.find{|b|!b.selected.nil?}
  death ||= deaths[0]
  death
end

#deathsObject



140
141
142
# File 'lib/ruby-fs-stack/familytree/person.rb', line 140

def deaths
  select_events('Death')
end

#divorces(for_person) ⇒ Object

This should only be called on a person containing relationships



158
159
160
# File 'lib/ruby-fs-stack/familytree/person.rb', line 158

def divorces(for_person)
  select_spouse_events('Divorce',for_person)
end

#endowmentsObject



301
302
303
# File 'lib/ruby-fs-stack/familytree/person.rb', line 301

def endowments
  select_ordinances('Endowment')
end

#father_idObject



414
415
416
# File 'lib/ruby-fs-stack/familytree/person.rb', line 414

def father_id
  parent_id('Male')
end

#full_nameObject



60
61
62
# File 'lib/ruby-fs-stack/familytree/person.rb', line 60

def full_name
  self.full_names.first
end

#full_namesObject



50
51
52
53
54
55
56
57
58
# File 'lib/ruby-fs-stack/familytree/person.rb', line 50

def full_names
  if assertions && assertions.names
    return assertions.names.collect do |name|
      (name.value.forms[0].fullText.nil?) ? name.value.forms[0].buildFullText : name.value.forms[0].fullText
    end
  else
    []
  end
end

#genderObject



79
80
81
82
83
84
85
# File 'lib/ruby-fs-stack/familytree/person.rb', line 79

def gender
  if assertions && assertions.genders && assertions.genders[0] && assertions.genders[0].value
    assertions.genders[0].value.type
  else
    nil
  end
end

#init_jaxb_json_hash(_o) ⇒ Object

initializes this Person with a json hash



3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3227

def init_jaxb_json_hash(_o)
  @requestedId = String.from_json(_o['requestedId']) unless _o['requestedId'].nil?
  @version = String.from_json(_o['version']) unless _o['version'].nil?
  @id = String.from_json(_o['id']) unless _o['id'].nil?
  @personId = String.from_json(_o['personId']) unless _o['personId'].nil?
  @tempId = String.from_json(_o['tempId']) unless _o['tempId'].nil?
  @properties = Org::Familysearch::Ws::Familytree::V2::Schema::PersonProperties.from_json(_o['properties']) unless _o['properties'].nil?
  @identifiers = Org::Familysearch::Ws::Familytree::V2::Schema::PersonIdentifiers.from_json(_o['identifiers']) unless _o['identifiers'].nil?
  @assertions = Org::Familysearch::Ws::Familytree::V2::Schema::PersonAssertions.from_json(_o['assertions']) unless _o['assertions'].nil?
  if !_o['families'].nil?
    @families = Array.new
    _oa = _o['families']
    _oa.each { | _item | @families.push Org::Familysearch::Ws::Familytree::V2::Schema::FamilyReference.from_json(_item) }
  end
  if !_o['parents'].nil?
    @parents = Array.new
    _oa = _o['parents']
    _oa.each { | _item | @parents.push Org::Familysearch::Ws::Familytree::V2::Schema::ParentsReference.from_json(_item) }
  end
  @personas = Org::Familysearch::Ws::Familytree::V2::Schema::PersonPersonas.from_json(_o['personas']) unless _o['personas'].nil?
  @relationships = Org::Familysearch::Ws::Familytree::V2::Schema::PersonRelationships.from_json(_o['relationships']) unless _o['relationships'].nil?
  @changes = Org::Familysearch::Ws::Familytree::V2::Schema::Changes.from_json(_o['changes']) unless _o['changes'].nil?
  if !_o['discussions'].nil?
    @discussions = Array.new
    _oa = _o['discussions']
    _oa.each { | _item | @discussions.push Org::Familysearch::Ws::Familytree::V2::Schema::Discussion.from_json(_item) }
  end
  if !_o['watches'].nil?
    @watches = Array.new
    _oa = _o['watches']
    _oa.each { | _item | @watches.push String.from_json(_item) }
  end
end

#initiatoriesObject



297
298
299
# File 'lib/ruby-fs-stack/familytree/person.rb', line 297

def initiatories
  select_ordinances('Initiatory')
end

#marriages(for_person) ⇒ Object

This should only be called on a person containing relationships



153
154
155
# File 'lib/ruby-fs-stack/familytree/person.rb', line 153

def marriages(for_person)
  select_spouse_events('Marriage',for_person)
end

#mother_idObject



418
419
420
# File 'lib/ruby-fs-stack/familytree/person.rb', line 418

def mother_id
  parent_id('Female')
end

#sealing_to_parentsObject



305
306
307
# File 'lib/ruby-fs-stack/familytree/person.rb', line 305

def sealing_to_parents
  select_ordinances(OrdinanceType::Sealing_to_Parents)
end

#sealing_to_spouses(id) ⇒ Object



309
310
311
# File 'lib/ruby-fs-stack/familytree/person.rb', line 309

def sealing_to_spouses(id)
  select_relationship_ordinances(:relationship_type => 'spouse', :id => id, :type => OrdinanceType::Sealing_to_Spouse)
end

#select_birth_summary(value_id) ⇒ Object

Select the birth for the summary view. This should be called on a Person record that contains a person id and version.

Params

value_id - the value id of a birth assertion that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_birth_summary('1000134')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



188
189
190
191
# File 'lib/ruby-fs-stack/familytree/person.rb', line 188

def select_birth_summary(value_id)
  add_assertions!
  assertions.select_event_summary('Birth',value_id)
end

#select_death_summary(value_id) ⇒ Object

Select the death for the summary view. This should be called on a Person record that contains a person id and version.

Params

value_id - the value id of a death assertion that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_death_summary('1000134')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



219
220
221
222
# File 'lib/ruby-fs-stack/familytree/person.rb', line 219

def select_death_summary(value_id)
  add_assertions!
  assertions.select_event_summary('Death',value_id)
end

#select_father_summary(person_id) ⇒ Object

Select the father for the summary view. This should be called on a Person record that contains a person id and version.

Make sure you set both the mother and father before saving the person. Otherwise you will set a single parent as the summary.

Params

person_id - the person id of the father that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_father_summary('KWQS-BBQ')
person.select_mother_summary('KWQS-BBT')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



263
264
265
266
267
268
# File 'lib/ruby-fs-stack/familytree/person.rb', line 263

def select_father_summary(person_id)
  add_parents!
  couple = parents[0] || ParentsReference.new
  couple.select_parent(person_id,'Male')
  parents[0] = couple 
end

#select_mother_summary(person_id) ⇒ Object

Select the mother for the summary view. This should be called on a Person record that contains a person id and version.

Make sure you set both the mother and father before saving the person. Otherwise you will set a single parent as the summary.

Params

person_id - the person id of the mother that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_mother_summary('KWQS-BBQ')
person.select_father_summary('KWQS-BBT')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



240
241
242
243
244
245
# File 'lib/ruby-fs-stack/familytree/person.rb', line 240

def select_mother_summary(person_id)
  add_parents!
  couple = parents[0] || ParentsReference.new
  couple.select_parent(person_id,'Female')
  parents[0] = couple 
end

#select_name_summary(value_id) ⇒ Object

Select the name for the summary view. This should be called on a Person record that contains a person id and version.

Params

value_id - the value id of a name assertion that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_name_summary('1000134')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



123
124
125
126
# File 'lib/ruby-fs-stack/familytree/person.rb', line 123

def select_name_summary(value_id)
  add_assertions!
  assertions.select_name(value_id)
end

#select_spouse_summary(person_id) ⇒ Object

Select the spouse for the summary view. This should be called on a Person record that contains a person id and version.

Params

person_id - the person id of the spouse that you would like to set as the summary

Example

person = com.familytree_v2.person 'KWQS-BBR', :names => 'none', :genders => 'none', :events => 'none'
person.select_spouse_summary('KWQS-BBQ')
com.familytree_v2.save_person person

This is the recommended approach, to start with a “Version” person (no names, genders, or events)



282
283
284
285
286
287
# File 'lib/ruby-fs-stack/familytree/person.rb', line 282

def select_spouse_summary(person_id)
  add_families!
  family = FamilyReference.new
  family.select_spouse(person_id)
  families << family 
end

#spouse_idObject



422
423
424
425
426
427
# File 'lib/ruby-fs-stack/familytree/person.rb', line 422

def spouse_id
  if families && families[0] && families[0].parents
    spouse_ref = families[0].parents.find{|p|p.id != self.id}
    spouse_ref.id if spouse_ref
  end
end

#surnameObject



75
76
77
# File 'lib/ruby-fs-stack/familytree/person.rb', line 75

def surname
  surnames.first
end

#surnamesObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/ruby-fs-stack/familytree/person.rb', line 64

def surnames
  if assertions && assertions.names
    names =  assertions.names.collect do |name|
      name.value.forms[0].surname
    end
    return names.reject{|n|n.nil?}
  else
    []
  end
end

#to_jaxb_json_hashObject

the json hash for this Person



3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3185

def to_jaxb_json_hash
  _h = {}
  _h['requestedId'] = requestedId.to_jaxb_json_hash unless requestedId.nil?
  _h['version'] = version.to_jaxb_json_hash unless version.nil?
  _h['id'] = id.to_jaxb_json_hash unless id.nil?
  _h['personId'] = personId.to_jaxb_json_hash unless personId.nil?
  _h['tempId'] = tempId.to_jaxb_json_hash unless tempId.nil?
  _h['properties'] = properties.to_jaxb_json_hash unless properties.nil?
  _h['identifiers'] = identifiers.to_jaxb_json_hash unless identifiers.nil?
  _h['assertions'] = assertions.to_jaxb_json_hash unless assertions.nil?
  if !families.nil?
    _ha = Array.new
    families.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['families'] = _ha
  end
  if !parents.nil?
    _ha = Array.new
    parents.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['parents'] = _ha
  end
  _h['personas'] = personas.to_jaxb_json_hash unless personas.nil?
  _h['relationships'] = relationships.to_jaxb_json_hash unless relationships.nil?
  _h['changes'] = changes.to_jaxb_json_hash unless changes.nil?
  if !discussions.nil?
    _ha = Array.new
    discussions.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['discussions'] = _ha
  end
  if !watches.nil?
    _ha = Array.new
    watches.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['watches'] = _ha
  end
  return _h
end

#to_jsonObject

the json (string form) for this Person



3222
3223
3224
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3222

def to_json
  to_jaxb_json_hash.to_json
end