Cleanup the meaning of "key" vs. "id" in our entity classes
We now use "Foo.Id" of any keys which are numerical, and have getId() accessors to read those keys. For any other keys we use "Foo.Key" and read them with getKey(). All PrimaryKey and SecondaryKey queries now use get() as their access method, rather than byFoo in some cases and get() in others. This simplifies callers when they are doing key based lookups for an entity. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -61,15 +61,15 @@ public class Link implements HistoryListener {
|
||||
return "dashboard," + acct.toString();
|
||||
}
|
||||
|
||||
public static String toPatchSideBySide(final Patch.Id id) {
|
||||
public static String toPatchSideBySide(final Patch.Key id) {
|
||||
return toPatch("sidebyside", id);
|
||||
}
|
||||
|
||||
public static String toPatchUnified(final Patch.Id id) {
|
||||
public static String toPatchUnified(final Patch.Key id) {
|
||||
return toPatch("unified", id);
|
||||
}
|
||||
|
||||
public static String toPatch(final String type, final Patch.Id id) {
|
||||
public static String toPatch(final String type, final Patch.Key id) {
|
||||
return "patch," + type + "," + id.toString();
|
||||
}
|
||||
|
||||
@@ -110,11 +110,11 @@ public class Link implements HistoryListener {
|
||||
|
||||
p = "patch,sidebyside,";
|
||||
if (token.startsWith(p))
|
||||
return new PatchSideBySideScreen(Patch.Id.parse(skip(p, token)));
|
||||
return new PatchSideBySideScreen(Patch.Key.parse(skip(p, token)));
|
||||
|
||||
p = "patch,unified,";
|
||||
if (token.startsWith(p))
|
||||
return new PatchUnifiedScreen(Patch.Id.parse(skip(p, token)));
|
||||
return new PatchUnifiedScreen(Patch.Key.parse(skip(p, token)));
|
||||
|
||||
p = "change,";
|
||||
if (token.startsWith(p))
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AccountServiceImpl extends BaseServiceImplementation implements
|
||||
public void myAccount(final AsyncCallback<Account> callback) {
|
||||
run(callback, new Action<Account>() {
|
||||
public Account run(ReviewDb db) throws OrmException {
|
||||
return db.accounts().byId(RpcUtil.getAccountId());
|
||||
return db.accounts().get(RpcUtil.getAccountId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ public class ChangeInfoBlock extends Composite {
|
||||
}
|
||||
|
||||
table.setWidget(R_PERMALINK, 1, new ChangeLink(Util.C.changePermalink(),
|
||||
chg.getKey()));
|
||||
chg.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ChangeScreen extends Screen {
|
||||
final GitwebLink gw = Gerrit.getGerritConfig().getGitwebLink();
|
||||
for (final PatchSet ps : detail.getPatchSets()) {
|
||||
final ComplexDisclosurePanel panel =
|
||||
new ComplexDisclosurePanel(Util.M.patchSetHeader(ps.getId()),
|
||||
new ComplexDisclosurePanel(Util.M.patchSetHeader(ps.getPatchSetId()),
|
||||
ps == currps);
|
||||
final PatchSetPanel psp = new PatchSetPanel(detail, ps);
|
||||
panel.setContent(psp);
|
||||
|
||||
@@ -58,11 +58,11 @@ class PatchSetPanel extends Composite implements DisclosureHandler {
|
||||
|
||||
infoTable.setText(R_DOWNLOAD, 1, Util.M.repoDownload(changeDetail
|
||||
.getChange().getDest().getParentKey().get(), changeDetail.getChange()
|
||||
.getId(), patchSet.getId()));
|
||||
.getChangeId(), patchSet.getPatchSetId()));
|
||||
|
||||
patchTable = new PatchTable();
|
||||
patchTable.setSavePointerId("patchTable "
|
||||
+ changeDetail.getChange().getId() + " " + patchSet.getId());
|
||||
+ changeDetail.getChange().getChangeId() + " " + patchSet.getPatchSetId());
|
||||
patchTable.display(detail.getPatches());
|
||||
patchTable.finishDisplay(false);
|
||||
|
||||
@@ -72,7 +72,7 @@ class PatchSetPanel extends Composite implements DisclosureHandler {
|
||||
|
||||
public void onOpen(final DisclosureEvent event) {
|
||||
if (infoTable == null) {
|
||||
Util.DETAIL_SVC.patchSetDetail(patchSet.getKey(),
|
||||
Util.DETAIL_SVC.patchSetDetail(patchSet.getId(),
|
||||
new GerritCallback<PatchSetDetail>() {
|
||||
public void onSuccess(final PatchSetDetail result) {
|
||||
ensureLoaded(result);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class AccountInfoCacheFactory {
|
||||
Account a = cache.get(id);
|
||||
if (a == null) {
|
||||
if (toFetch.isEmpty()) {
|
||||
a = db.accounts().byId(id);
|
||||
a = db.accounts().get(id);
|
||||
if (a != null) {
|
||||
cache.put(id, a);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class ChangeDetail {
|
||||
change = c;
|
||||
acc.want(change.getOwner());
|
||||
|
||||
patchSets = db.patchSets().byChange(change.getKey()).toList();
|
||||
messages = db.changeMessages().byChange(change.getKey()).toList();
|
||||
patchSets = db.patchSets().byChange(change.getId()).toList();
|
||||
messages = db.changeMessages().byChange(change.getId()).toList();
|
||||
for (final ChangeMessage m : messages) {
|
||||
acc.want(m.getAuthor());
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class ChangeDetail {
|
||||
// TODO Mark self-approved, self-verified if permitted.
|
||||
ad.put(d.getAccount(), d);
|
||||
}
|
||||
for (ChangeApproval ca : db.changeApprovals().byChange(change.getKey())) {
|
||||
for (ChangeApproval ca : db.changeApprovals().byChange(change.getId())) {
|
||||
ApprovalDetail d = ad.get(ca.getAccountId());
|
||||
if (d == null) {
|
||||
d = new ApprovalDetail(ca.getAccountId());
|
||||
@@ -93,7 +93,7 @@ public class ChangeDetail {
|
||||
for (final PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
|
||||
currentPatchSetId).toList()) {
|
||||
for (PatchSet p : db.patchSets().byRevision(a.getAncestorRevision())) {
|
||||
final Change.Id ck = p.getKey().getParentKey();
|
||||
final Change.Id ck = p.getId().getParentKey();
|
||||
if (changesToGet.add(ck)) {
|
||||
ancestorOrder.add(ck);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class ChangeDetail {
|
||||
//
|
||||
for (int i = patchSets.size() - 1; i >= 0; i--) {
|
||||
final PatchSet ps = patchSets.get(i);
|
||||
if (ps.getKey().equals(currentPatchSetId)) {
|
||||
if (ps.getId().equals(currentPatchSetId)) {
|
||||
return ps;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ChangeInfo {
|
||||
}
|
||||
|
||||
public ChangeInfo(final Change c, final AccountInfoCacheFactory acc) {
|
||||
id = c.getKey();
|
||||
id = c.getId();
|
||||
owner = c.getOwner();
|
||||
subject = c.getSubject();
|
||||
status = c.getStatus();
|
||||
|
||||
@@ -32,8 +32,8 @@ public class PatchSetDetail {
|
||||
|
||||
public void load(final ReviewDb db, final PatchSet ps) throws OrmException {
|
||||
patchSet = ps;
|
||||
info = db.patchSetInfo().get(patchSet.getKey());
|
||||
patches = db.patches().byPatchSet(patchSet.getKey()).toList();
|
||||
info = db.patchSetInfo().get(patchSet.getId());
|
||||
patches = db.patches().byPatchSet(patchSet.getId()).toList();
|
||||
}
|
||||
|
||||
public PatchSet getPatchSet() {
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.List;
|
||||
public abstract class AbstractPatchContentTable extends FancyFlexTable<Object> {
|
||||
private static final long AGE = 7 * 24 * 60 * 60 * 1000L;
|
||||
protected AccountInfoCache accountCache = AccountInfoCache.empty();
|
||||
protected Patch.Id patchKey;
|
||||
protected Patch.Key patchKey;
|
||||
private final Timestamp aged =
|
||||
new Timestamp(System.currentTimeMillis() - AGE);
|
||||
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractPatchContentTable extends FancyFlexTable<Object> {
|
||||
|
||||
protected PatchLineComment newComment(final int line, final short side) {
|
||||
final PatchLineComment r =
|
||||
new PatchLineComment(new PatchLineComment.Id(patchKey, "blargh"), line,
|
||||
new PatchLineComment(new PatchLineComment.Key(patchKey, "blargh"), line,
|
||||
Gerrit.getUserAccount().getId());
|
||||
r.setSide(side);
|
||||
r.setMessage("");
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractPatchContentTable extends FancyFlexTable<Object> {
|
||||
accountCache = aic;
|
||||
}
|
||||
|
||||
public void setPatchKey(final Patch.Id id) {
|
||||
public void setPatchKey(final Patch.Key id) {
|
||||
patchKey = id;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.google.gwtjsonrpc.client.RemoteJsonService;
|
||||
|
||||
public interface PatchDetailService extends RemoteJsonService {
|
||||
@AllowCrossSiteRequest
|
||||
void sideBySidePatchDetail(Patch.Id key,
|
||||
void sideBySidePatchDetail(Patch.Key key,
|
||||
AsyncCallback<SideBySidePatchDetail> callback);
|
||||
|
||||
@AllowCrossSiteRequest
|
||||
void unifiedPatchDetail(Patch.Id key,
|
||||
void unifiedPatchDetail(Patch.Key key,
|
||||
AsyncCallback<UnifiedPatchDetail> callback);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ import com.google.gerrit.client.reviewdb.Patch;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
|
||||
public class PatchScreen extends Screen {
|
||||
protected final Patch.Id patchId;
|
||||
protected final Patch.Key patchId;
|
||||
|
||||
public PatchScreen(final Patch.Id id) {
|
||||
public PatchScreen(final Patch.Key id) {
|
||||
patchId = id;
|
||||
setTitleText(id.get());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.google.gwt.user.client.ui.FlowPanel;
|
||||
public class PatchSideBySideScreen extends PatchScreen {
|
||||
private SideBySideTable sbsTable;
|
||||
|
||||
public PatchSideBySideScreen(final Patch.Id id) {
|
||||
public PatchSideBySideScreen(final Patch.Key id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
public class PatchUnifiedScreen extends PatchScreen {
|
||||
private UnifiedDiffTable diffTable;
|
||||
|
||||
public PatchUnifiedScreen(final Patch.Id id) {
|
||||
public PatchUnifiedScreen(final Patch.Key id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.google.gwtorm.client.ResultSet;
|
||||
public interface AccountAccess extends Access<Account, Account.Id> {
|
||||
/** Locate an account by our locally generated identity. */
|
||||
@PrimaryKey("accountId")
|
||||
Account byId(Account.Id key) throws OrmException;
|
||||
Account get(Account.Id key) throws OrmException;
|
||||
|
||||
@Query("WHERE preferredEmail = ? LIMIT 2")
|
||||
ResultSet<Account> byPreferredEmail(String email) throws OrmException;
|
||||
|
||||
@@ -25,5 +25,5 @@ public interface AccountGroupAccess extends
|
||||
AccountGroup get(AccountGroup.NameKey name) throws OrmException;
|
||||
|
||||
@SecondaryKey("groupId")
|
||||
AccountGroup byGroupId(AccountGroup.Id id) throws OrmException;
|
||||
AccountGroup get(AccountGroup.Id id) throws OrmException;
|
||||
}
|
||||
|
||||
@@ -19,18 +19,18 @@ import com.google.gwtorm.client.ShortKey;
|
||||
|
||||
/** Valid value for a {@link ApprovalCategory}. */
|
||||
public final class ApprovalCategoryValue {
|
||||
public static class Key extends ShortKey<ApprovalCategory.Id> {
|
||||
public static class Id extends ShortKey<ApprovalCategory.Id> {
|
||||
@Column
|
||||
protected ApprovalCategory.Id categoryId;
|
||||
|
||||
@Column
|
||||
protected short value;
|
||||
|
||||
protected Key() {
|
||||
protected Id() {
|
||||
categoryId = new ApprovalCategory.Id();
|
||||
}
|
||||
|
||||
public Key(final ApprovalCategory.Id cat, final short v) {
|
||||
public Id(final ApprovalCategory.Id cat, final short v) {
|
||||
categoryId = cat;
|
||||
value = v;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public final class ApprovalCategoryValue {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Key key;
|
||||
protected Id key;
|
||||
|
||||
@Column(length = 50)
|
||||
protected String name;
|
||||
@@ -60,7 +60,7 @@ public final class ApprovalCategoryValue {
|
||||
protected ApprovalCategoryValue() {
|
||||
}
|
||||
|
||||
public ApprovalCategoryValue(final ApprovalCategoryValue.Key id,
|
||||
public ApprovalCategoryValue(final ApprovalCategoryValue.Id id,
|
||||
final String name) {
|
||||
this.key = id;
|
||||
this.name = name;
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface ApprovalCategoryValueAccess extends
|
||||
Access<ApprovalCategoryValue, ApprovalCategoryValue.Key> {
|
||||
Access<ApprovalCategoryValue, ApprovalCategoryValue.Id> {
|
||||
@PrimaryKey("key")
|
||||
ApprovalCategoryValue get(ApprovalCategoryValue.Key key) throws OrmException;
|
||||
ApprovalCategoryValue get(ApprovalCategoryValue.Id key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.categoryId = ? ORDER BY key.value")
|
||||
ResultSet<ApprovalCategoryValue> byCategory(ApprovalCategory.Id id)
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.google.gwtorm.client.SecondaryKey;
|
||||
|
||||
public interface BranchAccess extends Access<Branch, Branch.NameKey> {
|
||||
@PrimaryKey("name")
|
||||
Branch byName(Branch.NameKey name) throws OrmException;
|
||||
Branch get(Branch.NameKey name) throws OrmException;
|
||||
|
||||
@SecondaryKey("branchId")
|
||||
Branch byId(Branch.Id id) throws OrmException;
|
||||
Branch get(Branch.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE name.projectName = ? ORDER BY name.branchName")
|
||||
ResultSet<Branch> byProject(Project.NameKey key) throws OrmException;
|
||||
|
||||
@@ -144,11 +144,11 @@ public final class Change {
|
||||
setStatus(Status.NEW);
|
||||
}
|
||||
|
||||
public Change.Id getKey() {
|
||||
public Change.Id getId() {
|
||||
return changeId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
public int getChangeId() {
|
||||
return changeId.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,18 +21,18 @@ import java.sql.Timestamp;
|
||||
|
||||
/** A message attached to a {@link Change}. */
|
||||
public final class ChangeMessage {
|
||||
public static class Id extends StringKey<Change.Id> {
|
||||
public static class Key extends StringKey<Change.Id> {
|
||||
@Column
|
||||
protected Change.Id changeId;
|
||||
|
||||
@Column(length = 40)
|
||||
protected String uuid;
|
||||
|
||||
protected Id() {
|
||||
protected Key() {
|
||||
changeId = new Change.Id();
|
||||
}
|
||||
|
||||
public Id(final Change.Id change, final String uuid) {
|
||||
public Key(final Change.Id change, final String uuid) {
|
||||
this.changeId = change;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public final class ChangeMessage {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Id key;
|
||||
protected Key key;
|
||||
|
||||
/** Who wrote this comment; null if it was written by the Gerrit system. */
|
||||
@Column(name = "author_id", notNull = false)
|
||||
@@ -71,13 +71,13 @@ public final class ChangeMessage {
|
||||
protected ChangeMessage() {
|
||||
}
|
||||
|
||||
public ChangeMessage(final ChangeMessage.Id k, final Account.Id a) {
|
||||
public ChangeMessage(final ChangeMessage.Key k, final Account.Id a) {
|
||||
key = k;
|
||||
author = a;
|
||||
writtenOn = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public ChangeMessage.Id getKey() {
|
||||
public ChangeMessage.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface ChangeMessageAccess extends
|
||||
Access<ChangeMessage, ChangeMessage.Id> {
|
||||
Access<ChangeMessage, ChangeMessage.Key> {
|
||||
@PrimaryKey("key")
|
||||
ChangeMessage get(ChangeMessage.Id id) throws OrmException;
|
||||
ChangeMessage get(ChangeMessage.Key id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.changeId = ? ORDER BY writtenOn")
|
||||
ResultSet<ChangeMessage> byChange(Change.Id id) throws OrmException;
|
||||
|
||||
@@ -19,18 +19,18 @@ import com.google.gwtorm.client.StringKey;
|
||||
|
||||
/** A single modified file in a {@link PatchSet}. */
|
||||
public final class Patch {
|
||||
public static class Id extends StringKey<PatchSet.Id> {
|
||||
public static class Key extends StringKey<PatchSet.Id> {
|
||||
@Column(name = Column.NONE)
|
||||
protected PatchSet.Id patchSetId;
|
||||
|
||||
@Column
|
||||
protected String fileName;
|
||||
|
||||
protected Id() {
|
||||
protected Key() {
|
||||
patchSetId = new PatchSet.Id();
|
||||
}
|
||||
|
||||
public Id(final PatchSet.Id ps, final String name) {
|
||||
public Key(final PatchSet.Id ps, final String name) {
|
||||
this.patchSetId = ps;
|
||||
this.fileName = name;
|
||||
}
|
||||
@@ -51,8 +51,8 @@ public final class Patch {
|
||||
}
|
||||
|
||||
/** Parse a Patch.Id out of a string representation. */
|
||||
public static Id parse(final String str) {
|
||||
final Id r = new Id();
|
||||
public static Key parse(final String str) {
|
||||
final Key r = new Key();
|
||||
r.fromString(str);
|
||||
return r;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public final class Patch {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Id key;
|
||||
protected Key key;
|
||||
|
||||
/** What sort of change is this to the path; see {@link ChangeType}. */
|
||||
@Column
|
||||
@@ -144,13 +144,13 @@ public final class Patch {
|
||||
protected Patch() {
|
||||
}
|
||||
|
||||
public Patch(final Patch.Id newId) {
|
||||
public Patch(final Patch.Key newId) {
|
||||
key = newId;
|
||||
setChangeType(ChangeType.MODIFIED);
|
||||
setPatchType(PatchType.UNIFIED);
|
||||
}
|
||||
|
||||
public Patch.Id getKey() {
|
||||
public Patch.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import com.google.gwtorm.client.PrimaryKey;
|
||||
import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface PatchAccess extends Access<Patch, Patch.Id> {
|
||||
public interface PatchAccess extends Access<Patch, Patch.Key> {
|
||||
@PrimaryKey("key")
|
||||
Patch get(Patch.Id id) throws OrmException;
|
||||
Patch get(Patch.Key id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId = ? ORDER BY key.fileName")
|
||||
ResultSet<Patch> byPatchSet(PatchSet.Id ps) throws OrmException;
|
||||
|
||||
@@ -21,25 +21,25 @@ import java.sql.Timestamp;
|
||||
|
||||
/** A comment left by a user on a specific line of a {@link Patch}. */
|
||||
public final class PatchLineComment {
|
||||
public static class Id extends StringKey<Patch.Id> {
|
||||
public static class Key extends StringKey<Patch.Key> {
|
||||
@Column(name = Column.NONE)
|
||||
protected Patch.Id patchId;
|
||||
protected Patch.Key patchKey;
|
||||
|
||||
@Column(length = 40)
|
||||
protected String uuid;
|
||||
|
||||
protected Id() {
|
||||
patchId = new Patch.Id();
|
||||
protected Key() {
|
||||
patchKey = new Patch.Key();
|
||||
}
|
||||
|
||||
public Id(final Patch.Id p, final String uuid) {
|
||||
this.patchId = p;
|
||||
public Key(final Patch.Key p, final String uuid) {
|
||||
this.patchKey = p;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Patch.Id getParentKey() {
|
||||
return patchId;
|
||||
public Patch.Key getParentKey() {
|
||||
return patchKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,7 +82,7 @@ public final class PatchLineComment {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Id key;
|
||||
protected Key key;
|
||||
|
||||
/** Line number this comment applies to; it should display after the line. */
|
||||
@Column
|
||||
@@ -111,7 +111,7 @@ public final class PatchLineComment {
|
||||
protected PatchLineComment() {
|
||||
}
|
||||
|
||||
public PatchLineComment(final PatchLineComment.Id id, final int line,
|
||||
public PatchLineComment(final PatchLineComment.Key id, final int line,
|
||||
final Account.Id a) {
|
||||
key = id;
|
||||
lineNbr = line;
|
||||
@@ -120,7 +120,7 @@ public final class PatchLineComment {
|
||||
setStatus(Status.DRAFT);
|
||||
}
|
||||
|
||||
public PatchLineComment.Id getKey() {
|
||||
public PatchLineComment.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,17 @@ import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface PatchLineCommentAccess extends
|
||||
Access<PatchLineComment, PatchLineComment.Id> {
|
||||
Access<PatchLineComment, PatchLineComment.Key> {
|
||||
@PrimaryKey("key")
|
||||
PatchLineComment get(PatchLineComment.Id id) throws OrmException;
|
||||
PatchLineComment get(PatchLineComment.Key id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchId = ? AND status = '"
|
||||
@Query("WHERE key.patchKey = ? AND status = '"
|
||||
+ PatchLineComment.STATUS_PUBLISHED + "' ORDER BY lineNbr,writtenOn")
|
||||
ResultSet<PatchLineComment> published(Patch.Id id) throws OrmException;
|
||||
ResultSet<PatchLineComment> published(Patch.Key patch) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchId = ? AND status = '" + PatchLineComment.STATUS_DRAFT
|
||||
@Query("WHERE key.patchKey = ? AND status = '"
|
||||
+ PatchLineComment.STATUS_DRAFT
|
||||
+ "' AND author = ? ORDER BY lineNbr,writtenOn")
|
||||
ResultSet<PatchLineComment> draft(Patch.Id patch, Account.Id author)
|
||||
ResultSet<PatchLineComment> draft(Patch.Key patch, Account.Id author)
|
||||
throws OrmException;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class PatchSet {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Id key;
|
||||
protected Id id;
|
||||
|
||||
@Column(notNull = false)
|
||||
protected RevId revision;
|
||||
@@ -68,15 +68,15 @@ public final class PatchSet {
|
||||
}
|
||||
|
||||
public PatchSet(final PatchSet.Id k) {
|
||||
key = k;
|
||||
id = k;
|
||||
}
|
||||
|
||||
public PatchSet.Id getKey() {
|
||||
return key;
|
||||
public PatchSet.Id getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return key.get();
|
||||
public int getPatchSetId() {
|
||||
return id.get();
|
||||
}
|
||||
|
||||
public RevId getRevision() {
|
||||
@@ -90,7 +90,7 @@ public final class PatchSet {
|
||||
public String getRefName() {
|
||||
final StringBuilder r = new StringBuilder();
|
||||
r.append("refs/changes/");
|
||||
final int changeId = key.getParentKey().get();
|
||||
final int changeId = id.getParentKey().get();
|
||||
final int m = changeId % 100;
|
||||
if (m < 10) {
|
||||
r.append('0');
|
||||
@@ -99,7 +99,7 @@ public final class PatchSet {
|
||||
r.append('/');
|
||||
r.append(changeId);
|
||||
r.append('/');
|
||||
r.append(key.get());
|
||||
r.append(id.get());
|
||||
return r.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface PatchSetAccess extends Access<PatchSet, PatchSet.Id> {
|
||||
@PrimaryKey("key")
|
||||
@PrimaryKey("id")
|
||||
PatchSet get(PatchSet.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.changeId = ? ORDER BY key.patchSetId")
|
||||
@Query("WHERE id.changeId = ? ORDER BY id.patchSetId")
|
||||
ResultSet<PatchSet> byChange(Change.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE revision = ? LIMIT 2")
|
||||
|
||||
@@ -19,18 +19,18 @@ import com.google.gwtorm.client.IntKey;
|
||||
|
||||
/** Ancestors of a {@link PatchSet} that the PatchSet depends upon. */
|
||||
public final class PatchSetAncestor {
|
||||
public static class Key extends IntKey<PatchSet.Id> {
|
||||
public static class Id extends IntKey<PatchSet.Id> {
|
||||
@Column(name = Column.NONE)
|
||||
protected PatchSet.Id patchSetId;
|
||||
|
||||
@Column
|
||||
protected int position;
|
||||
|
||||
protected Key() {
|
||||
protected Id() {
|
||||
patchSetId = new PatchSet.Id();
|
||||
}
|
||||
|
||||
public Key(final PatchSet.Id psId, final int pos) {
|
||||
public Id(final PatchSet.Id psId, final int pos) {
|
||||
this.patchSetId = psId;
|
||||
this.position = pos;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public final class PatchSetAncestor {
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Key key;
|
||||
protected Id key;
|
||||
|
||||
@Column
|
||||
protected RevId ancestorRevision;
|
||||
@@ -60,11 +60,11 @@ public final class PatchSetAncestor {
|
||||
protected PatchSetAncestor() {
|
||||
}
|
||||
|
||||
public PatchSetAncestor(final PatchSetAncestor.Key k) {
|
||||
public PatchSetAncestor(final PatchSetAncestor.Id k) {
|
||||
key = k;
|
||||
}
|
||||
|
||||
public PatchSetAncestor.Key getKey() {
|
||||
public PatchSetAncestor.Id getId() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface PatchSetAncestorAccess extends
|
||||
Access<PatchSetAncestor, PatchSetAncestor.Key> {
|
||||
Access<PatchSetAncestor, PatchSetAncestor.Id> {
|
||||
@PrimaryKey("key")
|
||||
PatchSetAncestor get(PatchSetAncestor.Key key) throws OrmException;
|
||||
PatchSetAncestor get(PatchSetAncestor.Id key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId = ? ORDER BY key.position")
|
||||
ResultSet<PatchSetAncestor> ancestorsOf(PatchSet.Id id) throws OrmException;
|
||||
|
||||
@@ -23,10 +23,10 @@ import com.google.gwtorm.client.SecondaryKey;
|
||||
|
||||
public interface ProjectAccess extends Access<Project, Project.NameKey> {
|
||||
@PrimaryKey("name")
|
||||
Project byName(Project.NameKey name) throws OrmException;
|
||||
Project get(Project.NameKey name) throws OrmException;
|
||||
|
||||
@SecondaryKey("projectId")
|
||||
Project byId(Project.Id id) throws OrmException;
|
||||
Project get(Project.Id id) throws OrmException;
|
||||
|
||||
@Query("ORDER BY name")
|
||||
ResultSet<Project> all() throws OrmException;
|
||||
|
||||
@@ -20,32 +20,32 @@ import com.google.gerrit.client.patches.PatchUnifiedScreen;
|
||||
import com.google.gerrit.client.reviewdb.Patch;
|
||||
|
||||
public abstract class PatchLink extends DirectScreenLink {
|
||||
protected Patch.Id id;
|
||||
protected Patch.Key key;
|
||||
|
||||
public PatchLink(final String text, final Patch.Id p, final String token) {
|
||||
public PatchLink(final String text, final Patch.Key p, final String token) {
|
||||
super(text, token);
|
||||
id = p;
|
||||
key = p;
|
||||
}
|
||||
|
||||
public static class SideBySide extends PatchLink {
|
||||
public SideBySide(final String text, final Patch.Id p) {
|
||||
public SideBySide(final String text, final Patch.Key p) {
|
||||
super(text, p, Link.toPatchSideBySide(p));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Screen createScreen() {
|
||||
return new PatchSideBySideScreen(id);
|
||||
return new PatchSideBySideScreen(key);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Unified extends PatchLink {
|
||||
public Unified(final String text, final Patch.Id p) {
|
||||
public Unified(final String text, final Patch.Key p) {
|
||||
super(text, p, Link.toPatchUnified(p));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Screen createScreen() {
|
||||
return new PatchUnifiedScreen(id);
|
||||
return new PatchUnifiedScreen(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,12 +102,12 @@ public class PatchSetImporter {
|
||||
// If we aren't a new patch set then we need to load the existing
|
||||
// files so we can update or delete them if there are corrections.
|
||||
//
|
||||
info = db.patchSetInfo().get(dst.getKey());
|
||||
for (final Patch p : db.patches().byPatchSet(dst.getKey())) {
|
||||
info = db.patchSetInfo().get(dst.getId());
|
||||
for (final Patch p : db.patches().byPatchSet(dst.getId())) {
|
||||
patchExisting.put(p.getFileName(), p);
|
||||
}
|
||||
for (final PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
|
||||
dst.getKey())) {
|
||||
dst.getId())) {
|
||||
ancestorExisting.put(a.getPosition(), a);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class PatchSetImporter {
|
||||
|
||||
private void importInfo() {
|
||||
if (info == null) {
|
||||
info = new PatchSetInfo(dst.getKey());
|
||||
info = new PatchSetInfo(dst.getId());
|
||||
infoIsNew = true;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class PatchSetImporter {
|
||||
for (int p = 0; p < src.getParentCount(); p++) {
|
||||
PatchSetAncestor a = ancestorExisting.remove(p + 1);
|
||||
if (a == null) {
|
||||
a = new PatchSetAncestor(new PatchSetAncestor.Key(dst.getKey(), p + 1));
|
||||
a = new PatchSetAncestor(new PatchSetAncestor.Id(dst.getId(), p + 1));
|
||||
ancestorInsert.add(a);
|
||||
} else {
|
||||
ancestorUpdate.add(a);
|
||||
@@ -191,7 +191,7 @@ public class PatchSetImporter {
|
||||
|
||||
Patch p = patchExisting.remove(path);
|
||||
if (p == null) {
|
||||
p = new Patch(new Patch.Id(dst.getKey(), path));
|
||||
p = new Patch(new Patch.Key(dst.getId(), path));
|
||||
patchInsert.add(p);
|
||||
} else {
|
||||
p.setSourceFileName(null);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ReimportPatchSets {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Change c = db.changes().get(ps.getKey().getParentKey());
|
||||
final Change c = db.changes().get(ps.getId().getParentKey());
|
||||
if (c == null) {
|
||||
System.err.println();
|
||||
System.err.println("Orphan " + psid);
|
||||
|
||||
@@ -62,7 +62,12 @@ public class GerritServer {
|
||||
public static synchronized GerritServer getInstance() throws OrmException,
|
||||
XsrfException {
|
||||
if (impl == null) {
|
||||
impl = new GerritServer();
|
||||
try {
|
||||
impl = new GerritServer();
|
||||
} catch (OrmException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return impl;
|
||||
}
|
||||
@@ -186,7 +191,7 @@ public class GerritServer {
|
||||
|
||||
private static ApprovalCategoryValue value(final ApprovalCategory cat,
|
||||
final int value, final String name) {
|
||||
return new ApprovalCategoryValue(new ApprovalCategoryValue.Key(cat.getId(),
|
||||
return new ApprovalCategoryValue(new ApprovalCategoryValue.Id(cat.getId(),
|
||||
(short) value), name);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class LoginServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
if (acctExt != null) {
|
||||
account = d.accounts().byId(acctExt.getAccountId());
|
||||
account = d.accounts().get(acctExt.getAccountId());
|
||||
} else {
|
||||
account = null;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class LoginServlet extends HttpServlet {
|
||||
try {
|
||||
final ReviewDb db = server.getDatabase().open();
|
||||
try {
|
||||
account = db.accounts().byId(id);
|
||||
account = db.accounts().get(id);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class UrlRewriteFilter implements Filter {
|
||||
} else if (patches.size() == 1) {
|
||||
final StringBuffer url = toGerrit(req);
|
||||
url.append('#');
|
||||
url.append(Link.toChange(patches.get(0).getKey().getParentKey()));
|
||||
url.append(Link.toChange(patches.get(0).getId().getParentKey()));
|
||||
rsp.sendRedirect(url.toString());
|
||||
} else {
|
||||
// TODO Someday this should be a menu of choices.
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.List;
|
||||
abstract class PatchDetailAction<T> implements Action<T> {
|
||||
protected static final byte[] EMPTY_FILE = {};
|
||||
|
||||
protected final Patch.Id key;
|
||||
protected final Patch.Key key;
|
||||
protected Patch patch;
|
||||
protected FileHeader file;
|
||||
protected int fileCnt;
|
||||
@@ -58,7 +58,7 @@ abstract class PatchDetailAction<T> implements Action<T> {
|
||||
protected HashMap<Integer, List<PatchLineComment>> published[];
|
||||
protected HashMap<Integer, List<PatchLineComment>> drafted[];
|
||||
|
||||
PatchDetailAction(final Patch.Id key) {
|
||||
PatchDetailAction(final Patch.Key key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
server = gs;
|
||||
}
|
||||
|
||||
public void sideBySidePatchDetail(final Patch.Id key,
|
||||
public void sideBySidePatchDetail(final Patch.Key key,
|
||||
final AsyncCallback<SideBySidePatchDetail> callback) {
|
||||
final RepositoryCache rc = server.getRepositoryCache();
|
||||
if (rc == null) {
|
||||
@@ -42,7 +42,7 @@ public class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
run(callback, new SideBySidePatchDetailAction(rc, key));
|
||||
}
|
||||
|
||||
public void unifiedPatchDetail(final Patch.Id key,
|
||||
public void unifiedPatchDetail(final Patch.Key key,
|
||||
final AsyncCallback<UnifiedPatchDetail> callback) {
|
||||
run(callback, new UnifiedPatchDetailAction(key));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class SideBySidePatchDetailAction extends
|
||||
private byte[][] fileContents;
|
||||
private IntList[] lineIndex;
|
||||
|
||||
SideBySidePatchDetailAction(final RepositoryCache rc, final Patch.Id key) {
|
||||
SideBySidePatchDetailAction(final RepositoryCache rc, final Patch.Key key) {
|
||||
super(key);
|
||||
repoCache = rc;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.spearce.jgit.patch.HunkHeader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class UnifiedPatchDetailAction extends PatchDetailAction<UnifiedPatchDetail> {
|
||||
UnifiedPatchDetailAction(final Patch.Id key) {
|
||||
UnifiedPatchDetailAction(final Patch.Key key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ abstract class AbstractGitCommand extends AbstractCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
proj = db.projects().byName(new Project.NameKey(projectName));
|
||||
proj = db.projects().get(new Project.NameKey(projectName));
|
||||
} catch (OrmException e) {
|
||||
throw new Failure(1, "fatal: cannot query project database");
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ class Receive extends AbstractGitCommand {
|
||||
|
||||
try {
|
||||
destBranch =
|
||||
db.branches().byName(
|
||||
db.branches().get(
|
||||
new Branch.NameKey(proj.getNameKey(), destBranchName));
|
||||
} catch (OrmException e) {
|
||||
reject(cmd, "database error");
|
||||
@@ -312,7 +312,7 @@ class Receive extends AbstractGitCommand {
|
||||
final Change change =
|
||||
new Change(new Change.Id(db.nextChangeId()), userAccount.getId(),
|
||||
destBranch.getNameKey());
|
||||
final PatchSet ps = new PatchSet(new PatchSet.Id(change.getKey(), 1));
|
||||
final PatchSet ps = new PatchSet(new PatchSet.Id(change.getId(), 1));
|
||||
final PatchSetImporter imp = new PatchSetImporter(db, repo, c, ps, true);
|
||||
imp.setTransaction(txn);
|
||||
imp.run();
|
||||
@@ -327,7 +327,7 @@ class Receive extends AbstractGitCommand {
|
||||
|
||||
final String url = server.getCanonicalURL();
|
||||
if (url != null) {
|
||||
rp.sendMessage("New change: " + url + change.getId());
|
||||
rp.sendMessage("New change: " + url + change.getChangeId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user