Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused internal models #1789

Merged
merged 1 commit into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}