/** Creates some attachments and assigns them to the test workflow. */ @Test public void testAttachments() { final PK workflowPk = testWorkflow.getPK(); // create product attachment final Product product = jaloSession.getProductManager().createProduct("sabbers"); assertNotNull("Product not null", product); Map<String, Object> map = new HashMap<String, Object>(); map.put(WorkflowItemAttachment.CODE, "productTest"); map.put(WorkflowItemAttachment.ITEM, product); map.put(WorkflowItemAttachment.WORKFLOW, testWorkflow); final WorkflowItemAttachment attachProduct = WorkflowManager.getInstance().createWorkflowItemAttachment(map); assertNotNull("Attachment not null", attachProduct); // create category attachment final Category category = CategoryManager.getInstance().createCategory(PK.createUUIDPK(0).getHex()); assertNotNull("Category not null", category); map = new HashMap<String, Object>(); map.put(WorkflowItemAttachment.CODE, "categoryTest"); map.put(WorkflowItemAttachment.ITEM, category); map.put(WorkflowItemAttachment.WORKFLOW, testWorkflow); final WorkflowItemAttachment attachCategory = WorkflowManager.getInstance().createWorkflowItemAttachment(map); assertNotNull("Attachment not null", attachCategory); final WorkflowAction action1 = getAction(ACTIONCODES.ACTION1.name()); action1.setAttachments( Arrays.asList(new WorkflowItemAttachment[] {attachProduct, attachCategory})); // restart Registry.getCurrentTenant().getCache(); // check attachments final Workflow found = JaloSession.getCurrentSession().getItem(workflowPk); assertEquals("Excpected number of attachments", 2, found.getAttachments().size()); final WorkflowAction foundAction = getAction(ACTIONCODES.ACTION1.name()); assertEquals( "Excpected number of attachments of action 1", 2, foundAction.getAttachments().size()); }
public void ensureEvaluated(WorkingSet workingSet) throws WorkflowManagerException { final Collection<Assessment> assessments = WorkflowManager.getAllAssessments(session, workingSet); Debug.println("Ensuring evaluation on " + assessments.size() + " assessments..."); final String table = "RedListEvaluated"; final Collection<String> failedSpecies = new ArrayList<String>(); for (Assessment data : assessments) { // final String uid = data.getAssessmentID() + "_" + AssessmentType.DRAFT_ASSESSMENT_TYPE; final String uid = "" + data.getId(); final SelectQuery query = new SelectQuery(); query.select(table, "asm_id"); query.constrain( new CanonicalColumnName(table, "is_evaluated"), QConstraint.CT_EQUALS, "true"); query.constrain( QConstraint.CG_AND, new CanonicalColumnName(table, "approval_status"), QConstraint.CT_EQUALS, Integer.valueOf(1)); query.constrain( QConstraint.CG_AND, new CanonicalColumnName(table, "uid"), QConstraint.CT_EQUALS, uid); final Row.Loader rl = new Row.Loader(); try { ec.doQuery(query, rl); } catch (DBException e) { failedSpecies.add(data.getSpeciesName()); continue; } if (rl.getRow() == null) failedSpecies.add(data.getSpeciesName()); } if (!failedSpecies.isEmpty()) { final StringBuilder builder = new StringBuilder(); builder.append("The following species have not yet been marked as evaluted: "); for (Iterator<String> iter = failedSpecies.iterator(); iter.hasNext(); ) builder.append(iter.next() + (iter.hasNext() ? ", " : "")); throw new WorkflowManagerException(builder.toString()); } }
public ActionDescriptor getActionDescriptor() { if (actionDescriptor == null) { try { actionDescriptor = workflowManager.getWorkflow(getIssue()).getDescriptor().getAction(actionId); } catch (WorkflowException e) { throw new IllegalArgumentException( "Cannot find workflow transition with id '" + actionId + "'."); } } if (actionDescriptor == null) throw new IllegalArgumentException( "No workflow action with id '" + actionId + "' available for issue " + getIssue().getKey()); return actionDescriptor; }
public ErrorCollection progress() { // Only update issue if transition has a screen if (hasScreen()) { for (FieldScreenRenderTab fieldScreenRenderTab : getFieldScreenRenderer().getFieldScreenRenderTabs()) { for (FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem : fieldScreenRenderTab.getFieldScreenRenderLayoutItemsForProcessing()) { if (fieldScreenRenderLayoutItem.isShow(getIssue())) { fieldScreenRenderLayoutItem .getOrderableField() .updateIssue(fieldScreenRenderLayoutItem.getFieldLayoutItem(), getIssue(), params); } } } } workflowManager.doWorkflowAction(this); return errorCollection; }