InlineEdit: Add change edit collection and resource
Change-Id: I3039fdccd214d748d5c06d1019f34caf756bbf1f
This commit is contained in:
committed by
David Ostrovsky
parent
f5115454fd
commit
3a270f1249
@@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (C) 2014 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.change;
|
||||||
|
|
||||||
|
import com.google.gerrit.extensions.restapi.RestResource;
|
||||||
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
|
import com.google.gerrit.server.edit.ChangeEdit;
|
||||||
|
import com.google.gerrit.server.project.ChangeControl;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
public class ChangeEditResource implements RestResource {
|
||||||
|
public static final TypeLiteral<RestView<ChangeEditResource>> CHANGE_EDIT_KIND =
|
||||||
|
new TypeLiteral<RestView<ChangeEditResource>>() {};
|
||||||
|
|
||||||
|
private final ChangeResource change;
|
||||||
|
private final ChangeEdit edit;
|
||||||
|
|
||||||
|
public ChangeEditResource(ChangeResource change, ChangeEdit edit) {
|
||||||
|
this.change = change;
|
||||||
|
this.edit = edit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(davido): Make this cacheable.
|
||||||
|
// Should just depend on the SHA-1 of the edit itself.
|
||||||
|
public boolean isCacheable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeResource getChangeResource() {
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeControl getControl() {
|
||||||
|
return getChangeResource().getControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Change getChange() {
|
||||||
|
return edit.getChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeEdit getChangeEdit() {
|
||||||
|
return edit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Account.Id getAccountId() {
|
||||||
|
return getUser().getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
IdentifiedUser getUser() {
|
||||||
|
return edit.getUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2014 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.change;
|
||||||
|
|
||||||
|
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||||
|
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||||
|
import com.google.gerrit.extensions.restapi.IdString;
|
||||||
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class ChangeEdits implements
|
||||||
|
ChildCollection<ChangeResource, ChangeEditResource> {
|
||||||
|
private final DynamicMap<RestView<ChangeEditResource>> views;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ChangeEdits(DynamicMap<RestView<ChangeEditResource>> views) {
|
||||||
|
this.views = views;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DynamicMap<RestView<ChangeEditResource>> views() {
|
||||||
|
return views;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RestView<ChangeResource> list() {
|
||||||
|
throw new IllegalStateException("not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChangeEditResource parse(ChangeResource change, IdString id) {
|
||||||
|
throw new IllegalStateException("not yet implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import static com.google.gerrit.server.change.DraftResource.DRAFT_KIND;
|
|||||||
import static com.google.gerrit.server.change.FileResource.FILE_KIND;
|
import static com.google.gerrit.server.change.FileResource.FILE_KIND;
|
||||||
import static com.google.gerrit.server.change.ReviewerResource.REVIEWER_KIND;
|
import static com.google.gerrit.server.change.ReviewerResource.REVIEWER_KIND;
|
||||||
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
|
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
|
||||||
|
import static com.google.gerrit.server.change.ChangeEditResource.CHANGE_EDIT_KIND;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiModule;
|
import com.google.gerrit.extensions.restapi.RestApiModule;
|
||||||
@@ -44,6 +45,7 @@ public class Module extends RestApiModule {
|
|||||||
DynamicMap.mapOf(binder(), FILE_KIND);
|
DynamicMap.mapOf(binder(), FILE_KIND);
|
||||||
DynamicMap.mapOf(binder(), REVIEWER_KIND);
|
DynamicMap.mapOf(binder(), REVIEWER_KIND);
|
||||||
DynamicMap.mapOf(binder(), REVISION_KIND);
|
DynamicMap.mapOf(binder(), REVISION_KIND);
|
||||||
|
DynamicMap.mapOf(binder(), CHANGE_EDIT_KIND);
|
||||||
|
|
||||||
get(CHANGE_KIND).to(GetChange.class);
|
get(CHANGE_KIND).to(GetChange.class);
|
||||||
get(CHANGE_KIND, "detail").to(GetDetail.class);
|
get(CHANGE_KIND, "detail").to(GetDetail.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user