mirror of
https://github.com/google/nomulus.git
synced 2025-08-12 12:39:39 +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
|
@Override
|
||||||
public VKey<OneTime> createVKey() {
|
public VKey<OneTime> createVKey() {
|
||||||
return VKey.create(
|
return VKey.create(getClass(), getId(), Key.create(this));
|
||||||
getClass(),
|
|
||||||
parent.getParent().getName() + "/" + parent.getId() + "/" + getId(),
|
|
||||||
Key.create(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VKey<OneTime> createVKey(Key<OneTime> key) {
|
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
|
return VKey.create(OneTime.class, key.getId(), key);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -505,21 +489,11 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VKey<Recurring> createVKey() {
|
public VKey<Recurring> createVKey() {
|
||||||
return VKey.create(
|
return VKey.create(getClass(), getId(), Key.create(this));
|
||||||
getClass(),
|
|
||||||
parent.getParent().getName() + "/" + parent.getId() + "/" + getId(),
|
|
||||||
Key.create(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VKey<Recurring> createVKey(Key<Recurring> key) {
|
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
|
return VKey.create(Recurring.class, key.getId(), key);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -639,21 +613,11 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VKey<Cancellation> createVKey() {
|
public VKey<Cancellation> createVKey() {
|
||||||
return VKey.create(
|
return VKey.create(getClass(), getId(), Key.create(this));
|
||||||
getClass(),
|
|
||||||
parent.getParent().getName() + "/" + parent.getId() + "/" + getId(),
|
|
||||||
Key.create(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VKey<Cancellation> createVKey(Key<Cancellation> key) {
|
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
|
return VKey.create(Cancellation.class, key.getId(), key);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -733,21 +697,11 @@ public abstract class BillingEvent extends ImmutableObject
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VKey<Modification> createVKey() {
|
public VKey<Modification> createVKey() {
|
||||||
return VKey.create(
|
return VKey.create(getClass(), getId(), Key.create(this));
|
||||||
getClass(),
|
|
||||||
parent.getParent().getName() + "/" + parent.getId() + "/" + getId(),
|
|
||||||
Key.create(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VKey<Modification> createVKey(Key<Modification> key) {
|
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
|
return VKey.create(Modification.class, key.getId(), key);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -155,15 +155,7 @@ public abstract class PollMessage extends ImmutableObject
|
||||||
public abstract VKey<? extends PollMessage> createVKey();
|
public abstract VKey<? extends PollMessage> createVKey();
|
||||||
|
|
||||||
public static VKey<PollMessage> createVKey(Key<PollMessage> key) {
|
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
|
return VKey.create(PollMessage.class, key.getId(), 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Override Buildable.asBuilder() to give this method stronger typing. */
|
/** Override Buildable.asBuilder() to give this method stronger typing. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue