From d302d494a995b976df92a9d4fc0bb21122d3c7f3 Mon Sep 17 00:00:00 2001 From: Hylston Barbosa Date: Mon, 14 Aug 2023 16:49:28 -0300 Subject: [PATCH] okapi dependency update from V. 0.36 to 1.43.0 which is the latest version supporting java 8 extractNoteFromXMLComment fix - replaced textUnit.getProperty to textUnitUtils.getNote method getNote fix - return textUnit.getProperty(NoteAnnotation.LOC_NOTE) if the property is not null adding empty line at the end of the yaml files. The source file has the empty line at the end, so okapi version upgrade should have fixed it. XLIFFNoteAnnotation was deprecated and removed. NoteAnnotation class came as a replacement for the old XLIFFNoteAnnotation class. XLIFFNote was deprecated and removed. Note class came as a replacement for the old XLIFFNote class. Property.NOTE string constant was deprecated and removed. It as replaced by NoteAnnotation.LOC_NOTE. The value of the string constant is no longer the same. Property.NOTE value was 'note' and NoteAnnotation.LOC_NOTE value is 'developer' --- .../expected/demo_fr-CA.yaml | 2 +- .../expected/demo_fr-FR.yaml | 2 +- .../expected/demo_ja-JP.yaml | 2 +- .../box/l10n/mojito/okapi/TextUnitUtils.java | 14 +++--- .../mojito/okapi/filters/AndroidFilter.java | 3 +- .../l10n/mojito/okapi/filters/CSVFilter.java | 3 +- .../l10n/mojito/okapi/filters/JSFilter.java | 3 +- .../l10n/mojito/okapi/filters/JSONFilter.java | 43 +++++++++---------- .../filters/MacStringsdictFilterKey.java | 3 +- ...FilterEventsToInMemoryRawDocumentStep.java | 4 +- pom.xml | 2 +- .../okapi/ImportExportTextUnitUtils.java | 16 +++---- .../box/l10n/mojito/okapi/TranslateStep.java | 2 +- .../box/l10n/mojito/okapi/XLIFFWriter.java | 16 +++---- .../mojito/okapi/qualitycheck/Parameters.java | 1 - .../translationkit/TranslationKitFilter.java | 12 +++--- .../l10n/mojito/factory/XliffDataFactory.java | 5 ++- 17 files changed, 67 insertions(+), 66 deletions(-) diff --git a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-CA.yaml b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-CA.yaml index b4a2299c82..5686254f49 100644 --- a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-CA.yaml +++ b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-CA.yaml @@ -64,4 +64,4 @@ components: schema: type: string pattern: ^\d+$ - maxLength: 18 \ No newline at end of file + maxLength: 18 diff --git a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-FR.yaml b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-FR.yaml index b4a2299c82..5686254f49 100644 --- a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-FR.yaml +++ b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_fr-FR.yaml @@ -64,4 +64,4 @@ components: schema: type: string pattern: ^\d+$ - maxLength: 18 \ No newline at end of file + maxLength: 18 diff --git a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_ja-JP.yaml b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_ja-JP.yaml index 8da13603b2..540601a2c7 100644 --- a/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_ja-JP.yaml +++ b/cli/src/test/resources/com/box/l10n/mojito/cli/command/ImportLocalizedAssetCommandTest_IO/importYamlWithExtractFields/expected/demo_ja-JP.yaml @@ -64,4 +64,4 @@ components: schema: type: string pattern: ^\d+$ - maxLength: 18 \ No newline at end of file + maxLength: 18 diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/TextUnitUtils.java b/common/src/main/java/com/box/l10n/mojito/okapi/TextUnitUtils.java index a315f816ef..3cb6d94010 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/TextUnitUtils.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/TextUnitUtils.java @@ -1,7 +1,7 @@ package com.box.l10n.mojito.okapi; import java.util.Objects; -import net.sf.okapi.common.annotation.XLIFFNoteAnnotation; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.resource.ITextUnit; import net.sf.okapi.common.resource.Property; import net.sf.okapi.common.resource.TextContainer; @@ -30,12 +30,12 @@ public String getNote(ITextUnit textUnit) { if (textUnit != null) { - XLIFFNoteAnnotation xliffNoteAnnotation = textUnit.getAnnotation(XLIFFNoteAnnotation.class); - - if (xliffNoteAnnotation == null) { - note = Objects.toString(textUnit.getProperty(Property.NOTE), null); + NoteAnnotation noteAnnotation = textUnit.getAnnotation(NoteAnnotation.class); + Property noteProp = textUnit.getProperty(NoteAnnotation.LOC_NOTE); + if (noteAnnotation == null || noteProp != null) { + note = Objects.toString(noteProp, null); } else { - note = xliffNoteAnnotation.getNote(0).getNoteText(); + note = noteAnnotation.getNote(0).getNoteText(); } } @@ -51,7 +51,7 @@ public String getNote(ITextUnit textUnit) { public void setNote(ITextUnit textUnit, String note) { if (textUnit != null) { - textUnit.setProperty(new Property(Property.NOTE, note)); + textUnit.setProperty(new Property(NoteAnnotation.LOC_NOTE, note)); } } diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/AndroidFilter.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/AndroidFilter.java index 690df5243f..305328857e 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/AndroidFilter.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/AndroidFilter.java @@ -10,7 +10,6 @@ import net.sf.okapi.common.LocaleId; import net.sf.okapi.common.filters.FilterConfiguration; import net.sf.okapi.common.resource.ITextUnit; -import net.sf.okapi.common.resource.Property; import net.sf.okapi.common.resource.RawDocument; import net.sf.okapi.common.resource.TextUnit; import net.sf.okapi.common.skeleton.GenericSkeleton; @@ -198,7 +197,7 @@ protected void extractNoteFromXMLCommentInSkeletonIfNone(TextUnit textUnit) { String skeleton = textUnit.getSkeleton().toString(); - if (textUnit.getProperty(Property.NOTE) == null) { + if (textUnitUtils.getNote(textUnit) == null) { String note = getNoteFromXMLCommentsInSkeleton(skeleton); if (note != null) { textUnitUtils.setNote(textUnit, note); diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/CSVFilter.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/CSVFilter.java index 1e5b30c654..a96c5765a4 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/CSVFilter.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/CSVFilter.java @@ -1,5 +1,6 @@ package com.box.l10n.mojito.okapi.filters; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.resource.ITextUnit; import net.sf.okapi.common.resource.Property; import net.sf.okapi.filters.table.csv.CommaSeparatedValuesFilter; @@ -45,7 +46,7 @@ public CSVFilter() { @Override protected boolean processTU(ITextUnit textUnit) { - Property note = textUnit.getProperty(Property.NOTE); + Property note = textUnit.getProperty(NoteAnnotation.LOC_NOTE); if (note != null) { String comments = note.toString(); char quote = "\"".charAt(0); diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSFilter.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSFilter.java index 0426dad4e2..7b0a6ae3f6 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSFilter.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSFilter.java @@ -14,6 +14,7 @@ import net.sf.okapi.common.IParameters; import net.sf.okapi.common.MimeTypeMapper; import net.sf.okapi.common.Util; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.encoder.EncoderManager; import net.sf.okapi.common.exceptions.OkapiIOException; import net.sf.okapi.common.exceptions.OkapiUnsupportedEncodingException; @@ -268,7 +269,7 @@ private TextUnit readTextUnit() { skel.append(data.toString()); textUnit = processKeyValueLine(); if (textUnit != null && comment != null) { - textUnit.setProperty(new Property(Property.NOTE, comment, true)); + textUnit.setProperty(new Property(NoteAnnotation.LOC_NOTE, comment, true)); } break; } else { diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java index 255d5ab2f6..55233f7d4e 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/JSONFilter.java @@ -10,8 +10,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.okapi.common.Event; -import net.sf.okapi.common.annotation.XLIFFNote; -import net.sf.okapi.common.annotation.XLIFFNoteAnnotation; +import net.sf.okapi.common.annotation.Note; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.filters.FilterConfiguration; import net.sf.okapi.common.resource.ITextUnit; import net.sf.okapi.common.resource.RawDocument; @@ -44,7 +44,7 @@ public class JSONFilter extends net.sf.okapi.filters.json.JSONFilter { */ boolean noteKeepOrReplace = false; - XLIFFNoteAnnotation xliffNoteAnnotation; + NoteAnnotation noteAnnotation; UsagesAnnotation usagesAnnotation; String currentKeyName; String comment = null; @@ -144,17 +144,17 @@ void extractUsageIfMatch(String value) { } } - void addXliffNote(String value) { - XLIFFNote xliffNote = new XLIFFNote(value); - xliffNote.setFrom(currentKeyName); - xliffNote.setAnnotates(XLIFFNote.Annotates.SOURCE); + void addNote(String value) { + Note note = new Note(value); + note.setFrom(currentKeyName); + note.setAnnotates(Note.Annotates.SOURCE); - if (xliffNoteAnnotation == null || noteKeepOrReplace) { - logger.debug("create the xliff note annotation"); - xliffNoteAnnotation = new XLIFFNoteAnnotation(); + if (noteAnnotation == null || noteKeepOrReplace) { + logger.debug("create the note annotation"); + noteAnnotation = new NoteAnnotation(); } - xliffNoteAnnotation.add(xliffNote); + noteAnnotation.add(note); } void extractNoteIfMatch(String value) { @@ -163,7 +163,7 @@ void extractNoteIfMatch(String value) { if (m.matches()) { logger.debug("key matches noteKeyPattern, add the value as note"); - addXliffNote(value); + addNote(value); } } } @@ -172,10 +172,10 @@ void processComment() { if (comment != null) { ITextUnit textUnit = getEventTextUnit(); if (textUnit != null) { - String xliffNote = comment.replace("//", "").trim(); - addXliffNote(xliffNote); - textUnit.setAnnotation(xliffNoteAnnotation); - xliffNoteAnnotation = null; + String note = comment.replace("//", "").trim(); + addNote(note); + textUnit.setAnnotation(noteAnnotation); + noteAnnotation = null; } comment = null; } @@ -184,14 +184,14 @@ void processComment() { @Override public void handleObjectEnd() { - if (xliffNoteAnnotation != null || usagesAnnotation != null) { + if (noteAnnotation != null || usagesAnnotation != null) { ITextUnit textUnit = getEventTextUnit(); if (textUnit != null) { - if (xliffNoteAnnotation != null) { + if (noteAnnotation != null) { logger.debug("Set note on text unit with name: {}", textUnit.getName()); - textUnit.setAnnotation(xliffNoteAnnotation); + textUnit.setAnnotation(noteAnnotation); } if (usagesAnnotation != null) { @@ -203,10 +203,9 @@ public void handleObjectEnd() { } } - logger.debug( - "Reset the xliffNoteAnnotation and Usage Annotation if not using keepOrReplace option"); + logger.debug("Reset the noteAnnotation and Usage Annotation if not using keepOrReplace option"); if (!noteKeepOrReplace) { - xliffNoteAnnotation = null; + noteAnnotation = null; } if (!usagesKeepOrReplace) { diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/filters/MacStringsdictFilterKey.java b/common/src/main/java/com/box/l10n/mojito/okapi/filters/MacStringsdictFilterKey.java index afb13631cf..7ca3d8eb48 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/filters/MacStringsdictFilterKey.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/filters/MacStringsdictFilterKey.java @@ -6,6 +6,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.okapi.common.*; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.filters.FilterConfiguration; import net.sf.okapi.common.resource.*; import net.sf.okapi.common.skeleton.GenericSkeleton; @@ -121,7 +122,7 @@ protected void extractNoteFromXMLCommentInSkeletonIfNone(TextUnit textUnit) { String skeleton = textUnit.getSkeleton().toString(); - if (textUnit.getProperty(Property.NOTE) == null) { + if (textUnit.getProperty(NoteAnnotation.LOC_NOTE) == null) { String note = getNoteFromXMLCommentsInSkeleton(skeleton); if (note != null) { comment = note; diff --git a/common/src/main/java/com/box/l10n/mojito/okapi/steps/FilterEventsToInMemoryRawDocumentStep.java b/common/src/main/java/com/box/l10n/mojito/okapi/steps/FilterEventsToInMemoryRawDocumentStep.java index a7119fea45..5c3c93c401 100644 --- a/common/src/main/java/com/box/l10n/mojito/okapi/steps/FilterEventsToInMemoryRawDocumentStep.java +++ b/common/src/main/java/com/box/l10n/mojito/okapi/steps/FilterEventsToInMemoryRawDocumentStep.java @@ -80,7 +80,7 @@ public Event handleEvent(Event event) { switch (event.getEventType()) { case START_DOCUMENT: handleStartDocument(event); - return Event.NOOP_EVENT; + return Event.createNoopEvent(); case END_DOCUMENT: return processEndDocument(event); @@ -95,7 +95,7 @@ public Event handleEvent(Event event) { case TEXT_UNIT: // handle all the events between START_DOCUMENT and END_DOCUMENT filterWriter.handleEvent(event); - return Event.NOOP_EVENT; + return Event.createNoopEvent(); } // Else, just return the event diff --git a/pom.xml b/pom.xml index 6c0d98727d..760253f7d9 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 3.5.1 2.8.2 2.5.3 - 0.36 + 1.43.0 29.0-jre 1.4 6.0.1.GA diff --git a/webapp/src/main/java/com/box/l10n/mojito/okapi/ImportExportTextUnitUtils.java b/webapp/src/main/java/com/box/l10n/mojito/okapi/ImportExportTextUnitUtils.java index 381fe2d68d..cef36422f5 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/okapi/ImportExportTextUnitUtils.java +++ b/webapp/src/main/java/com/box/l10n/mojito/okapi/ImportExportTextUnitUtils.java @@ -3,8 +3,8 @@ import com.box.l10n.mojito.json.ObjectMapper; import com.box.l10n.mojito.service.tm.ImportExportNote; import java.io.IOException; -import net.sf.okapi.common.annotation.XLIFFNote; -import net.sf.okapi.common.annotation.XLIFFNoteAnnotation; +import net.sf.okapi.common.annotation.Note; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.resource.ITextUnit; import net.sf.okapi.common.resource.Property; import net.sf.okapi.common.resource.TextUnit; @@ -33,7 +33,7 @@ public class ImportExportTextUnitUtils { public void setNote(ITextUnit textUnit, String note) { if (textUnit != null) { - textUnit.setProperty(new Property(Property.NOTE, note)); + textUnit.setProperty(new Property(NoteAnnotation.LOC_NOTE, note)); } } @@ -76,15 +76,15 @@ public void setImportExportNote(ITextUnit textUnit, ImportExportNote importExpor String importExportNoteStr = objectMapper.writeValueAsStringUnchecked(importExportNote); - XLIFFNoteAnnotation xliffNoteAnnotation = textUnit.getAnnotation(XLIFFNoteAnnotation.class); + NoteAnnotation noteAnnotation = textUnit.getAnnotation(NoteAnnotation.class); - if (xliffNoteAnnotation == null) { - xliffNoteAnnotation = new XLIFFNoteAnnotation(); - textUnit.setAnnotation(xliffNoteAnnotation); + if (noteAnnotation == null) { + noteAnnotation = new NoteAnnotation(); + textUnit.setAnnotation(noteAnnotation); } else { setNote(textUnit, importExportNoteStr); } - xliffNoteAnnotation.add(new XLIFFNote(importExportNoteStr)); + noteAnnotation.add(new Note(importExportNoteStr)); } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/okapi/TranslateStep.java b/webapp/src/main/java/com/box/l10n/mojito/okapi/TranslateStep.java index b77c3ab405..e4ebcdb9ec 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/okapi/TranslateStep.java +++ b/webapp/src/main/java/com/box/l10n/mojito/okapi/TranslateStep.java @@ -138,7 +138,7 @@ protected Event handleTextUnit(Event event) { if (androidEvent == null) { switch (getRemoveUntranslatedStrategyFromAnnotation()) { case NOOP_EVENT: - event = Event.NOOP_EVENT; + event = Event.createNoopEvent(); break; case PLACEHOLDER_AND_POST_PROCESSING: logger.debug("Set untranslated placeholder for text unit with name: {}", name); diff --git a/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java b/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java index c5ff71ef39..8b57f70688 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java +++ b/webapp/src/main/java/com/box/l10n/mojito/okapi/XLIFFWriter.java @@ -18,9 +18,9 @@ import net.sf.okapi.common.annotation.GenericAnnotations; import net.sf.okapi.common.annotation.ITSLQIAnnotations; import net.sf.okapi.common.annotation.ITSProvenanceAnnotations; +import net.sf.okapi.common.annotation.Note; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.annotation.TermsAnnotation; -import net.sf.okapi.common.annotation.XLIFFNote; -import net.sf.okapi.common.annotation.XLIFFNoteAnnotation; import net.sf.okapi.common.encoder.EncoderManager; import net.sf.okapi.common.filterwriter.IFilterWriter; import net.sf.okapi.common.filterwriter.ITSContent; @@ -602,23 +602,23 @@ public void writeTextUnit(ITextUnit tu, String phaseName) { } // Notes - if (tu.hasProperty(Property.NOTE)) { + if (tu.hasProperty(NoteAnnotation.LOC_NOTE)) { writer.writeStartElement("note"); - writer.writeString(tu.getProperty(Property.NOTE).getValue()); + writer.writeString(tu.getProperty(NoteAnnotation.LOC_NOTE).getValue()); writer.writeEndElementLineBreak(); // note } - if (tu.hasProperty(Property.TRANSNOTE)) { + if (tu.hasProperty(NoteAnnotation.TRANS_NOTE)) { writer.writeStartElement("note"); writer.writeAttributeString("from", "translator"); - writer.writeString(tu.getProperty(Property.TRANSNOTE).getValue()); + writer.writeString(tu.getProperty(NoteAnnotation.TRANS_NOTE).getValue()); writer.writeEndElementLineBreak(); // note } // CHANGES FOR MOJITO - XLIFFNoteAnnotation annotation = tu.getAnnotation(XLIFFNoteAnnotation.class); + NoteAnnotation annotation = tu.getAnnotation(NoteAnnotation.class); if (annotation != null) { - XLIFFNote note = annotation.getNote(0); + Note note = annotation.getNote(0); writer.writeStartElement("note"); writer.writeString(note.getNoteText()); writer.writeEndElementLineBreak(); diff --git a/webapp/src/main/java/com/box/l10n/mojito/okapi/qualitycheck/Parameters.java b/webapp/src/main/java/com/box/l10n/mojito/okapi/qualitycheck/Parameters.java index 218c5d24ff..ff410462bc 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/okapi/qualitycheck/Parameters.java +++ b/webapp/src/main/java/com/box/l10n/mojito/okapi/qualitycheck/Parameters.java @@ -19,7 +19,6 @@ public void disableAllChecks() { setCheckXliffSchema(false); setCheckPatterns(false); setCheckWithLT(false); - setTranslateLTMsg(false); setLtBilingualMode(false); setDoubledWord(false); setCorruptedCharacters(false); diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/translationkit/TranslationKitFilter.java b/webapp/src/main/java/com/box/l10n/mojito/service/translationkit/TranslationKitFilter.java index 6b590dbb10..916c4d5506 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/translationkit/TranslationKitFilter.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/translationkit/TranslationKitFilter.java @@ -19,8 +19,8 @@ import net.sf.okapi.common.EventType; import net.sf.okapi.common.IParameters; import net.sf.okapi.common.LocaleId; -import net.sf.okapi.common.annotation.XLIFFNote; -import net.sf.okapi.common.annotation.XLIFFNoteAnnotation; +import net.sf.okapi.common.annotation.Note; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.encoder.EncoderManager; import net.sf.okapi.common.filters.FilterConfiguration; import net.sf.okapi.common.filters.IFilter; @@ -235,10 +235,10 @@ private TextUnit getNextTextUnit() throws NoSuchElementException { if (textUnitDTO.getComment() != null) { importExportTextUnitUtils.setNote(textUnit, textUnitDTO.getComment()); - XLIFFNoteAnnotation xliffNoteAnnotation = new XLIFFNoteAnnotation(); - XLIFFNote xliffNote = new XLIFFNote(textUnitDTO.getComment()); - xliffNoteAnnotation.add(xliffNote); - textUnit.getSource().setAnnotation(xliffNoteAnnotation); + NoteAnnotation noteAnnotation = new NoteAnnotation(); + Note xliffNote = new Note(textUnitDTO.getComment()); + noteAnnotation.add(xliffNote); + textUnit.getSource().setAnnotation(noteAnnotation); } return textUnit; diff --git a/webapp/src/test/java/com/box/l10n/mojito/factory/XliffDataFactory.java b/webapp/src/test/java/com/box/l10n/mojito/factory/XliffDataFactory.java index d8ee736fd8..2ef852b934 100644 --- a/webapp/src/test/java/com/box/l10n/mojito/factory/XliffDataFactory.java +++ b/webapp/src/test/java/com/box/l10n/mojito/factory/XliffDataFactory.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Objects; import net.sf.okapi.common.LocaleId; +import net.sf.okapi.common.annotation.NoteAnnotation; import net.sf.okapi.common.resource.Property; import net.sf.okapi.common.resource.TextContainer; import net.sf.okapi.common.resource.TextUnit; @@ -51,7 +52,7 @@ public TextUnit createTextUnit( textUnit.setName(name); if (note != null) { - textUnit.setSourceProperty(new Property(Property.NOTE, note)); + textUnit.setSourceProperty(new Property(NoteAnnotation.LOC_NOTE, note)); } if (target != null && targetBcp47Tag != null) { @@ -130,7 +131,7 @@ private String generateXliff(List textUnits, String targetBcp47Tag) { ">" + textUnit.getTarget(LocaleId.fromBCP47(targetBcp47Tag)).toString() + "\n"; } - String note = Objects.toString(textUnit.getSourceProperty(Property.NOTE), null); + String note = Objects.toString(textUnit.getSourceProperty(NoteAnnotation.LOC_NOTE), null); if (note != null) { if (!isTargetXliff) { // Okapi does not indent code properly...