Example #1
0
 public function testReadCoupleRelationshipChangeHistory()
 {
     $factory = new FamilyTreeStateFactory();
     $this->collectionState($factory);
     /** @var FamilyTreePersonState $husband */
     $husband = $this->createPerson('male')->get();
     $wife = $this->createPerson('female');
     /** @var FamilyTreeRelationshipState $relationship */
     $relationship = $husband->addSpouse($wife)->get();
     $this->queueForDelete($relationship);
     $fact = new Fact();
     $attribution = new Attribution();
     $attribution->setChangeMessage("Change message");
     $fact->setType("http://gedcomx.org/Marriage");
     $fact->setAttribution($attribution);
     $date = new DateInfo();
     $date->setOriginal("3 Apr 1930");
     $date->setFormal("+1930");
     $fact->setDate($date);
     $place = new PlaceReference();
     $place->setOriginal("Moscow, Russia");
     $fact->setPlace($place);
     $relationship->addFact($fact);
     $state = $relationship->readChangeHistory();
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals((int) $state->getResponse()->getStatusCode(), 200);
     $this->assertNotNull($state->getPage());
     $this->assertNotNull($state->getPage()->getEntries());
     $this->assertGreaterThan(0, count($state->getPage()->getEntries()));
 }
Example #2
0
 /**
  * Writes the contents of this Conclusion to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->confidence) {
         $writer->writeAttribute('confidence', $this->confidence);
     }
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     parent::writeXmlContents($writer);
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sources) {
         foreach ($this->sources as $i => $x) {
             $writer->startElementNs('gx', 'source', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->analysis) {
         $writer->startElementNs('gx', 'analysis', null);
         $this->analysis->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->notes) {
         foreach ($this->notes as $i => $x) {
             $writer->startElementNs('gx', 'note', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Example #3
0
 /**
  * Writes the contents of this Collection to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     parent::writeXmlContents($writer);
     if ($this->title) {
         $writer->startElementNs('gx', 'title', null);
         $writer->text($this->title);
         $writer->endElement();
     }
     if ($this->size) {
         $writer->startElementNs('gx', 'size', null);
         $writer->text($this->size);
         $writer->endElement();
     }
     if ($this->content) {
         foreach ($this->content as $i => $x) {
             $writer->startElementNs('gx', 'content', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Example #4
0
 /**
  * Writes the contents of this EvidenceReference to an XML writer. The startElement is expected to be already
  * provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->resourceId) {
         $writer->writeAttribute('resourceId', $this->resourceId);
     }
     if ($this->resource) {
         $writer->writeAttribute('resource', $this->resource);
     }
     parent::writeXmlContents($writer);
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Example #5
0
 /**
  * Writes the contents of this SourceReference to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->descriptionRef) {
         $writer->writeAttribute('description', $this->descriptionRef);
     }
     parent::writeXmlContents($writer);
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->qualifiers) {
         foreach ($this->qualifiers as $i => $x) {
             $writer->startElementNs('gx', 'qualifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }
Example #6
0
 /**
  * Writes the contents of this Note to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     parent::writeXmlContents($writer);
     if ($this->subject) {
         $writer->startElementNs('gx', 'subject', null);
         $writer->text($this->subject);
         $writer->endElement();
     }
     if ($this->text) {
         $writer->startElementNs('gx', 'text', null);
         $writer->text($this->text);
         $writer->endElement();
     }
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Example #7
0
 /**
  * Writes the contents of this SourceDescription to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->about) {
         $writer->writeAttribute('about', $this->about);
     }
     if ($this->mediaType) {
         $writer->writeAttribute('mediaType', $this->mediaType);
     }
     if ($this->resourceType) {
         $writer->writeAttribute('resourceType', $this->resourceType);
     }
     parent::writeXmlContents($writer);
     if ($this->citations) {
         foreach ($this->citations as $i => $x) {
             $writer->startElementNs('gx', 'citation', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->mediator) {
         $writer->startElementNs('gx', 'mediator', null);
         $this->mediator->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sources) {
         foreach ($this->sources as $i => $x) {
             $writer->startElementNs('gx', 'source', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->analysis) {
         $writer->startElementNs('gx', 'analysis', null);
         $this->analysis->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->componentOf) {
         $writer->startElementNs('gx', 'componentOf', null);
         $this->componentOf->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->titles) {
         foreach ($this->titles as $i => $x) {
             $writer->startElementNs('gx', 'title', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->titleLabel) {
         $writer->startElementNs('gx', 'titleLabel', null);
         $this->titleLabel->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->notes) {
         foreach ($this->notes as $i => $x) {
             $writer->startElementNs('gx', 'note', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->sortKey) {
         $writer->startElementNs('gx', 'sortKey', null);
         $writer->text($this->sortKey);
         $writer->endElement();
     }
     if ($this->descriptions) {
         foreach ($this->descriptions as $i => $x) {
             $writer->startElementNs('gx', 'description', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->identifiers) {
         foreach ($this->identifiers as $i => $x) {
             $writer->startElementNs('gx', 'identifier', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->created) {
         $writer->startElementNs('gx', 'created', null);
         $writer->text($this->created);
         $writer->endElement();
     }
     if ($this->modified) {
         $writer->startElementNs('gx', 'modified', null);
         $writer->text($this->modified);
         $writer->endElement();
     }
     if ($this->coverage) {
         foreach ($this->coverage as $i => $x) {
             $writer->startElementNs('gx', 'coverage', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->rights) {
         foreach ($this->rights as $i => $x) {
             $writer->startElementNs('gx', 'rights', null);
             $writer->text($x);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->repository) {
         $writer->startElementNs('gx', 'repository', null);
         $this->repository->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->descriptorRef) {
         $writer->startElementNs('gx', 'descriptor', null);
         $this->descriptorRef->writeXmlContents($writer);
         $writer->endElement();
     }
 }
Example #8
0
 /**
  * @link https://familysearch.org/developers/docs/api/sources/Move_Sources_to_a_User-Defined_Collection_usecase
  */
 public function testMoveSourcesToAUserDefinedCollection()
 {
     $factory = new FamilySearchStateFactory();
     /** @var FamilySearchCollectionState $collection */
     $collection = $this->collectionState($factory, "https://sandbox.familysearch.org/platform/collections/sources");
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $contributor = new ResourceReference();
     $contributor->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $contributor->setResourceId("MM6M-8QJ");
     $attribution->setContributor($contributor);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->SetAttribution($attribution);
     /** @var FamilySearchSourceDescriptionState $description */
     $description = $collection->addSourceDescription($sd);
     $this->queueForDelete($description);
     $this->assertEquals(HttpStatus::CREATED, $description->getResponse()->getStatusCode());
     $description = $description->get();
     $this->assertEquals(HttpStatus::OK, $description->getResponse()->getStatusCode());
     /** @var CollectionState $subcollection */
     $c = new Collection();
     $c->setTitle($this->faker->sha1);
     $subcollection = $collection->addCollection($c)->get();
     $this->queueForDelete($subcollection);
     /** @var FamilySearchSourceDescriptionState $state */
     $state = $description->moveToCollection($subcollection);
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals(HttpStatus::NO_CONTENT, $state->getResponse()->getStatusCode());
     // Ensure it doesn't exist in the old collection
     $rootCollection = $this->getRootCollection($collection);
     $found = $this->findInCollection($description->getSourceDescription(), $rootCollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertFalse($found);
     // Ensure it exists in the new collection
     $found = $this->findInCollection($description->getSourceDescription(), $subcollection->readSourceDescriptions()->getEntity()->getSourceDescriptions());
     $this->assertTrue($found);
 }
Example #9
0
 /**
  * @return \Gedcomx\Source\SourceDescription
  */
 private function createSourceDescription()
 {
     $sd = new SourceDescription();
     $citation = new SourceCitation();
     $citation->setValue("\"United States Census, 1900.\" database and digital images, FamilySearch (https://familysearch.org/: accessed 17 Mar 2012), Ethel Hollivet, 1900; citing United States Census Office, Washington, D.C., 1900 Population Census Schedules, Los Angeles, California, population schedule, Los Angeles Ward 6, Enumeration District 58, p. 20B, dwelling 470, family 501, FHL microfilm 1,240,090; citing NARA microfilm publication T623, roll 90.");
     $sd->setCitations(array($citation));
     $title = new TextValue();
     $title->setValue("1900 US Census, Ethel Hollivet");
     $sd->setTitles(array($title));
     $note = new Note();
     $note->setText("Ethel Hollivet (line 75) with husband Albert Hollivet (line 74); also in the dwelling: step-father Joseph E Watkins (line 72), mother Lina Watkins (line 73), and grandmother -- Lina's mother -- Mary Sasnett (line 76).  Albert's mother and brother also appear on this page -- Emma Hollivet (line 68), and Eddie (line 69).");
     $sd->setNotes(array($note));
     $attribution = new Attribution();
     $rr = new ResourceReference();
     $rr->setResource("https://familysearch.org/platform/users/agents/MM6M-8QJ");
     $rr->setResourceId("MM6M-8QJ");
     $attribution->setContributor($rr);
     $attribution->setModified(time());
     $attribution->setChangeMessage("This is the change message");
     $sd->setAttribution($attribution);
     return $sd;
 }
Example #10
0
 /**
  * @vcr PedigreeTests/testReadPersonDescendancyWithSpecifiedSpouseAndAdditionalPersonAndMarriageDetails.json
  * @link https://familysearch.org/developers/docs/api/tree/Read_Person_Descendancy_with_Specified_Spouse_and_additional_person_and_marriage_details_usecase
  * @throws \Gedcomx\Rs\Client\Exception\GedcomxApplicationException
  */
 public function testReadPersonDescendancyWithSpecifiedSpouseAndAdditionalPersonAndMarriageDetails()
 {
     $factory = new FamilyTreeStateFactory();
     $collection = $this->collectionState($factory);
     $father = $this->createPerson('male');
     $this->assertEquals(HttpStatus::CREATED, $father->getStatus());
     $father = $father->get();
     $this->assertEquals(HttpStatus::OK, $father->getStatus());
     $mother = $this->createPerson('female');
     $this->assertEquals(HttpStatus::CREATED, $mother->getStatus());
     $son = $this->createPerson('male');
     $this->assertEquals(HttpStatus::CREATED, $son->getStatus());
     $fact = new Fact();
     $attribution = new Attribution();
     $attribution->setChangeMessage("Change message");
     $fact->setType("http://gedcomx.org/Marriage");
     $fact->setAttribution($attribution);
     $date = new DateInfo();
     $date->setOriginal("3 Apr 1930");
     $date->setFormal("+1930");
     $fact->setDate($date);
     $place = new PlaceReference();
     $place->setOriginal("Moscow, Russia");
     $fact->setPlace($place);
     $father->addSpouse($mother)->addFact($fact);
     $relationship = new ChildAndParentsRelationship();
     $relationship->setFather($father->getResourceReference());
     $relationship->setMother($mother->getResourceReference());
     $relationship->setChild($son->getResourceReference());
     $r1 = $collection->addChildAndParentsRelationship($relationship);
     $this->queueForDelete($r1);
     $this->assertEquals(HttpStatus::CREATED, $r1->getStatus());
     $state = $father->readDescendancy(new QueryParameter(true, "spouse", $mother->getHeader("X-ENTITY-ID")[0]), new QueryParameter(true, "personDetails", "true"), new QueryParameter(true, "marriageDetails", "true"));
     $this->assertNotNull($state->ifSuccessful());
     $this->assertEquals((int) $state->getStatus(), 200);
     $this->assertNotNull($state->getTree());
     $this->assertNotNull($state->getTree()->getRoot());
     $this->assertNotNull($state->getTree()->getRoot()->getPerson());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse());
     $this->assertNotNull($state->getTree()->getRoot()->getChildren());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getDisplayExtension());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getDisplayExtension()->getMarriageDate());
     $this->assertNotNull($state->getTree()->getRoot()->getPerson()->getFacts());
     $this->assertNotNull($state->getTree()->getRoot()->getSpouse()->getFacts());
     $this->assertEquals(1, count($state->getTree()->getRoot()->getChildren()));
     $this->assertNotNull($state->getTree()->getRoot()->Children[0]->getPerson());
     $this->assertEquals($father->getPerson()->getId(), $state->getTree()->getRoot()->getPerson()->getId());
     $this->assertEquals($mother->getHeader("X-ENTITY-ID")[0], $state->getTree()->getRoot()->getSpouse()->getId());
     $this->assertEquals($son->getHeader("X-ENTITY-ID")[0], $state->getTree()->getRoot()->Children[0]->getPerson()->getId());
 }
