/**
  * Reads the person from the specified person model.
  *
  * @param \Gedcomx\Conclusion\Person                       $person
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return PersonState|null
  */
 public function readPersonFromConclusion(Person $person, StateTransitionOption $option = null)
 {
     $link = $person->getLink(Rel::PERSON);
     if ($link === null) {
         $link = $person->getLink(Rel::SELF);
     }
     if ($link === null || $link->getHref() === null) {
         return null;
     }
     $request = $this->createAuthenticatedGedcomxRequest("GET", $link->getHref());
     return $this->stateFactory->createState("PersonState", $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
示例#2
0
 public static function XMLRelationshipData()
 {
     //  MOTHER
     $birthDate = new \DateTime('January 21, 1923');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Flagstaff, Arizona, United States'))));
     $deathDate = new \DateTime('October 12, 1987');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $mother = new Person();
     $mother->setGender(new Gender(array("type" => GenderType::FEMALE)));
     $mother->setLiving(false);
     $mother->setPrincipal(false);
     $name = PersonBuilder::makeName('Hildegard', 'Schmidlab');
     $mother->setNames(array($name));
     $mother->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::FEMALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $mother->setDisplayExtension($display);
     //  FATHER
     $birthDate = new \DateTime('February 2, 1915');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Flagstaff, Arizona, United States'))));
     $deathDate = new \DateTime('January 12, 1977');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $father = new Person();
     $father->setGender(new Gender(array("type" => GenderType::MALE)));
     $father->setLiving(false);
     $father->setPrincipal(false);
     $name = PersonBuilder::makeName('Marvin', 'Schmidlab');
     $father->setNames(array($name));
     $father->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::MALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $father->setDisplayExtension($display);
     //  CHILD
     $birthDate = new \DateTime('March 12, 1935');
     $birth = new Fact(array("type" => FactType::BIRTH, "date" => new DateInfo(array("original" => $birthDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "possibly, maybe, don't know", "original" => 'Santa Fe, New Mexico, United States'))));
     $deathDate = new \DateTime('January 2, 2007');
     $death = new Fact(array("type" => FactType::DEATH, "date" => new DateInfo(array("original" => $deathDate->format("F d, Y"))), "place" => new PlaceReference(array("description" => "One. Two. Buckle my shoe.", "original" => 'San Antonio, Texas, United States'))));
     $facts = array();
     $facts[] = $birth;
     $facts[] = $death;
     $child = new Person();
     $child->setGender(new Gender(array("type" => GenderType::MALE)));
     $child->setLiving(false);
     $child->setPrincipal(false);
     $name = PersonBuilder::makeName('Englebert', 'Schmidlab');
     $child->setNames(array($name));
     $child->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => GenderType::MALE, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . $death->getDate()->getDateTime()->format("d M Y"), "name" => $name->toString()));
     $child->setDisplayExtension($display);
     return array('father' => $father, 'mother' => $mother, 'child' => $child);
 }
 /**
  * Return the
  * @param \Gedcomx\Conclusion\Person $spouse
  *
  * @return ChildAndParentsRelationship|null
  */
 public function findChildAndParentsRelationshipTo(Person $spouse)
 {
     $relationships = $this->getChildAndParentsRelationships();
     if (relationships != null) {
         foreach ($relationships as $relation) {
             $personReference = $relation->getFather();
             if ($personReference != null) {
                 $reference = $personReference->getResource()->toString();
                 if ($reference == "#" . $spouse->getId()) {
                     return $relation;
                 }
             }
             $personReference = $relation->getMother();
             if ($personReference != null) {
                 $reference = $personReference->getResource()->toString();
                 if ($reference == "#" . $spouse->getId()) {
                     return $relation;
                 }
             }
         }
     }
     return null;
 }
示例#4
0
 public static function buildPerson($gender)
 {
     /*
      * Can't use faker for dates. It doesn't deal well with negative timestamps.
      */
     switch ($gender) {
         case 'male':
             $gender = GenderType::MALE;
             break;
         case 'female':
             $gender = GenderType::FEMALE;
             break;
         default:
             $gender = self::faker()->boolean() ? GenderType::FEMALE : GenderType::MALE;
     }
     $birth = FactBuilder::birth();
     $death = FactBuilder::death($birth);
     $facts = array();
     $facts[] = $birth;
     $living = false;
     if ($death->getDate()->getDateTime()->getTimestamp() > time()) {
         $living = true;
     } else {
         $facts[] = $death;
     }
     $person = new Person();
     $person->setGender(new Gender(array("type" => $gender)));
     $person->setLiving($living);
     $person->setPrincipal(false);
     $name = self::birthName($gender);
     $person->setNames(array($name));
     $person->setFacts($facts);
     $display = new DisplayProperties(array("birthDate" => $birth->getDate()->getDateTime()->format("d M Y"), "birthPlace" => $birth->getPlace()->getOriginal(), "gender" => $gender, "lifespan" => $birth->getDate()->getDateTime()->format("d M Y") . " - " . ($living ? '' : $death->getDate()->getDateTime()->format("d M Y")), "name" => $name->toString()));
     $person->setDisplayExtension($display);
     return $person;
 }
示例#5
0
 /**
  * Update a person
  *
  * @param \Gedcomx\Conclusion\Person               $person
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return \Gedcomx\Rs\Client\PersonState
  */
 public function update(Person $person, StateTransitionOption $option = null)
 {
     if ($this->getLink(Rel::CONCLUSIONS) != null && ($person->getNames() != null || $person->getFacts() != null || $person->getGender() != null)) {
         $this->passOptionsTo('updateConclusions', array($person), func_get_args());
     }
     if ($this->getLink(Rel::EVIDENCE_REFERENCES) != null && $person->getEvidence() != null) {
         $this->passOptionsTo('updateEvidenceReferences', array($person), func_get_args());
     }
     if ($this->getLink(Rel::MEDIA_REFERENCES) != null && $person->getMedia() != null) {
         $this->passOptionsTo('updateMediaReferences', array($person), func_get_args());
     }
     if ($this->getLink(Rel::SOURCE_REFERENCES) != null && $person->getSources() != null) {
         $this->passOptionsTo('updateSourceReferences', array($person), func_get_args());
     }
     if ($this->getLink(Rel::NOTES) != null && $person->getNotes() != null) {
         $this->passOptionsTo('updateNotes', array($person), func_get_args());
     }
     $gx = new Gedcomx();
     $gx->addPerson($person);
     $request = $this->createAuthenticatedGedcomxRequest('POST', $this->getSelfUri(), [], null, $gx->toJson());
     return $this->stateFactory->createState("PersonState", $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
示例#6
0
 /**
  * Creates a parent child relationship for the specified persons.     *
  *
  * @param \Gedcomx\Conclusion\Person                       $parent
  * @param \Gedcomx\Conclusion\Person                       $child
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $options
  *
  * @return mixed
  */
 public function addParentChildRelationship(Person $parent, Person $child, StateTransitionOption $options = null)
 {
     $relationship = new Relationship();
     $relationship->setPerson1(new ResourceReference($parent->getSelfUri()));
     $relationship->setPerson2(new ResourceReference($child->getSelfUri()));
     $relationship->setKnownType(RelationshipType::COUPLE);
     return $this->addRelationship($relationship, $options);
 }
 /**
  * Declares the match status for the current person the specified search result entry.
  *
  * @param Entry $entry
  * @param string $status
  * @param StateTransitionOption $options
  * @return PersonMatchResultsState
  */
 public function updateMatchStatus(Entry $entry, $status, StateTransitionOption $options = null)
 {
     $updateStatusUri = $this->getSelfUri();
     $entity = new Gedcomx();
     $person = new Person();
     $id = new Identifier();
     $id->setType(IdentifierType::PERSISTENT);
     $id->setValue($entry->getId());
     $person->setIdentifiers(array($id));
     $entity->setPersons(array($person));
     $request = $this->createAuthenticatedGedcomxRequest("POST", $updateStatusUri, [], null, $entity->toJson());
     $request = $request->withoutHeader("Accept");
     return $this->stateFactory->createState("PersonMatchResultsState", $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
 /**
  * Removes the declared non match person from this collection.
  *
  * @param \Gedcomx\Conclusion\Person                       $nonMatch
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return mixed|null
  */
 public function removeNonMatch(Person $nonMatch, StateTransitionOption $option = null)
 {
     $link = $nonMatch->getLink(Rel::NOT_A_MATCHES);
     if ($link == null || $link->getHref() == null) {
         return null;
     }
     $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
     return $this->stateFactory->createState('PersonNonMatchesState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }
示例#9
0
 /**
  * Read the Decendancy based on this spouse
  *
  * @param \Gedcomx\Conclusion\Person                       $person
  * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
  *
  * @return \Gedcomx\Rs\Client\PersonState|null
  */
 public function readDescendancyWithSpouse(Person $person, StateTransitionOption $option = null)
 {
     $link = $person->getLink(Rel::DESCENDANCY);
     if ($link == null || $link->getHref() == null) {
         return null;
     }
     $request = $this->createAuthenticatedGedcomxRequest('GET', $link->getHref());
     return $this->stateFactory->createState('PersonState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken);
 }