repos.jspf revision 6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%--
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal$Id$
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCDDL HEADER START
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalThe contents of this file are subject to the terms of the
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCommon Development and Distribution License (the "License").
888273610a036b1d0d39339d0057352922648a5bVladimir KotalYou may not use this file except in compliance with the License.
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalSee LICENSE.txt included in this distribution for the specific
888273610a036b1d0d39339d0057352922648a5bVladimir Kotallanguage governing permissions and limitations under the License.
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalWhen distributing Covered Code, include this CDDL HEADER in each
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalfile and include the License file at LICENSE.txt.
888273610a036b1d0d39339d0057352922648a5bVladimir KotalIf applicable, add the following below this CDDL HEADER, with the
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalfields enclosed by brackets "[]" replaced with your own identifying
888273610a036b1d0d39339d0057352922648a5bVladimir Kotalinformation: Portions Copyright [yyyy] [name of copyright owner]
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCDDL HEADER END
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir KotalCopyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal--%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Collections"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.TreeMap"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Comparator"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Iterator"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.ArrayList"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Collection"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.Map"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.HashMap"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.io.File"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.configuration.RuntimeEnvironment"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.history.RepositoryInfo"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.history.Repository"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.web.Util"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.configuration.Project"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="java.util.List"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%@page import="org.opensolaris.opengrok.web.PageConfig"%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<%
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal{
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal Comparator<Project> comparatorProj = new Comparator<Project>() {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal public int compare(Project p1, Project p2) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal return p1.getDescription().compareTo(p2.getDescription());
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal };
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal Comparator<RepositoryInfo> comparatorRepo = new Comparator<RepositoryInfo>() {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal public int compare(RepositoryInfo r1, RepositoryInfo r2) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal return r1.getDirectoryName().compareTo(r2.getDirectoryName());
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal };
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal List<Project> projects = cfg.getEnv().getProjects();
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal if (projects.size() > 0) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal // Create structure for mapping a project to list of related repositories.
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal RuntimeEnvironment env = cfg.getEnv();
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal TreeMap<Project, ArrayList<RepositoryInfo>> map =
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal new TreeMap<Project, ArrayList<RepositoryInfo>>(comparatorProj);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal for (RepositoryInfo r: env.getRepositories()) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal Project proj;
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal String repoPath = env.getPathRelativeToSourceRoot(
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal new File(r.getDirectoryName()), 0);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal if ((proj = Project.getProject(repoPath)) != null) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal ArrayList<RepositoryInfo> values = map.get(proj);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal if (values == null) {
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal values = new ArrayList<RepositoryInfo>();
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal map.put(proj, values);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal values.add(r);
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal // Print table of project-repository mappings.
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal if (map.keySet().size() > 0) { %>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <table>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <tr>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <td><b>Project</b></td>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <td><b>SCM type</b></td>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <td><b>Parent (branch)</b></td>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal </tr>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <%
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal Iterator<Project> keySetIterator = map.keySet().iterator();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal while (keySetIterator.hasNext()) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal Project proj = keySetIterator.next();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal ArrayList<RepositoryInfo> repos = map.get(proj);
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal String projDesc = proj.getDescription();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal Integer cnt = 0;
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal Collections.sort(repos, comparatorRepo);
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal for (RepositoryInfo ri : repos) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal if (cnt != 0) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal projDesc = "";
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal }
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal %>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal <tr><td><%= Util.htmlize(projDesc) %></td><%
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal String parent = ri.getParent();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal if (parent == null) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal parent = "N/A";
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal }
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal String type = ri.getType();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal if (type == null) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal type = "N/A";
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal }
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal String branch = ri.getBranch();
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal if (branch == null) {
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal branch = "N/A";
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal }
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal %><td><%= Util.htmlize(type) %></td><%
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal %><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal %></tr><%
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal cnt++;
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal %>
6d0bbc3c98687adba7128b171c9a3ed2a4daf5b8Vladimir Kotal </table> <%
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal }
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal}
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal%>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<br/>
888273610a036b1d0d39339d0057352922648a5bVladimir Kotal<br/>