Example #11
0
 /**
  * Writes the contents of this Gedcomx to an XML writer. The startElement is expected to be already provided.
  *
  * @param \XMLWriter $writer The XML writer.
  */
 public function writeXmlContents(\XMLWriter $writer)
 {
     if ($this->lang) {
         $writer->writeAttribute('xml:lang', $this->lang);
     }
     if ($this->descriptionRef) {
         $writer->writeAttribute('description', $this->descriptionRef);
     }
     if ($this->profile) {
         $writer->writeAttribute('profile', $this->profile);
     }
     parent::writeXmlContents($writer);
     if ($this->attribution) {
         $writer->startElementNs('gx', 'attribution', null);
         $this->attribution->writeXmlContents($writer);
         $writer->endElement();
     }
     if ($this->persons) {
         foreach ($this->persons as $i => $x) {
             $writer->startElementNs('gx', 'person', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->relationships) {
         foreach ($this->relationships as $i => $x) {
             $writer->startElementNs('gx', 'relationship', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->sourceDescriptions) {
         foreach ($this->sourceDescriptions as $i => $x) {
             $writer->startElementNs('gx', 'sourceDescription', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->agents) {
         foreach ($this->agents as $i => $x) {
             $writer->startElementNs('gx', 'agent', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->events) {
         foreach ($this->events as $i => $x) {
             $writer->startElementNs('gx', 'event', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->places) {
         foreach ($this->places as $i => $x) {
             $writer->startElementNs('gx', 'place', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->documents) {
         foreach ($this->documents as $i => $x) {
             $writer->startElementNs('gx', 'document', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->collections) {
         foreach ($this->collections as $i => $x) {
             $writer->startElementNs('gx', 'collection', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->fields) {
         foreach ($this->fields as $i => $x) {
             $writer->startElementNs('gx', 'field', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
     if ($this->recordDescriptors) {
         foreach ($this->recordDescriptors as $i => $x) {
             $writer->startElementNs('gx', 'recordDescriptor', null);
             $x->writeXmlContents($writer);
             $writer->endElement();
         }
     }
 }