Created
February 14, 2012 09:36
-
-
Save anonymous/1825347 to your computer and use it in GitHub Desktop.
This file contains 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
import com.atlassian.jira.ComponentManager | |
import com.atlassian.jira.issue.CustomFieldManager | |
import com.atlassian.jira.issue.Issue | |
import com.opensymphony.user.Group | |
import com.atlassian.jira.issue.MutableIssue | |
import com.atlassian.jira.config.SubTaskManager | |
import org.ofbiz.core.entity.GenericValue | |
import com.opensymphony.user.User | |
import com.atlassian.core.user.UserUtils | |
import com.atlassian.jira.user.util.UserManager | |
import com.opensymphony.workflow.WorkflowContext | |
import com.atlassian.jira.security.util.GroupSelectorUtils | |
ComponentManager componentManager = ComponentManager.getInstance() | |
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager() | |
def issueFactory = componentManager.getIssueFactory() | |
def issueManager = componentManager.getIssueManager() | |
def indexManager = componentManager.getIndexManager() | |
def groupCf = customFieldManager.getCustomFieldObjectByName("Kompetenzcluster") // name of group CF | |
def UserList = [] | |
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller() | |
User currentUserObj = UserUtils.getUser(currentUser) | |
GroupSelectorUtils util = (GroupSelectorUtils) ComponentManager.getInstance().getContainer().getComponentInstanceOfType(GroupSelectorUtils.class) | |
//Group group = issue.getCustomFieldValue(groupCf) as Group | |
issue.getCustomFieldValue(groupCf).each {Object group -> | |
if (group) { | |
Group groupObj = util.getGroups((String) group) | |
groupObj.getUsers().each {String user -> | |
if(!UserList.contains(user) && user != currentUser) { | |
MutableIssue newIssue = issueFactory.getIssue() | |
newIssue.summary = "$user: " + issue.summary | |
newIssue.issueTypeId = '71' | |
newIssue.project = issue.project | |
newIssue.reporter = UserUtils.getUser(user) | |
newIssue.assignee = UserUtils.getUser(user) | |
newIssue.assigneeId = user | |
newIssue.priority = issue.priority | |
//newIssue.affectedVersions = issue.affectedVersions | |
//newIssue.fixVersions = issue.fixVersions | |
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object> | |
//User currentUser = componentManager.getJiraAuthenticationContext().getUser() | |
GenericValue newIssueGv = issueManager.createIssue(currentUserObj, newIssueParams) | |
indexManager.reIndex(newIssueGv); | |
SubTaskManager subTaskManager = componentManager.getSubTaskManager() | |
subTaskManager.createSubTaskIssueLink(issue, newIssue, componentManager.getJiraAuthenticationContext().getUser()) | |
indexManager.reIndex(newIssueGv); | |
indexManager.reIndex(issue); | |
UserList.add(user) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I added the code for creating auto subtask for a list of users in the group.
please help me in resolving this error ""No such property: issue for class: