public List<Relationship> getSpouseRelationships() { List<Relationship> relationships = getRelationships(); relationships = relationships == null ? null : new ArrayList<Relationship>(relationships); if (relationships != null) { Iterator<Relationship> it = relationships.iterator(); while (it.hasNext()) { if (it.next().getKnownType() != RelationshipType.Couple) { it.remove(); } } } return relationships; }
public RelationshipState addSpouseRelationship(PersonState person1, PersonState person2, Fact fact, StateTransitionOption... options) { Relationship relationship = new Relationship(); relationship.setPerson1(new ResourceReference(new org.gedcomx.common.URI(person1.getSelfUri().toString()))); relationship.setPerson2(new ResourceReference(new org.gedcomx.common.URI(person2.getSelfUri().toString()))); relationship.setKnownType(RelationshipType.Couple); relationship.addFact(fact); return addRelationship(relationship, options); }
protected Relationship createEmptySelf() { Relationship relationship = new Relationship(); relationship.setId(getLocalSelfId()); return relationship; }
public List<Relationship> getChildRelationships() { List<Relationship> relationships = getRelationships(); relationships = relationships == null ? null : new ArrayList<Relationship>(relationships); if (relationships != null) { Iterator<Relationship> it = relationships.iterator(); while (it.hasNext()) { Relationship relationship = it.next(); if (relationship.getKnownType() != RelationshipType.ParentChild || !refersToMe(relationship.getPerson1())) { it.remove(); } } } return relationships; }
public List<Relationship> getParentRelationships() { List<Relationship> relationships = getRelationships(); relationships = relationships == null ? null : new ArrayList<Relationship>(relationships); if (relationships != null) { Iterator<Relationship> it = relationships.iterator(); while (it.hasNext()) { Relationship relationship = it.next(); if (relationship.getKnownType() != RelationshipType.ParentChild || !refersToMe(relationship.getPerson2())) { it.remove(); } } } return relationships; }
Relationship fatherChildRelationship = new Relationship(); fatherChildRelationship.setId("F" + relationshipId); fatherChildRelationship.setKnownType(RelationshipType.ParentChild); fatherChildRelationship.setPerson1(childAndParentsRelationship.getFather()); fatherChildRelationship.setPerson2(childAndParentsRelationship.getChild()); if (primaryIdentifier != null) { fatherChildRelationship.setIdentifiers(new ArrayList<>(1)); fatherChildRelationship.getIdentifiers().add(new Identifier()); fatherChildRelationship.getIdentifiers().get(0).setType(FamilySearchIdentifierType.ChildAndParentsRelationship.toQNameURI(), true); fatherChildRelationship.getIdentifiers().get(0).setValue(primaryIdentifier.getValue()); fatherChildRelationship.setTransientProperty(transientProperty.getKey(), transientProperty.getValue()); fatherChildRelationship.setSortKey(childAndParentsRelationship.getSortKey()); addRelationship(fatherChildRelationship); Relationship motherChildRelationship = new Relationship(); motherChildRelationship.setId("M" + relationshipId); motherChildRelationship.setKnownType(RelationshipType.ParentChild); motherChildRelationship.setPerson1(childAndParentsRelationship.getMother()); motherChildRelationship.setPerson2(childAndParentsRelationship.getChild()); if (primaryIdentifier != null) { motherChildRelationship.setIdentifiers(new ArrayList<>(1)); motherChildRelationship.getIdentifiers().add(new Identifier()); motherChildRelationship.getIdentifiers().get(0).setType(FamilySearchIdentifierType.ChildAndParentsRelationship.toQNameURI(), true); motherChildRelationship.getIdentifiers().get(0).setValue(primaryIdentifier.getValue()); motherChildRelationship.setTransientProperty(transientProperty.getKey(), transientProperty.getValue());
for (Relationship relationship : doc.getRelationships()) { boolean foundPerson = false; for (ResourceReference ref : new ResourceReference[]{relationship.getPerson1(), relationship.getPerson2()}) { if (ref != null) { if (ref.getResource() == null && ref.getResourceId() != null) { errors.append("Error 7: A relationship failed to reference anyone inside the document. At least one person must be in the document.\n"); checkSources(errors, "Error 8: relationship", relationship.getSources(), relationship.getFacts(), relationship.getFields(), docMap); checkSources(errors, "Error 9: relationship (media)", relationship.getMedia(), null, null, docMap);
/** * Find the couple relationship (if any) that corresponds to the relationship between the people with the given IDs. * @param person1 - person1 to find (i.e., husband) * @param person2 - person2 to find (i.e., wife) * @return the couple relationship for the parents in the family, if any, or null if there isn't one (or if there are not two parents). */ public Relationship findCoupleRelationship(ResourceReference person1, ResourceReference person2) { if (getRelationships() != null) { for (Relationship relationship : getRelationships()) { if (relationship.getKnownType() == RelationshipType.Couple && samePerson(person1, relationship.getPerson1()) && samePerson(person2, relationship.getPerson2())) { return relationship; } } } return null; }
public RelationshipState readRelationship(Relationship relationship, StateTransitionOption... options) { Link link = relationship.getLink(Rel.RELATIONSHIP); link = link == null ? relationship.getLink(Rel.SELF) : link; if (link == null || link.getHref() == null) { return null; } ClientRequest request = createAuthenticatedGedcomxRequest().build(link.getHref().toURI(), HttpMethod.GET); return this.stateFactory.newRelationshipState(request, invoke(request, options), this.accessToken); }
/** * Build out this relationship with a reference to person 1. * * @param person1 person 1. * @return this. */ public Relationship person1(ResourceReference person1) { setPerson1(person1); return this; }
/** * Build out this relationship with a reference to person 2. * * @param person2 person 2. * @return this. */ public Relationship person2(ResourceReference person2) { setPerson2(person2); return this; }
@Override public void visitRelationship(Relationship relationship) { this.contextStack.push(relationship); visitSubject(relationship); List<Fact> facts = relationship.getFacts(); if (facts != null) { for (Fact fact : facts) { if (fact != null) { fact.accept(this); } } } List<Field> fields = relationship.getFields(); if (fields != null) { for (Field field : fields) { if (field != null) { field.accept(this); } } } this.contextStack.pop(); }
/** * Build out this relationship with a type. * @param type The type. * @return this. */ public Relationship type(RelationshipType type) { setKnownType(type); return this; }
protected String getLocalSelfId() { Relationship me = getRelationship(); return me == null ? null : me.getId(); }
/** * Build out this relationship with a fact. * @param fact The fact. * @return this */ public Relationship fact(Fact fact) { addFact(fact); return this; }
/** * Find the parent-child relationship between the given two persons. * @param parent - Reference to the parent to find. * @param child - Reference to the child to find. * @return parent-child relationship for the given parent and child, or null if not found in the document. */ public Relationship findParentChildRelationship(ResourceReference parent, ResourceReference child) { if (parent != null && child != null && getRelationships() != null && parent.getResource() != null && child.getResource() != null) { for (Relationship relationship : getRelationships()) { if (relationship.getKnownType().equals(RelationshipType.ParentChild) && samePerson(relationship.getPerson1(), parent) && samePerson(relationship.getPerson2(), child)) { return relationship; } } } return null; }
public RelationshipState readRelationship(Relationship relationship, StateTransitionOption... options) { Link link = relationship.getLink(Rel.RELATIONSHIP); link = link == null ? relationship.getLink(Rel.SELF) : link; if (link == null || link.getHref() == null) { return null; } ClientRequest request = createAuthenticatedGedcomxRequest().build(link.getHref().toURI(), HttpMethod.GET); return this.stateFactory.newRelationshipState(request, invoke(request, options), this.accessToken); }