Mercurial > public > JIRA
comparison ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidator.java @ 3:e90b3c5c8df3 tip
Improve validator if work has already been logged.
author | smith |
---|---|
date | Fri, 20 Jun 2008 12:23:06 -0400 |
parents | 56349dc044f5 |
children |
comparison
equal
deleted
inserted
replaced
2:4ca1ef5be75e | 3:e90b3c5c8df3 |
---|---|
4 * Created on May 14, 2007, 1:04 PM | 4 * Created on May 14, 2007, 1:04 PM |
5 * | 5 * |
6 * To change this template, choose Tools | Template Manager | 6 * To change this template, choose Tools | Template Manager |
7 * and open the template in the editor. | 7 * and open the template in the editor. |
8 */ | 8 */ |
9 | |
10 package org.nwoca.ssdt.jira; | 9 package org.nwoca.ssdt.jira; |
11 | 10 |
12 import com.atlassian.jira.ComponentManager; | |
13 import com.atlassian.jira.ManagerFactory; | |
14 import com.atlassian.jira.issue.Issue; | 11 import com.atlassian.jira.issue.Issue; |
15 import com.atlassian.jira.issue.MutableIssue; | |
16 import com.atlassian.jira.issue.fields.CustomField; | |
17 import com.atlassian.jira.issue.link.IssueLink; | |
18 import com.atlassian.jira.issue.link.IssueLinkManager; | |
19 import com.atlassian.jira.workflow.WorkflowActionsBean; | |
20 import com.opensymphony.module.propertyset.PropertySet; | 12 import com.opensymphony.module.propertyset.PropertySet; |
21 import com.opensymphony.workflow.InvalidInputException; | 13 import com.opensymphony.workflow.InvalidInputException; |
22 import com.opensymphony.workflow.Validator; | 14 import com.opensymphony.workflow.Validator; |
23 import com.opensymphony.workflow.WorkflowException; | 15 import com.opensymphony.workflow.WorkflowException; |
24 import java.util.Collection; | |
25 import java.util.List; | |
26 import java.util.Map; | 16 import java.util.Map; |
27 | 17 |
28 /** | 18 /** |
29 * Validator blocks Fixed resolution. Use for Workflow steps where "fixed" is | 19 * Validator blocks Fixed resolution. Use for Workflow steps where "fixed" is |
30 *not appropriate. | 20 *not appropriate. |
31 * | 21 * |
32 * @author SMITH | 22 * @author SMITH |
33 */ | 23 */ |
34 public class RequireEstimateValidator implements Validator { | 24 public class RequireEstimateValidator implements Validator { |
35 | 25 |
36 | |
37 /** | 26 /** |
38 * Creates a new instance of RequireDocumentIssueValidator. | 27 * Creates a new instance of RequireDocumentIssueValidator. |
39 */ | 28 */ |
40 public RequireEstimateValidator() { | 29 public RequireEstimateValidator() { |
41 } | 30 } |
42 | 31 |
43 public void validate(Map transientVars, Map args, PropertySet ps) | 32 public void validate(Map transientVars, Map args, PropertySet ps) |
44 throws InvalidInputException, WorkflowException { | 33 throws InvalidInputException, WorkflowException { |
45 | 34 |
46 Issue issue = (Issue) transientVars.get("issue"); | 35 Issue issue = (Issue) transientVars.get("issue"); |
47 | 36 |
48 if (issue.getOriginalEstimate() == null || issue.getOriginalEstimate().equals(0)) { | 37 if (isZero(issue.getTimeSpent())) { |
49 throw new InvalidInputException("Original Estimate is required at this step"); | 38 if (isZero(issue.getOriginalEstimate())) { |
39 throw new InvalidInputException("Original Estimate is required at this step"); | |
40 } | |
41 } else if (isZero(issue.getEstimate())) { | |
42 throw new InvalidInputException("Remaining Estimate is required at this step"); | |
43 | |
50 } | 44 } |
51 | |
52 } | 45 } |
53 | 46 |
47 private boolean isZero(Long value) { | |
48 return value == null || value.longValue() == 0; | |
49 } | |
54 } | 50 } |