continue;
}
int nPlurals = textFlow.isPlural() ? numPlurals : 1;
// we have eagerly loaded all targets upfront
HTextFlowTarget hTarget = textFlow.getTargets().get(locale.getId());
ContentState currentState = ContentState.New;
if (hTarget != null) {
currentState = hTarget.getState();
}
if (mergeType == MergeType.IMPORT) {
removedTargets.remove(hTarget);
}
TranslationMergeServiceFactory.MergeContext mergeContext =
new TranslationMergeServiceFactory.MergeContext(
mergeType, textFlow, locale, hTarget,
nPlurals);
TranslationMergeService mergeService =
translationMergeServiceFactory
.getMergeService(mergeContext);
boolean targetChanged =
mergeService.merge(incomingTarget, hTarget,
extensions);
if (hTarget == null) {
// in case hTarget was null, we need to
// retrieve it after merge
hTarget = textFlow.getTargets().get(locale.getId());
}
targetChanged |=
adjustContentsAndState(hTarget, nPlurals, warnings);
// update translation information if applicable
if (targetChanged) {
hTarget.setVersionNum(hTarget.getVersionNum() + 1);
changed = true;
Long actorId;
if (incomingTarget.getTranslator() != null) {
String email =
incomingTarget.getTranslator().getEmail();
HPerson hPerson = personDAO.findByEmail(email);
if (hPerson == null) {
hPerson = new HPerson();
hPerson.setEmail(email);
hPerson.setName(incomingTarget.getTranslator()
.getName());
personDAO.makePersistent(hPerson);
}
hTarget.setTranslator(hPerson);
hTarget.setLastModifiedBy(hPerson);
actorId = hPerson.getId();
} else {
hTarget.setTranslator(null);
hTarget.setLastModifiedBy(null);
actorId = null;
}
textFlowTargetDAO.makePersistent(hTarget);
signalPostTranslateEvent(actorId, hTarget, currentState);
}