Upgrade schema for resolvable comments
Adds a boolean field to PatchLineComment to track whether or not the comment thread is resolved. Also implements this field in NoteDB, albeit not in a settable way. Feature: Issue 4752, Issue 4879 Change-Id: I199248cbb83e1fadd1a366e265c0f490c3dabd90
This commit is contained in:
@@ -190,19 +190,21 @@ public class Comment {
|
||||
public String tag;
|
||||
public String revId;
|
||||
public String serverId;
|
||||
public boolean unresolved;
|
||||
|
||||
public Comment(Comment c) {
|
||||
this(new Key(c.key), c.author.getId(), new Timestamp(c.writtenOn.getTime()),
|
||||
c.side, c.message, c.serverId);
|
||||
c.side, c.message, c.serverId, c.unresolved);
|
||||
this.lineNbr = c.lineNbr;
|
||||
this.realAuthor = c.realAuthor;
|
||||
this.range = c.range != null ? new Range(c.range) : null;
|
||||
this.tag = c.tag;
|
||||
this.revId = c.revId;
|
||||
this.unresolved = c.unresolved;
|
||||
}
|
||||
|
||||
public Comment(Key key, Account.Id author, Timestamp writtenOn,
|
||||
short side, String message, String serverId) {
|
||||
short side, String message, String serverId, boolean unresolved) {
|
||||
this.key = key;
|
||||
this.author = new Comment.Identity(author);
|
||||
this.realAuthor = this.author;
|
||||
@@ -210,6 +212,7 @@ public class Comment {
|
||||
this.side = side;
|
||||
this.message = message;
|
||||
this.serverId = serverId;
|
||||
this.unresolved = unresolved;
|
||||
}
|
||||
|
||||
public void setLineNbrAndRange(Integer lineNbr,
|
||||
@@ -271,8 +274,9 @@ public class Comment {
|
||||
.append("parentUuid=")
|
||||
.append(Objects.toString(parentUuid, "")).append(',')
|
||||
.append("range=").append(Objects.toString(range, "")).append(',')
|
||||
.append("revId=").append(revId != null ? revId : "")
|
||||
.append("tag=").append(Objects.toString(tag, ""))
|
||||
.append("revId=").append(revId != null ? revId : "").append(',')
|
||||
.append("tag=").append(Objects.toString(tag, "")).append(',')
|
||||
.append("unresolved=").append(unresolved)
|
||||
.append('}')
|
||||
.toString();
|
||||
}
|
||||
|
@@ -174,6 +174,10 @@ public final class PatchLineComment {
|
||||
@Column(id = 11, notNull = false)
|
||||
protected Account.Id realAuthor;
|
||||
|
||||
/** True if this comment requires further action. */
|
||||
@Column(id = 12)
|
||||
protected boolean unresolved;
|
||||
|
||||
/**
|
||||
* The RevId for the commit to which this comment is referring.
|
||||
*
|
||||
@@ -321,7 +325,7 @@ public final class PatchLineComment {
|
||||
|
||||
public Comment asComment(String serverId) {
|
||||
Comment c = new Comment(key.asCommentKey(), author, writtenOn, side,
|
||||
message, serverId);
|
||||
message, serverId, unresolved);
|
||||
c.setRevId(revId);
|
||||
c.setRange(range);
|
||||
c.lineNbr = lineNbr;
|
||||
@@ -373,8 +377,10 @@ public final class PatchLineComment {
|
||||
.append(',');
|
||||
builder.append("range=").append(Objects.toString(range, ""))
|
||||
.append(',');
|
||||
builder.append("revId=").append(revId != null ? revId.get() : "");
|
||||
builder.append("tag=").append(Objects.toString(tag, ""));
|
||||
builder.append("revId=").append(revId != null ? revId.get() : "")
|
||||
.append(',');
|
||||
builder.append("tag=").append(Objects.toString(tag, "")).append(',');
|
||||
builder.append("unresolved=").append(unresolved);
|
||||
builder.append('}');
|
||||
return builder.toString();
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ public class RobotComment extends Comment {
|
||||
public RobotComment(Key key, Account.Id author, Timestamp writtenOn,
|
||||
short side, String message, String serverId, String robotId,
|
||||
String robotRunId) {
|
||||
super(key, author, writtenOn, side, message, serverId);
|
||||
super(key, author, writtenOn, side, message, serverId, false);
|
||||
this.robotId = robotId;
|
||||
this.robotRunId = robotRunId;
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public class RobotComment extends Comment {
|
||||
.append("range=").append(Objects.toString(range, "")).append(',')
|
||||
.append("revId=").append(revId != null ? revId : "").append(',')
|
||||
.append("tag=").append(Objects.toString(tag, "")).append(',')
|
||||
.append("unresolved=").append(unresolved).append(',')
|
||||
.append("url=").append(url).append(',')
|
||||
.append("properties=").append(properties != null ? properties : "")
|
||||
.append("fixSuggestions=")
|
||||
|
@@ -147,7 +147,8 @@ public class CommentsUtil {
|
||||
short side, String message) throws OrmException {
|
||||
Comment c = new Comment(
|
||||
new Comment.Key(ChangeUtil.messageUUID(ctx.getDb()), path, psId.get()),
|
||||
ctx.getUser().getAccountId(), ctx.getWhen(), side, message, serverId);
|
||||
ctx.getUser().getAccountId(), ctx.getWhen(), side, message, serverId,
|
||||
true);
|
||||
ctx.getUser().updateRealAccountId(c::setRealAuthor);
|
||||
return c;
|
||||
}
|
||||
|
@@ -232,7 +232,7 @@ public class ChangeBundle {
|
||||
checkColumns(PatchSetApproval.Key.class, 1, 2, 3);
|
||||
checkColumns(PatchSetApproval.class, 1, 2, 3, 6, 7, 8);
|
||||
checkColumns(PatchLineComment.Key.class, 1, 2);
|
||||
checkColumns(PatchLineComment.class, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
||||
checkColumns(PatchLineComment.class, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
|
||||
}
|
||||
|
||||
private final Change change;
|
||||
|
@@ -94,6 +94,7 @@ public class ChangeNoteUtil {
|
||||
private static final String REAL_AUTHOR = "Real-author";
|
||||
private static final String REVISION = "Revision";
|
||||
private static final String UUID = "UUID";
|
||||
private static final String UNRESOLVED = "Unresolved";
|
||||
private static final String TAG = FOOTER_TAG.getName();
|
||||
|
||||
public static String formatTime(PersonIdent ident, Timestamp t) {
|
||||
@@ -275,7 +276,8 @@ public class ChangeNoteUtil {
|
||||
? (short) (parentNumber == null ? 0 : -parentNumber)
|
||||
: (short) 1,
|
||||
message,
|
||||
serverId);
|
||||
serverId,
|
||||
false);
|
||||
c.lineNbr = range.getEndLine();
|
||||
c.parentUuid = parentUUID;
|
||||
c.tag = tag;
|
||||
|
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
public static final Class<Schema_137> C = Schema_137.class;
|
||||
public static final Class<Schema_138> C = Schema_138.class;
|
||||
|
||||
public static int getBinaryVersion() {
|
||||
return guessVersion(C);
|
||||
|
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/* Add resolved field to PatchLineComment */
|
||||
public class Schema_138 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_138(Provider<Schema_137> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
@@ -59,7 +59,7 @@ public class AbstractParserTest {
|
||||
protected static Comment newComment(String uuid, String file,
|
||||
String message, int line) {
|
||||
Comment c = new Comment(new Comment.Key(uuid, file, 1),
|
||||
new Account.Id(0), new Timestamp(0l), (short) 0, message, "");
|
||||
new Account.Id(0), new Timestamp(0l), (short) 0, message, "", false);
|
||||
c.lineNbr = line;
|
||||
return c;
|
||||
}
|
||||
|
@@ -258,7 +258,8 @@ public abstract class AbstractChangeNotesTest extends GerritBaseTests {
|
||||
t,
|
||||
side,
|
||||
message,
|
||||
serverId);
|
||||
serverId,
|
||||
false);
|
||||
c.lineNbr = line;
|
||||
c.parentUuid = parentUUID;
|
||||
c.revId = commitSHA1;
|
||||
|
Reference in New Issue
Block a user