WorkflowDescriptor convertXMLtoWorkflowDescriptor(final String parentWorkflowXML) throws FactoryException { return WorkflowUtil.convertXMLtoWorkflowDescriptor(parentWorkflowXML); }
WorkflowDescriptor convertXMLtoWorkflowDescriptor(String parentWorkflowXML) throws FactoryException { return WorkflowUtil.convertXMLtoWorkflowDescriptor(parentWorkflowXML); }
WorkflowDescriptor cloneDescriptor(WorkflowDescriptor workflowDescriptor) throws FactoryException { return WorkflowUtil.convertXMLtoWorkflowDescriptor(WorkflowUtil.convertDescriptorToXML(workflowDescriptor)); }
WorkflowDescriptor convertGVToDescriptor(final GenericValue gv) throws FactoryException { WorkflowDescriptor descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(gv.getString(DESCRIPTOR_ENTITY_FIELD)); descriptor.setEntityId(gv.getLong("id").intValue()); return descriptor; } }
private ImportableJiraWorkflow getJiraWorkflowFromPlan(SharedWorkflowImportPlan plan) throws Exception { ImportableJiraWorkflow jiraWorkflow; try { String xml = FileUtils.readFileToString(plan.getWorkflowXml()); WorkflowDescriptor descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(xml); jiraWorkflow = new ImportableJiraWorkflow(plan.getWorkflowName(), descriptor, workflowManager); } catch (Exception e) { throw new Exception(i18n.getText("wfshare.exception.unable.to.create.workflow.descriptor"), e); } return jiraWorkflow; }
public JiraWorkflow getDraftWorkflow(String parentWorkflowName) throws DataAccessException { final GenericValue draftWorkflowGV = getDraftWorkflowGV(parentWorkflowName); if (draftWorkflowGV == null) { return null; } final WorkflowDescriptor workflowDescriptor; try { workflowDescriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(draftWorkflowGV.getString(DESCRIPTOR_ENTITY_FIELD)); } catch (FactoryException e) { throw new RuntimeException(e); } return new JiraDraftWorkflow(parentWorkflowName, getWorkflowManager(), workflowDescriptor); }
private String createClassicWorkflow() throws FactoryException, IOException { WorkflowDescriptor descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(defaultClassicXml()); String workflowName = uniqueWorkflowName(); descriptor.getMetaAttributes().put("jira.description", workflowDescription()); // Using the store instead of talking directly to the db because we need the store to put it in its cache. descriptorStore.saveWorkflow(workflowName, descriptor, false); // Add information about the visual layout of the workflow, so it doesn't appear all jumbled. Long layoutEntryKey = ofBizDelegator.createValue("OSPropertyEntry", ImmutableMap.<String, Object>of("entityName", "com.atlassian.jira.plugins.jira-workflow-designer", "entityId", 1, "propertyKey", layoutKey(workflowName), "type", 6)).getLong("id"); ofBizDelegator.createValue("OSPropertyText", ImmutableMap.<String, Object>of("id", layoutEntryKey, "value", defaultLayoutJson())); return workflowName; }
@Override public Map<String,StatusMapping> getStatusHolders(File xmlFile) throws Exception { Collection<Status> jiraStatuses = constantsManager.getStatusObjects(); Map<String,StatusMapping> holders = new HashMap<String, StatusMapping>(); String xml = FileUtils.readFileToString(xmlFile); WorkflowDescriptor descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(xml); List<StepDescriptor> steps = descriptor.getSteps(); for(StepDescriptor step : steps) { if ((step.getMetaAttributes() != null) && step.getMetaAttributes().containsKey(JiraWorkflow.STEP_STATUS_KEY)) { String statusId = (String) step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY); try { Status found = Iterables.find(jiraStatuses,new StatusNamePredicate(step.getName())); holders.put(statusId,new StatusMapping(statusId,step.getName(),found.getId(),getSuggestedName(jiraStatuses,found.getName()))); } catch (NoSuchElementException e) { holders.put(statusId, new StatusMapping(statusId, step.getName(), "-1", step.getName())); } } } return holders; }
.convertXMLtoWorkflowDescriptor(draftWorkflowGV.getString(DESCRIPTOR_ENTITY_FIELD));
private void updateWorkflow(GenericValue workflow, String entityName) { final WorkflowDescriptor descriptor; try { descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(workflow.getString(DESCRIPTOR_ENTITY_FIELD)); } catch (FactoryException fe) { log.error("Unable to update username references in corrupted workflow: " + fe); return; } convertAuthorUsernameToUserKey(descriptor); convertAssigneeFieldValueToUserKey(descriptor); String postConversionDescriptor = WorkflowUtil.convertDescriptorToXML(descriptor); final Update.WhereContext query = Update.into(entityName) .set(DESCRIPTOR_ENTITY_FIELD, postConversionDescriptor) .whereIdEquals(workflow.getLong("id")); entityEngine.execute(query); }