summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/services
diff options
context:
space:
mode:
authorBartosz Bosak <bbosak@man.poznan.pl>2013-11-18 13:26:33 (GMT)
committer Bartosz Bosak <bbosak@man.poznan.pl>2013-11-18 13:26:33 (GMT)
commita6dabdba1fd650b849ee6ead4ffc000662ed7a14 (patch)
treeb2482c909cf9e508c9ebe296cfdd5b6032731c14 /idrop-web/grails-app/services
parent47428502f9feaf1b3a898f50061e7e9bc92c8c1f (diff)
parent9300b5f96fdc3989d232051a68e765d376200cf3 (diff)
downloadQCG-Data-a6dabdba1fd650b849ee6ead4ffc000662ed7a14.zip
QCG-Data-a6dabdba1fd650b849ee6ead4ffc000662ed7a14.tar.gz
QCG-Data-a6dabdba1fd650b849ee6ead4ffc000662ed7a14.tar.bz2
Merge of Mike changesidrop-black
Diffstat (limited to 'idrop-web/grails-app/services')
-rw-r--r--idrop-web/grails-app/services/org/irods/mydrop/service/RuleProcessingService.groovy85
1 files changed, 85 insertions, 0 deletions
diff --git a/idrop-web/grails-app/services/org/irods/mydrop/service/RuleProcessingService.groovy b/idrop-web/grails-app/services/org/irods/mydrop/service/RuleProcessingService.groovy
new file mode 100644
index 0000000..44d74a4
--- /dev/null
+++ b/idrop-web/grails-app/services/org/irods/mydrop/service/RuleProcessingService.groovy
@@ -0,0 +1,85 @@
+package org.irods.mydrop.service
+
+import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory
+import org.irods.jargon.core.pub.RuleProcessingAO
+import org.irods.jargon.core.utils.LocalFileUtils
+import org.irods.jargon.core.utils.MiscIRODSUtils
+import org.irods.jargon.ruleservice.composition.RuleCompositionService
+import org.irods.jargon.ruleservice.composition.RuleCompositionServiceImpl
+
+
+class RuleProcessingService {
+
+ static transactional = false
+ IRODSAccessObjectFactory irodsAccessObjectFactory
+
+ def loadRuleFromIrodsFile(IRODSAccount irodsAccount, String rulePath) {
+
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ log.info("attempting to retrieve rule for ${rulePath}")
+
+ return ruleService.loadRuleFromIrods(rulePath)
+ }
+
+ def storeRule(IRODSAccount irodsAccount, String rulePath, String ruleBody, List<String> inputParameters, List<String> outputParameters) {
+
+ log.info("storeRule")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.storeRuleFromParts(rulePath, ruleBody, inputParameters, outputParameters)
+ }
+
+ def executeRule(IRODSAccount irodsAccount, String ruleBody, List<String> inputParameters, List<String> outputParameters) {
+
+ log.info("executeRule")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.executeRuleFromParts(ruleBody, inputParameters, outputParameters)
+ }
+
+ def isRule(String rulePath) {
+ if (!rulePath) {
+ return false
+ }
+
+ def fileName = MiscIRODSUtils.getLastPathComponentForGiveAbsolutePath(rulePath)
+ def fileExtension = LocalFileUtils.getFileExtension(fileName)
+ log.info("extension is:${fileExtension}")
+
+ if (fileExtension && fileExtension == ".r") {
+ return true
+ } else {
+ return false
+ }
+ }
+
+ def deleteOutputParam(IRODSAccount irodsAccount, String absPath, String parameter) {
+ log.info("deleteOutputParam")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.deleteOutputParameterFromRule(absPath, parameter)
+ }
+
+
+ def deleteInputParam(IRODSAccount irodsAccount, String absPath, String parameter) {
+ log.info("deleteInputParam")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.deleteInputParameterFromRule(absPath, parameter)
+ }
+
+ def addRuleInputParam(IRODSAccount irodsAccount, String absPath, String parameterName, String parameterValue) {
+ log.info("addInputParam")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.addInputParameterToRule(absPath, parameterName, parameterValue)
+ }
+
+ def addRuleOutputParam(IRODSAccount irodsAccount, String absPath, String parameterName) {
+ log.info("addOutputParam")
+ RuleCompositionService ruleService = new RuleCompositionServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return ruleService.addOutputParameterToRule(absPath, parameterName)
+ }
+
+ def listDelayedRuleExecutions(IRODSAccount irodsAccount, int offset) {
+ log.info("listDelayedRuleExecutions()")
+ RuleProcessingAO ruleProcessingAO = irodsAccessObjectFactory.getRuleProcessingAO(irodsAccount)
+ return ruleProcessingAO.listAllDelayedRuleExecutions(offset)
+ }
+}