Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
  /**
   * 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;
  }