Mercurial > public > JIRA
changeset 3:e90b3c5c8df3 tip
Improve validator if work has already been logged.
author | smith |
---|---|
date | Fri, 20 Jun 2008 12:23:06 -0400 |
parents | 4ca1ef5be75e |
children | |
files | ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidator.java |
diffstat | 1 files changed, 16 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidator.java Fri May 23 18:06:10 2008 -0400 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidator.java Fri Jun 20 12:23:06 2008 -0400 @@ -6,23 +6,13 @@ * To change this template, choose Tools | Template Manager * and open the template in the editor. */ - package org.nwoca.ssdt.jira; -import com.atlassian.jira.ComponentManager; -import com.atlassian.jira.ManagerFactory; import com.atlassian.jira.issue.Issue; -import com.atlassian.jira.issue.MutableIssue; -import com.atlassian.jira.issue.fields.CustomField; -import com.atlassian.jira.issue.link.IssueLink; -import com.atlassian.jira.issue.link.IssueLinkManager; -import com.atlassian.jira.workflow.WorkflowActionsBean; import com.opensymphony.module.propertyset.PropertySet; import com.opensymphony.workflow.InvalidInputException; import com.opensymphony.workflow.Validator; import com.opensymphony.workflow.WorkflowException; -import java.util.Collection; -import java.util.List; import java.util.Map; /** @@ -32,23 +22,29 @@ * @author SMITH */ public class RequireEstimateValidator implements Validator { - - + /** * Creates a new instance of RequireDocumentIssueValidator. */ public RequireEstimateValidator() { } - + public void validate(Map transientVars, Map args, PropertySet ps) - throws InvalidInputException, WorkflowException { - + throws InvalidInputException, WorkflowException { + Issue issue = (Issue) transientVars.get("issue"); - - if (issue.getOriginalEstimate() == null || issue.getOriginalEstimate().equals(0)) { - throw new InvalidInputException("Original Estimate is required at this step"); + + if (isZero(issue.getTimeSpent())) { + if (isZero(issue.getOriginalEstimate())) { + throw new InvalidInputException("Original Estimate is required at this step"); + } + } else if (isZero(issue.getEstimate())) { + throw new InvalidInputException("Remaining Estimate is required at this step"); + } - } - + + private boolean isZero(Long value) { + return value == null || value.longValue() == 0; + } }