Hi everyone, I have been working on trying to get the Holiday list from the Tempo plugin and I have been having difficulties. So far this is my good for that section:
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl; import com.onresolve.scriptrunner.runner.customisers.PluginModule; import com.onresolve.scriptrunner.runner.customisers.WithPlugin; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.customfields.manager.OptionsManager import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import com.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import java.lang.Object import com.atlassian.jira.issue.worklog.WorklogImpl2 import java.text.SimpleDateFormat import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.worklog.DefaultWorklogManager import com.atlassian.jira.security.roles.ProjectRoleManager import com.atlassian.jira.issue.worklog.Worklog import com.atlassian.jira.datetime.LocalDate import groovy.xml.DOMBuilder import javax.xml.parsers.* ******************************************************************************************************* def URLflooting = "http://yourserver.yourserver/rest/tempo-core/1/holidayscheme/1/days/floating" def URLfixed = "http://yourserver.yourserver/rest/tempo-core/1/holidayscheme/1/days/fixed" ****************************************************************************************************** def componentManager = ComponentManager.getInstance() def customFieldManager = ComponentAccessor.getCustomFieldManager() def cfend = customFieldManager.getCustomFieldObjectByName("End Date") def cfstart = customFieldManager.getCustomFieldObjectByName("Start Date") def cfdays = customFieldManager.getCustomFieldObjectByName("Used vacation days") def reporter = issue.reporter.name def worklogManager = ComponentAccessor.getWorklogManager(); //Take customfield date object and change it to days int days = (issue.getCustomFieldValue(cfdays) as int)//return the number of days ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager def UsersRole = projectRoleManager.getProjectRole("Users") long timespent = 27000 int counter = 0; int check = 0; for(int i=0; check == 0 ;i++){ //Checks if it is sunday if(((issue.getCustomFieldValue(cfstart) as Date) + i).getDay() == 0){ i++ def worklog = new WorklogImpl2(issue, null, issue.reporter.name, issue.summary, (issue.getCustomFieldValue(cfstart) as Date)+ i, null, null,timespent, UsersRole) worklogManager.create(issue.reporter, worklog, 0L, true) } //Checks if it is Saturday else if(((issue.getCustomFieldValue(cfstart) as Date) + i).getDay() == 6){ i = i + 2 def worklog = new WorklogImpl2(issue, null, issue.reporter.name, issue.summary, (issue.getCustomFieldValue(cfstart) as Date) + i, null, null,timespent, UsersRole) worklogManager.create(issue.reporter, worklog, 0L, true) } //Any other day in the week else{ def worklog = new WorklogImpl2(issue, null, issue.reporter.name, issue.summary, (issue.getCustomFieldValue(cfstart) as Date) + i, null, null,timespent, UsersRole) worklogManager.create(issue.reporter, worklog, 0L, true) } counter++ if(days == counter){ check =1; } } return 0;
I am not to sure what the URLflooting and URLfixed returns. I want it to return a string or an array so I can compare it to a date. I checked the http addresses for both the URL's and they both gave me a page that looked like a text file. I have been stuck for a while on this spot and I am not sure how to continue or to progress.
I have put asterisks where I am having trouble so it is easy to find. Please let me know if anybody finds a way to import that data.
Hi Andrew,
I know I'm a bit late to the party, but this could be carried out using HTTP requests, and only HTTP requests. If you are not sure how to do this, please check this link, in which I explain how to do a POST request. In your case, you need a GET, so that's even easier.
Do tell if you need more help.
Cheers
DYelamos
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.