Mercurial > public > JIRA
annotate ssdt-jira-plugins-v2/plugins/src/main/java/org/nwoca/ssdt/jira/RequireDocumentIssueValidator.java @ 0:92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
for JIRA 3.12.
author | smith |
---|---|
date | Tue, 20 May 2008 17:11:35 -0400 |
parents | |
children |
rev | line source |
---|---|
0
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
1 /* |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
2 * RequireDocumentIssueValidator.java |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
3 * |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
4 * Created on May 14, 2007, 1:04 PM |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
5 * |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
6 * To change this template, choose Tools | Template Manager |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
7 * and open the template in the editor. |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
8 */ |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
9 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
10 package org.nwoca.ssdt.jira; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
11 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
12 import com.atlassian.jira.ComponentManager; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
13 import com.atlassian.jira.ManagerFactory; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
14 import com.atlassian.jira.issue.Issue; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
15 import com.atlassian.jira.issue.MutableIssue; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
16 import com.atlassian.jira.issue.fields.CustomField; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
17 import com.atlassian.jira.issue.link.IssueLink; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
18 import com.atlassian.jira.issue.link.IssueLinkManager; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
19 import com.atlassian.jira.workflow.WorkflowActionsBean; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
20 import com.opensymphony.module.propertyset.PropertySet; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
21 import com.opensymphony.workflow.InvalidInputException; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
22 import com.opensymphony.workflow.Validator; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
23 import com.opensymphony.workflow.WorkflowException; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
24 import java.util.Collection; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
25 import java.util.List; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
26 import java.util.Map; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
27 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
28 /** |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
29 * Validator requires to an issue type of "Document" or a sub-task of type "Document". |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
30 * |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
31 * These are custom issue types used by the SSDT. |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
32 * |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
33 * @author SMITH |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
34 */ |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
35 public class RequireDocumentIssueValidator implements Validator { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
36 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
37 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
38 /** |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
39 * Creates a new instance of RequireDocumentIssueValidator |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
40 */ |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
41 public RequireDocumentIssueValidator() { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
42 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
43 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
44 public void validate(Map transientVars, Map args, PropertySet ps) |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
45 throws InvalidInputException, WorkflowException { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
46 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
47 Issue issue = (Issue) transientVars.get("issue"); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
48 CustomField docRequiredField = ManagerFactory.getCustomFieldManager() |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
49 .getCustomFieldObjectByName("Documentation Required"); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
50 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
51 if (docRequiredField == null) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
52 return; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
53 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
54 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
55 String docRequired = (String)issue.getCustomFieldValue(docRequiredField); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
56 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
57 if (docRequired == null || docRequired.startsWith("No")) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
58 return; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
59 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
60 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
61 if (docRequired.startsWith("Yes")) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
62 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
63 Collection subtasks = issue.getSubTaskObjects(); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
64 for (Object o : subtasks) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
65 MutableIssue subt = (MutableIssue)o; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
66 if (subt.getIssueTypeObject().getName().equals("Document Subtask")) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
67 return; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
68 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
69 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
70 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
71 IssueLinkManager lm = ComponentManager.getInstance().getIssueLinkManager(); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
72 List links = lm.getOutwardLinks(issue.getId()); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
73 for (Object o : links) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
74 IssueLink link = (IssueLink)o; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
75 if (link.getIssueLinkType().getName().equals("Documention") ) { |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
76 return; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
77 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
78 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
79 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
80 throw new InvalidInputException("Issue requiring documentation must have " |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
81 + "at least one 'Document' Subtask or a 'Documention' link." ); |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
82 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
83 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
84 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
85 return; |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
86 } |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
87 |
92d945347fc0
V2 of the SSDT JIRA Plugins. Uses new Maven 2 based project. Created
smith
parents:
diff
changeset
|
88 } |