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

Commit

Permalink
Merge pull request #58 from zanata/fix-optimization-bug
Browse files Browse the repository at this point in the history
rely on content not content state when determine what can be omitted in push
  • Loading branch information
Patrick Huang committed Apr 23, 2015
2 parents 70be8f9 + ed6acb0 commit 01b6542
Showing 1 changed file with 19 additions and 5 deletions.
Expand Up @@ -39,10 +39,13 @@
import org.zanata.rest.dto.resource.TranslationsResource;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.base.Strings;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.UniformInterfaceException;

import static com.google.common.collect.Collections2.filter;
import static com.google.common.collect.Iterables.all;

/**
* @author Sean Flanigan <a
* href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
Expand Down Expand Up @@ -452,14 +455,25 @@ private static void stripUntranslatedEntriesIfMergeTypeIsNotImport(
if (!MergeType.IMPORT.name().equalsIgnoreCase(mergeType)) {
List<TextFlowTarget> originalTargets =
translationResources.getTextFlowTargets();
Collection<TextFlowTarget> untranslatedEntries = Collections2
.filter(originalTargets,
final Predicate<String> blankStringPredicate =
new Predicate<String>() {
@Override
public boolean apply(String input) {
return Strings.isNullOrEmpty(input);
}
};

Collection<TextFlowTarget> untranslatedEntries =
filter(originalTargets,
new Predicate<TextFlowTarget>() {
@Override
public boolean apply(
TextFlowTarget input) {
return input == null ||
input.getState().isUntranslated();
// it's unsafe to rely on content state (plural entries)
return input == null
|| input.getContents().isEmpty()
|| all(input.getContents(),
blankStringPredicate);
}
});
log.debug(
Expand Down

0 comments on commit 01b6542

Please sign in to comment.