Following Jira Report Plugin Tutorial, Report isn't visible in Jira 7.2.2

This is my first time asking a question and I am quite new to plugin development. So far I've completed a JQL function plugin successfully and I've been asked to develop a report plugin so I figured I would start with the tutorial. However, I either don't know where my report should be visible or its just not appearing and I'm not sure why.

This is my CreationReport java class

package com.teledyne.plugin.jira.report.reports;

import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.bc.project.ProjectService;
import com.atlassian.jira.datetime.DateTimeFormatter;;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.jql.builder.JqlQueryBuilder;
import com.atlassian.jira.plugin.report.impl.AbstractReport;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.util.ParameterUtils;
import com.atlassian.jira.web.action.ProjectActionSupport;
import com.atlassian.query.Query;
import com.atlassian.sal.api.search.SearchProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

public class CreationReport extends AbstractReport
{
// private static final Logger log = Logger.getLogger(CreationReport.class);
private static final int MAX_HEIGHT = 200;
private Long DEFAULT_INTERVAL = new Long(7);
private long maxCount = 0;
private Collection<Long> openIssueCounts = new ArrayList<Long>();
private Collection<Date> dates = new ArrayList<Date>();
private final SearchService searchService;
private final DateTimeFormatter dateTimeFormatter;
private final ProjectManager projectManager;
private final UserManager userManager;

public CreationReport(SearchService searchService,
DateTimeFormatter dateTimeFormatter,
ProjectManager projectManager,
UserManager userManager)
{
this.searchService = searchService;
this.dateTimeFormatter = dateTimeFormatter;
this.projectManager = projectManager;
this.userManager = userManager;
}
public String generateReportHtml(ProjectActionSupport projectActionSupport, Map params) throws Exception
{
ApplicationUser remoteUser = projectActionSupport.getLoggedInUser();

Long projectId = ParameterUtils.getLongParam(params, "selectedProjectId");

String startDateStr = ParameterUtils.getStringParam(params, "startDate");
Date startDate = dateTimeFormatter.parse(startDateStr);

String endDateStr = ParameterUtils.getStringParam(params, "endDate");
Date endDate = dateTimeFormatter.parse(endDateStr);

Long interval = ParameterUtils.getLongParam(params, "interval");

if (interval == null || interval.longValue() <= 0)
{
interval = DEFAULT_INTERVAL;
// TODO: add error logging
}

getIssueCount(startDate, endDate, interval, remoteUser, projectId);


return null;
}

private long getOpenIssueCount(ApplicationUser remoteUser, Date startDate, Date endDate, Long projectId) throws SearchException
{
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
Query query = queryBuilder.where().createdBetween(startDate, endDate).and().project(projectId).buildQuery();
return searchService.searchCount(remoteUser, query);
}

private void getIssueCount(Date startDate, Date endDate, Long interval, ApplicationUser remoteUser, Long projectId) throws SearchException
{
long intervalValue = interval.longValue() * TimeUnit.DAYS.toMillis(1);
Date newStartDate;
long count = 0;
while (startDate.before(endDate))
{
newStartDate = new Date(startDate.getTime() + intervalValue);
if (newStartDate.after(endDate)) {
count = getOpenIssueCount(remoteUser, startDate, endDate, projectId);
} else {
count = getOpenIssueCount(remoteUser, startDate, newStartDate, projectId);
}

if (maxCount < count)
{
maxCount = count;
}

openIssueCounts.add(new Long(count));
dates.add(startDate);
startDate = newStartDate;
}
}

public void validate(ProjectActionSupport projectActionSupport, Map params)
{
ApplicationUser remoteUser = projectActionSupport.getLoggedInUser();
Long projectId = ParameterUtils.getLongParam(params, "selectedProjectId");

String startDateStr = ParameterUtils.getStringParam(params, "startDate");
Date startDate = dateTimeFormatter.parse(startDateStr);

String endDateStr = ParameterUtils.getStringParam(params, "endDate");
Date endDate = dateTimeFormatter.parse(endDateStr);

Long interval = ParameterUtils.getLongParam(params, "interval");

if (startDate == null)
{
projectActionSupport.addError("startDate", projectActionSupport.getText("report.issuecreation.startdate.required"));
}

if (endDate == null)
{
projectActionSupport.addError("endDate", projectActionSupport.getText("report.issuecreation.enddate.required"));
}

if (interval == null || interval.longValue() <= 0)
{
projectActionSupport.addError("interval", projectActionSupport.getText("report.issuecreation.interval.invalid"));
}

if (projectId == null)
{
projectActionSupport.addError("selectedProjectId", projectActionSupport.getText("report.issuecreation.projectid.invalid"));
}

if (startDate != null && endDate != null && endDate.before(startDate))
{
projectActionSupport.addError("endDate", projectActionSupport.getText("report.issuecreation.before.startdate"));
}
}
}

 I couldn't really follow the tutorial exactly sinced it isn't updated for 7.2 which is why there are some differences.

Here is my atlassian-plugin.xml

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}"/>
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="jira-report-plugin"/>
<!-- add our web resources -->
<web-resource key="jira-report-plugin-resources" name="jira-report-plugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="jira-report-plugin.css" location="/css/jira-report-plugin.css"/>
<resource type="download" name="jira-report-plugin.js" location="/js/jira-report-plugin.js"/>
<resource type="download" name="images/" location="/images"/>
<context>jira-report-plugin</context>
</web-resource>
<report name="Creation Report" i18n-name-key="creation-report.name" key="creation-report" class="com.teledyne.plugin.jira.report.reports.CreationReport">
<description key="creation-report.description">The Creation Report Plugin</description>
<resource name="view" type="velocity" location="/templates/reports/creation-report/view.vm"/>
<resource name="i18n" type="i18n" location="CreationReport"/>
<label key="creation-report.label"></label>
<properties>
<property>
<key>projectid</key>
<name>report.issuecreation.projectid.name</name>
<description>report.issuecreation.projectid.description</description>
<type>filterprojectpicker</type>
</property>
<property>
<key>startDate</key>
<name>report.issuecreation.startdate</name>
<description>report.issuecreation.startdate.description</description>
<type>date</type>
</property>
<property>
<key>endDate</key>
<name>report.issuecreation.enddate</name>
<description>report.issuecreation.enddate.description</description>
<type>date</type>
</property>
<property>
<key>interval</key>
<name>report.issuecreation.interval</name>
<description>report.issuecreation.interval.description</description>
<type>long</type>
<default>3</default>
</property>
</properties>
</report>
</atlassian-plugin>

 

1 answer

I figured out that because I was using the constructor to grab components it wasn't showing up in Jira. I don't know why but for some reason that method doesn't work with Reports or Project Tabs

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,312 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot