Mercurial > public > JIRA
changeset 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 | 56349dc044f5 |
children | e90b3c5c8df3 |
files | 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/RequireTimeSpentValidator.java ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireTimeSpentValidatorFactory.java ssdt-jira-plugins-v2/plugins/src/main/resources/atlassian-plugin.xml ssdt-jira-plugins-v2/plugins/src/main/resources/templates/requiretimespent-validator-view.vm |
diffstat | 5 files changed, 104 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidator.java Thu May 22 15:45:43 2008 -0400 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireNoTimeRemainingValidator.java Fri May 23 18:06:10 2008 -0400 @@ -8,17 +8,12 @@ */ 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; /** @@ -29,21 +24,21 @@ */ public class RequireNoTimeRemainingValidator implements Validator { - private final List<CustomField> cfs = new ArrayList<CustomField>(); +// 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()); - } - - } +// 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()); +// } +// +// } }
--- /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."); + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireTimeSpentValidatorFactory.java Fri May 23 18:06:10 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 RequireTimeSpentValidatorFactory extends + AbstractWorkflowPluginFactory implements WorkflowPluginValidatorFactory { + /** Creates a new instance of RequireDocumentIssueValidatorFactory */ + public RequireTimeSpentValidatorFactory() { + } + + 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 Thu May 22 15:45:43 2008 -0400 +++ b/ssdt-jira-plugins-v2/plugins/src/main/resources/atlassian-plugin.xml Fri May 23 18:06:10 2008 -0400 @@ -46,7 +46,16 @@ <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"/> + location="templates/requirenotimeremaining-validator-view.vm"/> + </workflow-validator> + + <workflow-validator key="requiretimespent-validator" + name="Require Time Spent" + class="org.nwoca.ssdt.jira.RequireTimeSpentValidatorFactory"> + <description>Require Time Spent</description> + <validator-class>org.nwoca.ssdt.jira.RequireTimeSpentValidator</validator-class> + <resource type="velocity" name="view" + location="templates/requiretimespent-validator-view.vm"/> </workflow-validator> </atlassian-plugin>