Skip to content

Commit

Permalink
refactor: remove unused internal models (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars-lan authored Aug 8, 2020
1 parent 6d62713 commit 1efe249
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 119 deletions.
22 changes: 0 additions & 22 deletions li-utils/src/main/pegasus/com/linkedin/common/Locale.pdl

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions li-utils/src/main/pegasus/com/linkedin/common/MultiProductUrn.pdl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
import com.linkedin.common.CorpGroupUrnArray;
import com.linkedin.common.CorpuserUrnArray;
import com.linkedin.common.DatasetUrnArray;
import com.linkedin.common.MultiLocaleString;
import com.linkedin.common.Owner;
import com.linkedin.common.Ownership;
import com.linkedin.common.urn.CorpuserUrn;
import com.linkedin.common.urn.DatasetUrn;
import com.linkedin.common.urn.Urn;
import com.linkedin.data.template.GetMode;
import com.linkedin.data.template.StringArray;
import java.net.URISyntaxException;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -76,24 +73,6 @@ public static StringArray getCorpGroupnames(@Nonnull CorpGroupUrnArray corpgroup
return corpgroupUrns.stream().map(urn -> urn.getGroupNameEntity()).collect(Collectors.toCollection(StringArray::new));
}

/**
* Convert a Multi locale String to users preferred language
* @param multiLocaleString
* @param locale {@link String} User's preferred language such as "en_US"
* @return Localized String
*/
@Nonnull
public static String convertMultiLocaleStringToString(@Nonnull MultiLocaleString multiLocaleString, @Nonnull String locale) {
String convertedString = multiLocaleString.getLocalized().get(locale);
if (convertedString == null) {
Set<String> keySet = multiLocaleString.getLocalized(GetMode.STRICT).keySet();
if (!keySet.isEmpty() && keySet.iterator().hasNext()) {
convertedString = multiLocaleString.getLocalized().get(keySet.iterator().next());
}
}
return convertedString != null ? convertedString : "";
}

/**
* Get normalized browse field by replacing special browse hiearchy seperator's with a replacement
* @param field browse field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import com.linkedin.common.DatasetUrnArray;
import com.linkedin.common.FabricType;
import com.linkedin.common.MultiLocaleString;
import com.linkedin.common.Owner;
import com.linkedin.common.OwnerArray;
import com.linkedin.common.Ownership;
import com.linkedin.common.urn.CorpGroupUrn;
import com.linkedin.common.urn.CorpuserUrn;
import com.linkedin.common.urn.DataPlatformUrn;
import com.linkedin.common.urn.DatasetUrn;
import com.linkedin.data.template.StringMap;
import java.util.Arrays;
import java.util.List;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -39,38 +37,4 @@ public void testGetDatasetNames() {
assertEquals(BuilderUtils.getDatasetNames(datasetUrns), Arrays.asList("testDataset1", "testDataset2"));
}

@Test
public void testMultiLocale() {

String enUSLocale = "en_US";
String enINLocale = "en_IN";
String deDELocale = "de_DE";

String enUSStr = "English USA";
String enINStr = "English India";
String deDEStr = "German String";

MultiLocaleString multiLocaleString = new MultiLocaleString();
StringMap stringMap = new StringMap();
multiLocaleString.setLocalized(stringMap);
assertEquals(BuilderUtils.convertMultiLocaleStringToString(multiLocaleString, enUSLocale), "");

stringMap.put(enUSLocale, enUSStr);
multiLocaleString.setLocalized(stringMap);
assertEquals(BuilderUtils.convertMultiLocaleStringToString(multiLocaleString, enUSLocale), enUSStr);

MultiLocaleString multiLocaleString1 = new MultiLocaleString();
StringMap stringMap1 = new StringMap();
stringMap1.put(enINLocale, enINStr);
multiLocaleString1.setLocalized(stringMap1);
assertEquals(BuilderUtils.convertMultiLocaleStringToString(multiLocaleString1, enUSLocale), enINStr);

MultiLocaleString multiLocaleString2 = new MultiLocaleString();
StringMap stringMap2 = new StringMap();
stringMap2.put(enINLocale, enINStr);
stringMap2.put(deDELocale, deDEStr);
stringMap2.put(enUSLocale, enUSStr);
multiLocaleString2.setLocalized(stringMap2);
assertEquals(BuilderUtils.convertMultiLocaleStringToString(multiLocaleString2, enUSLocale), enUSStr);
}
}

0 comments on commit 1efe249

Please sign in to comment.