<commit_before>package org.zanata.webtrans.shared.rpc;

import java.util.List;

import org.zanata.webtrans.client.service.GetTransUnitActionContext;
import org.zanata.webtrans.shared.model.ContentStateGroup;
import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.TransUnitId;
import org.zanata.webtrans.shared.model.ValidationId;

import com.google.common.base.Objects;

public class GetTransUnitList extends AbstractWorkspaceAction<GetTransUnitListResult>
{
   private static final long serialVersionUID = 1L;
   private int offset;
   private int count;
   private DocumentId documentId;
   private String phrase;
   private ContentStateGroup filterStates;
   private boolean filterHasError;
   private List<ValidationId> validationIds;
   private TransUnitId targetTransUnitId;
   private boolean needReloadIndex = false;

   private GetTransUnitList()
   {
   }

   private GetTransUnitList(GetTransUnitActionContext context)
   {
      documentId = context.getDocument().getId();
      offset = context.getOffset();
      count = context.getCount();
      phrase = context.getFindMessage();
      // @formatter :off
      filterStates = ContentStateGroup.builder()
            .includeNew(context.isFilterUntranslated())
            .includeFuzzy(context.isFilterNeedReview())
            .includeTranslated(context.isFilterTranslated())
            .includeApproved(context.isFilterApproved())
            .includeRejected(context.isFilterRejected())
            .build();
      // @formatter :on
      filterHasError = context.isFilterHasError();
      targetTransUnitId = context.getTargetTransUnitId();
      validationIds = context.getValidationIds();
   }

   public static GetTransUnitList newAction(GetTransUnitActionContext context)
   {
      return new GetTransUnitList(context);
   }<commit_msg>make editor request all states when no states checked in UI<commit_after>package org.zanata.webtrans.shared.rpc;

import java.util.List;

import org.zanata.webtrans.client.service.GetTransUnitActionContext;
import org.zanata.webtrans.shared.model.ContentStateGroup;
import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.TransUnitId;
import org.zanata.webtrans.shared.model.ValidationId;

import com.google.common.base.Objects;

public class GetTransUnitList extends AbstractWorkspaceAction<GetTransUnitListResult>
{
   private static final long serialVersionUID = 1L;
   private int offset;
   private int count;
   private DocumentId documentId;
   private String phrase;
   private ContentStateGroup filterStates;
   private boolean filterHasError;
   private List<ValidationId> validationIds;
   private TransUnitId targetTransUnitId;
   private boolean needReloadIndex = false;

   private GetTransUnitList()
   {
   }

   private GetTransUnitList(GetTransUnitActionContext context)
   {
      documentId = context.getDocument().getId();
      offset = context.getOffset();
      count = context.getCount();
      phrase = context.getFindMessage();
      setIncludeStatesFrom(context);
      setIncludeAllStateIfNoneSelected();
      filterHasError = context.isFilterHasError();
      targetTransUnitId = context.getTargetTransUnitId();
      validationIds = context.getValidationIds();
   }

   private void setIncludeStatesFrom(GetTransUnitActionContext context)
   {
      // @formatter :off
      filterStates = ContentStateGroup.builder()
            .includeNew(context.isFilterUntranslated())
            .includeFuzzy(context.isFilterNeedReview())
            .includeTranslated(context.isFilterTranslated())
            .includeApproved(context.isFilterApproved())
            .includeRejected(context.isFilterRejected())
            .build();
      // @formatter :on
   }

   private void setIncludeAllStateIfNoneSelected()
   {
      if (filterStates.hasNoStates())
      {
         filterStates = ContentStateGroup.builder().addAll().build();
      }
   }

   public static GetTransUnitList newAction(GetTransUnitActionContext context)
   {
      return new GetTransUnitList(context);
   }
{'fraction_non_alphanumeric': 0.08699902248289346, 'fraction_numerical': 0.0004887585532746823, 'mean_word_length': 3.8726190476190476, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2146636', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1089, 'n_words': 211}