use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class AbstractQueryProjectsTest method byParent.
@Test
public void byParent() throws Exception {
assertQuery("parent:project");
ProjectInfo parent = createProject(name("parent"));
assertQuery("parent:" + parent.name);
ProjectInfo child = createProject(name("child"), parent.name);
assertQuery("parent:" + parent.name, child);
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class AdminSetParent method getChildrenForReparenting.
/**
* Returns the children of the specified parent project that should be reparented. The returned
* list of child projects does not contain projects that were specified to be excluded from
* reparenting.
*/
private List<Project.NameKey> getChildrenForReparenting(final ProjectControl parent) throws PermissionBackendException {
final List<Project.NameKey> childProjects = new ArrayList<>();
final List<Project.NameKey> excluded = new ArrayList<>(excludedChildren.size());
for (final ProjectControl excludedChild : excludedChildren) {
excluded.add(excludedChild.getProject().getNameKey());
}
final List<Project.NameKey> automaticallyExcluded = new ArrayList<>(excludedChildren.size());
if (newParentKey != null) {
automaticallyExcluded.addAll(getAllParents(newParentKey));
}
for (final ProjectInfo child : listChildProjects.apply(new ProjectResource(parent))) {
final Project.NameKey childName = new Project.NameKey(child.name);
if (!excluded.contains(childName)) {
if (!automaticallyExcluded.contains(childName)) {
childProjects.add(childName);
} else {
stdout.println("Automatically excluded '" + childName + "' " + "from reparenting because it is in the parent " + "line of the new parent '" + newParentKey + "'.");
}
}
}
return childProjects;
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ParentProjectPredicate method predicates.
protected static List<Predicate<ChangeData>> predicates(ProjectCache projectCache, Provider<ListChildProjects> listChildProjects, Provider<CurrentUser> self, String value) {
ProjectState projectState = projectCache.get(new Project.NameKey(value));
if (projectState == null) {
return Collections.emptyList();
}
List<Predicate<ChangeData>> r = new ArrayList<>();
r.add(new ProjectPredicate(projectState.getProject().getName()));
try {
ProjectResource proj = new ProjectResource(projectState.controlFor(self.get()));
ListChildProjects children = listChildProjects.get();
children.setRecursive(true);
for (ProjectInfo p : children.apply(proj)) {
r.add(new ProjectPredicate(p.name));
}
} catch (PermissionBackendException e) {
log.warn("cannot check permissions to expand child projects", e);
}
return r;
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ProjectJson method format.
public ProjectInfo format(Project p) {
ProjectInfo info = new ProjectInfo();
info.name = p.getName();
Project.NameKey parentName = p.getParent(allProjects);
info.parent = parentName != null ? parentName.get() : null;
info.description = Strings.emptyToNull(p.getDescription());
info.state = p.getState();
info.id = Url.encode(info.name);
ImmutableList<WebLinkInfo> links = webLinks.getProjectLinks(p.getName());
info.webLinks = links.isEmpty() ? null : links;
return info;
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ProjectJson method format.
public ProjectInfo format(ProjectState projectState) {
ProjectInfo info = format(projectState.getProject());
info.labels = new HashMap<>();
for (LabelType t : projectState.getLabelTypes().getLabelTypes()) {
LabelTypeInfo labelInfo = new LabelTypeInfo();
labelInfo.values = t.getValues().stream().collect(toMap(LabelValue::formatValue, LabelValue::getText, (v1, v2) -> {
logger.atSevere().log("Duplicate values for project: %s, label: %s found: '%s':'%s'", projectState.getName(), t.getName(), v1, v2);
return v1;
}));
labelInfo.defaultValue = t.getDefaultValue();
info.labels.put(t.getName(), labelInfo);
}
return info;
}
Aggregations