Change project ownership to be strictly one group
Like group ownership, a project can only be owned by one group. This simplifies the data model considerably, and starts to make a pattern where rights are granted to one group, and one group only, for any particular rights concept, especially ownership. When importing from Gerrit1 we generate a synthetic group for each project that has more than one entity in its ownership. This produces ~33 additional groups on the Android site, we can sort the ownership mess out later once its in Gerrit2. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -76,6 +76,9 @@ public final class Project {
|
||||
@Column(length = Integer.MAX_VALUE, notNull = false)
|
||||
protected String description;
|
||||
|
||||
@Column
|
||||
protected AccountGroup.Id ownerGroupId;
|
||||
|
||||
protected Project() {
|
||||
}
|
||||
|
||||
@@ -103,4 +106,12 @@ public final class Project {
|
||||
public void setDescription(final String d) {
|
||||
description = d;
|
||||
}
|
||||
|
||||
public AccountGroup.Id getOwnerGroupId() {
|
||||
return ownerGroupId;
|
||||
}
|
||||
|
||||
public void setOwnerGroupId(final AccountGroup.Id id) {
|
||||
ownerGroupId = id;
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +0,0 @@
|
||||
// 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.CompoundKey;
|
||||
|
||||
/** Single {@link Account} as owner/manager of a project. */
|
||||
public final class ProjectLeadAccount {
|
||||
public static class Key extends CompoundKey<Project.NameKey> {
|
||||
@Column
|
||||
protected Project.NameKey projectName;
|
||||
|
||||
@Column
|
||||
protected Account.Id accountId;
|
||||
|
||||
protected Key() {
|
||||
projectName = new Project.NameKey();
|
||||
accountId = new Account.Id();
|
||||
}
|
||||
|
||||
public Key(final Project.NameKey p, final Account.Id a) {
|
||||
projectName = p;
|
||||
accountId = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project.NameKey getParentKey() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.gwtorm.client.Key<?>[] members() {
|
||||
return new com.google.gwtorm.client.Key<?>[] {accountId};
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Key key;
|
||||
|
||||
protected ProjectLeadAccount() {
|
||||
}
|
||||
|
||||
public ProjectLeadAccount(final ProjectLeadAccount.Key k) {
|
||||
key = k;
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
// 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 ProjectLeadAccountAccess extends
|
||||
Access<ProjectLeadAccount, ProjectLeadAccount.Key> {
|
||||
@PrimaryKey("key")
|
||||
ProjectLeadAccount get(ProjectLeadAccount.Key key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.projectName= ?")
|
||||
ResultSet<ProjectLeadAccount> byProject(Project.NameKey id)
|
||||
throws OrmException;
|
||||
|
||||
@Query("WHERE key.accountId = ?")
|
||||
ResultSet<ProjectLeadAccount> byAccount(Account.Id id) throws OrmException;
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
// 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.CompoundKey;
|
||||
|
||||
/** {@link AccountGroup} as owner/manager of a project. */
|
||||
public final class ProjectLeadGroup {
|
||||
public static class Key extends CompoundKey<Project.NameKey> {
|
||||
@Column
|
||||
protected Project.NameKey projectName;
|
||||
|
||||
@Column
|
||||
protected AccountGroup.Id groupId;
|
||||
|
||||
protected Key() {
|
||||
projectName = new Project.NameKey();
|
||||
groupId = new AccountGroup.Id();
|
||||
}
|
||||
|
||||
public Key(final Project.NameKey p, final AccountGroup.Id a) {
|
||||
projectName = p;
|
||||
groupId = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project.NameKey getParentKey() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.gwtorm.client.Key<?>[] members() {
|
||||
return new com.google.gwtorm.client.Key<?>[] {groupId};
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Key key;
|
||||
|
||||
protected ProjectLeadGroup() {
|
||||
}
|
||||
|
||||
public ProjectLeadGroup(final ProjectLeadGroup.Key k) {
|
||||
key = k;
|
||||
}
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
// 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 ProjectLeadGroupAccess extends
|
||||
Access<ProjectLeadGroup, ProjectLeadGroup.Key> {
|
||||
@PrimaryKey("key")
|
||||
ProjectLeadGroup get(ProjectLeadGroup.Key key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.projectName= ?")
|
||||
ResultSet<ProjectLeadGroup> byProject(Project.NameKey id) throws OrmException;
|
||||
|
||||
@Query("WHERE key.groupId = ?")
|
||||
ResultSet<ProjectLeadGroup> byGroup(AccountGroup.Id id) throws OrmException;
|
||||
}
|
@@ -62,12 +62,6 @@ public interface ReviewDb extends Schema {
|
||||
@Relation
|
||||
BranchAccess branches();
|
||||
|
||||
@Relation
|
||||
ProjectLeadAccountAccess projectLeadAccounts();
|
||||
|
||||
@Relation
|
||||
ProjectLeadGroupAccess projectLeadGroups();
|
||||
|
||||
@Relation
|
||||
ChangeAccess changes();
|
||||
|
||||
|
Reference in New Issue
Block a user