/**
  * Indicates if a Copy Trans found match should overwrite the currently stored one based on their
  * states.
  */
 private static boolean shouldOverwrite(HTextFlowTarget currentlyStored, ContentState matchState) {
   if (matchState == ContentState.New) {
     return false;
   } else if (currentlyStored != null) {
     if (currentlyStored.getState().isRejectedOrFuzzy() && matchState.isTranslated()) {
       return true; // If it's fuzzy, replace only with approved ones
     } else if (currentlyStored.getState() == ContentState.Translated && matchState.isApproved()) {
       return true; // If it's Translated and found an Approved one
     } else if (currentlyStored.getState() == ContentState.New) {
       return true; // If it's new, replace always
     } else {
       return false;
     }
   }
   return true;
 }
Exemplo n.º 2
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = super.hashCode();
   result = prime * result + ((description == null) ? 0 : description.hashCode());
   result = prime * result + ((extensions == null) ? 0 : extensions.hashCode());
   result = prime * result + ((resId == null) ? 0 : resId.hashCode());
   result = prime * result + ((state == null) ? 0 : state.hashCode());
   result = prime * result + ((translator == null) ? 0 : translator.hashCode());
   result = prime * result + ((revision == null) ? 0 : revision.hashCode());
   result = prime * result + ((textFlowRevision == null) ? 0 : textFlowRevision.hashCode());
   return result;
 }
  /**
   * Run enforced validation check(Error) if translation is saving as 'Translated'.
   *
   * @param newState
   * @param projectVersion
   * @param sources
   * @param translations
   * @return if translation has validation error
   */
  private boolean validationTranslations(
      ContentState newState,
      HProjectIteration projectVersion,
      List<String> sources,
      List<String> translations) {
    if (newState.isTranslated()) {
      List<String> validationMessages =
          validationServiceImpl.validateWithServerRules(
              projectVersion, sources, translations, ValidationAction.State.Error);

      if (!validationMessages.isEmpty()) {
        log.warn(validationMessages.toString());
        return true;
      }
    }
    return false;
  }
Exemplo n.º 4
0
 public void setContentState(String contentState) {
   this.contentState = ContentState.valueOf(contentState);
 }