Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
rhbz867657 - Break up translation push into different transactions.
The translation push process is now broken up into several transactions to avoid transaction timeouts for large documents (using async push).
  • Loading branch information
Carlos Munoz committed Oct 19, 2012
1 parent 8c64537 commit c11c40c
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 114 deletions.
Expand Up @@ -261,8 +261,10 @@ public HTextFlowTarget getOrCreateTarget(HTextFlow hTextFlow, HLocale hLocale)
public HTextFlowTarget getTextFlowTarget(HTextFlow hTextFlow, HLocale hLocale)
{
HTextFlowTarget hTextFlowTarget =
(HTextFlowTarget)getSession().createQuery("select tf.targets[:localeId] from HTextFlow tf")
.setParameter("localeId", hLocale.getId())
(HTextFlowTarget)getSession().createQuery(
"select tft from HTextFlowTarget tft where tft.textFlow = :textFlow and tft.locale = :locale")
.setParameter("textFlow", hTextFlow)
.setParameter("locale", hLocale)
.uniqueResult();
return hTextFlowTarget;
}
Expand Down
Expand Up @@ -251,6 +251,12 @@ public ProcessStatus startTranslatedDocCreationOrUpdate(final @PathParam("id") S
RunnableProcess<MessagesProcessHandle> process =
new RunnableProcess<MessagesProcessHandle>()
{
@Override
protected void prepare(MessagesProcessHandle handle)
{
handle.setMaxProgress( translatedDoc.getTextFlowTargets().size() );
}

@Override
protected void run(MessagesProcessHandle handle) throws Throwable
{
Expand Down Expand Up @@ -302,7 +308,7 @@ public ProcessStatus getProcessStatus(@PathParam("processId") String processId)
int perComplete = 100;
if(handle.getMaxProgress() > 0)
{
perComplete = (handle.getCurrentProgress() / handle.getMaxProgress()) * 100;
perComplete = (handle.getCurrentProgress() * 100 / handle.getMaxProgress());
}
status.setPercentageComplete(perComplete);
status.setUrl("" + processId);
Expand Down
Expand Up @@ -390,7 +390,7 @@ private boolean tryGetOrCreateTargetHeader(HDocument doc, HLocale locale, MergeT
// value
// not
// needed
doc.getPoTargetHeaders().put(locale, toTargetHeader);
entityManager.persist(toTargetHeader);
entityManager.flush();
}
else
Expand Down

0 comments on commit c11c40c

Please sign in to comment.