private VelocityContext createContextFrom(final Map<String, Object> suppliedParameters) { final Map<String, Object> contextParameters = CompositeMap.of ( suppliedParameters, Collections.<String, Object>singletonMap("baseurl", getBaseUrl()) ); return new VelocityContext(CompositeMap.of(Maps.<String, Object>newHashMap(), contextParameters)); }
/** * Make a composite caching map of the local and master maps. * * @param localValues any values that may override elements in the Master. * @return a map instance that will be lazily populated with the values from the master. */ public Map<K, V> toMap(final Map<K, ? extends V> localValues) { @SuppressWarnings("unchecked") final Map<K, V> map = (Map<K, V>) localValues; return CompositeMap.of(map, new MemoizingMap<K, V>(suppliers)); }
@SuppressWarnings ("unchecked") @Override protected VelocityContext createVelocityContext(final Map params) { // decorate the passed in map so we can modify it as the super call does... return super.createVelocityContext(CompositeMap.of(new HashMap<String, Object>(), (Map<String, Object>) params)); }
/** * Make a composite {@link Master} of the other and this master. * * @param other any values that may override elements in this Master. * @return a map instance that will be lazily populated with the values from the master. */ public Master<K, V> combine(final Master<K, V> other) { return new Master<K, V>(CompositeMap.of(other.suppliers, suppliers)); }
@Override @SuppressWarnings ("unchecked") protected Map<String, ?> createContextParams(final String baseurl, final Map contextParameters) { final Map<String, Object> result = new HashMap<String, Object>(); result.put(Key.BASE_URL, baseurl); result.put(Key.FORMATTER, getDateFormat()); return CompositeMap.of((Map<String, Object>) contextParameters, result); }
/** * Static method to construct a map with a number of common parameters used by velocity templates. * <p> * For API compliance, use {@link VelocityParamFactory#getDefaultVelocityParams(java.util.Map, com.atlassian.jira.security.JiraAuthenticationContext)} instead. * * @param startingParams Map of parameters that may be used to override any of the parameters set here. * @param authenticationContext JiraAuthenticationContext * @return a Map with common velocity parameters */ public static Map<String, Object> getDefaultVelocityParams(Map<String, Object> startingParams, final JiraAuthenticationContext authenticationContext) { //JRADEV-990: startingParams needs to be a mutable map. startingParams = (startingParams == null) ? new HashMap<>() : startingParams; return CompositeMap.of(startingParams, createVelocityParams(authenticationContext)); }
protected Map<String, Object> getVelocityParams(final FieldLayoutItem fieldLayoutItem, final I18nHelper i18nHelper, final Map<String, Object> displayParams, final Issue issue) { final Map<String, Object> velocityParams = new HashMap<>(); velocityParams.put("req", ExecutingHttpRequest.get()); // todo: remove when no longer used velocityParams.put("field", this); velocityParams.put("i18n", i18nHelper); velocityParams.put("urlcodec", new URLCodec()); // TODO: this should probably be named differently from Velocity usages of JiraUrlCodec velocityParams.put("issue", issue); velocityParams.put("displayParams", displayParams); velocityParams.put("fieldLayoutItem", fieldLayoutItem); return CompositeMap.of(velocityParams, JiraVelocityUtils.getDefaultVelocityParams(authenticationContext)); }
public void write(final Issue issue) throws IOException { issueCount++; if (issueCount == 1) { asHtml(writer, ISSUETABLE_HEADER, params); } final Map<String, Object> issueParams = new HashMap<String, Object>(); issueParams.put("issue", issue); issueParams.put("issueCount", issueCount); asHtml(writer, ISSUETABLE_SINGLE_ISSUE, CompositeMap.of(issueParams, params)); }
protected Map<String, Object> getVelocityParams(I18nHelper isI18nHelper, Map displayParams, Issue issue) { Map<String, Object> velocityParams = new HashMap<String, Object>(); velocityParams.put(CommonVelocityKeys.I18N, isI18nHelper); velocityParams.put(CommonVelocityKeys.DISPLAY_PARAMS, displayParams); velocityParams.put(CommonVelocityKeys.DISPLAY_PARAMETERS, displayParams); if (displayParams != null) { velocityParams.put(CommonVelocityKeys.READ_ONLY, (displayParams.get("readonly") == null ? Boolean.FALSE: displayParams.get("readonly"))); velocityParams.put(CommonVelocityKeys.TEXT_ONLY, (displayParams.get("textOnly") == null ? Boolean.FALSE: displayParams.get("textOnly"))); velocityParams.put(CommonVelocityKeys.EXCEL_VIEW, (displayParams.get("excel_view") == null ? Boolean.FALSE: displayParams.get("excel_view"))); velocityParams.put(CommonVelocityKeys.NO_LINK, (displayParams.get("nolink") == null ? Boolean.FALSE: displayParams.get("nolink"))); velocityParams.put(CommonVelocityKeys.PREFIX, (displayParams.get("prefix") == null ? "": displayParams.get("prefix"))); } else { velocityParams.put(CommonVelocityKeys.READ_ONLY, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.TEXT_ONLY, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.EXCEL_VIEW, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.NO_LINK, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.PREFIX, ""); } return CompositeMap.of(velocityParams, getVelocityParams(issue)); }
protected Map<String, Object> createVelocityParams(final Map<String, Object> startingParams) { final Map<String, Object> params = getVelocityRequestContextFactory().getDefaultVelocityParams(startingParams, authenticationContext); final Map<String, Object> result = new HashMap<String, Object>(); if (!params.containsKey("i18n")) { result.put("i18n", getI18nBean()); } //JRA-29836 if (!params.containsKey("ctx")) { result.put("ctx", params); } result.put("descriptor", this); return CompositeMap.of(result, params); }
protected Map<String, Object> getVelocityParams(final FieldLayoutItem fieldLayoutItem, final Action action, final Issue issue, final Map displayParams) { final Map<String, Object> velocityParams = new HashMap<String, Object>(); velocityParams.put(CommonVelocityKeys.DISPLAY_PARAMS, displayParams); velocityParams.put(CommonVelocityKeys.DISPLAY_PARAMETERS, displayParams); if (displayParams != null) { velocityParams.put(CommonVelocityKeys.READ_ONLY, (displayParams.get("readonly") == null ? Boolean.FALSE: displayParams.get("readonly"))); velocityParams.put(CommonVelocityKeys.TEXT_ONLY, (displayParams.get("textOnly") == null ? Boolean.FALSE: displayParams.get("textOnly"))); velocityParams.put(CommonVelocityKeys.EXCEL_VIEW, (displayParams.get("excel_view") == null ? Boolean.FALSE: displayParams.get("excel_view"))); velocityParams.put(CommonVelocityKeys.NO_LINK, (displayParams.get("nolink") == null ? Boolean.FALSE: displayParams.get("nolink"))); velocityParams.put(CommonVelocityKeys.PREFIX, (displayParams.get("prefix") == null ? "": displayParams.get("prefix"))); } else { velocityParams.put(CommonVelocityKeys.READ_ONLY, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.TEXT_ONLY, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.EXCEL_VIEW, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.NO_LINK, Boolean.FALSE); velocityParams.put(CommonVelocityKeys.PREFIX, ""); } velocityParams.put("fieldLayoutItem", fieldLayoutItem); velocityParams.put("action", action); velocityParams.put("i18n", action); velocityParams.put("auiparams", new HashMap<String, Object>()); velocityParams.put("helpUtil", HelpUtil.getInstance()); return CompositeMap.of(velocityParams, getVelocityParams(issue)); }
protected Map<String, Object> getVelocityParams(final Issue issue) { final Map<String, Object> velocityParams = new HashMap<String, Object>(); velocityParams.put("field", this); velocityParams.put("issue", issue); // express if there is a calendar translation file for the current language final CalendarLanguageUtil calLangUtil = ComponentAccessor.getComponentOfType(CalendarLanguageUtil.class); final String language = authenticationContext.getI18nHelper().getLocale().getLanguage(); velocityParams.put("hasCalendarTranslation", calLangUtil.hasTranslationForLanguage(language)); return CompositeMap.of(velocityParams, MASTER.toMap(JiraVelocityUtils.createVelocityParams(authenticationContext))); }
@Override public String getHtml(final Map displayParams, final Issue issue) { final Map<String, Object> localParams = new HashMap<String, Object>(); localParams.put("issue", issue); localParams.put("atl_token", xsrfTokenGenerator.generateToken()); localParams.put("displayParams", displayParams); localParams.put("i18n", authenticationContext.getI18nHelper()); final Map<String, Object> velocityParams = CompositeMap.of(localParams, JiraVelocityUtils.getDefaultVelocityParams(authenticationContext)); return templatingEngine.render(file(ISSUE_ACTIONS_DROPDOWN_TEMPLATE_PATH)).applying(velocityParams).asHtml(); }
@Override public Map<String, Object> getContextMap(Map<String, Object> context) { Map<String, Object> returnContext = MapBuilder.newBuilder(context).toMutableMap(); for (ContextProvider provider : ctxProviders) { returnContext = CompositeMap.of(returnContext, provider.getContextMap(context)); } return returnContext; }
@Override public Map<String, Object> getContextMap(final Map<String, Object> context) { Map<String, Object> returnContext = MapBuilder.newBuilder(context).toMutableMap(); for (ContextProvider provider : contextProviders) { returnContext = CompositeMap.of(returnContext, provider.getContextMap(context)); } return returnContext; } }
protected Map<String, Object> getVelocityParams(final ApplicationUser searcher, final SearchContext searchContext, final FieldLayoutItem fieldLayoutItem, final FieldValuesHolder fieldValuesHolder, final Map<?, ?> displayParameters, final Action action) { final JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext(); final Map<String, Object> velocityParams = new HashMap<String, Object>(20); velocityParams.put("searchContext", searchContext); velocityParams.put("fieldValuesHolder", fieldValuesHolder); velocityParams.put("displayParameters", displayParameters); velocityParams.put("fieldLayoutItem", fieldLayoutItem); velocityParams.put("action", action); velocityParams.put("errors", action); velocityParams.put("isKickass", true); // Static shit. Surely we can make this not instantiate every time velocityParams.put("baseurl", velocityRequestContextFactory.getJiraVelocityRequestContext().getBaseUrl()); velocityParams.put("searcherId", searcherId); velocityParams.put("searcherNameKey", searcherNameKey); velocityParams.put("helpUtil", HelpUtil.getInstance()); velocityParams.put("jirakeyutils", new JiraKeyUtilsBean()); velocityParams.put("i18n", getI18n(searcher)); // put in date formats for js popup calendar velocityParams.put("dateFormat", CustomFieldUtils.getDateFormat()); velocityParams.put("dateTimeFormat", CustomFieldUtils.getDateTimeFormat()); velocityParams.put("timeFormat", CustomFieldUtils.getTimeFormat()); // required for custom/system field templates velocityParams.put("auiparams", new HashMap<String, Object>()); return CompositeMap.of(velocityParams, ComponentAccessor.getVelocityParamFactory().getDefaultVelocityParams(jiraAuthenticationContext)); }
public Map<String, Object> getContextParams() { final Map<String, Object> newParams = MapBuilder.<String, Object> newBuilder(). add("project", project). add("request", request). toMutableMap(); return CompositeMap.of(newParams, params); }
/** * Renders a given date/time in column view. Depending on the displayParams, this can either the Excel view or the * regular issue navigator view. * * @return a String containing rendered date/time */ String render(NavigableFieldImpl field, FieldLayoutItem fieldLayoutItem, Map displayParams, Issue issue, @Nullable Date date) { // these aren't really used by our templates, but i'm leaving them here in case people have overriden the // templates and are relying on these params. Map<String, Object> legacyVelocityParams = field.getVelocityParams(fieldLayoutItem, authenticationContext.getI18nHelper(), displayParams, issue); // the new templates only use these 3 context values Map<String, Object> dateVelocityParams = Collections.emptyMap(); if (date != null) { DateTimeStyle displayStyle = displayParams.containsKey(EXCEL_VIEW) ? DateTimeStyle.COMPLETE : DateTimeStyle.DATE; dateVelocityParams = new Flat3Map(); dateVelocityParams.put("title", dateTimeFormatter.withStyle(DateTimeStyle.COMPLETE).format(date)); dateVelocityParams.put("iso8601", dateTimeFormatter.withStyle(DateTimeStyle.ISO_8601_DATE_TIME).format(date)); dateVelocityParams.put("value", dateTimeFormatter.withStyle(displayStyle).format(date)); } return field.renderTemplate(displayParams.containsKey(EXCEL_VIEW) ? EXCEL_VIEW_TEMPLATE : ISSUE_NAV_TEMPLATE, CompositeMap.of(legacyVelocityParams, dateVelocityParams)); } }
CompositeMap.of(substitutions, sessionFieldSubstitutionMap.get(orderableField.getId())); sessionFieldSubstitutionMap.put(orderableField.getId(), compositeMap);