Add inheritance of prolog rules

Projects now inherit the prolog rules defined in their parent project.
Submit results from the child project are filtered by the parent
project using the filter predicate defined the parent's rules.pl.
The results of the filtering are then passed up to the parent's parent
and filtered. This process repeats up to the top level All-Projects.
If a parent does not have a filter rule defined, the results are not
filtered.

Change-Id: I961d10149f62996d1c3c74c80935b2f72ea0acc7
This commit is contained in:
Jason Tsay
2011-06-30 15:42:37 -07:00
parent b1d60c18c3
commit 82c088e282
4 changed files with 235 additions and 2 deletions

View File

@@ -52,6 +52,7 @@ public class ProjectState {
}
private final boolean isAllProjects;
private final AllProjectsName allProjectsName;
private final ProjectCache projectCache;
private final ProjectControl.AssistedFactory projectControlFactory;
private final PrologEnvironment.Factory envFactory;
@@ -84,6 +85,7 @@ public class ProjectState {
@Assisted final ProjectConfig config) {
this.projectCache = projectCache;
this.isAllProjects = config.getProject().getNameKey().equals(allProjectsName);
this.allProjectsName = allProjectsName;
this.projectControlFactory = projectControlFactory;
this.envFactory = envFactory;
this.gitMgr = gitMgr;
@@ -257,4 +259,20 @@ public class ProjectState {
public ProjectControl controlFor(final CurrentUser user) {
return projectControlFactory.create(user, this);
}
}
/**
* @return ProjectState of project's parent. If the project does not have a
* parent, return state of the top level project, All-Projects. If
* this project is All-Projects, return null.
*/
public ProjectState getParentState() {
if (isAllProjects) {
return null;
}
Project.NameKey parentName = getProject().getParent();
if (parentName == null) {
parentName = allProjectsName;
}
return projectCache.get(parentName);
}
}