Skip to content

Instantly share code, notes, and snippets.

@rherrick
Forked from anonymous/haiku.groovy
Last active February 5, 2016 19:49
Show Gist options
  • Save rherrick/7a8df6038f1be89efad9 to your computer and use it in GitHub Desktop.
Save rherrick/7a8df6038f1be89efad9 to your computer and use it in GitHub Desktop.
haiku script
importClass(org.nrg.xnat.turbine.utils.ArcSpecManager);
importPackage(java.io);
var cache = org.nrg.xnat.turbine.utils.ArcSpecManager.GetInstance().getCachePathForProject(externalId);
var file = new java.io.File(cache, "haiku.txt");
var writer = new java.io.PrintWriter(new FileWriter(file));
writer.println("Into the ancient pond");
writer.println("A frog jumps");
writer.println("Waters sound!");
writer.println("User: " + user.login + "(" + user.class.name + ")");
writer.println("Script ID: " + scriptId + "(" + scriptId.class.name + ")");
writer.println("Event: " + event + "(" + event.class.name + ")");
writer.println("Data Type: " + dataType + "(" + dataType.class.name + ")");
writer.println("Data ID: " + dataId + "(" + dataId.class.name + ")");
writer.println("External ID: " + externalId + "(" + externalId.class.name + ")");
writer.println("Src Workflow ID: " + srcWorkflowId + "(" + srcWorkflowId.class.name + ")");
writer.println("Script Workflow ID: " + scriptWorkflowId + "(" scriptWorkflowId+ .class.name + ")");
writer.println("Workflow: " + workflow.wrkWorkflowdataId + "(" + workflow.class.name + ")");
var ArcSpecManager = Java.type("org.nrg.xnat.turbine.utils.ArcSpecManager");
var File = Java.type("java.io.File");
var FileWriter = Java.type("java.io.FileWriter");
var PrintWriter = Java.type("java.io.PrintWriter");
var cache = ArcSpecManager.GetInstance().getCachePathForProject(externalId);
var file = new File(cache, "haiku.txt");
var writer = new PrintWriter(new FileWriter(file));
writer.println("Into the ancient pond");
writer.println("A frog jumps");
writer.println("Waters sound!");
writer.println("User: " + user.login + "(" + user.class.name + ")");
writer.println("Script ID: " + scriptId + "(" + scriptId.class.name + ")");
writer.println("Event: " + event + "(" + event.class.name + ")");
writer.println("Data Type: " + dataType + "(" + dataType.class.name + ")");
writer.println("Data ID: " + dataId + "(" + dataId.class.name + ")");
writer.println("External ID: " + externalId + "(" + externalId.class.name + ")");
writer.println("Src Workflow ID: " + srcWorkflowId + "(" + srcWorkflowId.class.name + ")");
writer.println("Script Workflow ID: " + scriptWorkflowId + "(" scriptWorkflowId+ .class.name + ")");
writer.println("Workflow: " + workflow.wrkWorkflowdataId + "(" + workflow.class.name + ")");
import org.nrg.xnat.turbine.utils.ArcSpecManager
def cache = ArcSpecManager.GetInstance().getCachePathForProject(externalId)
new File(cache, 'haiku.txt').withWriter('utf-8') { writer ->
writer.writeLine 'Into the ancient pond'
writer.writeLine 'A frog jumps'
writer.writeLine 'Waters sound!'
writer.writeLine "User: ${user.login} (${user.class.name})")
writer.writeLine "Script ID: ${scriptId} (${scriptId.class.name})")
writer.writeLine "Event: ${event} (${event.class.name})")
writer.writeLine "Data Type: ${dataType} (${dataType.class.name})")
writer.writeLine "Data ID: ${dataId} (${dataId.class.name})")
writer.writeLine "External ID: ${externalId} (${externalId.class.name})")
writer.writeLine "Src Workflow ID: ${srcWorkflowId} (${srcWorkflowId.class.name})")
writer.writeLine "Script Workflow ID: ${scriptWorkflowId} ${scriptWorkflowId.class.name}")
writer.writeLine "Workflow: ${workflow.wrkWorkflowdataId} (${workflow.class.name})")
}
from org.nrg.xnat.turbine.utils import ArcSpecManager
from java.io import File
from java.io import PrintWriter
from java.io import FileWriter
cache = ArcSpecManager.GetInstance().getCachePathForProject(externalId)
file = File(cache, "haiku.txt")
writer = PrintWriter(FileWriter(file))
writer.println("Into the ancient pond")
writer.println("A frog jumps")
writer.println("Waters sound!")
writer.println("User: " + user.login)
writer.println("Script ID: " + scriptId)
writer.println("Event: " + event)
writer.println("Data Type: " + dataType)
writer.println("Data ID: " + dataId)
writer.println("External ID: " + externalId)
writer.println("Src Workflow ID: " + srcWorkflowId)
writer.println("Script Workflow ID: " + scriptWorkflowId)
writer.println("Workflow: " + workflow.wrkWorkflowdataId)
import org.nrg.xdat.XDAT
import org.nrg.mail.services.MailService
def MailService service = XDAT.getMailService()
// Not sure about the incoming bind parameters in here. Validate with a working email server.
service.sendHtmlMessage($user.email, "[email protected]", null, null, "Created a new manual QC", "<p>You created a new manual QC in project <b>${externalId}</b>:</p><p><b>${dataType}</b> ${dataId}.</p><p>Workflow IDs are:</p><ul><li> <b>srcWorkflowId:</b> $srcWorkflowId</li><li> <b>groovyWorkflowId:</b> $groovyWorkflowId</li><li> <b>groovyWorkflow:</b> $groovyWorkflow.wrkWorkflowdataId</li></ul>")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment