public void updateSchemesForRenamedWorkflow(final String oldWorkflowName, final String newWorkflowName) { if (StringUtils.isBlank(oldWorkflowName)) { throw new IllegalArgumentException("oldWorkflowName must not be null or empty string"); } if (StringUtils.isBlank(newWorkflowName)) { throw new IllegalArgumentException("newWorkflowName must not be null or empty string"); } //TODO: Will have to fix this for workflow schemes. ofBizDelegator.bulkUpdateByAnd(getEntityName(), ImmutableMap.of(COLUMN_WORKFLOW, newWorkflowName), ImmutableMap.of(COLUMN_WORKFLOW, oldWorkflowName)); draftWorkflowSchemeStore.renameWorkflow(oldWorkflowName, newWorkflowName); clearWorkflowCache(); }
public Collection<GenericValue> getSchemesForWorkflow(final JiraWorkflow workflow) { // TODO This does not cater for default workflow which is used by schemes with no default for all issue types and // by projects that do not have a workflow shceme assigned final Collection<GenericValue> schemes = new LinkedList<GenericValue>(); final Set<Long> schemeIds = new HashSet<Long>(); // Find all scheme entities with the workflow name final List<GenericValue> schemeEntities = ofBizDelegator.findByAnd(getEntityName(), MapBuilder.build(COLUMN_WORKFLOW, workflow.getName())); // Loop through all the entities and retrieve the scheme ids for (final GenericValue schemeEntity : schemeEntities) { final Long schemeId = schemeEntity.getLong("scheme"); // Only retrieve schemes that we have not retrieved already if (!schemeIds.contains(schemeId)) { schemes.add(getScheme(schemeId)); schemeIds.add(schemeId); } } return schemes; }
public GenericValue createSchemeEntity(long schemeId, final SchemeEntity schemeEntity) throws GenericEntityException { if (!(schemeEntity.getEntityTypeId() instanceof String)) { throw new IllegalArgumentException("Workflow scheme IDs must be String values."); } try { return EntityUtils.createValue(getEntityName(), FieldMap.build("scheme", schemeId, COLUMN_WORKFLOW, schemeEntity.getType(), COLUMN_ISSUETYPE, schemeEntity.getEntityTypeId().toString())); } finally { clearWorkflowSchemeEntityCache(); } }