Created
January 27, 2012 18:28
-
-
Save jechlin/1690170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.onresolve.jira.groovy.canned.admin | |
import com.onresolve.jira.groovy.canned.CannedScript | |
import org.apache.log4j.Category | |
import com.atlassian.jira.util.ErrorCollection | |
import com.onresolve.jira.groovy.canned.utils.CannedScriptUtils | |
import com.atlassian.jira.ComponentManager | |
import com.atlassian.jira.issue.search.SearchProvider | |
import com.atlassian.jira.jql.builder.JqlQueryBuilder | |
import com.atlassian.jira.issue.search.SearchRequest | |
import com.atlassian.jira.issue.search.SearchResults | |
import com.atlassian.jira.web.bean.PagerFilter | |
import com.atlassian.jira.issue.Issue | |
class ExampleBuiltinScript implements CannedScript{ | |
public static String FIELD_PROJECT = "FIELD_PROJECT" | |
private static final Category log = Category.getInstance(ExampleBuiltinScript.class) | |
String getName() { | |
"Example script" | |
} | |
String getDescription() { | |
"Script for messing around with" | |
} | |
List getCategories() { | |
["ADMIN"] | |
} | |
List getParameters(Map params) { | |
[ | |
[ | |
Name:FIELD_PROJECT, | |
Label:"Project", | |
Description:"A useful parameter description", | |
Type:"list", | |
Values: CannedScriptUtils.getProjectOptions(true), | |
], | |
] | |
} | |
ErrorCollection doValidate(Map params, boolean forPreview) { | |
null | |
} | |
Map doScript(Map params) { | |
// Script goes here | |
def componentManager = ComponentManager.getInstance() | |
SearchProvider searchProvider = componentManager.getSearchProvider() | |
def customFieldManager = componentManager.getCustomFieldManager() | |
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder() | |
def cf = customFieldManager.getCustomFieldObjectByName("TextFieldA") | |
// enter additional terms here to be more selective on what you want to filter on | |
def query = builder.where().issueTypeIsSubtask().and().not().resolution("7", "8").buildQuery() | |
SearchRequest sr = new SearchRequest(query) | |
SearchResults results = searchProvider.search(sr.getQuery(), componentManager.getJiraAuthenticationContext().getUser(), PagerFilter.getUnlimitedFilter()) | |
new File("c:/temp/foo.txt").withWriter {Writer w -> | |
results.issues.each {Issue issue -> | |
if (issue.fixVersions.sort() != issue.parentObject.fixVersions.sort()) { | |
w.write("Issue: ${issue.key} has fixVersions different from the parent. Components: ${issue.componentObjects*.name}. ") | |
w.write("Custom field: ${cf.name} : ${issue.getCustomFieldValue(cf)} ") | |
w.write("\n") | |
} | |
// if (issue.getCustomFieldValue(cf) != issue.parentObject.getCustomFieldValue(cf)) | |
} | |
} | |
params | |
} | |
String getDescription(Map params, boolean forPreview) { | |
"You clicked preview... and selected the project ${params[FIELD_PROJECT]}" | |
} | |
public static void main(String[] args) { | |
log.debug ("main method") | |
} | |
Boolean isFinalParamsPage(Map params) { | |
true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment