All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xebia.mojo.dashboard.reports.xml.ChangelogDashboardReport Maven / Gradle / Ivy

Go to download

This plugin provides a Dashboard for a Maven2 site. This dashboard closely resembles the one which is available in Maven1.

There is a newer version: 0.8.22
Show newest version
/*
 * Copyright The Sett Ltd, 2005 to 2014.
 *
 * 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.xebia.mojo.dashboard.reports.xml;

import java.util.Arrays;
import java.util.List;

import com.xebia.mojo.dashboard.DashboardReport;
import com.xebia.mojo.dashboard.reports.XmlFileXpathReport;
import com.xebia.mojo.dashboard.util.DashboardUtil;
import com.xebia.mojo.dashboard.util.XmlUtil;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;

/**
 * {@link DashboardReport} for the Changelog plugin.
 *
 * @author Jeroen van Erp
 */
public class ChangelogDashboardReport extends XmlFileXpathReport
{
    private static final List COLUMN_NAMES = Arrays.asList(new String[] { "commits", "changes" });

    /** {@inheritDoc} */
    public List getColumnNames()
    {
        return COLUMN_NAMES;
    }

    /** {@inheritDoc} */
    public Node getContent(MavenProject subProject, int column) throws MojoExecutionException
    {
        String xpath = null;

        switch (column)
        {
        case 0:
            xpath = "count(//changelog-entry)";
            break;

        case 1:
            xpath = "count(//file)";
            break;

        default:
            return DocumentHelper.createText(XmlUtil.NBSP);
        }

        Document document = xmlUtil.readXmlDocument(getReportFile(subProject));

        return DocumentHelper.createText(DashboardUtil.executeXpathFunctionOnDocument(document, xpath));
    }

    /** {@inheritDoc} */
    public String getHeaderForColumn(int columnNumber)
    {
        switch (columnNumber)
        {
        case 0:
            return "Commits";

        case 1:
            return "Changed files";

        default:
            return XmlUtil.NBSP;
        }
    }

    /** {@inheritDoc} */
    public String getLinkLocation()
    {
        return "changelog.html";
    }

    /** {@inheritDoc} */
    public String title()
    {
        return "Changelog";
    }

    /** {@inheritDoc} */
    protected String getReportFileName()
    {
        return "changelog.xml";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy