mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 08:22:13 +02:00
Fix vkey construction in PollMessage and BillingEvent (#747)
* Fix vkey construction in PollMessage and BillingEvent * Remove null check
This commit is contained in:
parent
bc8df8f34e
commit
7b2b49dd53
2 changed files with 9 additions and 63 deletions
|
@ -347,27 +347,11 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
|
||||
@Override
|
||||
public VKey<OneTime> 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<OneTime> createVKey(Key<OneTime> 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<Recurring> 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<Recurring> createVKey(Key<Recurring> 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<Cancellation> 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<Cancellation> createVKey(Key<Cancellation> 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<Modification> 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<Modification> createVKey(Key<Modification> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -155,15 +155,7 @@ public abstract class PollMessage extends ImmutableObject
|
|||
public abstract VKey<? extends PollMessage> createVKey();
|
||||
|
||||
public static VKey<PollMessage> createVKey(Key<PollMessage> 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. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue