familysearch-gedcomx 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in familysearch-gedcomx.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jimmy Zimmerman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,119 @@
1
+ # FamilySearch::Gedcomx
2
+
3
+ This familysearch gem extension provides a structured data model for the application/x-fs-v1+json media type.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'familysearch-gedcomx'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install familysearch-gedcomx
18
+
19
+ *Note:* If you install the familysearch gem, this gem will automatically be installed by virtue of gem dependency.
20
+
21
+ ## Basic Usage
22
+
23
+ The FamilySearch API returns the application/x-fs-v1+json media type, which would be parsed into a Hash by any JSON parser. In the following usage examples, we will assume that we already have a Hash named fs_hash, which was parsed from the JSON.
24
+
25
+ familysearch = FamilySearch::Gedcomx::FamilySearch.new fs_hash
26
+ person = familysearch.persons[0] #=> FamilySearch::Gedcomx::Person object
27
+
28
+ If you are using the familysearch gem, the data returned from the client should already be a fa
29
+
30
+ ## Convenience Methods
31
+
32
+ Convenience methods have been added to the Person object to help you access data buried deep into the person data model.
33
+
34
+ person.full_name
35
+ #=> "Marshall P Felch"
36
+ person.surname
37
+ #=> "Felch"
38
+ person.given_name
39
+ #=> "Marshall P"
40
+
41
+ ### Vital Information
42
+
43
+ To access the vital events, the following methods have been created to make it easier to jump to the birth information.
44
+
45
+ person.birth
46
+ person.christening
47
+ person.death
48
+ person.burial
49
+
50
+ In the Gedcomx data model, standardized place information is not found within the Fact, but rather are found in a separate collection of places at the root of the FamilySearch object. This can be difficult to access, so as a convenience, when a FamilySearch::Gedcomx::FamilySearch object is parsed, it connects the PlaceReference to the PlaceDescription. This allows you to do the following.
51
+
52
+ person.birth.place.normalized.value
53
+ # => "Middlesex, Massachusetts, United States"
54
+
55
+ ## Traversing the Full Data Model
56
+
57
+ You can traverse the plain Gedcomx data model to get further details about names, facts, relationships, places, etc. Anything that appears in the underlying JSON should be retrievable via the data model objects.
58
+
59
+ person.facts.find{|f|f.type == "http://gedcomx.org/Birth"}.date.original
60
+ person.names.each do |name|
61
+ puts name.confidence #=> "http://gedcomx.org/Low"
62
+ puts name.attribution.contributor.resource #=> "https://familysearch.org/platform/users/agents/MMMM-MM8"
63
+ puts name.type #=> "http://gedcomx.org/BirthName"
64
+ name.nameForms.each do |form|
65
+ puts form.fullText
66
+ form.parts.each do |part|
67
+ puts part.type #=> "http://gedcomx.org/Surname"
68
+ #=> or "http://gedcomx.org/Given"
69
+ puts part.value
70
+ end
71
+ end
72
+ end
73
+
74
+ You can browse the entire data model schema in the lib/familysearch/gedcomx/data_model.rb file.
75
+ ### Objects are Hashes
76
+
77
+ Each object ultimately inherits from Hash and all of their attributes are stored as hash values. The methods, like #name or #name= simply map to the underlying ['name'] hash value. If desired, you can traverse the structures via Hash key access notations:
78
+
79
+ person['facts'].find{|f|f['type'] == 'http://gedcomx.org/Birth'}['date']['original']
80
+ #=> 'Jun 1834'
81
+ person['display']['gender'] #=> 'Male'
82
+
83
+ One major advantage of using a Hash-like structure for the data model objects is with JSON serialization. You simply pass the FamilySearch::Gedcomx::FamilySearch object to a JSON serializer and it will serialize the Hash appropriately.
84
+
85
+ ## Graph (Pedigree) Traversal
86
+
87
+ Many API use cases involve displaying family ancestral pedigrees. This gem provides a mechanism for connecting objects and traversing the graph. To take advantage of this, make persons-with-relationships requests and throw the result into a Graph object.
88
+
89
+ graph = FamilySearch::Gedcomx::Graph.new
90
+
91
+ # Get persons with relationships
92
+ familysearch_child = client.template('person-with-relationships').get({'person' => 'KWQS-BBQ'}).body
93
+
94
+ graph << familysearch_child
95
+ graph.root #=> the person of the object you just pushed into the graph
96
+ father_id = graph.root.father_id
97
+
98
+ familysearch_father = client.template('person-with-relationships').get({'person' => father_id}).body
99
+
100
+ graph << familysearch_father
101
+
102
+ graph.root.father #=> person object of the father you just pushed into the graph
103
+
104
+
105
+ ## Versioning
106
+
107
+ The major version of this gem will match the current value of the application/x-fs-v1+json media type. If the FamilySearch API bumps this to x-fs-v2+json, there should be a version of the gem released to match that version.
108
+
109
+ Minor version updates should indicate a potential break in backwards compatibility. If a new feature is introduced in this library that will potentially break a client relying on a "~> 1.0.0" dependency, then the minor version will be incremented.
110
+
111
+ Any other versions that introduce new features that are backwards compatible, will bump the patch number (1.0.1).
112
+
113
+ ## Contributing
114
+
115
+ 1. Fork it
116
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
117
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
118
+ 4. Push to the branch (`git push origin my-new-feature`)
119
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'familysearch/gedcomx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "familysearch-gedcomx"
8
+ spec.version = FamilySearch::Gedcomx::VERSION
9
+ spec.authors = ["Jimmy Zimmerman"]
10
+ spec.email = ["jimmy.zimmerman@gmail.com"]
11
+ spec.description = %q{A structured object model for the application/x-fs-v1+json media type.}
12
+ spec.summary = %q{A structured object model for the application/x-fs-v1+json media type}
13
+ spec.homepage = "https://github.com/jimmyz/familysearch-gedcomx-rb"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "hashie", "~> 2.0.5"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,5 @@
1
+ require "familysearch/gedcomx/version"
2
+ require "familysearch/gedcomx/super_dash"
3
+ require "familysearch/gedcomx/super_coercion"
4
+ require "familysearch/gedcomx/data_model"
5
+ require "familysearch/gedcomx/graph"
@@ -0,0 +1,665 @@
1
+ module FamilySearch
2
+ module Gedcomx
3
+ class ExtensibleData < SuperDash
4
+ include SuperCoercion
5
+ property :id
6
+ end
7
+
8
+ class Link < SuperDash
9
+ property :hreflang
10
+ property :template
11
+ property :title
12
+ property :allow
13
+ property :accept
14
+ property :rel
15
+ property :type
16
+ property :href
17
+ end
18
+
19
+ class HypermediaEnabledData < ExtensibleData
20
+ property :links
21
+ coerce_key :links, {'key' => Link}
22
+ end
23
+
24
+ class ResourceReference < SuperDash
25
+ property :resourceId
26
+ property :resource
27
+ end
28
+
29
+ class Address < ExtensibleData
30
+ property :city
31
+ property :country
32
+ property :postalCode
33
+ property :stateOrProvince
34
+ property :street
35
+ property :street2
36
+ property :street3
37
+ property :value
38
+ end
39
+
40
+ class OnlineAccount < ExtensibleData
41
+ property :accountName
42
+ property :serviceHomepage
43
+ coerce_key :serviceHomepage, [ResourceReference]
44
+ end
45
+
46
+ class Identifier < SuperDash
47
+ property :type
48
+ property :value
49
+ end
50
+
51
+ class TextValue < SuperDash
52
+ property :lang
53
+ property :value
54
+ end
55
+
56
+ class Agent < HypermediaEnabledData
57
+ property :accounts
58
+ property :addresses
59
+ property :emails
60
+ property :homepage
61
+ property :identifiers
62
+ property :names
63
+ property :openid
64
+ property :phones
65
+ coerce_key :accounts, [OnlineAccount]
66
+ coerce_key :addresses, [Address]
67
+ coerce_key :emails, [ResourceReference]
68
+ coerce_key :homepage, [ResourceReference]
69
+ coerce_key :identifiers, [Identifier]
70
+ coerce_key :names, [TextValue]
71
+ coerce_key :openid, ResourceReference
72
+ coerce_key :phones, [ResourceReference]
73
+ end
74
+
75
+ class Attribution < ExtensibleData
76
+ property :contributor
77
+ property :modified
78
+ property :changeMessage
79
+ coerce_key :contributor, ResourceReference
80
+ end
81
+
82
+ class ChangeInfo < SuperDash
83
+ property :objectModifier
84
+ property :operation
85
+ property :reason
86
+ property :parent
87
+ property :objectType
88
+ end
89
+
90
+ class Qualifier < SuperDash
91
+ property :value
92
+ end
93
+
94
+ class SourceReference < HypermediaEnabledData
95
+ property :description
96
+ property :resource
97
+ property :attribution
98
+ property :qualifiers
99
+
100
+ coerce_key :attribution, Attribution
101
+ coerce_key :qualifiers, [Qualifier]
102
+ end
103
+
104
+ class Note < HypermediaEnabledData
105
+ property :lang
106
+ property :subject
107
+ property :text
108
+ property :attribution
109
+ coerce_key :attribution, Attribution
110
+ end
111
+
112
+ class Conclusion < HypermediaEnabledData
113
+ property :confidence
114
+ property :lang
115
+ property :attribution
116
+ property :sources
117
+ property :analysis
118
+ property :notes
119
+ coerce_key :attribution, Attribution
120
+ coerce_key :sources, [SourceReference]
121
+ coerce_key :analysis, [ResourceReference]
122
+ coerce_key :notes, [Note]
123
+ end
124
+
125
+ class EvidenceReference < HypermediaEnabledData
126
+ property :resourceId
127
+ property :resource
128
+ property :analysis
129
+ property :attribution
130
+ coerce_key :analysis, ResourceReference
131
+ coerce_key :attribution, Attribution
132
+ end
133
+
134
+ class PlaceReference < ExtensibleData
135
+ property :description
136
+ property :field
137
+ property :original
138
+ coerce_key :field, EvidenceReference
139
+ # Not part of the GedcomX spec, but used for convenience.
140
+ property :normalized
141
+ end
142
+
143
+ class Date < ExtensibleData
144
+ property :original
145
+ property :formal
146
+ property :normalized
147
+ property :field
148
+ coerce_key :normalized, [TextValue]
149
+ coerce_key :field, EvidenceReference
150
+ end
151
+
152
+ class Fact < Conclusion
153
+ property :type
154
+ property :date
155
+ property :place
156
+ property :value
157
+ property :qualifiers
158
+ property :field
159
+ coerce_key :date, FamilySearch::Gedcomx::Date
160
+ coerce_key :place, PlaceReference
161
+ coerce_key :qualifiers, [Qualifier]
162
+ coerce_key :field, EvidenceReference
163
+ end
164
+
165
+ class ChildAndParentsRelationship < Conclusion
166
+ property :father
167
+ property :mother
168
+ property :child
169
+ property :fatherFacts
170
+ property :motherFacts
171
+ coerce_key :father, ResourceReference
172
+ coerce_key :mother, ResourceReference
173
+ coerce_key :child, ResourceReference
174
+ coerce_key :fatherFacts, [Fact]
175
+ coerce_key :motherFacts, [Fact]
176
+ end
177
+
178
+ class CitationField <SuperDash
179
+ property :name
180
+ property :value
181
+ end
182
+
183
+ class CollectionCoverage < HypermediaEnabledData
184
+ property :completeness
185
+ property :count
186
+ property :recordType
187
+ property :resourceType
188
+ property :spatial
189
+ property :temporal
190
+ coerce_key :spatial, PlaceReference
191
+ coerce_key :temporal, FamilySearch::Gedcomx::Date
192
+ end
193
+
194
+ class FacetValue < HypermediaEnabledData
195
+ property :title
196
+ property :value
197
+ property :count
198
+ end
199
+
200
+ class Facet < HypermediaEnabledData
201
+ property :type
202
+ property :title
203
+ property :key
204
+ property :facets
205
+ property :values
206
+ coerce_key :facets, [Facet]
207
+ coerce_key :values, [FacetValue]
208
+ end
209
+
210
+ class Collection < HypermediaEnabledData
211
+ property :lang
212
+ property :title
213
+ property :description
214
+ property :collection
215
+ property :size
216
+ property :coverage
217
+ property :facets
218
+ property :attribution
219
+ coerce_key :collection, ResourceReference
220
+ coerce_key :coverage, CollectionCoverage
221
+ coerce_key :facets, [Facet]
222
+ coerce_key :attribution, Attribution
223
+ end
224
+
225
+ class Comment < HypermediaEnabledData
226
+ property :text
227
+ property :created
228
+ property :contributor
229
+ coerce_key :contributor, ResourceReference
230
+ end
231
+
232
+ class Discussion < HypermediaEnabledData
233
+ property :title
234
+ property :details
235
+ property :created
236
+ property :contributor
237
+ property :modified
238
+ property :numberOfComments
239
+ property :comments
240
+ coerce_key :contributor, ResourceReference
241
+ coerce_key :comments, [Comment]
242
+ end
243
+
244
+ class DiscussionReference < HypermediaEnabledData
245
+ property :resource
246
+ end
247
+
248
+ class DisplayProperties < ExtensibleData
249
+ property :ascendancyNumber
250
+ property :birthDate
251
+ property :birthPlace
252
+ property :deathDate
253
+ property :deathPlace
254
+ property :descendancyNumber
255
+ property :gender
256
+ property :lifespan
257
+ property :name
258
+ end
259
+
260
+ class Document < Conclusion
261
+ property :textType
262
+ property :extracted
263
+ property :type
264
+ property :text
265
+ end
266
+
267
+ class Error < SuperDash
268
+ property :code
269
+ property :label
270
+ property :message
271
+ property :stacktrace
272
+ end
273
+
274
+ class Subject < Conclusion
275
+ property :extracted
276
+ property :evidence
277
+ property :media
278
+ property :identifiers
279
+
280
+ coerce_key :evidence, [EvidenceReference]
281
+ coerce_key :media, [SourceReference]
282
+ coerce_key :identifiers, [Identifier]
283
+ end
284
+
285
+ class EventRole < Conclusion
286
+ property :type
287
+ property :person
288
+ property :details
289
+ coerce_key :person, ResourceReference
290
+ end
291
+
292
+ class Event < Subject
293
+ property :type
294
+ property :date
295
+ property :place
296
+ property :roles
297
+ coerce_key :date, FamilySearch::Gedcomx::Date
298
+ coerce_key :place, PlaceReference
299
+ coerce_key :roles, [EventRole]
300
+ end
301
+
302
+ class Gender < Conclusion
303
+ property :type
304
+ property :field
305
+ coerce_key :field, EvidenceReference
306
+ end
307
+
308
+ class NamePart < ExtensibleData
309
+ property :value
310
+ property :type
311
+ property :field
312
+ property :qualifiers
313
+
314
+ coerce_key :field, EvidenceReference
315
+ coerce_key :qualifiers, [Qualifier]
316
+ end
317
+
318
+ class NameForm < ExtensibleData
319
+ property :lang
320
+ property :fullText
321
+ property :parts
322
+ property :field
323
+
324
+ coerce_key :parts, [NamePart]
325
+ coerce_key :field, EvidenceReference
326
+
327
+ def surname
328
+ return '' if parts.nil?
329
+ surname_piece = parts.find{|p|p.type == 'http://gedcomx.org/Surname'}
330
+ surname_piece ? surname_piece.value : ''
331
+ end
332
+
333
+ def given_name
334
+ return '' if parts.nil?
335
+ given_piece = parts.find{|p|p.type == 'http://gedcomx.org/Given'}
336
+ given_piece ? given_piece.value : ''
337
+ end
338
+
339
+ end
340
+
341
+ class Name < Conclusion
342
+ property :type
343
+ property :preferred
344
+ property :date
345
+ property :nameForms
346
+ coerce_key :date, FamilySearch::Gedcomx::Date
347
+ coerce_key :nameForms, [NameForm]
348
+
349
+ def fullText
350
+ (nameForms && nameForms[0]) ? nameForms[0].fullText : ""
351
+ end
352
+
353
+ def surname
354
+ (nameForms && nameForms[0]) ? nameForms[0].surname : ""
355
+ end
356
+
357
+ def given_name
358
+ (nameForms && nameForms[0]) ? nameForms[0].given_name : ""
359
+ end
360
+
361
+ end
362
+
363
+ class Person < Subject
364
+ property :collection
365
+ property :living
366
+ property :gender
367
+ property :names
368
+ property :facts
369
+ property :display
370
+
371
+ coerce_key :gender, Gender
372
+ coerce_key :names, [Name]
373
+ coerce_key :facts, [Fact]
374
+ coerce_key :display, DisplayProperties
375
+
376
+ # Returns the first name in the names array
377
+ def name
378
+ names[0] if names
379
+ end
380
+
381
+ def full_name
382
+ (name) ? name.fullText : ''
383
+ end
384
+
385
+ def surname
386
+ (name) ? name.surname : ''
387
+ end
388
+
389
+ def given_name
390
+ (name) ? name.given_name : ''
391
+ end
392
+
393
+ def birth
394
+ facts.find{|f|f.type == "http://gedcomx.org/Birth"} if facts
395
+ end
396
+
397
+ def death
398
+ facts.find{|f|f.type == "http://gedcomx.org/Death"} if facts
399
+ end
400
+
401
+ def christening
402
+ facts.find{|f|f.type == "http://gedcomx.org/Christening"} if facts
403
+ end
404
+
405
+ def burial
406
+ facts.find{|f|f.type == "http://gedcomx.org/Burial"} if facts
407
+ end
408
+ end
409
+
410
+ class Relationship < Subject
411
+ property :type
412
+ property :person1
413
+ property :person2
414
+ property :facts
415
+ property :field
416
+ coerce_key :person1, ResourceReference
417
+ coerce_key :person2, ResourceReference
418
+ coerce_key :facts, [Fact]
419
+ coerce_key :field, EvidenceReference
420
+ end
421
+
422
+ class SourceCitation < HypermediaEnabledData
423
+ property :lang
424
+ property :citationTemplate
425
+ property :fields
426
+ property :value
427
+
428
+ coerce_key :citationTemplate, ResourceReference
429
+ coerce_key :fields, [CitationField]
430
+ end
431
+
432
+ class SourceDescription < HypermediaEnabledData
433
+ property :about
434
+ property :mediaType
435
+ property :resourceType
436
+ property :citations
437
+ property :mediator
438
+ property :sources
439
+ property :analysis
440
+ property :componentOf
441
+ property :titles
442
+ property :notes
443
+ property :attribution
444
+
445
+ coerce_key :citations, [SourceCitation]
446
+ coerce_key :mediator, ResourceReference
447
+ coerce_key :sources, [SourceReference]
448
+ coerce_key :analysis, ResourceReference
449
+ coerce_key :componentOf, SourceReference
450
+ coerce_key :titles, [TextValue]
451
+ coerce_key :notes, [Note]
452
+ coerce_key :attribution, Attribution
453
+ end
454
+
455
+ class PlaceDescription < Subject
456
+ property :type
457
+ property :names
458
+ property :temporalDescription
459
+ property :latitude
460
+ property :longitude
461
+ property :spatialDescription
462
+ coerce_key :names, [TextValue]
463
+ coerce_key :temporalDescription, FamilySearch::Gedcomx::Date
464
+ coerce_key :spatialDescription, ResourceReference
465
+
466
+ def value
467
+ names[0].value if names
468
+ end
469
+ end
470
+
471
+ class FieldValue < Conclusion
472
+ property :resource
473
+ property :datatype
474
+ property :type
475
+ property :interpretationSources
476
+ property :text
477
+ coerce_key :interpretationSources, [ResourceReference]
478
+ end
479
+
480
+ class Field < HypermediaEnabledData
481
+ property :type
482
+ property :label
483
+ property :values
484
+ coerce_key :values, [FieldValue]
485
+ end
486
+
487
+ class Record < HypermediaEnabledData
488
+ property :type
489
+ property :sources
490
+ property :identifiers
491
+ property :principalPersons
492
+ property :primaryEvent
493
+ property :collection
494
+ property :descriptor
495
+ property :fields
496
+ property :notes
497
+ property :attribution
498
+ coerce_key :sources, [SourceReference]
499
+ coerce_key :identifiers, [Identifier]
500
+ coerce_key :principalPersons, [ResourceReference]
501
+ coerce_key :primaryEvent, ResourceReference
502
+ coerce_key :collection, ResourceReference
503
+ coerce_key :descriptor, ResourceReference
504
+ coerce_key :fields, [Field]
505
+ coerce_key :notes, [Note]
506
+ coerce_key :attribution, Attribution
507
+ end
508
+
509
+ class FieldDescriptor < SuperDash
510
+ property :displayOriginalValue
511
+ property :description
512
+ property :displayLabel
513
+ property :originalLabel
514
+ property :systemLabel
515
+ end
516
+
517
+ class RecordDescriptor < HypermediaEnabledData
518
+ property :lang
519
+ property :fields
520
+ coerce_key :fields, [FieldDescriptor]
521
+ end
522
+
523
+ class Gedcomx < HypermediaEnabledData
524
+ property :lang
525
+ property :attribution
526
+ property :persons
527
+ property :relationships
528
+ property :sourceDescriptions
529
+ property :agents
530
+ property :events
531
+ property :places
532
+ property :documents
533
+ property :collections
534
+ property :records
535
+ property :recordDescriptors
536
+ coerce_key :attribution, Attribution
537
+ coerce_key :persons, [Person]
538
+ coerce_key :relationships, [Relationship]
539
+ coerce_key :sourceDescriptions, [SourceDescription]
540
+ coerce_key :agents, [Agent]
541
+ coerce_key :events, [Event]
542
+ coerce_key :places, [PlaceDescription]
543
+ coerce_key :documents, [Document]
544
+ coerce_key :collections, [Collection]
545
+ coerce_key :records, [Record]
546
+ coerce_key :recordDescriptors, [RecordDescriptor]
547
+ end
548
+
549
+ class User < HypermediaEnabledData
550
+ property :alternateEmail
551
+ property :birthDate
552
+ property :contactName
553
+ property :country
554
+ property :displayName
555
+ property :email
556
+ property :familyName
557
+ property :fullName
558
+ property :gender
559
+ property :givenName
560
+ property :helperAccessPin
561
+ property :id
562
+ property :ldsMemberAccount
563
+ property :mailingAddress
564
+ property :personId
565
+ property :phoneNumber
566
+ property :preferredLanguage
567
+ property :treeUserId
568
+ end
569
+
570
+ class Merge < SuperDash
571
+ include SuperCoercion
572
+ property :resourcesToDelete
573
+ property :resourcesToCopy
574
+ coerce_key :resourcesToDelete, [ResourceReference]
575
+ coerce_key :resourcesToCopy, [ResourceReference]
576
+ end
577
+
578
+ class MergeConflict < SuperDash
579
+ include SuperCoercion
580
+ property :survivorResource
581
+ property :duplicateResource
582
+ coerce_key :survivorResource, ResourceReference
583
+ coerce_key :duplicateResource, ResourceReference
584
+ end
585
+
586
+ class MergeAnalysis < SuperDash
587
+ include SuperCoercion
588
+ property :survivorResources
589
+ property :duplicateResources
590
+ property :conflictingResources
591
+ property :survivor
592
+ property :duplicate
593
+
594
+ coerce_key :survivorResources, [ResourceReference]
595
+ coerce_key :duplicateResources, [ResourceReference]
596
+ coerce_key :conflictingResources, [MergeConflict]
597
+ coerce_key :survivor, ResourceReference
598
+ coerce_key :duplicate, ResourceReference
599
+ end
600
+
601
+ class FamilySearch < Gedcomx
602
+ property :childAndParentsRelationships
603
+ property :discussions
604
+ property :users
605
+ property :merges
606
+ property :mergeAnalyses
607
+ coerce_key :childAndParentsRelationships, [ChildAndParentsRelationship]
608
+ coerce_key :discussions, [Discussion]
609
+ coerce_key :users, [User]
610
+ coerce_key :merges, [Merge]
611
+ coerce_key :mergeAnalyses, [MergeAnalysis]
612
+
613
+ def initialize(args)
614
+ super(args)
615
+ inject_places_into_people()
616
+ end
617
+
618
+ private
619
+
620
+ def inject_places_into_people()
621
+ if self.places
622
+ place_references = find_place_references(self)
623
+ place_references.each do |pr|
624
+ if pr.description
625
+ id = pr.description.gsub("#","")
626
+ place = self.places.find{|pd|pd.id == id}
627
+ pr.normalized = place
628
+ end
629
+ end
630
+ end
631
+ end
632
+
633
+ def find_place_references(hash_obj)
634
+ place_references = []
635
+ hash_obj.each do |k,v|
636
+ if v.class == PlaceReference
637
+ place_references << v
638
+ elsif v.class == Array
639
+ v.each do |obj|
640
+ place_references += find_place_references(obj) if obj.kind_of? Hash
641
+ end
642
+ elsif v.kind_of? Hash
643
+ place_references += find_place_references(v)
644
+ end
645
+ end
646
+ return place_references
647
+ end
648
+ end
649
+
650
+ class HealthConfig < SuperDash
651
+ property :buildDate
652
+ property :buildVersion
653
+ property :databaseVersion
654
+ property :platformVersion
655
+ end
656
+
657
+ class ResultConfidence < SuperDash
658
+ # Here to give a number 1-5. Not really a significant piece of the model.
659
+ end
660
+
661
+ class Tag < SuperDash
662
+ property :resource
663
+ end
664
+ end
665
+ end