private void analyzeParents(FamilyMember m) { HistoricalFigure father = m.hf.getHfLink("father"); FamilyMember m1 = null, m2 = null; if (father.getId() != -1) { try { m1 = get(father.getId(), new FamilyMember(father, m.generation - 1, m.distance + 1)); if (!m1.getRelation().equals("")) { m.father = m1; analyzeParents(m1); addMember(m1); if (m.generation == 0) analyzeChildren(m1); } else { m1 = null; } } catch (MemeberExistsException e) { } } HistoricalFigure mother = m.hf.getHfLink("mother"); if (mother.getId() != -1) { try { m2 = get(mother.getId(), new FamilyMember(mother, m.generation - 1, m.distance + 1)); if (!m2.getRelation().equals("")) { m.mother = m2; analyzeParents(m2); addMember(m2); } else { m2 = null; } } catch (MemeberExistsException e) { } } if (m1 != null && m2 != null) { m1.spouse = m2; m2.spouse = m1; links.add(new FamilyLink("spouse", m1, m2)); } if (m1 != null) { links.add(new FamilyLink("child", m1, m)); m1.children.add(m); } if (m2 != null) { links.add(new FamilyLink("child", m2, m)); m2.children.add(m); } }
private void analyzeBites(FamilyMember m) { if (members.contains(m)) return; members.add(m); World.getHistoricalEvents() .stream() .collect( Filters.filterEvent( HfDoesInteractionEvent.class, e -> e.getDoerHfId() == m.hf.getId() && e.getInteraction().startsWith(interaction))) .map(HfDoesInteractionEvent::getTargetHfId) .map(World::getHistoricalFigure) .forEach( hf -> { FamilyMember m2 = new FamilyMember(hf, m.getGeneration() + 1, m.getDistance() + 1); m2.father = m; m.children.add(m2); links.add(new FamilyLink("child", m, m2)); analyzeBites(m2); }); }