Use Prolog Cafe for ChangeControl.canSubmit()
Re-implement the canSubmit() logic in Prolog, removing one of the last uses of FunctionState. This is a simple re-implementation that does not provide any new functionality. PatchSetApproval objects are exposed into Prolog on demand by loading them from the database if the submit predicate needs them. These get indexed in a temporary HashMap by their label name (aka ApprovalCategory), making access faster during evaluation of the rule. ApprovalTypes are loaded into Prolog on demand from the Guice Injector. This will eventually go away when we get rid of the global declaration of ApprovalCategories in the web UI. CurrentUser instances are loaded and cached within the Prolog environment as needed to consider PatchSetApproval objects and if the user has the necessary permission to make that assertion. Bug: 971 Change-Id: I7e261948db08b7c3180e590e81f492ff3e6f237e Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2011 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.rules;
|
||||
|
||||
import com.google.gerrit.server.config.FactoryModule;
|
||||
|
||||
public class PrologModule extends FactoryModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
factory(PrologEnvironment.Factory.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user