/** Test individual(s)'s age at given date property */ /*package*/ void test( Property prop, TagPath trigger, List<ViewContext> issues, ReportValidate report) { // get to the date PropertyDate date; if (path2date != null) { date = (PropertyDate) prop.getProperty(path2date); } else { date = (PropertyDate) prop; } if (date == null || !date.isValid()) return; // find indi we compute age for Property pindi = prop.getProperty(path2indi); if (!(pindi instanceof Indi)) return; Indi indi = (Indi) pindi; // calc pit of date PointInTime pit2 = date.getStart(); // get birth PropertyDate birt = indi.getBirthDate(); if (birt == null || !birt.isValid()) return; PointInTime pit1 = birt.getStart(); // don't test if birth<date? if (pit1.compareTo(pit2) > 0) return; // calculate delta Delta delta = Delta.get(pit1, pit2); if (delta == null) return; // test it if (isError(delta.getYears())) { WordBuffer words = new WordBuffer(); if (comparison == UNDER) { words.append(report.translate("err.age.under", indi.toString(), String.valueOf(years))); } else { words.append(report.translate("err.age.over", indi.toString(), String.valueOf(years))); } words.append("-"); words.append(report.translate(explanation)); issues.add( new ViewContext(prop) .setText(words.toString()) .setImage( prop instanceof PropertyDate ? prop.getParent().getImage(false) : prop.getImage(false))); } // done }
/** test a prop for existance */ /*package*/ void test( Property prop, TagPath trigger, List<ViewContext> issues, ReportValidate report) { // check for property by path1 Property prop1 = prop.getProperty(path1); if (prop1 == null) return; // then check for property by path2 Property prop2 = prop.getProperty(path2); if (prop2 != null) return; // found path1 but not path2! String text = report.translate( "err.exists.without", Gedcom.getName(prop1.getTag()), Gedcom.getName(path2.getLast())); issues.add(new ViewContext(prop1).setText(text)); }