use of com.google.gerrit.extensions.api.projects.DashboardSectionInfo in project gerrit by GerritCodeReview.
the class DashboardsCollection method parse.
static DashboardInfo parse(Project definingProject, String refName, String path, Config config, String project, boolean setDefault) {
DashboardInfo info = newDashboardInfo(refName, path);
info.project = project;
info.definingProject = definingProject.getName();
String title = config.getString("dashboard", null, "title");
info.title = replace(project, title == null ? info.path : title);
info.description = replace(project, config.getString("dashboard", null, "description"));
info.foreach = config.getString("dashboard", null, "foreach");
if (setDefault) {
String id = refName + ":" + path;
info.isDefault = id.equals(defaultOf(definingProject)) ? true : null;
}
UrlEncoded u = new UrlEncoded("/dashboard/");
u.put("title", MoreObjects.firstNonNull(info.title, info.path));
if (info.foreach != null) {
u.put("foreach", replace(project, info.foreach));
}
for (String name : config.getSubsections("section")) {
DashboardSectionInfo s = new DashboardSectionInfo();
s.name = name;
s.query = config.getString("section", name, "query");
u.put(s.name, replace(project, s.query));
info.sections.add(s);
}
info.url = u.toString().replace("%3A", ":");
return info;
}
use of com.google.gerrit.extensions.api.projects.DashboardSectionInfo in project gerrit by GerritCodeReview.
the class DashboardIT method createDashboard.
private DashboardInfo createDashboard(DashboardInfo info) throws Exception {
String canonicalRef = DashboardsCollection.normalizeDashboardRef(info.ref);
try {
project().branch(canonicalRef).create(new BranchInput());
} catch (ResourceConflictException e) {
// The branch already exists if this method has already been called once.
if (!e.getMessage().contains("already exists")) {
throw e;
}
}
try (Repository r = repoManager.openRepository(project);
TestRepository<Repository> tr = new TestRepository<>(r)) {
TestRepository<Repository>.CommitBuilder cb = tr.branch(canonicalRef).commit();
StringBuilder content = new StringBuilder("[dashboard]\n");
if (info.title != null) {
content.append("title = ").append(info.title).append("\n");
}
if (info.description != null) {
content.append("description = ").append(info.description).append("\n");
}
if (info.foreach != null) {
content.append("foreach = ").append(info.foreach).append("\n");
}
if (info.sections != null) {
for (DashboardSectionInfo section : info.sections) {
content.append("[section \"").append(section.name).append("\"]\n");
content.append("query = ").append(section.query).append("\n");
}
}
cb.add(info.path, content.toString());
RevCommit c = cb.create();
project().commit(c.name());
}
return info;
}
use of com.google.gerrit.extensions.api.projects.DashboardSectionInfo in project gerrit by GerritCodeReview.
the class DashboardIT method newDashboardInfo.
private DashboardInfo newDashboardInfo(String ref, String path) {
DashboardInfo info = DashboardsCollection.newDashboardInfo(ref, path);
info.title = "Reviewer";
info.description = "Own review requests";
info.foreach = "owner:self";
DashboardSectionInfo section = new DashboardSectionInfo();
section.name = "Open";
section.query = "is:open";
info.sections = ImmutableList.of(section);
return info;
}
Aggregations