Mercurial > public > JIRA
changeset 1:56349dc044f5
Added validators for Time tracking. Validators: Require an estimate
and require no time remaining
author | smith |
---|---|
date | Thu, 22 May 2008 15:45:43 -0400 |
parents | 92d945347fc0 |
children | 4ca1ef5be75e |
files | ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidator.java ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidatorFactory.java ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidator.java ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidatorFactory.java ssdt-jira-plugins-v2/plugins/src/main/resources/atlassian-plugin.xml ssdt-jira-plugins-v2/plugins/src/main/resources/templates/requireestimate-validator-view.vm ssdt-jira-plugins-v2/plugins/src/main/resources/templates/requirenotimeremaining-validator-view.vm ssdt-jira-plugins-v2/plugins/src/test/java/it/IntegrationTestMyPlugin.java ssdt-jira-plugins-v2/plugins/src/test/java/org/nwoca/ssdt/jira/UnitTestMyPlugin.java |
diffstat | 9 files changed, 244 insertions(+), 20 deletions(-) [+] |
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/RequireEstimateValidator.java Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,54 @@ +/* + * 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.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; + +/** + * Validator blocks Fixed resolution. Use for Workflow steps where "fixed" is + *not appropriate. + * + * @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 { + + Issue issue = (Issue) transientVars.get("issue"); + + if (issue.getOriginalEstimate() == null || issue.getOriginalEstimate().equals(0)) { + throw new InvalidInputException("Original Estimate is required at this step"); + } + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireEstimateValidatorFactory.java Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,40 @@ +/* + * RequireDocumentIssueValidatorFactory.java + * + * Created on May 14, 2007, 2:56 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.plugin.workflow.AbstractWorkflowPluginFactory; +import com.atlassian.jira.plugin.workflow.WorkflowPluginValidatorFactory; +import com.opensymphony.workflow.loader.AbstractDescriptor; +import java.util.Map; + +/** + * + * @author SMITH + */ +public class RequireEstimateValidatorFactory extends + AbstractWorkflowPluginFactory implements WorkflowPluginValidatorFactory { + /** Creates a new instance of RequireDocumentIssueValidatorFactory */ + public RequireEstimateValidatorFactory() { + } + + protected void getVelocityParamsForView(Map map, AbstractDescriptor abstractDescriptor) { + } + + protected void getVelocityParamsForInput(Map map) { + } + + protected void getVelocityParamsForEdit(Map map, AbstractDescriptor abstractDescriptor) { + } + + public Map getDescriptorParams(Map map) { + return map; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidator.java Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,89 @@ +/* + * 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.ManagerFactory; +import com.atlassian.jira.issue.CustomFieldManager; +import com.atlassian.jira.issue.Issue; +import com.atlassian.jira.issue.IssueUtils; +import com.atlassian.jira.issue.fields.CustomField; +import com.opensymphony.module.propertyset.PropertySet; +import com.opensymphony.workflow.InvalidInputException; +import com.opensymphony.workflow.Validator; +import com.opensymphony.workflow.WorkflowException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Requires zero time remaining if the issue has Time Tracking. Can use + * during resolve step. + * + * @author SMITH + */ +public class RequireNoTimeRemainingValidator implements Validator { + + private final List<CustomField> cfs = new ArrayList<CustomField>(); + + /** + * Creates a new instance of RequireDocumentIssueValidator. + */ + public RequireNoTimeRemainingValidator() { + CustomFieldManager cfm = ManagerFactory.getCustomFieldManager(); + for (Object obj : cfm.getCustomFieldObjects()) { + CustomField cf = (CustomField) obj; + if (!cf.getName().contains("Message")) { + cfs.add(cf); + System.out.println("Custom Field: " + cf.getName()); + } + + } + + } + + public void validate(Map transientVars, Map args, PropertySet ps) + throws InvalidInputException, WorkflowException { + + Issue issue = (Issue) transientVars.get("issue"); + +// System.out.println("Issue: " + issue.getKey()); +// System.out.println(" OE: " + issue.getOriginalEstimate()); +// System.out.println(" E: " + issue.getEstimate() + "/" +issue.getEstimate() ); +// System.out.println(" TS: " + issue.getTimeSpent()); +// System.out.println(" hasTimeTracking:" + IssueUtils.hasTimeTracking(issue)); +// +// for (CustomField cf : cfs) { +// System.out.println(" CF " + cf.getName() + ": " + issue.getCustomFieldValue(cf)); +// } +// +// { +// Iterator it = transientVars.entrySet().iterator(); +// System.out.println(" Transient: "); +// while (it.hasNext()) { +// Map.Entry e = (Map.Entry) it.next(); +// System.out.println(" " + e.getKey() + ": " + e.getValue()); +// } +// } +// +// { +// Iterator it = args.entrySet().iterator(); +// System.out.println(" Args: "); +// while (it.hasNext()) { +// Map.Entry e = (Map.Entry) it.next(); +// System.out.println(" " + e.getKey() + ": " + e.getValue()); +// } +// } +// +// + if (IssueUtils.hasTimeTracking(issue) && issue.getEstimate().longValue() != 0 ) { + throw new InvalidInputException("There is still Estimated Time Remaining on this issue."); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidatorFactory.java Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,40 @@ +/* + * RequireDocumentIssueValidatorFactory.java + * + * Created on May 14, 2007, 2:56 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.plugin.workflow.AbstractWorkflowPluginFactory; +import com.atlassian.jira.plugin.workflow.WorkflowPluginValidatorFactory; +import com.opensymphony.workflow.loader.AbstractDescriptor; +import java.util.Map; + +/** + * + * @author SMITH + */ +public class RequireNoTimeRemainingValidatorFactory extends + AbstractWorkflowPluginFactory implements WorkflowPluginValidatorFactory { + /** Creates a new instance of RequireDocumentIssueValidatorFactory */ + public RequireNoTimeRemainingValidatorFactory() { + } + + protected void getVelocityParamsForView(Map map, AbstractDescriptor abstractDescriptor) { + } + + protected void getVelocityParamsForInput(Map map) { + } + + protected void getVelocityParamsForEdit(Map map, AbstractDescriptor abstractDescriptor) { + } + + public Map getDescriptorParams(Map map) { + return map; + } + +}
--- a/ssdt-jira-plugins-v2/plugins/src/main/resources/atlassian-plugin.xml Tue May 20 17:11:35 2008 -0400 +++ b/ssdt-jira-plugins-v2/plugins/src/main/resources/atlassian-plugin.xml Thu May 22 15:45:43 2008 -0400 @@ -30,4 +30,23 @@ <resource type="velocity" name="view" location="templates/blockfixed-validator-view.vm"/> </workflow-validator> + + <workflow-validator key="requireestimate-validator" + name="Require Estimate" + class="org.nwoca.ssdt.jira.RequireEstimateValidatorFactory"> + <description>Require Estimate</description> + <validator-class>org.nwoca.ssdt.jira.RequireEstimateValidator</validator-class> + <resource type="velocity" name="view" + location="templates/requireestimate-validator-view.vm"/> + </workflow-validator> + + <workflow-validator key="requirenotimeremaining-validator" + name="Require No Time Remaining" + class="org.nwoca.ssdt.jira.RequireNoTimeRemainingValidatorFactory"> + <description>Require No Time Remaining</description> + <validator-class>org.nwoca.ssdt.jira.RequireNoTimeRemainingValidator</validator-class> + <resource type="velocity" name="view" + location="templates/requirenotimeremaining-validator-view.vm"/> + </workflow-validator> + </atlassian-plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/resources/templates/requireestimate-validator-view.vm Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,1 @@ +Require an Original Estimate at this step. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/resources/templates/requirenotimeremaining-validator-view.vm Thu May 22 15:45:43 2008 -0400 @@ -0,0 +1,1 @@ +Require no Time Remaining at this step. \ No newline at end of file
--- a/ssdt-jira-plugins-v2/plugins/src/test/java/it/IntegrationTestMyPlugin.java Tue May 20 17:11:35 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package it; - -import junit.framework.TestCase; - -public class IntegrationTestMyPlugin extends TestCase -{ - public void testSomething() - { - } -} \ No newline at end of file
--- a/ssdt-jira-plugins-v2/plugins/src/test/java/org/nwoca/ssdt/jira/UnitTestMyPlugin.java Tue May 20 17:11:35 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package org.nwoca.ssdt.jira; - -import junit.framework.TestCase; - -public class UnitTestMyPlugin extends TestCase -{ - public void testSomething() - { - } -} \ No newline at end of file