customInjectionIds.add(sequenceID.topicId);
/*
* Pull the topic out of the list of related topics
*/
final TopicV1 relatedTopic = relatedTopicsDatabase.getTopic(sequenceID.topicId);
/*
* See if the topic is also available in the main
* database (if the main database is available)
*/
final boolean isInDatabase = database == null ? true : database.getTopic(sequenceID.topicId) != null;
/*
* It is possible that the topic id referenced in the
* injection point has not been related, or has not been
* included in the list of topics to process. This is a
* validity error
*/
if (relatedTopic != null && isInDatabase)
{
/*
* build our list
*/
List<List<Element>> list = new ArrayList<List<Element>>();
/*
* each related topic is added to a string, which is
* stored in the customInjections collection. the
* customInjections key is the custom injection text
* from the source xml. this allows us to match the
* xrefs we are generating for the related topic
* with the text in the xml file that these xrefs
* will eventually replace
*/
if (customInjections.containsKey(comment))
list = customInjections.get(comment).listItems;
/* wrap the xref up in a listitem */
if (sequenceID.optional)
{
if (internal)
{
final TranslatedTopicDataV1 relatedTranslatedTopicData = translatedTopicData.getLatestRelatedTranslationDataByTopicID(relatedTopic.getId());
if (relatedTranslatedTopicData != null)
{
final String url = getURLToInternalTranslatedTopic(relatedTranslatedTopicData.getTranslatedTopic().getId(), relatedTranslatedTopicData.getTranslationLocale());
/* Get the related translated data object and the title from the XML */
final String relatedTitle = DocBookUtilities.findTitle(relatedTranslatedTopicData.getTranslatedXml());
list.add(DocbookUtils.buildEmphasisPrefixedULink(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, url, relatedTitle));
}
else
{
final String url = getURLToInternalTopic(relatedTopic.getId());
final String relatedTopicTitle = "[" + relatedTopic.getLocale() + "] " + relatedTopic.getTitle() + "*";
list.add(DocbookUtils.buildEmphasisPrefixedULink(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, url, relatedTopicTitle));
/* Create an error note that is added at the bottom of the topic */
}
}
else
{
if (usedFixedUrls)
{
final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
if (propTag != null)
{
list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, propTag.getValue()));
}
else
{
list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
}
}
else
{
list.add(DocbookUtils.buildEmphasisPrefixedXRef(xmlDocument, XMLPreProcessor.OPTIONAL_LIST_PREFIX, relatedTopic.getXRefID()));
}
}
}
else
{
if (internal)
{
final TranslatedTopicDataV1 relatedTranslatedTopicData = translatedTopicData.getLatestRelatedTranslationDataByTopicID(relatedTopic.getId());
if (relatedTranslatedTopicData != null)
{
final String url = getURLToInternalTranslatedTopic(relatedTranslatedTopicData.getTranslatedTopic().getId(), relatedTranslatedTopicData.getTranslationLocale());
/* Get the related translated data object and the title from the XML */
final String relatedTitle = DocBookUtilities.findTitle(relatedTranslatedTopicData.getTranslatedXml());
list.add(DocbookUtils.buildULink(xmlDocument, url, relatedTitle));
}
else
{
final String url = getURLToInternalTopic(relatedTopic.getId());
final String relatedTopicTitle = "[" + relatedTopic.getLocale() + "] " + relatedTopic.getTitle() + "*";
list.add(DocbookUtils.buildULink(xmlDocument, url, relatedTopicTitle));
translatedTopicTitleErrors.addTitle(relatedTopic.getTitle());
}
}
else
{
if (usedFixedUrls)
{
final PropertyTagV1 propTag = relatedTopic.getProperty(CommonConstants.FIXED_URL_PROP_TAG_ID);
if (propTag != null)
{
list.add(DocbookUtils.buildXRef(xmlDocument, propTag.getValue()));
}
else
{
list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
}
}
else
{
list.add(DocbookUtils.buildXRef(xmlDocument, relatedTopic.getXRefID()));
}
}
}
/*