-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathEmmaBocockExampleTest.java
More file actions
76 lines (60 loc) · 3.13 KB
/
EmmaBocockExampleTest.java
File metadata and controls
76 lines (60 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package org.gedcomx.examples;
import org.gedcomx.Gedcomx;
import org.gedcomx.agent.Agent;
import org.gedcomx.common.Attribution;
import org.gedcomx.conclusion.*;
import org.gedcomx.rt.SerializationUtil;
import org.gedcomx.source.SourceCitation;
import org.gedcomx.source.SourceDescription;
import org.gedcomx.types.FactType;
import org.gedcomx.types.GenderType;
import org.gedcomx.types.RelationshipType;
import org.gedcomx.types.ResourceType;
import org.junit.jupiter.api.Test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* @author Ryan Heaton
*/
class EmmaBocockExampleTest {
@Test
void example() throws Exception {
Agent contributor = new Agent().id("A-1").name("Jane Doe").email("example@example.org");
Agent repository = new Agent().id("A-2").name("General Registry Office, Southport");
Attribution attribution = new Attribution().contributor(contributor).modified(parse("2014-03-07")).changeMessage("change message example");
SourceDescription sourceDescription = new SourceDescription().id("S-1")
.title("Birth Certificate of Emma Bocock, 23 July 1843, General Registry Office")
.citation(new SourceCitation().value("England, birth certificate for Emma Bocock, born 23 July 1843; citing 1843 Birth in District and Sub-district of Ecclesall-Bierlow in the County of York, 303; General Registry Office, Southport."))
.resourceType(ResourceType.PhysicalArtifact)
.created(parse("1843-07-27"))
.repository(repository);
Fact birth = new Fact()
.type(FactType.Birth)
.date(new Date().original("23 June 1843"))
.place(new PlaceReference().original("Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom"));
Person emma = new Person().id("P-1").extracted(true).source(sourceDescription).name("Emma Bocock").gender(GenderType.Female).fact(birth);
Person father = new Person().id("P-2").extracted(true).source(sourceDescription).name("William Bocock").fact(new Fact().type(FactType.Occupation).value("Toll Collector"));
Person mother = new Person().id("P-3").extracted(true).source(sourceDescription).name("Sarah Bocock formerly Brough");
Relationship fatherRelationship = new Relationship().type(RelationshipType.ParentChild).person1(father).person2(emma);
Relationship motherRelationship = new Relationship().type(RelationshipType.ParentChild).person1(mother).person2(emma);
Document analysis = new Document().id("D-1").text("...Jane Doe's analysis document...");
Person emmaConclusion = new Person().id("C-1").evidence(emma).analysis(analysis);
Gedcomx gx = new Gedcomx()
.agent(contributor)
.agent(repository)
.attribution(attribution)
.sourceDescription(sourceDescription)
.person(emma)
.person(father)
.person(mother)
.relationship(fatherRelationship)
.relationship(motherRelationship)
.document(analysis)
.person(emmaConclusion);
SerializationUtil.processThroughXml(gx);
SerializationUtil.processThroughJson(gx);
}
private java.util.Date parse(String date) throws ParseException {
return new SimpleDateFormat("yyyy-MM-dd").parse(date);
}
}