Help Syncing with Merlin Project Management
Added by Kyle Plattner almost 14 years ago
I really would like some help getting the OS X project management software Merlin to sync tickets with Redmine. I was told that this can be done through AppleScript. If anyone could help it would really be appreciated, I am new to redmine and know very little about AppleScripting. I found the following but do not understand it:
(*
FLOW3 Forge to Merlin connector
Copyright ©2010 Robert Lemke <robert@typo3.org>
*)
set pathToServer to "https://forge.typo3.org/generate-merlin-issues-feed.php"set issuesFeed to do shell script "curl --insecure " & quoted form of (pathToServer) as «class utf8»
set AppleScript's text item delimiters to {"☃"}
set issuesLines to every text item of issuesFeed
set AppleScript's text item delimiters to {""}set importedIssues to {}
set createdIssues to {}
set deletedIssues to {}repeat with currentLine in issuesLines
set AppleScript's text item delimiters to {""}
set rawIssueList to every text item of currentLine
set AppleScript's text item delimiters to {""}if (rawIssueList ≠ {}) and (item 1 of rawIssueList ≠ "") then
copy rawIssueList to end of importedIssues
end ifend repeat
using terms from application "Merlin"
tell application "Merlin"
activateset currentProject to root project of the first document
repeat with firstLevelObject in (activities of currentProject whose (class is activity and title contains "FLOW3"))
set parentActivity to firstLevelObject
set currentVersionName to title of parentActivity as textrepeat with importedIssue in importedIssues
-- Check for new and updated issues:
set foundActivities to (activities of parentActivity whose (class is activity) and (title starts with (item 2 of importedIssue) & " "))
if foundActivities ≠ {} then
set foundActivity to item 1 of foundActivities
else
set foundActivity to false
end ifif ("FLOW3 " & item 1 of importedIssue) is currentVersionName then
-- Create new activity if it does not exist yet:
if foundActivity is false then
tell application "Merlin" to set foundActivity to (make new activity at end of activities of parentActivity) as specifier
copy item 2 of importedIssue to end of createdIssues
end if-- Set properties of found activity:
tell foundActivity to set title to item 2 of importedIssue & " " & item 3 of importedIssue
set assignedPersonName to item 4 of importedIssue
set foundResources to (resources of currentProject whose title is assignedPersonName)if foundResources ≠ {} then
assign resource (item 1 of foundResources) to activity foundActivity
end ifset currentStatus to item 5 of importedIssue
set completion to item 10 of importedIssue
if currentStatus is "Closed" then set completion to 100
tell foundActivity to set given actual completion to (completion / 100)set givenPlannedWork to item 7 of importedIssue
if givenPlannedWork ≠ {} then
tell foundActivity to set given planned work to givenPlannedWork
end ifset startDateString to item 8 of importedIssue as text
if startDateString ≠ "" and completion > 0 then
set startDate to date "Freitag, 1. Januar 2010 09:00:00"
set AppleScript's text item delimiters to {"."}
set year of startDate to text item 3 of startDateString
set month of startDate to text item 2 of startDateString
set day of startDate to text item 1 of startDateString
tell foundActivity to set actual start date to startDate
set AppleScript's text item delimiters to {""}
end ifset updatedDateString to item 9 of importedIssue as text
if ((currentStatus is "Resolved") or (currentStatus is "Closed")) and (updatedDateString ≠ "") then
set updatedDate to date "Freitag, 1. Januar 2010 09:00:00"
set AppleScript's text item delimiters to {"."}
set year of updatedDate to text item 3 of updatedDateString
set month of updatedDate to text item 2 of updatedDateString
set day of updatedDate to text item 1 of updatedDateString
tell foundActivity to set actual end date to updatedDate
set AppleScript's text item delimiters to {""}if givenPlannedWork ≠ {} then
set AppleScript's text item delimiters to {"h?"}
set givenPlannedWorkHours to text item 1 of givenPlannedWork
set AppleScript's text item delimiters to {""}
set startDate to updatedDate - (givenPlannedWorkHours * 60 * 60)
tell foundActivity to set actual start date to startDate
end if
end ifelse if foundActivity is not false then
tell application "Merlin" to delete foundActivity
copy item 2 of importedIssue to end of deletedIssues
end ifend repeat
end repeat
end tell
end using terms fromset AppleScript's text item delimiters to {", "}
display dialog "Created issues:" & return & createdIssues & return & "Deleted issues:" & deletedIssues