diff ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireTimeSpentValidator.java @ 2:4ca1ef5be75e

Added validators for Time tracking. New validator to require Time Spent.
author smith
date Fri, 23 May 2008 18:06:10 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireTimeSpentValidator.java	Fri May 23 18:06:10 2008 -0400
@@ -0,0 +1,43 @@
+/*
+ * RequireDocumentIssueValidator.java
+ *
+ * Created on May 14, 2007, 1:04 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+package org.nwoca.ssdt.jira;
+
+import com.atlassian.jira.issue.Issue;
+import com.atlassian.jira.issue.IssueUtils;
+import com.opensymphony.module.propertyset.PropertySet;
+import com.opensymphony.workflow.InvalidInputException;
+import com.opensymphony.workflow.Validator;
+import com.opensymphony.workflow.WorkflowException;
+import java.util.Map;
+
+/**
+ * Requires zero time remaining if the issue has Time Tracking.  Can use
+ * during resolve step.
+ *
+ * @author SMITH
+ */
+public class RequireTimeSpentValidator implements Validator {
+
+    /**
+     * Creates a new instance of RequireDocumentIssueValidator.
+     */
+    public RequireTimeSpentValidator() {
+    }
+
+    public void validate(Map transientVars, Map args, PropertySet ps)
+            throws InvalidInputException, WorkflowException {
+
+        Issue issue = (Issue) transientVars.get("issue");
+
+        if (IssueUtils.hasTimeTracking(issue) && (issue.getTimeSpent() == null || issue.getTimeSpent().longValue() == 0)) {
+            throw new InvalidInputException("There is has been no Time Spent on this issue. Please update work log.");
+        }
+
+    }
+}