if (dqSource.getRepositoryRef() != null) {
Marker repoContext = ConversionContext.getDetachedMarker("REPO");
ConversionContext.addReference(repoContext);
try {
RepositoryRef dqRepositoryRef = dqSource.getRepositoryRef();
if (dqRepositoryRef.getRef() != null) {
gedxSourceDescription.setMediator(new ResourceReference(URI.create(CommonMapper.getOrganizationReference(dqRepositoryRef.getRef()))));
// TODO: map NOTEs as another note associated with this SourceDescription
}
else {
String inlineRepoId = dqSource.getId() + ".REPO";
Agent gedxOrganization = new Agent();
gedxOrganization.setId(inlineRepoId);
for (Note dqNote : dqRepositoryRef.getNotes()) {
org.gedcomx.common.Note gedxNote = new org.gedcomx.common.Note();
gedxNote.setText(dqNote.getValue());
gedxOrganization.addExtensionElement(gedxNote);
}
for (NoteRef dqNoteRef : dqRepositoryRef.getNoteRefs()) {
logger.warn(ConversionContext.getContext(), "Unable to associate a note ({}) with the inline-defined organization ({})", dqNoteRef.getRef(), inlineRepoId);
}
result.addOrganization(gedxOrganization);
gedxSourceDescription.setMediator(new ResourceReference(URI.create(CommonMapper.getOrganizationReference(inlineRepoId))));
}
if (dqRepositoryRef.getCallNumber() != null) {
CitationField field = new CitationField();
field.setName(URI.create("gedcom5:citation-template/call-number"));
field.setValue(dqRepositoryRef.getCallNumber());
citation.getFields().add(field);
citation.setValue(citation.getValue() + (citation.getValue().length() > 0 ? ", " + dqRepositoryRef.getCallNumber() : dqRepositoryRef.getCallNumber()));
}
}
finally {
ConversionContext.removeReference(repoContext);
}