I am implementing a fragment with a REST endpoint and I am writing the condition as a script. I need to call a function from another class called Configuration_CreateMultipleSubtasks.groovy.
Here is the structure of my files in the script editor
I need to call a function located in the file Configuration_CreateMultipleSubtasks.groovy. The latter file contains some constant values that I decided to store there.
Here is the code for my condition Fragment_Condition_CreateMultipleSubtasks.groovy. I would like to call the function getSubTaskCreatorHashMap() which is located in another file given that this function stores some constant values.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.plugin.ProjectPermissionKey
import com.atlassian.jira.plugin.webfragment.model.JiraHelper
import CreateMultipleSubtasks.Configuration_CreateMultipleSubtasks
import com.atlassian.jira.project.Project
import org.apache.log4j.Logger
def log = Logger.getLogger("atlassian-jira.log")
Configuration_CreateMultipleSubtasks conf= new Configuration_CreateMultipleSubtasks();
def subTaskCreatorHashMap= conf.getSubTaskCreatorHashMap()
String projectKey1 = subTaskCreatorHashMap["projectKey"] ;
String issueTypeName1 =subTaskCreatorHashMap["issueTypeName"];
String projectKey = "PIE" ;
String issueTypeName ="Defect";
def val=jiraHelper.project?.key==projectKey && issue.issueType.name==issueTypeName
log.warn("MOUNA CONDITION IS TRUE"+ projectKey1+" "+issueTypeName1)
return val
Obviously, my import is not working since I am not able to print projectKey1 and projejctKey2 in the code below.
public class Configuration_CreateMultipleSubtasks {
static def getSubTaskCreatorHashMap(){
def map = [itracCreatemultiplesubtasksIssueTypesId:5,
itracCreatemultiplesubtasksProjectCategoriesID: [10011, 10200, 10220, 10230, 10240, 10670, 10170, 11170, 11270, 11870, 11871, 11872, 11873, 11874, 11875, 12470],
itracCreatemultiplesubtasksProjectCategoriesURL: "http://itrac-sustservice.eur.ad.sag:5555/web/subtaskmgr/Login.jsp?iTrac=:1:&reporter=:2:",
projectKey: "PIE",
issueTypeName: "Defect"]
return map
}
}
I have found the answer, the solution is to write a package declaration before the imports that fixed the problem