コード例 #1
0
 private Set<Status> statusEn(List<TranslateableText> texts) {
   Set<Status> stati = new HashSet<Status>();
   for (TranslateableText translateableText : texts) {
     stati.add(translateableText.getStatusEn());
   }
   return stati;
 }
コード例 #2
0
 private Map<String, List<TranslateableText>> divideByFileType(List<TranslateableText> texts) {
   Map<String, List<TranslateableText>> fileMap =
       new LinkedHashMap<String, List<TranslateableText>>();
   for (TranslateableText text : texts) {
     addToMap(fileMap, text, text.getFileType());
   }
   return fileMap;
 }
コード例 #3
0
 @Test
 public void testGetOtherText() {
   TranslateableText text = mock(TranslateableText.class);
   modelElementDisplayController.setLang("it");
   when(text.getTextIt()).thenReturn("text_it");
   when(modelElementDisplayController.imageUrlUtil.adaptImageUrls(
           eq("text_it"), anyString(), eq("it")))
       .thenReturn("adapted_text_it");
   Assert.assertEquals("adapted_text_it", modelElementDisplayController.getOtherText(text));
 }
コード例 #4
0
 public void markModelElementAsInArbeit(ModelElement modelElement, List<String> langsToGenerate) {
   for (TranslateableText translateableText : modelElement.getTexts()) {
     if (langsToGenerate.contains("fr")) {
       translateableText.setStatusFr(IN_ARBEIT);
     }
     if (langsToGenerate.contains("it")) {
       translateableText.setStatusIt(IN_ARBEIT);
     }
     if (langsToGenerate.contains("en")) {
       translateableText.setStatusEn(IN_ARBEIT);
     }
     translateableTextDAO.merge(translateableText);
   }
 }
コード例 #5
0
 @Override
 public String getLocalizedText(
     String modelIdentifier, String language, String elementIdentifier, String textIdentifier) {
   TranslateableText t = getTranslateableText(modelIdentifier, elementIdentifier, textIdentifier);
   if (t == null) {
     return null;
   }
   if ("fr".equals(language)) {
     return t.getTextFr();
   }
   if ("it".equals(language)) {
     return t.getTextIt();
   }
   if ("en".equals(language)) {
     return t.getTextEn();
   }
   return t.getTextDe();
 }
コード例 #6
0
  public ModelElement getModelElement(String modelIdentifier, String rootElementIdentifier) {
    List<TranslateableText> modelElementTexts = new ArrayList<TranslateableText>();
    List<TranslateableText> texts = translateableTextDAO.getTexts(modelIdentifier);
    for (TranslateableText text : texts) {
      if (text.getRootElementIdentifier().equals(rootElementIdentifier)) {
        modelElementTexts.add(text);
      }
    }

    TranslateableText firstText = modelElementTexts.get(0);
    return new ModelElement(
        firstText.getFileType(),
        firstText.getFileName(),
        status(statusFr(modelElementTexts)),
        status(statusIt(modelElementTexts)),
        status(statusEn(modelElementTexts)),
        modelElementTexts);
  }
コード例 #7
0
 @Test
 public void testDeleteTexts() {
   modelElementDisplayController.setLang("fr");
   TranslateableText text = mock(TranslateableText.class);
   when(text.getElementIdentifier()).thenReturn("element");
   when(text.getModelIdentifier()).thenReturn("model_identifier");
   when(text.getTextIdentifier()).thenReturn("text_identifier");
   EPFModel model = mock(EPFModel.class);
   ModelElement modelElement = mock(ModelElement.class);
   when(model.isPublished()).thenReturn(false);
   when(modelElementDisplayController.webPublisherFacade.getModel(anyString())).thenReturn(model);
   when(modelElementDisplayController.webPublisherFacade.getModelElement(anyString(), anyString()))
       .thenReturn(modelElement);
   SelectableRow<TranslateableText> row = new SelectableRow<TranslateableText>(text);
   row.setSelected(true);
   modelElementDisplayController.translateableTexts =
       new ArrayList<SelectableRow<TranslateableText>>();
   modelElementDisplayController.translateableTexts.add(row);
   modelElementDisplayController.deleteTexts();
   verify(modelElementDisplayController.webPublisherFacade)
       .deleteTranslateableText("model_identifier", "element", "text_identifier", "fr");
 }