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; }
/** * Get the list of couple relationships in the document. * * @return The list of couple relationships in the document. */ @XmlTransient @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public List<Relationship> getCoupleRelationships() { ArrayList<Relationship> filtered = null; if (this.relationships != null) { filtered = new ArrayList<Relationship>(); for (Relationship relationship : this.relationships) { if (relationship.getKnownType() == RelationshipType.Couple) { filtered.add(relationship); } } } return filtered; }
/** * Get the list of parent-child relationships in the document. * * @return The list of parent-child relationships in the document. */ @XmlTransient @JsonIgnore @org.codehaus.jackson.annotate.JsonIgnore public List<Relationship> getParentChildRelationships() { ArrayList<Relationship> filtered = null; if (this.relationships != null) { filtered = new ArrayList<Relationship>(); for (Relationship relationship : this.relationships) { if (relationship.getKnownType() == RelationshipType.ParentChild) { filtered.add(relationship); } } } return filtered; }
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; }
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; }
@Override public RelationshipState addRelationship(Relationship relationship, StateTransitionOption... options) { if (relationship.getKnownType() == RelationshipType.ParentChild) { throw new GedcomxApplicationException("FamilySearch Family Tree doesn't support adding parent-child relationships. You must instead add a child-and-parents relationship."); } return super.addRelationship(relationship, options); }
@Override public RelationshipsState addRelationships(List<Relationship> relationships, StateTransitionOption... options) { for (Relationship relationship : relationships) { if (relationship.getKnownType() == RelationshipType.ParentChild) { throw new GedcomxApplicationException("FamilySearch Family Tree doesn't support adding parent-child relationships. You must instead add a child-and-parents relationship."); } } return super.addRelationships(relationships, options); }
@Override public RelationshipState addRelationship(Relationship relationship, StateTransitionOption... options) { if (relationship.getKnownType() == RelationshipType.ParentChild) { throw new GedcomxApplicationException("FamilySearch Family Tree doesn't support adding parent-child relationships. You must instead add a child-and-parents relationship."); } return super.addRelationship(relationship, options); }
/** * 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; }
/** * 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; }