public RoadMapGraphingBean(final BrowseContext ctx, final SearchProvider searchProvider, final ConstantsManager constantsManager, final SearchService searchService) { this.ctx = ctx; this.searchProvider = searchProvider; this.constantsManager = constantsManager; this.searchService = searchService; statsBean = createStatsBean(); }
public String getHtml(final BrowseContext ctx) { return descriptor.getHtml("view", createVelocityParams(ctx)); }
/** * Determines whether or not to display all the versions or only the first {@link #SUBSET_SIZE}. This is remember on * a per Context basis. * * @param ctx the context under which this is running. * @param uniqueKey a key that is unique to this roadmap / changelog. * @return whether or not to display all the versions or only the first {@link #SUBSET_SIZE}. */ private Boolean showAllVersions(final BrowseContext ctx, final String uniqueKey) { final String key = uniqueKey + "_allVersions_" + ctx.getContextKey(); String requestParameter = getPassedParameter(ALL_VERSIONS); if (!StringUtils.isEmpty(requestParameter)) { final Boolean showAllVersions = Boolean.valueOf(requestParameter); getSession().put(key, showAllVersions); return showAllVersions; } final Boolean showAllVersions = (Boolean) getSession().get(key); return showAllVersions != null && showAllVersions; }
final boolean isExpanding = getPassedParameter(EXPAND_VERSION) != null; final boolean isCollapsing = getPassedParameter(COLLAPSE_VERSION) != null; final boolean isContentOnly = Boolean.valueOf(getPassedParameter(CONTENT_ONLY)); startingParams.put("versionHelper", new VersionHelperBean(ctx, searchProvider)); startingParams.put("versionManager", versionManager); startingParams.put("isExpanding", isExpanding); startingParams.put("isCollapsing", isCollapsing); startingParams.put("isContentOnly", isContentOnly); startingParams.put("selectedVersions", getSelectedVersions(ctx, uniqueKey)); final boolean showAllVersions = showAllVersions(ctx, uniqueKey); startingParams.put("versions", trimVersions(versions, showAllVersions)); if (isContentOnly && isExpanding) final Version expandingVersion = versionManager.getVersion(Long.valueOf(getPassedParameter(EXPAND_VERSION))); startingParams.put("graphingBean", new RoadMapGraphingBean(ctx, searchProvider, constantsManager, searchService));
/** * The query string for unresolved issues. * * @return The query string for unresolved issues. */ public String getUnresolvedQueryString() { final Clause resolutionClause = JqlQueryBuilder.newClauseBuilder().unresolved().buildClause(); return getQuerySnipper(resolutionClause); }
/** * Retrieves the html for a non-personal roadmap/changelog * * @param ctx The context under which this is running * @param uniqueKey a key that is unique ot this roadmap/changelog * @param versions the list of versions for this context * @return The escaped html of the roadmap */ @Override public String getHtml(final BrowseContext ctx, final String uniqueKey, final Collection<Version> versions) { final Map<String, Object> params = createVelocityParams(ctx, uniqueKey, versions); try { return templatingEngine.render(file("templates/plugins/jira/projectpanels/roadmap-panel.vm")).applying(params).asHtml(); } catch (VelocityException e) { log.error("Error occurred while rendering velocity template: 'templates/plugins/jira/projectpanels/roadmap-panel.vm'.", e); throw new RuntimeException(e); } }
public boolean showPanel(BrowseContext browseContext) { if (super.showPanel(browseContext)) { final CustomFieldManager customFieldManager = ManagerFactory.getCustomFieldManager(); final List<CustomField> customFields = customFieldManager.getCustomFieldObjects(browseContext.getProject().getId(), ConstantsManager.ALL_ISSUE_TYPES); for (final CustomField customField : customFields) { if (LabelsCFType.class.getName().equals(customField.getCustomFieldType().getClass().getName())) { return true; } } } return false; } }
/** * Gets a progress graph model for the current version under the current context. Though this does not take a version, * the underlying macro that generates the percentage chart takes a version. * * @param openCount The number of open issues for this version under this context * @param allCount The total issues under this context * @return a graph model representing the percentage of issues that are resolved. */ public PercentageGraphModel getIssueSummaryByFixForVersion(final Version version, final ProjectComponent component, final int openCount, final int allCount) { if (allCount == 0) { return new PercentageGraphModel(); } final I18nBean i18nBean = new I18nBean(ctx.getUser()); PercentageGraphModel model = new PercentageGraphModel(); model.addRow("#009900", allCount - openCount, i18nBean.getText("common.concepts.resolved.issues"), getNavigatorUrl(ctx.getProject(), version, component, false)); model.addRow("#cc0000", openCount, i18nBean.getText("common.concepts.unresolved.issues"), getNavigatorUrl(ctx.getProject(), version, component, true)); return model; }
@Override protected Map<String, Object> createVelocityParams(BrowseContext ctx) { Map<String, Object> params = super.createVelocityParams(ctx); Iterable<? extends Build> builds = buildPanelHelper.getBuildsByRelation(ctx.getProject()); List<BuildAction> buildActions = buildPanelHelper.getBuildActions(builds, true); params.put("actions", buildActions); return params; }
/** * Get a collections of Long that represents what versions have been selected per context basis. * * @param ctx the context under which this is running. * @param uniqueKey a key that is unique to this roadmap/changelog. * @return a list of version ids representing which versions should be expanded. */ private Collection<Long> getSelectedVersions(final BrowseContext ctx, final String uniqueKey) { final Map<String, Object> session = getSession(); final String key = uniqueKey + "_selected_" + ctx.getContextKey(); Set<Long> versions = (Set<Long>) session.get(key); if (versions == null) { versions = new HashSet<Long>(); session.put(key, versions); } String requestParameter = getPassedParameter(EXPAND_VERSION); if (!StringUtils.isEmpty(requestParameter)) { versions.add(Long.valueOf(requestParameter)); } requestParameter = getPassedParameter(COLLAPSE_VERSION); if (!StringUtils.isEmpty(requestParameter)) { versions.remove(Long.valueOf(requestParameter)); } return versions; }
/** * The query string for resolved issues. * * @return The query string for resolved issues. */ public String getResolvedQueryString() { final Collection<Resolution> resolutionObjects = constantsManager.getResolutionObjects(); final List<Long> resolutions = Lists.newArrayListWithCapacity(resolutionObjects.size()); for (Resolution resolution : resolutionObjects) { resolutions.add(new Long(resolution.getId())); } if (!resolutions.isEmpty()) { final Clause resolutionClause = JqlQueryBuilder.newClauseBuilder().resolution().inNumbers(resolutions).buildClause(); return getQuerySnipper(resolutionClause); } return ""; }