You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by se...@apache.org on 2022/07/25 12:37:33 UTC

svn commit: r1903007 - /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java

Author: seanfinan
Date: Mon Jul 25 12:37:32 2022
New Revision: 1903007

URL: http://svn.apache.org/viewvc?rev=1903007&view=rev
Log:
Add optional command directory

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java?rev=1903007&r1=1903006&r2=1903007&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/ae/CommandRunner.java Mon Jul 25 12:37:32 2022
@@ -11,6 +11,7 @@ import org.apache.uima.fit.descriptor.Co
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.resource.ResourceInitializationException;
 
+import java.io.File;
 import java.io.IOException;
 
 /**
@@ -35,6 +36,15 @@ public class CommandRunner extends JCasA
    )
    private String _cmd;
 
+   static public final String CMD_DIR_PARAM = "CommandDir";
+   static public final String CMD_DIR_DESC = "Set a value for parameter Command's directory.";
+   @ConfigurationParameter(
+         name = CMD_DIR_PARAM,
+         description = CMD_DIR_DESC,
+         mandatory = false
+   )
+   private String _cmdDir;
+
    static public final String DIR_PARAM = "Dir";
    static public final String DIR_DESC = "Set a value for parameter Command's root directory.";
    @ConfigurationParameter(
@@ -127,7 +137,8 @@ public class CommandRunner extends JCasA
 
 
    private void runCommand() throws IOException {
-      final SystemUtil.CommandRunner runner = new SystemUtil.CommandRunner( _cmd );
+      final String command = _cmdDir.isEmpty() ? _cmd : _cmdDir + File.separator + _cmd;
+      final SystemUtil.CommandRunner runner = new SystemUtil.CommandRunner( command );
       if ( _logFile != null && !_logFile.isEmpty() ) {
          runner.setLogFiles( _logFile, _logFile );
       } else {
@@ -140,7 +151,10 @@ public class CommandRunner extends JCasA
       if ( _dir != null && !_dir.isEmpty() ) {
          runner.setDirectory( _dir );
       }
-      LOGGER.info( "Running " + _cmd + " ..." );
+      LOGGER.info( "Running " + command + " ..." );
+      if ( _logFile != null && !_logFile.isEmpty() ) {
+         LOGGER.info( "Log File is " + _logFile );
+      }
       SystemUtil.run( runner );
       if ( _pause < 1 ) {
          return;