Remove Datastore references in BaseDomainLabelList (#1304)

This commit is contained in:
sarahcaseybot 2021-09-02 13:21:45 -04:00 committed by GitHub
parent 33e3223cbf
commit cb7f5d13e5
2 changed files with 3 additions and 20 deletions

View file

@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.tld.Registries.getTlds; import static google.registry.model.tld.Registries.getTlds;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException; import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
@ -29,14 +28,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multiset; import com.google.common.collect.Multiset;
import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.common.util.concurrent.UncheckedExecutionException;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Parent;
import google.registry.model.Buildable; import google.registry.model.Buildable;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.annotations.InCrossTld;
import google.registry.model.common.EntityGroupRoot;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -47,37 +40,28 @@ import javax.annotation.Nullable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** /**
* Base class for {@link ReservedList} and {@link PremiumList} objects stored in Datastore. * Base class for {@link ReservedList} and {@link PremiumList} objects.
* *
* @param <T> The type of the root value being listed, e.g. {@link ReservationType}. * @param <T> The type of the root value being listed, e.g. {@link ReservationType}.
* @param <R> The type of domain label entry being listed, e.g. {@link * @param <R> The type of domain label entry being listed, e.g. {@link
* ReservedList.ReservedListEntry} (note, must subclass {@link DomainLabelEntry}. * ReservedList.ReservedListEntry} (note, must subclass {@link DomainLabelEntry}.
*/ */
@MappedSuperclass @MappedSuperclass
@InCrossTld
public abstract class BaseDomainLabelList<T extends Comparable<?>, R extends DomainLabelEntry<T, ?>> public abstract class BaseDomainLabelList<T extends Comparable<?>, R extends DomainLabelEntry<T, ?>>
extends ImmutableObject implements Buildable { extends ImmutableObject implements Buildable {
@Ignore @Id
@javax.persistence.Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
Long revisionId; Long revisionId;
@Id
@Column(nullable = false) @Column(nullable = false)
String name; String name;
@Parent @Transient Key<EntityGroupRoot> parent = getCrossTldKey();
// The list in Cloud SQL is immutable, we only have a creation_timestamp field and it should be
// set to the timestamp when the list is created. In Datastore, we have two fields and the
// lastUpdateTime is set to the current timestamp when creating and updating a list. So, we use
// lastUpdateTime as the creation_timestamp column during the dual-write phase for compatibility.
@Column(name = "creation_timestamp") @Column(name = "creation_timestamp")
DateTime creationTimestamp; DateTime creationTimestamp;

View file

@ -286,7 +286,6 @@ class ReservedListTest {
ReservedList clone = original.asBuilder().build(); ReservedList clone = original.asBuilder().build();
assertThat(clone.getName()).isEqualTo("tld-reserved-cloning"); assertThat(clone.getName()).isEqualTo("tld-reserved-cloning");
assertThat(clone.creationTimestamp).isEqualTo(original.creationTimestamp); assertThat(clone.creationTimestamp).isEqualTo(original.creationTimestamp);
assertThat(clone.parent).isEqualTo(original.parent);
assertThat(original.getReservedListEntries()).isEqualTo(clone.getReservedListEntries()); assertThat(original.getReservedListEntries()).isEqualTo(clone.getReservedListEntries());
} }