Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address of IndividualAttribute printed twice #208

Open
LukasHolzner opened this issue Aug 21, 2022 · 0 comments
Open

Address of IndividualAttribute printed twice #208

LukasHolzner opened this issue Aug 21, 2022 · 0 comments

Comments

@LukasHolzner
Copy link

When adding an address to the IndividualAttribute, e.g. RESIdence, then the address appears twice in the resulting file.

The reason seems to be that the EventEmitter used to print the IndividualAttribute includes the AddressEmitter as well as the IndividualEmitter#emitIndividualAttributes

Extract from EventEmitter

    protected void emit() throws GedcomWriterException {
        emitTagIfValueNotNull(startLevel, "TYPE", writeFrom.getSubType());
        emitTagIfValueNotNull(startLevel, "DATE", writeFrom.getDate());
        new PlaceEmitter(baseWriter, startLevel, writeFrom.getPlace()).emit();
        new AddressEmitter(baseWriter, startLevel, writeFrom.getAddress()).emit(); // <--- Here the address is already emitted
        emitTagIfValueNotNull(startLevel, "AGE", writeFrom.getAge());
        emitTagIfValueNotNull(startLevel, "AGNC", writeFrom.getRespAgency());
        emitTagIfValueNotNull(startLevel, "CAUS", writeFrom.getCause());
        emitTagIfValueNotNull(startLevel, "RELI", writeFrom.getReligiousAffiliation());
        emitTagIfValueNotNull(startLevel, "RESN", writeFrom.getRestrictionNotice());
        new CitationEmitter(baseWriter, startLevel, writeFrom.getCitations()).emit();
        new MultimediaLinksEmitter(baseWriter, startLevel, writeFrom.getMultimedia()).emit();
        new NoteStructureEmitter(baseWriter, startLevel, writeFrom.getNoteStructures()).emit();
        emitCustomFacts(startLevel, writeFrom.getCustomFacts());
    }

Extract from IndividualEmitter

    private void emitIndividualAttributes(int level, List<IndividualAttribute> attributes) throws GedcomWriterException {
        if (attributes != null) {
            for (IndividualAttribute a : attributes) {
                emitTagWithOptionalValueAndCustomSubtags(level, a.getType().getTag(), a.getDescription());
                new EventEmitter(baseWriter, level + 1, a).emit();
                new AddressEmitter(baseWriter, level + 1, a.getAddress()).emit(); // <--- here it is emitted again
                emitStringsWithCustomFacts(level + 1, a.getPhoneNumbers(), "PHON");
                emitStringsWithCustomFacts(level + 1, a.getWwwUrls(), "WWW");
                emitStringsWithCustomFacts(level + 1, a.getFaxNumbers(), "FAX");
                emitStringsWithCustomFacts(level + 1, a.getEmails(), "EMAIL");
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant