mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Perform minor refactors on premium list code
Principally, this moves a load method into DatastoreHelper that is now only used by tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148649087
This commit is contained in:
parent
8d84397e80
commit
90114858fa
7 changed files with 29 additions and 40 deletions
|
@ -987,5 +987,23 @@ public class DatastoreHelper {
|
|||
}});
|
||||
}
|
||||
|
||||
/** Returns the entire map of {@link PremiumListEntry}s for the given {@link PremiumList}. */
|
||||
public static ImmutableMap<String, PremiumListEntry> loadPremiumListEntries(
|
||||
PremiumList premiumList) {
|
||||
try {
|
||||
ImmutableMap.Builder<String, PremiumListEntry> entriesMap = new ImmutableMap.Builder<>();
|
||||
if (premiumList.getRevisionKey() != null) {
|
||||
for (PremiumListEntry entry :
|
||||
ofy().load().type(PremiumListEntry.class).ancestor(premiumList.getRevisionKey())) {
|
||||
entriesMap.put(entry.getLabel(), entry);
|
||||
}
|
||||
}
|
||||
return entriesMap.build();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"Could not retrieve entries for premium list " + premiumList.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private DatastoreHelper() {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue