diff --git a/core/src/main/java/google/registry/model/billing/BillingEvent.java b/core/src/main/java/google/registry/model/billing/BillingEvent.java index 043d2ce9c..951b6b9e2 100644 --- a/core/src/main/java/google/registry/model/billing/BillingEvent.java +++ b/core/src/main/java/google/registry/model/billing/BillingEvent.java @@ -347,27 +347,11 @@ public abstract class BillingEvent extends ImmutableObject @Override public VKey createVKey() { - return VKey.create( - getClass(), - parent.getParent().getName() + "/" + parent.getId() + "/" + getId(), - Key.create(this)); + return VKey.create(getClass(), getId(), Key.create(this)); } public static VKey createVKey(Key key) { - // TODO(b/159207551): As it stands, the SQL key generated here doesn't mesh with the primary - // key type for the table, which is a single long integer. - if (key == null) { - return null; - } - Key parent = key.getParent(); - Key grandparent = (parent != null) ? parent.getParent() : null; - String path = - (grandparent != null ? grandparent.getName() : "") - + "/" - + (parent != null ? parent.getId() : "") - + "/" - + key.getId(); - return VKey.create(OneTime.class, path, key); + return VKey.create(OneTime.class, key.getId(), key); } @Override @@ -505,21 +489,11 @@ public abstract class BillingEvent extends ImmutableObject @Override public VKey createVKey() { - return VKey.create( - getClass(), - parent.getParent().getName() + "/" + parent.getId() + "/" + getId(), - Key.create(this)); + return VKey.create(getClass(), getId(), Key.create(this)); } public static VKey createVKey(Key key) { - // TODO(b/159207551): As it stands, the SQL key generated here doesn't mesh with the primary - // key type for the table, which is a single long integer. - if (key == null) { - return null; - } - String path = - key.getParent().getParent().getName() + "/" + key.getParent().getId() + "/" + key.getId(); - return VKey.create(Recurring.class, path, key); + return VKey.create(Recurring.class, key.getId(), key); } @Override @@ -639,21 +613,11 @@ public abstract class BillingEvent extends ImmutableObject @Override public VKey createVKey() { - return VKey.create( - getClass(), - parent.getParent().getName() + "/" + parent.getId() + "/" + getId(), - Key.create(this)); + return VKey.create(getClass(), getId(), Key.create(this)); } public static VKey createVKey(Key key) { - // TODO(b/159207551): As it stands, the SQL key generated here doesn't mesh with the primary - // key type for the table, which is a single long integer. - if (key == null) { - return null; - } - String path = - key.getParent().getParent().getName() + "/" + key.getParent().getId() + "/" + key.getId(); - return VKey.create(Cancellation.class, path, key); + return VKey.create(Cancellation.class, key.getId(), key); } @Override @@ -733,21 +697,11 @@ public abstract class BillingEvent extends ImmutableObject @Override public VKey createVKey() { - return VKey.create( - getClass(), - parent.getParent().getName() + "/" + parent.getId() + "/" + getId(), - Key.create(this)); + return VKey.create(getClass(), getId(), Key.create(this)); } public static VKey createVKey(Key key) { - // TODO(b/159207551): As it stands, the SQL key generated here doesn't mesh with the primary - // key type for the table, which is a single long integer. - if (key == null) { - return null; - } - String path = - key.getParent().getParent().getName() + "/" + key.getParent().getId() + "/" + key.getId(); - return VKey.create(Modification.class, path, key); + return VKey.create(Modification.class, key.getId(), key); } /** diff --git a/core/src/main/java/google/registry/model/poll/PollMessage.java b/core/src/main/java/google/registry/model/poll/PollMessage.java index 7094f8623..c1fcbf805 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessage.java +++ b/core/src/main/java/google/registry/model/poll/PollMessage.java @@ -155,15 +155,7 @@ public abstract class PollMessage extends ImmutableObject public abstract VKey createVKey(); public static VKey createVKey(Key key) { - // TODO(b/159207551): As it stands, the SQL key generated here doesn't mesh with the primary key - // type for the table, which is a single long integer. Also note that the class id is not - // correct here and as such the resulting key will not be loadable from SQL. - if (key == null) { - return null; - } - String path = - key.getParent().getParent().getName() + "/" + key.getParent().getId() + key.getId(); - return VKey.create(PollMessage.class, path, key); + return VKey.create(PollMessage.class, key.getId(), key); } /** Override Buildable.asBuilder() to give this method stronger typing. */