Skip to content

Commit

Permalink
Merge pull request zanata#971 from zanata/java18
Browse files Browse the repository at this point in the history
enable Java 1.8 for compilation
  • Loading branch information
seanf committed Sep 29, 2015
2 parents d10c4c6 + 4799399 commit b6fda00
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 192 deletions.
22 changes: 21 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@
<lucene.version>3.6.2</lucene.version>
<org.mock-server.version>3.9.17</org.mock-server.version>

<!--
Version of java compiler used for building. (Specified as major.minor,
as used by javac -source and -target).
-->
<required.java>1.8</required.java>
<!--
Version of Java used for runtime (major.minor) and for bytecode
generation. Should correspond with animal.sniffer.signature.
-->
<!-- NB: When changing this, be sure to update the rpm's spec file to match -->
<required.jvm>1.8</required.jvm>
<!--
Version of Java used for API compatibility checking. Should
correspond with required.jvm.
-->
<animal.sniffer.signature>java18</animal.sniffer.signature>

<!-- Not currently working for Java 1.8: https://github.com/mojohaus/animal-sniffer/issues/1 -->
<animal.sniffer.skip>true</animal.sniffer.skip>

<!--
Not used yet.
Expand Down Expand Up @@ -1519,7 +1539,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<version>2.7</version>
<configuration>
<formats>
<format>xml</format>
Expand Down
17 changes: 7 additions & 10 deletions zanata-model/src/main/java/org/zanata/model/HTextFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,9 @@ public Map<Long, HTextFlowTarget> getTargets() {
@Override
public ITextFlowTarget getTargetContents(LocaleId localeId) {
// TODO performance: need efficient way to look up a target by LocaleId
Collection<HTextFlowTarget> targets = getTargets().values();
for (HTextFlowTarget tft : targets) {
if (tft.getLocaleId().equals(localeId))
return tft;
}
return null;
return getTargets().values().stream()
.filter(tft -> tft.getLocaleId().equals(localeId))
.findFirst().orElse(null);
}

@Transient
Expand Down Expand Up @@ -445,10 +442,10 @@ private void updateWordCount() {
String locale = toBCP47(document.getLocale());
// TODO strip (eg) HTML tags before counting words. Needs more metadata
// about the content type.
long count = 0;
for (String content : this.getContents()) {
count += OkapiUtil.countWords(content, locale);
}

long count = this.getContents().stream()
.mapToLong(s -> OkapiUtil.countWords(s, locale))
.sum();
setWordCount(count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
package org.zanata.model.tm;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -47,8 +49,6 @@
import org.zanata.util.HashUtil;
import org.zanata.util.OkapiUtil;

import com.google.common.collect.Maps;

/**
* A translation unit variant. This is the equivalent of a translated string.
*
Expand Down Expand Up @@ -138,10 +138,9 @@ public void setMetadata(@Nonnull TMMetadataType tmType, String metadata) {

public static Map<String, TransMemoryUnitVariant> newMap(
TransMemoryUnitVariant... tuvs) {
Map<String, TransMemoryUnitVariant> map = Maps.newHashMap();
for (TransMemoryUnitVariant target : tuvs) {
map.put(target.getLanguage(), target);
}
Map<String, TransMemoryUnitVariant> map = new HashMap<>();
Arrays.stream(tuvs)
.forEach(tuv -> map.put(tuv.getLanguage(), tuv));
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.zanata.model;

import java.util.Date;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -113,7 +114,8 @@ public void hashMapDataTerm3Test() {

@Test
public void hashMapDataTest() {
entry.getGlossaryTerms().clear();
Map<HLocale, HGlossaryTerm> glossaryTerms = entry.getGlossaryTerms();
glossaryTerms.clear();

// Glossary Term 1 - EN_US
setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L);
Expand All @@ -124,11 +126,11 @@ public void hashMapDataTest() {
// Glossary Term 3 - ES
setupTerm(3L, "TERM 3", LocaleId.ES, 3L);

for (HLocale key : entry.getGlossaryTerms().keySet()) {
assertTrue(entry.getGlossaryTerms().containsKey(key));
assertNotNull(entry.getGlossaryTerms().get(key));
}

// TODO I'm not sure if this really tests anything:
glossaryTerms.forEach((locale, term) -> {
assertTrue(glossaryTerms.containsKey(locale));
assertNotNull(glossaryTerms.get(locale));
});
}

private HLocale setupTerm(Long id, String content, LocaleId locale,
Expand Down
1 change: 1 addition & 0 deletions zanata-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@
<autoProvides>false</autoProvides>
<autoRequires>false</autoRequires>
<requires>
<require>java &gt;= 1:${required.java}</require>
<require>jbossas-standalone &gt;= ${jboss.as.standalone.version}</require>
</requires>
</configuration>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zanata.adapter.TranslatableSeparator.SplitString;
import org.zanata.common.ContentState;
import org.zanata.common.ContentType;
import org.zanata.common.HasContents;
Expand Down Expand Up @@ -212,7 +213,7 @@ private String getTranslatableText(TextUnit tu) {
GenericContent.fromFragmentToLetterCoded(tu.getSource()
.getFirstContent(), true);
if (separateNonTranslatable) {
return getPartitionedText(letterCodedText).get("str");
return getPartitionedText(letterCodedText).str;
} else {
return letterCodedText;
}
Expand All @@ -223,7 +224,7 @@ private String getTranslatableText(TextUnit tu) {
*
* @param tu
*/
private Map<String, String> getPartitionedText(TextUnit tu) {
private SplitString getPartitionedText(TextUnit tu) {
return TranslatableSeparator.separate(GenericContent
.fromFragmentToLetterCoded(tu.getSource().getFirstContent(),
true));
Expand All @@ -234,7 +235,7 @@ private Map<String, String> getPartitionedText(TextUnit tu) {
*
* @param letterCodedText
*/
private Map<String, String> getPartitionedText(String letterCodedText) {
private SplitString getPartitionedText(String letterCodedText) {
return TranslatableSeparator.separate(letterCodedText);
}

Expand Down Expand Up @@ -468,9 +469,9 @@ private void generateTranslatedFile(URI originalFile,

private String getFullTranslationText(TextUnit tu, String translated) {
if (separateNonTranslatable) {
Map<String, String> partitionedContent = getPartitionedText(tu);
return partitionedContent.get("pre") + translated
+ partitionedContent.get("suf");
SplitString partitionedContent = getPartitionedText(tu);
return partitionedContent.pre + translated
+ partitionedContent.suf;
} else {
return translated;
}
Expand Down
Loading

0 comments on commit b6fda00

Please sign in to comment.