Add Change, PatchSet, Patch, PatchLineComment entities
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
166
webapp/src/com/google/gerrit/client/reviewdb/Change.java
Normal file
166
webapp/src/com/google/gerrit/client/reviewdb/Change.java
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
import com.google.gwtorm.client.IntKey;
|
||||||
|
import com.google.gwtorm.client.RowVersion;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
/** A change recommended to be inserted into {@link Branch}. */
|
||||||
|
public final class Change {
|
||||||
|
public static class Id extends IntKey<com.google.gwtorm.client.Key<?>> {
|
||||||
|
@Column
|
||||||
|
protected int id;
|
||||||
|
|
||||||
|
protected Id() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Id(final int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int get() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum Status {
|
||||||
|
NEW('n'),
|
||||||
|
|
||||||
|
MERGED('M'),
|
||||||
|
|
||||||
|
ABANDONED('A');
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
private Status(final char c) {
|
||||||
|
code = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status forCode(final char c) {
|
||||||
|
for (final Status s : Status.values()) {
|
||||||
|
if (s.code == c) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Locally assigned unique identifier of the change */
|
||||||
|
@Column
|
||||||
|
protected Id changeId;
|
||||||
|
|
||||||
|
/** optimistic locking */
|
||||||
|
@Column
|
||||||
|
@RowVersion
|
||||||
|
protected int rowVersion;
|
||||||
|
|
||||||
|
/** When this change was first introduced into the database. */
|
||||||
|
@Column
|
||||||
|
protected Timestamp createdOn;
|
||||||
|
|
||||||
|
@Column(name = "owner_account_id")
|
||||||
|
protected Account.Id owner;
|
||||||
|
|
||||||
|
/** The branch (and project) this change merges into. */
|
||||||
|
@Column
|
||||||
|
protected Branch.NameKey dest;
|
||||||
|
|
||||||
|
/** Current state code; see {@link Status}. */
|
||||||
|
@Column
|
||||||
|
protected char status;
|
||||||
|
|
||||||
|
/** The total number of {@link PatchSet} children in this Change. */
|
||||||
|
@Column
|
||||||
|
protected int nbrPatchSets;
|
||||||
|
|
||||||
|
/** The current patch set. */
|
||||||
|
@Column
|
||||||
|
protected int currentPatchSetId;
|
||||||
|
|
||||||
|
/** Subject from the current patch set. */
|
||||||
|
@Column
|
||||||
|
protected String subject;
|
||||||
|
|
||||||
|
protected Change() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change(final Change.Id newId, final Account.Id ownedBy,
|
||||||
|
final Branch.NameKey forBranch) {
|
||||||
|
changeId = newId;
|
||||||
|
createdOn = new Timestamp(System.currentTimeMillis());
|
||||||
|
owner = ownedBy;
|
||||||
|
dest = forBranch;
|
||||||
|
setStatus(Status.NEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change.Id getKey() {
|
||||||
|
return changeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return changeId.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getCreatedOn() {
|
||||||
|
return createdOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account.Id getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Branch.NameKey getDest() {
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the id of the most current {@link PatchSet} in this change. */
|
||||||
|
public PatchSet.Id currentPatchSetId() {
|
||||||
|
if (currentPatchSetId > 0) {
|
||||||
|
return new PatchSet.Id(changeId, currentPatchSetId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPatchSet(final PatchSetInfo ps) {
|
||||||
|
currentPatchSetId = ps.getKey().get();
|
||||||
|
subject = ps.getSubject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate a new PatchSet id within this change.
|
||||||
|
* <p>
|
||||||
|
* <b>Note: This makes the change dirty. Call update() after.</b>
|
||||||
|
*/
|
||||||
|
public PatchSet.Id newPatchSetId() {
|
||||||
|
return new PatchSet.Id(changeId, ++nbrPatchSets);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return Status.forCode(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(final Status newStatus) {
|
||||||
|
status = newStatus.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Access;
|
||||||
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
import com.google.gwtorm.client.PrimaryKey;
|
||||||
|
|
||||||
|
public interface ChangeAccess extends Access<Change, Change.Id> {
|
||||||
|
@PrimaryKey("changeId")
|
||||||
|
Change get(Change.Id id) throws OrmException;
|
||||||
|
}
|
||||||
106
webapp/src/com/google/gerrit/client/reviewdb/Patch.java
Normal file
106
webapp/src/com/google/gerrit/client/reviewdb/Patch.java
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
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> {
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected PatchSet.Id patchSetId;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
protected String fileName;
|
||||||
|
|
||||||
|
protected Id() {
|
||||||
|
patchSetId = new PatchSet.Id();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Id(final PatchSet.Id ps, final String name) {
|
||||||
|
this.patchSetId = ps;
|
||||||
|
this.fileName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PatchSet.Id getParentKey() {
|
||||||
|
return patchSetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum ChangeType {
|
||||||
|
ADD('A'),
|
||||||
|
|
||||||
|
MODIFIED('M'),
|
||||||
|
|
||||||
|
DELETED('D');
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
private ChangeType(final char c) {
|
||||||
|
code = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChangeType forCode(final char c) {
|
||||||
|
for (final ChangeType s : ChangeType.values()) {
|
||||||
|
if (s.code == c) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected Id key;
|
||||||
|
|
||||||
|
/** What sort of change is this to the path; see {@link ChangeType}. */
|
||||||
|
@Column
|
||||||
|
protected char changeType;
|
||||||
|
|
||||||
|
/** Number of published comments on this patch. */
|
||||||
|
@Column
|
||||||
|
protected int nbrComments;
|
||||||
|
|
||||||
|
protected Patch() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Patch(final Patch.Id newId, final ChangeType type) {
|
||||||
|
key = newId;
|
||||||
|
setChangeType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCommentCount() {
|
||||||
|
return nbrComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeType getChangeType() {
|
||||||
|
return ChangeType.forCode(changeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChangeType(final ChangeType type) {
|
||||||
|
changeType = type.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Access;
|
||||||
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
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> {
|
||||||
|
@PrimaryKey("key")
|
||||||
|
Patch get(Patch.Id id) throws OrmException;
|
||||||
|
|
||||||
|
@Query("WHERE key.patchSetId = ? ORDER BY key.fileName")
|
||||||
|
ResultSet<Patch> byPatchSet(PatchSet.Id ps) throws OrmException;
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
import com.google.gwtorm.client.StringKey;
|
||||||
|
|
||||||
|
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> {
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected Patch.Id patchId;
|
||||||
|
|
||||||
|
@Column(length = 40)
|
||||||
|
protected String uuid;
|
||||||
|
|
||||||
|
protected Id() {
|
||||||
|
patchId = new Patch.Id();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Id(final Patch.Id p, final String uuid) {
|
||||||
|
this.patchId = p;
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Patch.Id getParentKey() {
|
||||||
|
return patchId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static final char STATUS_PUBLISHED = 'P';
|
||||||
|
|
||||||
|
public static enum Status {
|
||||||
|
DRAFT('d'),
|
||||||
|
|
||||||
|
PUBLISHED(STATUS_PUBLISHED);
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
private Status(final char c) {
|
||||||
|
code = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status forCode(final char c) {
|
||||||
|
for (final Status s : Status.values()) {
|
||||||
|
if (s.code == c) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum Side {
|
||||||
|
PRE_IMAGE('o'),
|
||||||
|
|
||||||
|
POST_IMAGE('n');
|
||||||
|
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
private Side(final char c) {
|
||||||
|
code = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Side forCode(final char c) {
|
||||||
|
for (final Side s : Side.values()) {
|
||||||
|
if (s.code == c) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected Id key;
|
||||||
|
|
||||||
|
/** Line number this comment applies to; it should display after the line. */
|
||||||
|
@Column
|
||||||
|
protected int lineNbr;
|
||||||
|
|
||||||
|
/** Who wrote this comment. */
|
||||||
|
@Column
|
||||||
|
protected Account.Id authorId;
|
||||||
|
|
||||||
|
/** When this comment was drafted. */
|
||||||
|
@Column
|
||||||
|
protected Timestamp writtenOn;
|
||||||
|
|
||||||
|
/** Current publication state of the comment; see {@link Status}. */
|
||||||
|
@Column
|
||||||
|
protected char status;
|
||||||
|
|
||||||
|
/** Which version of the file is this comment on (old vs. new). */
|
||||||
|
@Column
|
||||||
|
protected char side;
|
||||||
|
|
||||||
|
/** The text left by the user. */
|
||||||
|
@Column(notNull = false, length = Integer.MAX_VALUE)
|
||||||
|
protected String message;
|
||||||
|
|
||||||
|
protected PatchLineComment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchLineComment(final PatchLineComment.Id id, final int line,
|
||||||
|
final Account.Id author) {
|
||||||
|
key = id;
|
||||||
|
lineNbr = line;
|
||||||
|
authorId = author;
|
||||||
|
writtenOn = new Timestamp(System.currentTimeMillis());
|
||||||
|
setStatus(Status.DRAFT);
|
||||||
|
setSide(Side.POST_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchLineComment.Id getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLine() {
|
||||||
|
return lineNbr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account.Id getAuthorId() {
|
||||||
|
return authorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getWrittenOn() {
|
||||||
|
return writtenOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return Status.forCode(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(final Status s) {
|
||||||
|
status = s.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Side getSide() {
|
||||||
|
return Side.forCode(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSide(final Side s) {
|
||||||
|
side = s.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(final String s) {
|
||||||
|
message = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Access;
|
||||||
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
import com.google.gwtorm.client.PrimaryKey;
|
||||||
|
import com.google.gwtorm.client.Query;
|
||||||
|
import com.google.gwtorm.client.ResultSet;
|
||||||
|
|
||||||
|
public interface PatchLineCommentAccess extends
|
||||||
|
Access<PatchLineComment, PatchLineComment.Id> {
|
||||||
|
@PrimaryKey("key")
|
||||||
|
PatchLineComment get(PatchLineComment.Id id) throws OrmException;
|
||||||
|
|
||||||
|
@Query("WHERE key.patchId = ? AND status = '"
|
||||||
|
+ PatchLineComment.STATUS_PUBLISHED + "' ORDER BY writtenOn,lineNbr")
|
||||||
|
ResultSet<PatchLineComment> byPatch(Patch.Id id) throws OrmException;
|
||||||
|
}
|
||||||
78
webapp/src/com/google/gerrit/client/reviewdb/PatchSet.java
Normal file
78
webapp/src/com/google/gerrit/client/reviewdb/PatchSet.java
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
import com.google.gwtorm.client.IntKey;
|
||||||
|
|
||||||
|
/** A single revision of a {@link Change}. */
|
||||||
|
public final class PatchSet {
|
||||||
|
public static class Id extends IntKey<Change.Id> {
|
||||||
|
@Column
|
||||||
|
protected Change.Id changeId;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
protected int patchSetId;
|
||||||
|
|
||||||
|
protected Id() {
|
||||||
|
changeId = new Change.Id();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Id(final Change.Id change, final int id) {
|
||||||
|
this.changeId = change;
|
||||||
|
this.patchSetId = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Change.Id getParentKey() {
|
||||||
|
return changeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int get() {
|
||||||
|
return patchSetId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected Id key;
|
||||||
|
|
||||||
|
@Column(length = 40, notNull = false)
|
||||||
|
protected String revision;
|
||||||
|
|
||||||
|
protected PatchSet() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchSet(final PatchSet.Id k) {
|
||||||
|
key = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchSet(final PatchSet.Id k, final String rev) {
|
||||||
|
this(k);
|
||||||
|
revision = rev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchSet.Id getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return key.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRevision() {
|
||||||
|
return revision;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Access;
|
||||||
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
import com.google.gwtorm.client.PrimaryKey;
|
||||||
|
import com.google.gwtorm.client.Query;
|
||||||
|
import com.google.gwtorm.client.ResultSet;
|
||||||
|
|
||||||
|
public interface PatchSetAccess extends Access<PatchSet, PatchSet.Id> {
|
||||||
|
@PrimaryKey("key")
|
||||||
|
PatchSet get(PatchSet.Id id) throws OrmException;
|
||||||
|
|
||||||
|
@Query("WHERE key.changeId = ? ORDER BY key.patchSetId")
|
||||||
|
ResultSet<PatchSet> byChange(Change.Id id) throws OrmException;
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional data about a {@link PatchSet} not normally loaded.
|
||||||
|
* <p>
|
||||||
|
* This is stored out of band from the PatchSet itself, to reduce the size of
|
||||||
|
* each PatchSet record.
|
||||||
|
*/
|
||||||
|
public final class PatchSetInfo {
|
||||||
|
@Column(name = Column.NONE)
|
||||||
|
protected PatchSet.Id key;
|
||||||
|
|
||||||
|
/** First line of {@link #message}. */
|
||||||
|
@Column(notNull = false)
|
||||||
|
protected String subject;
|
||||||
|
|
||||||
|
/** The complete description of the change the patch set introduces. */
|
||||||
|
@Column(notNull = false, length = Integer.MAX_VALUE)
|
||||||
|
protected String message;
|
||||||
|
|
||||||
|
/** Identity of who wrote the patch set. May differ from {@link #committer}. */
|
||||||
|
@Column(notNull = false)
|
||||||
|
protected UserIdentity author;
|
||||||
|
|
||||||
|
/** Identity of who committed the patch set to the VCS. */
|
||||||
|
@Column(notNull = false)
|
||||||
|
protected UserIdentity committer;
|
||||||
|
|
||||||
|
protected PatchSetInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchSetInfo(final PatchSet.Id k) {
|
||||||
|
key = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatchSet.Id getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubject() {
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubject(final String s) {
|
||||||
|
subject = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(final String m) {
|
||||||
|
message = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserIdentity getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthor(final UserIdentity u) {
|
||||||
|
author = u;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserIdentity getCommitter() {
|
||||||
|
return committer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommitter(final UserIdentity u) {
|
||||||
|
committer = u;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Access;
|
||||||
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
import com.google.gwtorm.client.PrimaryKey;
|
||||||
|
|
||||||
|
public interface PatchSetInfoAccess extends Access<PatchSetInfo, PatchSet.Id> {
|
||||||
|
@PrimaryKey("key")
|
||||||
|
PatchSetInfo get(PatchSet.Id id) throws OrmException;
|
||||||
|
}
|
||||||
@@ -50,6 +50,21 @@ public interface ReviewDb extends Schema {
|
|||||||
@Relation
|
@Relation
|
||||||
ProjectLeadGroupAccess projectLeadGroups();
|
ProjectLeadGroupAccess projectLeadGroups();
|
||||||
|
|
||||||
|
@Relation
|
||||||
|
ChangeAccess changes();
|
||||||
|
|
||||||
|
@Relation
|
||||||
|
PatchSetAccess patchSets();
|
||||||
|
|
||||||
|
@Relation
|
||||||
|
PatchSetInfoAccess patchSetInfo();
|
||||||
|
|
||||||
|
@Relation
|
||||||
|
PatchAccess patches();
|
||||||
|
|
||||||
|
@Relation
|
||||||
|
PatchLineCommentAccess patchComments();
|
||||||
|
|
||||||
/** Create the next unique id for an {@link Account}. */
|
/** Create the next unique id for an {@link Account}. */
|
||||||
@Sequence(startWith = 1000000)
|
@Sequence(startWith = 1000000)
|
||||||
int nextAccountId();
|
int nextAccountId();
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.client.reviewdb;
|
||||||
|
|
||||||
|
import com.google.gwtorm.client.Column;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
public final class UserIdentity {
|
||||||
|
/** Full name of the user. */
|
||||||
|
@Column
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
/** Email address (or user@host style string anyway). */
|
||||||
|
@Column
|
||||||
|
protected String email;
|
||||||
|
|
||||||
|
/** Time (in UTC) when the identity was constructed. */
|
||||||
|
@Column
|
||||||
|
protected Timestamp when;
|
||||||
|
|
||||||
|
/** Offset from UTC */
|
||||||
|
@Column
|
||||||
|
protected int tz;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(final String n) {
|
||||||
|
name = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(final String e) {
|
||||||
|
email = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getDate() {
|
||||||
|
return when;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(final Timestamp d) {
|
||||||
|
when = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimeZone() {
|
||||||
|
return tz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeZone(final int offset) {
|
||||||
|
tz = offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user