@Override public Map<String, String> get() { return descriptor.getMetaAttributes(); }
/** * Get the translated description of the workflow transition. * * @param descriptor The action descriptor to get the description of * @return the translated description of the workflow transition. */ public static String getWorkflowTransitionDescription(final ActionDescriptor descriptor) { return (String) descriptor.getMetaAttributes().get("jira.description"); }
private Map<String, String> getMetaAttributes(ActionDescriptor actionDescriptor) { @SuppressWarnings ("unchecked") final Map<String, String> metaAttributes = actionDescriptor.getMetaAttributes(); return metaAttributes == null ? Collections.<String, String>emptyMap() : metaAttributes; }
public void visit(final JiraWorkflow workflow, final ActionDescriptor actionDescriptor, final Set<JiraWorkflow> workflowsToSave) { final String command = (String) actionDescriptor.getMetaAttributes().get( WorkflowHandler.COMMIT_COMMAND_MAPPING); if (command != null) { commands.add(command.toLowerCase()); } } });
public String isNameI8n() { ActionDescriptor transition = getTransition(); return (String) transition.getMetaAttributes().get(JiraWorkflow.JIRA_META_ATTRIBUTE_I18N); }
private Integer getSequenceFromAction(final ActionDescriptor action) { if (action == null) { return Integer.MAX_VALUE; } final Map metaAttributes = action.getMetaAttributes(); if (metaAttributes == null) { return Integer.MAX_VALUE; } final String value = (String) metaAttributes.get("opsbar-sequence"); if (value == null || StringUtils.isBlank(value) || !StringUtils.isNumeric(value)) { return Integer.MAX_VALUE; } return Integer.valueOf(value); }
@Override public Set<String> getClassnamesForScreenFromAction(ActionDescriptor action) { Set<String> classNames = new HashSet<String>(); if(FIELDSCREEN_VIEW.equals(action.getView()) && action.getMetaAttributes().containsKey(WorkflowScreensHelper.FIELDSCREEN_ID_NAME)) { String screenId = (String) action.getMetaAttributes().get(FIELDSCREEN_ID_NAME); classNames.addAll(getClassnamesForScreen(screenId)); } return classNames; }
@Override public void updateWorkflowScreenIds(ConfigurableJiraWorkflow jiraWorkflow, Map<Long, Long> oldToNewIdMapping) { Collection<ActionDescriptor> allActions = jiraWorkflow.getAllActions(); for (ActionDescriptor action : allActions) { if(FIELDSCREEN_VIEW.equals(action.getView()) && action.getMetaAttributes().containsKey(FIELDSCREEN_ID_NAME)) { String screenId = (String) action.getMetaAttributes().get(FIELDSCREEN_ID_NAME); if(StringUtils.isNumeric(screenId)) { Long oldScreenId = Long.parseLong(screenId); if(oldToNewIdMapping.containsKey(oldScreenId)) { action.getMetaAttributes().put(FIELDSCREEN_ID_NAME,Long.toString(oldToNewIdMapping.get(oldScreenId))); } } } } }
/** * Sets the view and screen for the given action. * * @param actionDescriptor Action who's screen to set. * @param screen Screen to be set for the action. Null indicates no screen. */ @SuppressWarnings("unchecked") public static void setActionScreen(@Nonnull ActionDescriptor actionDescriptor, @Nullable FieldScreen screen) { if (screen == null) { actionDescriptor.setView(null); actionDescriptor.getMetaAttributes().put(ACTION_SCREEN_ATTRIBUTE, null); } else { actionDescriptor.setView(VIEW_SCREEN); actionDescriptor.getMetaAttributes().put(ACTION_SCREEN_ATTRIBUTE, screen.getId().toString()); } } }
public String getI18nTextViaMetaAttr(String key, Object defaultValue) { final Object i18nKey = getActionDescriptor().getMetaAttributes().get(key); String localizedString; if ((i18nKey != null) && (i18nKey instanceof String)) { localizedString = getText((String) i18nKey); if (!i18nKey.equals(localizedString)) { return localizedString; } else { log.warn("The i18n key"+ i18nKey +" in property '"+key +"' for this transition does not contain a valid i18n key."); } } return defaultValue == null ? "" : defaultValue.toString(); }
Collection<String> getIncludeResolutionIds(OperationContext operationContext, String resolutionType) { if (operationContext != null && (operationContext.getIssueOperation() instanceof WorkflowIssueOperation)) { WorkflowIssueOperation issueOperation = (WorkflowIssueOperation) operationContext.getIssueOperation(); // Retrieve the ids of resolutions to exclude on this transition. The ids are stored as meta attributes // on the transition in the workflow. ActionDescriptor wfAction = issueOperation.getActionDescriptor(); if (wfAction != null) { Map metaAttributes = wfAction.getMetaAttributes(); String resolutionIdString = (String) metaAttributes.get(resolutionType); if (!StringUtils.isBlank(resolutionIdString)) { // If the meta attribute is set and is not empty retrieve the ids of resolutions to exclude String[] resolutionIds = StringUtils.split(resolutionIdString, ","); if (resolutionIds != null) { return Arrays.asList(resolutionIds); } } } } return Collections.EMPTY_LIST; }
@Override public String[] getCustomFieldIdsForWorkflowScreens(JiraWorkflow workflow) { Set<String> ids = new HashSet<String>(); Collection<ActionDescriptor> allActions = workflow.getAllActions(); for (ActionDescriptor action : allActions) { if(FIELDSCREEN_VIEW.equals(action.getView()) && action.getMetaAttributes().containsKey(FIELDSCREEN_ID_NAME)) { String screenId = (String) action.getMetaAttributes().get(FIELDSCREEN_ID_NAME); if(StringUtils.isNumeric(screenId)) { FieldScreen screen = fieldScreenManager.getFieldScreen(Long.parseLong(screenId)); for(FieldScreenTab tab : screen.getTabs()) { List<FieldScreenLayoutItem> items = tab.getFieldScreenLayoutItems(); for(FieldScreenLayoutItem item : items) { ids.add(item.getFieldId()); } } } } } return ids.toArray(new String[0]); }
public void visit(final JiraWorkflow workflow, final ActionDescriptor actionDescriptor, final Set<JiraWorkflow> workflowsToSave) { final String c = (String) actionDescriptor.getMetaAttributes().get( WorkflowHandler.COMMIT_COMMAND_MAPPING); if (c != null && lowerCaseCommand.equals(c.toLowerCase())) { transitions.add(new WorkflowTransition(workflow.getName(), workflow.isDraftWorkflow(), actionDescriptor.getId(), actionDescriptor.getName(), workflow.isSystemWorkflow())); } } });
public String getTransitionName(final String workflowName, final String actionDescriptorId) { final JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(workflowName); final ActionDescriptor descriptor = workflow.getDescriptor().getAction(Integer.parseInt(actionDescriptorId)); @SuppressWarnings ("unchecked") final Map<String, String> metadata = descriptor.getMetaAttributes(); if (metadata.containsKey(JiraWorkflow.JIRA_META_ATTRIBUTE_EDIT_ALLOWED)) { final String key = metadata.get(JiraWorkflow.JIRA_META_ATTRIBUTE_EDIT_ALLOWED); final I18nBean i18nBean = new I18nBean(); final String value = i18nBean.getText(key); if ((value != null) && !"".equals(value.trim()) && !value.trim().equals(key.trim())) { return value; } } return descriptor.getName(); }
/** * Get the translated display name of a workflow transition. * * @param descriptor The action descriptor to get the name of * @return The name of the transition. */ public static String getWorkflowTransitionDisplayName(final ActionDescriptor descriptor) { if(descriptor == null) { return getI18nBean().getText("common.words.unknown"); } final Map<String, Object> metadata = descriptor.getMetaAttributes(); if (metadata.containsKey(JiraWorkflow.JIRA_META_ATTRIBUTE_I18N)) { final String key = (String) metadata.get(JiraWorkflow.JIRA_META_ATTRIBUTE_I18N); final String value = getI18nBean().getText(key); if ((value != null) && !"".equals(value.trim()) && !value.trim().equals(key.trim())) { return value; } } return descriptor.getName(); }
@SuppressWarnings({"unchecked"}) private Map<String, String> getResolutions(ActionDescriptor actionDescriptor) { // We need to exclude any resolutions that are excluded from this transition String excludeIds = (String) actionDescriptor.getMetaAttributes().get( JiraWorkflow.JIRA_META_ATTRIBUTE_EXCLUDE_RESOLUTION); Collection<String> excludedSet = new HashSet<String>(); if (TextUtils.stringSet(excludeIds)) { // If the meta attribute is set and is not empty retrieve the ids of resolutions to exclude String[] resolutionIds = StringUtils.split(excludeIds, ","); if (resolutionIds != null) { excludedSet.addAll(Arrays.asList(resolutionIds)); } } Map<String, String> results = new HashMap<String, String>(); Collection<Resolution> resolutions = constantsManager.getResolutionObjects(); for (Resolution resolution : resolutions) { if (!excludedSet.contains(resolution.getId())) { results.put(resolution.getNameTranslation(), resolution.getId()); } } return results; }
public String doDefault() throws Exception { setTransitionName(action.getName()); setDescription((String) action.getMetaAttributes().get(JiraWorkflow.WORKFLOW_DESCRIPTION_ATTRIBUTE)); setDestinationStep(action.getUnconditionalResult().getStep()); FieldScreen fieldScreen = workflowActionsBean.getFieldScreenForView(action); setView(fieldScreen != null ? fieldScreen.getId().toString() : ""); return super.doDefault(); }
/** * Returns <meta> attributes of the initial "create issue" workflow action. */ private Map getWorkflowMetaAttributes() throws WorkflowException { JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(getPid(), getIssuetype()); return workflow.getDescriptor().getInitialAction(1).getMetaAttributes(); }
@RequiresXsrfCheck protected String doExecute() throws Exception { // setup the transition action action.setName(getTransitionName()); action.getMetaAttributes().put(JiraWorkflow.WORKFLOW_DESCRIPTION_ATTRIBUTE, getDescription()); setActionScreen(action, stringSet(getView()) ? getFieldScreen() : null); // setup the destination step result ResultDescriptor result = action.getUnconditionalResult(); result.setStep(getDestinationStep()); workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); return getRedirect(getCancelUrl()); }
@RequiresXsrfCheck protected String doExecute() throws Exception { // setup the transition action ActionDescriptor action = DescriptorFactory.getFactory().createActionDescriptor(); action.setId(getWorkflow().getNextActionId()); action.setName(getTransitionName()); action.getMetaAttributes().put(JiraWorkflow.WORKFLOW_DESCRIPTION_ATTRIBUTE, getDescription()); setActionScreen(action, stringSet(getView()) ? getFieldScreen() : null); // setup the result ResultDescriptor result = DescriptorFactory.getFactory().createResultDescriptor(); action.setUnconditionalResult(result); result.setStep(getDestinationStep()); result.setOldStatus("Not Done"); result.setStatus("Done"); initialiseTransition(action); action.setParent(getStep()); getStep().getActions().add(action); workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); return getRedirect(getCancelUrl()); }