tomcat8 @ merlin 3 лет назад
Сommit
339bb92644
4 измененных файлов с 125 добавлено и 0 удалено
  1. 4 0
      META-INF/MANIFEST.MF
  2. 23 0
      config/module.xml
  3. 47 0
      queries/study/softwareUpdate.js
  4. 51 0
      scripts/softwareManager/TriggerFcns.js

+ 4 - 0
META-INF/MANIFEST.MF

@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.9.3
+Created-By: 1.7.0_51-b13 (Oracle Corporation)
+

+ 23 - 0
config/module.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:util="http://www.springframework.org/schema/util"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+    <bean id="moduleBean" class="org.labkey.api.module.SimpleModule">
+        <property name="name" value="softwareManager"/>
+        <property name="version" value="0.1"/>
+        <property name="requiredServerVersion" value="0.0"/>
+        <property name="moduleDependencies" value=""/>
+        <property name="svnRevision" value="0"/>
+        <property name="svnUrl" value="Not built from a source control working copy"/>
+        <property name="buildUser" value="astuden"/>
+        <property name="buildTime" value="March 5 2020, 11:43 AM"/>
+        <property name="buildOS" value="Ubuntu"/>
+        <property name="buildPath" value=""/>
+        <property name="sourcePath" value=""/>
+        <property name="supportedDatabases" value=""/>
+        <property name="resourcePath" value=""/>
+        <property name="buildNumber" value="0"/>
+        <property name="enlistmentId" value="e1388c4c-18ab-432b-a8e0-f9f5d8193eac"/>
+    </bean>
+</beans>

+ 47 - 0
queries/study/softwareUpdate.js

@@ -0,0 +1,47 @@
+var shared = require("softwareManager/TriggerFcns");
+var console = require("console");
+var LABKEY = require("labkey");
+//importClass(Packages.java.io.File);
+//var fs = require ("fs");
+
+//how routines implemented from java look in javascript:
+//https://docs.nativescript.org/runtimes/android/marshalling/java-to-js
+function init(event, errors) {
+    console.log("init() called in orgs.js with an event type of " + event);
+    //console.log("Function in shared TriggerFcns.js script returns :" +  shared.sampleFunc('echo'));
+}
+
+function complete(event, errors) {
+    console.log("complete() called in orgs.js with an event type of " + event);
+}
+
+function afterInsert(row, errors){
+    console.log("afterInsert() called in orgs.js with a row object of  " + row);
+}
+
+function beforeUpdate(row, oldRow, errors){
+    console.log("softwareManager::beforeUpdate() called in orgs.js with a row object of  " + row + "  and an oldRow of " + oldRow);
+    
+    
+    	
+	
+}
+function beforeDelete(row, errors){
+    console.log("beforeDelete() called in orgs.js with a row object of  " + row);
+}
+function beforeInsert(row, errors){
+    console.log("beforeInsert() called in orgs.js with a row object of  " + row);
+
+}
+function afterUpdate(row, oldRow, errors){
+    console.log("afterUpdate() called in orgs.js with a row object of  " + row + "  and an oldRow of " + oldRow);
+    let scriptArg={};
+    scriptArg.softwarePackage=row['softwarePackage'];
+    scriptArg.source=row['source'];
+    scriptArg.branch=row['branch'];
+    shared.gitPull(scriptArg);
+    console.log('gitPull reports: '+scriptArg.output);
+}
+function afterDelete(row, errors){
+    console.log("afterDelete() called in orgs.js with a row object of  " + row);
+}

+ 51 - 0
scripts/softwareManager/TriggerFcns.js

@@ -0,0 +1,51 @@
+exports.gitPull=gitPull;
+
+
+function gitPull(arg){
+	//arg.dir is the root-path for subdirectories
+	//arg.container is the path to subdirectory containing @files/arg.dir directory
+	//arg.labkeyBase is the system wide file root
+	
+	
+	//ctr="/RadiomAnalFDGPETCTrakPljucImunoterapi";
+
+	//var labkeyBase="/data0/labkey/files";
+	
+
+
+        let softwareDir='/usr/share/labkey/externalModules/'+ arg.softwarePackage;
+
+	let gitPull=new Object();
+	gitPull.cmd="git -C "+softwareDir+' '+'pull'+' '+arg.source+' '+arg.branch+':'+arg.branch;
+	executeShell(gitPull);
+	
+	arg.output='gitPull: '+gitPull.output;
+	arg.exitValue+='gitPull: '+gitPull.exitValue;
+	
+	let gitCheckout=new Object();
+	gitCheckout.cmd="git -C "+softwareDir+' '+'checkout'+' '+arg.branch;
+	executeShell(gitCheckout);
+
+	arg.output+='\ngitCheckout: '+gitCheckout.output;
+	arg.exitValue+='\ngitCheckout: '+gitCheckout.exitValue;
+}
+
+function executeShell(arg){
+	//arg is an object
+	//executes arg.cmd and reports arg.exitValue as 
+	//return value of the process and arg.output as 
+	//what gets printed on the screen
+        var rt=java.lang.Runtime.getRuntime();
+	var process=rt.exec(arg.cmd);
+	arg.exitValue=process.waitFor();
+	var n=process.getInputStream().available();
+	var buffer="";
+	for (i=0;i<n;i++){
+		buffer=buffer+"a";
+	}
+	var fbuffer=new java.lang.String(buffer)
+	var bytes=fbuffer.getBytes();
+	process.getInputStream().read(bytes,0,n);
+	arg.output=java.lang.String(bytes);
+}
+