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 2020/05/01 16:38:32 UTC

svn commit: r1877264 - in /ctakes/trunk: ctakes-dockhand/ ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/ ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/ ctakes-dockhand/src/main/resources/org/apache/ctakes/dock...

Author: seanfinan
Date: Fri May  1 16:38:31 2020
New Revision: 1877264

URL: http://svn.apache.org/viewvc?rev=1877264&view=rev
Log:
ctakes-dockhand now copies webapp/ from ctakes-tiny-rest upon packaging
ctakes-tiny-rest refactored rest calls, output
ctakes-tiny-rest demo page made pretty

Added:
    ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/CopyFileSpec.java
    ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/README.txt
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/CuiListFormatter.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/FhirJsonFormatter.java
      - copied, changed from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyFhirJsonController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PrettyPrintFormatter.java
      - copied, changed from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPrettyPrintController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PropertyListFormatter.java
      - copied, changed from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPropertyController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/ResponseFormatter.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/UmlsJsonFormatter.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/XmiFormatter.java
      - copied, changed from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyXmiController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/
    ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/index.css
Removed:
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/AbstractTinyController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/DefaultTinyController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyFhirJsonController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPrettyPrintController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPropertyController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyXmiController.java
Modified:
    ctakes/trunk/ctakes-dockhand/pom.xml
    ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/BaseInstaller.java
    ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/LocalInstallBuilder.java
    ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/RestDockerBuilder.java
    ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/docker/Dockerfile
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/RestPipelineRunner.java
    ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyController.java
    ctakes/trunk/ctakes-tiny-rest/src/main/webapp/index.jsp
    ctakes/trunk/ctakes-tiny-rest/src/main/webapp/js/app.js

Modified: ctakes/trunk/ctakes-dockhand/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/pom.xml?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dockhand/pom.xml (original)
+++ ctakes/trunk/ctakes-dockhand/pom.xml Fri May  1 16:38:31 2020
@@ -48,6 +48,31 @@
             </configuration>
          </plugin>
 
+         <!--    ctakes-tiny-rest is a separate module with its own code repo.
+                 The ctakes distribution has the ctakes-tiny-rest jar but not the webapp directory.
+                 We need the webapp directory to build the rest war.  Copy it into our resources.   -->
+         <plugin>
+            <artifactId>maven-resources-plugin</artifactId>
+            <version>3.0.2</version>
+            <executions>
+               <execution>
+                  <id>copy-resources</id>
+                  <phase>compile</phase>
+                  <goals>
+                     <goal>copy-resources</goal>
+                  </goals>
+                  <configuration>
+                     <outputDirectory>${basedir}/target/classes/org/apache/ctakes/dockhand/goal/rest/webapp</outputDirectory>
+                     <resources>
+                        <resource>
+                           <directory>${basedir}/../ctakes-tiny-rest/src/main/webapp</directory>
+                           <filtering>true</filtering>
+                        </resource>
+                     </resources>
+                  </configuration>
+               </execution>
+            </executions>
+         </plugin>
       </plugins>
    </build>
 </project>

Modified: ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/BaseInstaller.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/BaseInstaller.java?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/BaseInstaller.java (original)
+++ ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/BaseInstaller.java Fri May  1 16:38:31 2020
@@ -3,10 +3,9 @@ package org.apache.ctakes.dockhand.build
 
 import org.apache.ctakes.gui.wizard.util.DialogUtil;
 import org.apache.ctakes.gui.wizard.util.RunnerUtil;
-import org.apache.ctakes.gui.wizard.util.SystemUtil;
 
 import java.io.*;
-import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.concurrent.Callable;
 
@@ -22,22 +21,22 @@ final public class BaseInstaller impleme
    static private final String PIPER_NAME = "DockhandPipeline.piper";
 
    private final String _installType;
-   private final String _sourceDirUrl;
-   private final String _goalPomFile;
    private final String _piperCommands;
-   private final String[] _extraFiles;
+   private final Collection<CopyFileSpec> _copyFileSpecs;
    private File _installDir;
 
    public BaseInstaller( final String installType,
                          final String sourceDirUrl,
                          final String goalPomFile,
                          final Collection<String> piperCommands,
-                         final String... extraFiles ) {
+                         final Collection<CopyFileSpec> extraFiles ) {
       _installType = installType;
-      _sourceDirUrl = sourceDirUrl;
-      _goalPomFile = goalPomFile;
       _piperCommands = String.join( "\n", piperCommands );
-      _extraFiles = extraFiles;
+      _copyFileSpecs = new ArrayList<>( extraFiles );
+      _copyFileSpecs.add( new CopyFileSpec( sourceDirUrl + "pom/" + goalPomFile, "pom.xml" ) );
+      _copyFileSpecs.add( new CopyFileSpec( "/log4j.xml" ) );
+      _copyFileSpecs.add( new CopyFileSpec( "/LICENSE" ) );
+      _copyFileSpecs.add( new CopyFileSpec( "/NOTICE" ) );
    }
 
 
@@ -55,29 +54,19 @@ final public class BaseInstaller impleme
 
    public File call() {
       final String installPath = _installDir.getAbsolutePath();
-      new File( installPath ).mkdirs();
+      writePiperFile( installPath, _piperCommands );
+      _copyFileSpecs.forEach( f -> f.copyToDisk( installPath ) );
+      return _installDir;
+   }
 
+   static private void writePiperFile( final String installPath, final String piperCommands ) {
+      new File( installPath ).mkdirs();
       final String piperPath = installPath + "/" + PIPER_NAME;
       try ( Writer writer = new BufferedWriter( new FileWriter( piperPath ) ) ) {
-         writer.write( _piperCommands + "\n" );
+         writer.write( piperCommands + "\n" );
       } catch ( IOException ioE ) {
          DialogUtil.showError( ioE.getMessage() );
       }
-      copyToDisk( _sourceDirUrl + "pom/" + _goalPomFile, installPath + "/pom.xml" );
-      copyToDisk( "/log4j.xml", installPath + "/log4j.xml" );
-      copyToDisk( "/LICENSE", installPath + "/LICENSE" );
-      copyToDisk( "/NOTICE", installPath + "/NOTICE" );
-
-      for ( String file : _extraFiles ) {
-         final String name = new File( file ).getName();
-         copyToDisk( file, installPath + "/" + name );
-      }
-
-      return _installDir;
-   }
-
-   private void copyToDisk( final String source, final String filePath ) {
-      SystemUtil.copyToDisk( getClass().getResourceAsStream( source ), Paths.get( filePath ) );
    }
 
 

Added: ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/CopyFileSpec.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/CopyFileSpec.java?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/CopyFileSpec.java (added)
+++ ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/CopyFileSpec.java Fri May  1 16:38:31 2020
@@ -0,0 +1,32 @@
+package org.apache.ctakes.dockhand.build;
+
+import org.apache.ctakes.gui.wizard.util.SystemUtil;
+
+import java.io.File;
+import java.nio.file.Paths;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 4/29/2020
+ */ // TODO pass vararg of TargetFileSpec to BaseInstaller.  Call its copyToDisk method.
+final public class CopyFileSpec {
+   private final String _source;
+   private final String _target;
+
+   public CopyFileSpec( final String name ) {
+      this( name, name );
+   }
+
+   public CopyFileSpec( final String source, final String target ) {
+      _source = source;
+      _target = target;
+   }
+
+   public void copyToDisk( final String targetRoot ) {
+      final String targetPath = targetRoot + "/" + _target;
+      new File( targetPath ).getParentFile().mkdirs();
+      SystemUtil.copyToDisk( getClass().getResourceAsStream( _source ), Paths.get( targetPath ) );
+   }
+
+}

Modified: ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/LocalInstallBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/LocalInstallBuilder.java?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/LocalInstallBuilder.java (original)
+++ ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/LocalInstallBuilder.java Fri May  1 16:38:31 2020
@@ -7,6 +7,7 @@ import org.apache.ctakes.gui.wizard.util
 import org.apache.ctakes.gui.wizard.util.SystemUtil;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collection;
 
 
@@ -39,12 +40,12 @@ final public class LocalInstallBuilder i
       final GoalPom goalPom = _wizardController.getGoalPom();
       final Collection<String> piperCommands = _wizardController.getPiperCommands();
 
+      final Collection<CopyFileSpec> extraFiles = new ArrayList<>();
+      extraFiles.add( new CopyFileSpec( SOURCE_URLDIR + "pom/build.xml", "build.xml" ) );
+      extraFiles.add( new CopyFileSpec( BINARY_DIR + "RunPiperGui.sh", "RunPiperGui.sh" ) );
+      extraFiles.add( new CopyFileSpec( BINARY_DIR + "RunPiperGui.bat", "RunPiperGui.bat" ) );
       final BaseInstaller baseInstaller
-            = new BaseInstaller( INSTALL_TYPE,
-            SOURCE_URLDIR, goalPom.getPomFile(), piperCommands,
-            SOURCE_URLDIR + "pom/build.xml",
-            BINARY_DIR + "RunPiperGui.sh",
-            BINARY_DIR + "RunPiperGui.bat" );
+            = new BaseInstaller( INSTALL_TYPE, SOURCE_URLDIR, goalPom.getPomFile(), piperCommands, extraFiles );
 
       final boolean install = baseInstaller.install();
       if ( !install ) {

Modified: ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/RestDockerBuilder.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/RestDockerBuilder.java?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/RestDockerBuilder.java (original)
+++ ctakes/trunk/ctakes-dockhand/src/main/java/org/apache/ctakes/dockhand/build/RestDockerBuilder.java Fri May  1 16:38:31 2020
@@ -4,6 +4,8 @@ import org.apache.ctakes.dockhand.gui.fe
 import org.apache.ctakes.dockhand.gui.wizard.DhWizardController;
 import org.apache.ctakes.gui.wizard.util.DialogUtil;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 
 
@@ -19,7 +21,16 @@ final public class RestDockerBuilder imp
    static private final String PIPER_DIR = "/org/apache/ctakes/dockhand/goal/rest/pipeline/";
    static private final String SOURCE_URLDIR = "/org/apache/ctakes/dockhand/goal/rest/";
    static private final String DOCKER_DIR = "/org/apache/ctakes/dockhand/goal/rest/docker/";
+   static private final String WEBAPP_SOURCE_DIR = "/org/apache/ctakes/dockhand/goal/rest/webapp/";
+   static private final String WEBAPP_TARGET_DIR = "/webapp/";
 
+   static private final String[] WEBAPPS = { "index.jsp",
+                                             "css/index.css",
+                                             "js/app.js",
+                                             "js/jquery.js",
+                                             "META-INF/MANIFEST.MF",
+                                             "WEB-INF/ctakes-rest-service-servlet.xml",
+                                             "WEB-INF/web.xml" };
 
    private final DhWizardController _wizardController;
 
@@ -31,11 +42,15 @@ final public class RestDockerBuilder imp
       final GoalPom goalPom = _wizardController.getGoalPom();
       final Collection<String> piperCommands = _wizardController.getPiperCommands();
 
+      final Collection<CopyFileSpec> extraFiles = new ArrayList<>();
+      extraFiles.add( new CopyFileSpec( SOURCE_URLDIR + "README.txt", "README.txt" ) );
+      extraFiles.add( new CopyFileSpec( DOCKER_DIR + "Dockerfile", "Dockerfile" ) );
+      extraFiles.add( new CopyFileSpec( PIPER_DIR + "TinyRestPipeline.piper", "TinyRestPipeline.piper" ) );
+      Arrays.stream( WEBAPPS )
+            .map( f -> new CopyFileSpec( WEBAPP_SOURCE_DIR + f, WEBAPP_TARGET_DIR + f ) )
+            .forEach( extraFiles::add );
       final BaseInstaller baseInstaller
-            = new BaseInstaller( INSTALL_TYPE,
-            SOURCE_URLDIR, goalPom.getPomFile(), piperCommands,
-            DOCKER_DIR + "Dockerfile",
-            PIPER_DIR + "TinyRestPipeline.piper" );
+            = new BaseInstaller( INSTALL_TYPE, SOURCE_URLDIR, goalPom.getPomFile(), piperCommands, extraFiles );
 
       final boolean finished = baseInstaller.install();
       if ( finished ) {

Added: ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/README.txt
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/README.txt?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/README.txt (added)
+++ ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/README.txt Fri May  1 16:38:31 2020
@@ -0,0 +1,19 @@
+To create a tiny rest server:
+
+1.  Execute "docker-machine env".
+     This will list the full DOCKER_HOST address.
+     e.g. "tcp://192.168.99.101:2376"
+2.  Make note of the address between "//" and ":".
+     e.g. "192.168.99.101".
+     Let us call this "IP.IP.IP.IP".
+3.  Change to the directory containing "Dockerfile".
+4.  Execute "docker build -t ctakes_tiny_rest .".
+     This will build an image with the tag "ctakes_tiny_rest".
+5.  Execute "docker run --name my_ctakes_rest --rm -d -p 8080:8080 ctakes_tiny_rest".
+     This will start a container named "my_ctakes_rest" that runs the server.
+6.  In a browser, visit "http://IP.IP.IP.IP:8080/ctakes_tiny_rest".
+     This should open a ctakes demo front page.
+
+7.  To stop the server, execute "docker stop my_ctakes_rest".
+8.  To remove the image, execute "docker rmi ctakes_tiny_rest".
+9.  To clean your docker machine, execute "docker image prune".

Modified: ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/docker/Dockerfile
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/docker/Dockerfile?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/docker/Dockerfile (original)
+++ ctakes/trunk/ctakes-dockhand/src/main/resources/org/apache/ctakes/dockhand/goal/rest/docker/Dockerfile Fri May  1 16:38:31 2020
@@ -3,8 +3,6 @@ FROM openjdk:8-alpine
 RUN apk update && apk add ca-certificates openssl wget unzip maven
 
 ## Download apache-tomcat and extract:
-# RUN wget http://mirror.cc.columbia.edu/pub/software/apache/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.zip
-# RUN unzip apache-tomcat-9.0.14.zip
 RUN wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.14/bin/apache-tomcat-9.0.14.zip \
 && unzip apache-tomcat-9.0.14.zip && rm apache-tomcat-9.0.14.zip
 
@@ -16,7 +14,8 @@ COPY DockhandPipeline.piper /ctakes_src/
 COPY log4j.xml /ctakes_src/
 COPY LICENSE /ctakes_src/
 COPY NOTICE /ctakes_src/
-#  RestServer calls TinyRestPipeline.
+COPY webapp /ctakes_src/src/main/webapp
+#  Rest Server calls TinyRestPipeline.
 
 WORKDIR /ctakes_src
 

Modified: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/RestPipelineRunner.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/RestPipelineRunner.java?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/RestPipelineRunner.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/RestPipelineRunner.java Fri May  1 16:38:31 2020
@@ -21,6 +21,7 @@ package org.apache.ctakes.rest.service;
 
 import org.apache.ctakes.core.pipeline.PipelineBuilder;
 import org.apache.ctakes.core.pipeline.PiperFileReader;
+import org.apache.ctakes.rest.service.response.ResponseFormatter;
 import org.apache.log4j.Logger;
 import org.apache.uima.UIMAException;
 import org.apache.uima.UIMAFramework;
@@ -67,7 +68,7 @@ public enum RestPipelineRunner {
       }
    }
 
-   public String process( final TinyController tinyController, final String text )
+   public String process( final ResponseFormatter formatter, final String text )
          throws AnalysisEngineProcessException {
       if ( text == null || text.trim().isEmpty() ) {
          return "";
@@ -81,7 +82,7 @@ public enum RestPipelineRunner {
             jcas.reset();
             jcas.setDocumentText( text );
             _engine.process( jcas );
-            final String resultText = tinyController.getResultText( jcas );
+            final String resultText = formatter.getResultText( jcas );
             _pool.releaseJCas( jcas );
             return resultText;
          } catch ( CASRuntimeException | AnalysisEngineProcessException multE ) {

Modified: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyController.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyController.java?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyController.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyController.java Fri May  1 16:38:31 2020
@@ -19,16 +19,67 @@ package org.apache.ctakes.rest.service;
  * under the License.
  */
 
+import org.apache.ctakes.rest.service.response.*;
+import org.apache.log4j.Logger;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
-import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+import java.util.Optional;
 
 /**
  * @author SPF , chip-nlp
  * @version %I%
  * @since 11/5/2019
  */
-public interface TinyController {
+@RestController
+public class TinyController {
+
+   static private final Logger LOGGER = Logger.getLogger( "TinyController" );
+
+   static private volatile boolean _initialized = false;
+
+   @PostConstruct
+   public void init() throws ResourceInitializationException {
+      synchronized ( LOGGER ) {
+         if ( _initialized ) {
+            return;
+         }
+         LOGGER.info( "Initializing analysis engine ..." );
+         try {
+            // The first access of a singleton enum instantiates it.
+            RestPipelineRunner.getInstance();
+         } catch ( ExceptionInInitializerError initE ) {
+            throw new ResourceInitializationException( initE );
+         }
+         LOGGER.info( "Analysis Engine Initialized." );
+         _initialized = true;
+      }
+   }
+
+   @RequestMapping( value = "/process", method = RequestMethod.POST )
+   @ResponseBody
+   public String processText( @RequestBody final String text,
+                              @RequestParam( "format" ) final Optional<String> responseFormat )
+         throws AnalysisEngineProcessException {
+      final String format = responseFormat.orElse( "default" ).toLowerCase();
+      switch ( format ) {
+         case "fhir":
+            return RestPipelineRunner.getInstance().process( new FhirJsonFormatter(), text );
+         case "pretty":
+            return RestPipelineRunner.getInstance().process( new PrettyPrintFormatter(), text );
+         case "property":
+            return RestPipelineRunner.getInstance().process( new PropertyListFormatter(), text );
+         case "umls":
+            return RestPipelineRunner.getInstance().process( new UmlsJsonFormatter(), text );
+         case "cui":
+            return RestPipelineRunner.getInstance().process( new CuiListFormatter(), text );
+         case "xmi":
+            return RestPipelineRunner.getInstance().process( new XmiFormatter(), text );
+      }
+      return RestPipelineRunner.getInstance().process( new FhirJsonFormatter(), text );
+   }
 
-   String getResultText( final JCas jCas ) throws AnalysisEngineProcessException;
 
 }

Added: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/CuiListFormatter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/CuiListFormatter.java?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/CuiListFormatter.java (added)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/CuiListFormatter.java Fri May  1 16:38:31 2020
@@ -0,0 +1,31 @@
+package org.apache.ctakes.rest.service.response;
+
+
+import org.apache.ctakes.core.util.annotation.OntologyConceptUtil;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+
+import java.util.stream.Collectors;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 5/1/2020
+ */
+final public class CuiListFormatter implements ResponseFormatter {
+
+   /**
+    * Returns a list of Cuis.
+    * {@inheritDoc}
+    */
+   @Override
+   public String getResultText( final JCas jCas ) throws AnalysisEngineProcessException {
+      return OntologyConceptUtil.getCuiCounts( jCas )
+                                .entrySet()
+                                .stream()
+                                .map( e -> e.getKey() + " : " + e.getValue() )
+                                .sorted()
+                                .collect( Collectors.joining( "\n" ) );
+   }
+
+}

Copied: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/FhirJsonFormatter.java (from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyFhirJsonController.java)
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/FhirJsonFormatter.java?p2=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/FhirJsonFormatter.java&p1=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyFhirJsonController.java&r1=1877263&r2=1877264&rev=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyFhirJsonController.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/FhirJsonFormatter.java Fri May  1 16:38:31 2020
@@ -1,4 +1,4 @@
-package org.apache.ctakes.rest.service;
+package org.apache.ctakes.rest.service.response;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -22,17 +22,13 @@ package org.apache.ctakes.rest.service;
 import org.apache.ctakes.fhir.cc.FhirJsonWriter;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.jcas.JCas;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 
 
 /*
  * Rest web service that takes clinical text
  * as input and produces extracted text as output
  */
-@RestController
-@RequestMapping( "/fhirjson" )
-public class TinyFhirJsonController extends AbstractTinyController {
+final public class FhirJsonFormatter implements ResponseFormatter {
 
    /**
     * Returns the document information according to the fhir standard, formatted in json.

Copied: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PrettyPrintFormatter.java (from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPrettyPrintController.java)
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PrettyPrintFormatter.java?p2=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PrettyPrintFormatter.java&p1=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPrettyPrintController.java&r1=1877263&r2=1877264&rev=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPrettyPrintController.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PrettyPrintFormatter.java Fri May  1 16:38:31 2020
@@ -1,4 +1,4 @@
-package org.apache.ctakes.rest.service;
+package org.apache.ctakes.rest.service.response;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -24,8 +24,6 @@ import org.apache.ctakes.typesystem.type
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.fit.util.JCasUtil;
 import org.apache.uima.jcas.JCas;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 
 import java.io.BufferedWriter;
 import java.io.IOException;
@@ -37,9 +35,7 @@ import java.util.Collection;
  * Rest web service that takes clinical text
  * as input and produces extracted text as output
  */
-@RestController
-@RequestMapping( "/prettyprint" )
-public class TinyPrettyPrintController extends AbstractTinyController {
+final public class PrettyPrintFormatter implements ResponseFormatter {
 
 
    /**

Copied: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PropertyListFormatter.java (from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPropertyController.java)
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PropertyListFormatter.java?p2=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PropertyListFormatter.java&p1=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPropertyController.java&r1=1877263&r2=1877264&rev=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyPropertyController.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/PropertyListFormatter.java Fri May  1 16:38:31 2020
@@ -1,4 +1,4 @@
-package org.apache.ctakes.rest.service;
+package org.apache.ctakes.rest.service.response;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -24,8 +24,6 @@ import org.apache.ctakes.typesystem.type
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.fit.util.JCasUtil;
 import org.apache.uima.jcas.JCas;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 
 import java.io.BufferedWriter;
 import java.io.IOException;
@@ -37,9 +35,7 @@ import java.util.Collection;
  * Rest web service that takes clinical text
  * as input and produces extracted text as output
  */
-@RestController
-@RequestMapping( "/property" )
-public class TinyPropertyController extends AbstractTinyController {
+final public class PropertyListFormatter implements ResponseFormatter {
 
 
    /**

Added: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/ResponseFormatter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/ResponseFormatter.java?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/ResponseFormatter.java (added)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/ResponseFormatter.java Fri May  1 16:38:31 2020
@@ -0,0 +1,25 @@
+package org.apache.ctakes.rest.service.response;
+
+import org.apache.ctakes.fhir.cc.FhirJsonWriter;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.jcas.JCas;
+
+/**
+ * Formats desired information in jCas to a string.
+ *
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 5/1/2020
+ */
+public interface ResponseFormatter {
+
+   /**
+    * @param jCas ye olde ...
+    * @return a string containing information from jcas.
+    * @throws AnalysisEngineProcessException hopefully not.
+    */
+   default String getResultText( final JCas jCas ) throws AnalysisEngineProcessException {
+      return FhirJsonWriter.createJson( jCas );
+   }
+
+}

Added: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/UmlsJsonFormatter.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/UmlsJsonFormatter.java?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/UmlsJsonFormatter.java (added)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/UmlsJsonFormatter.java Fri May  1 16:38:31 2020
@@ -0,0 +1,127 @@
+package org.apache.ctakes.rest.service.response;
+
+import com.google.gson.GsonBuilder;
+import org.apache.ctakes.core.util.annotation.IdentifiedAnnotationUtil;
+import org.apache.ctakes.core.util.annotation.OntologyConceptUtil;
+import org.apache.ctakes.core.util.annotation.SemanticTui;
+import org.apache.ctakes.typesystem.type.refsem.UmlsConcept;
+import org.apache.ctakes.typesystem.type.textsem.*;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.util.JCasUtil;
+import org.apache.uima.jcas.JCas;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 5/1/2020
+ */
+final public class UmlsJsonFormatter implements ResponseFormatter {
+
+   static private final List<Class<? extends IdentifiedAnnotation>> WANTED_CLASSES = Arrays.asList(
+         // UMLS types:
+         DiseaseDisorderMention.class,
+         SignSymptomMention.class,
+         ProcedureMention.class,
+         AnatomicalSiteMention.class,
+         MedicationMention.class
+   );
+
+
+   /**
+    * Returns UMLS identified annotation information formatted in json.
+    * {@inheritDoc}
+    */
+   @Override
+   public String getResultText( final JCas jCas ) throws AnalysisEngineProcessException {
+      final Map<String, List<UmlsObject>> umlsMap
+            = JCasUtil.select( jCas, IdentifiedAnnotation.class ).stream()
+                      .filter( a -> WANTED_CLASSES.contains( a.getClass() ) )
+                      .map( UmlsObject::new )
+                      .collect( Collectors.groupingBy( UmlsObject::getType ) );
+      return new GsonBuilder()
+            .setPrettyPrinting()
+            .create()
+            .toJson( umlsMap );
+   }
+
+
+   static public class UmlsObject {
+      final private String _type;
+      final public int begin;
+      final public int end;
+      final public String text;
+      final public Boolean negated;
+      final public Boolean uncertain;
+      final public Boolean generic;
+      final public Boolean conditional;
+      final public Boolean historic;
+
+      public Map<String, List<OntologyObject>> conceptMap;
+
+      private UmlsObject( final IdentifiedAnnotation annotation ) {
+         _type = annotation.getClass().getSimpleName();
+         begin = annotation.getBegin();
+         end = annotation.getEnd();
+         text = annotation.getCoveredText();
+         negated = booleanOrNull( IdentifiedAnnotationUtil.isNegated( annotation ) );
+         uncertain = booleanOrNull( IdentifiedAnnotationUtil.isUncertain( annotation ) );
+         generic = booleanOrNull( IdentifiedAnnotationUtil.isGeneric( annotation ) );
+         conditional = booleanOrNull( IdentifiedAnnotationUtil.isConditional( annotation ) );
+         historic = booleanOrNull( IdentifiedAnnotationUtil.isHistoric( annotation ) );
+         conceptMap
+               = OntologyConceptUtil.getUmlsConceptStream( annotation )
+                                    .map( OntologyObject::new )
+                                    .collect( Collectors.groupingBy( OntologyObject::getSemanticGroup ) );
+         if ( conceptMap.isEmpty() ) {
+            conceptMap = null;
+         }
+      }
+
+      final public String getType() {
+         return _type;
+      }
+
+      // gson can ignore (not serialize) properties with null values.
+      static private Boolean booleanOrNull( final boolean value ) {
+         return value ? Boolean.TRUE : null;
+      }
+   }
+
+   static private class OntologyObject {
+      final public String semanticGroup;
+      final public String semanticType;
+      final public String preferredText;
+      final public String cui;
+      final public String tui;
+      final public String codingScheme;
+      final public String code;
+
+      private OntologyObject( final UmlsConcept concept ) {
+         preferredText = textOrNull( concept.getPreferredText() );
+         cui = textOrNull( concept.getCui() );
+         final SemanticTui semanticTui = SemanticTui.getTui( concept );
+         semanticGroup = semanticTui.getGroupName();
+         semanticType = semanticTui.getSemanticType();
+         tui = textOrNull( concept.getTui() );
+         codingScheme = textOrNull( concept.getCodingScheme() );
+         code = textOrNull( concept.getCode() );
+      }
+
+      private String getSemanticGroup() {
+         return semanticGroup;
+      }
+
+      // gson can ignore (not serialize) properties with null values.
+      static private String textOrNull( final String text ) {
+         return text.isEmpty() ? null : text;
+      }
+   }
+
+
+}
\ No newline at end of file

Copied: ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/XmiFormatter.java (from r1877263, ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyXmiController.java)
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/XmiFormatter.java?p2=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/XmiFormatter.java&p1=ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyXmiController.java&r1=1877263&r2=1877264&rev=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/TinyXmiController.java (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/java/org/apache/ctakes/rest/service/response/XmiFormatter.java Fri May  1 16:38:31 2020
@@ -1,4 +1,4 @@
-package org.apache.ctakes.rest.service;
+package org.apache.ctakes.rest.service.response;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -23,8 +23,6 @@ import org.apache.ctakes.core.cc.XMISeri
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
 import org.apache.uima.cas.impl.XmiCasSerializer;
 import org.apache.uima.jcas.JCas;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import org.xml.sax.SAXException;
 
 import java.io.BufferedOutputStream;
@@ -37,9 +35,7 @@ import java.io.OutputStream;
  * Rest web service that takes clinical text
  * as input and produces extracted text as output
  */
-@RestController
-@RequestMapping( "/xmi" )
-public class TinyXmiController extends AbstractTinyController {
+final public class XmiFormatter implements ResponseFormatter {
 
 
    /**

Added: ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/index.css
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/index.css?rev=1877264&view=auto
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/index.css (added)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/webapp/css/index.css Fri May  1 16:38:31 2020
@@ -0,0 +1,13 @@
+header {
+  text-align: center;
+}
+textarea {
+    display: block;
+    margin-left: auto;
+    margin-right: auto;
+}
+.center {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+}

Modified: ctakes/trunk/ctakes-tiny-rest/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/webapp/index.jsp?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/webapp/index.jsp (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/webapp/index.jsp Fri May  1 16:38:31 2020
@@ -1,26 +1,28 @@
 <!DOCTYPE html>
 
 <html>
-    <head>
-<!--        <link rel="stylesheet" type="text/css" href="css/index.css">    -->
-        <title> cTAKES Proof of Function Service </title>
-		<script type="text/javascript" src="js/jquery.js"></script>			
-		<script type="text/javascript" src="js/app.js"></script>
-        <script>var myContextPath = "${pageContext.request.contextPath}"</script>
-    </head>
-    <body>
-        <img src="http://ctakes.apache.org/images/ctakes_logo.jpg"/>
-        <br>Version: 4.0.1</br>
-		</br>
-        <h3>cTAKES Tiny REST Service Tester</h3>
-        <textarea id="documentText" name="documentText" rows="6" cols="75" onFocus="this.value=''">Enter your text for analysis.</textarea>
-        <br>
-        <input type="button" value="FHIR" name="fhirjson" id="fhirjson"/>
-        <input type="button" value="Text" name="text" id="text"/>
-        <input type="button" value="Property" name="property" id="property"/>
-        <input type="button" value="XMI" name="xmi" id="xmi"/>
-        <br>
-         <textarea id="resultText" name="resultText" rows="6" cols="75" readonly>Your Result will appear here.</textarea>
-         <br>
-</body>
+   <head>
+      <link rel="stylesheet" type="text/css" href="css/index.css">
+      <title> cTAKES Proof of Function Service </title>
+      <script type="text/javascript" src="js/jquery.js"></script>
+      <script type="text/javascript" src="js/app.js"></script>
+      <script>var myContextPath = "${pageContext.request.contextPath}"</script>
+   </head>
+   <body>
+      <img src="http://ctakes.apache.org/images/ctakes_logo.jpg" alt="Apache cTAKES" class="center"/>
+      <h3>Apache cTAKES 4.0.1 Tiny REST Service Tester</h3>
+      <label>Input Text: </label>
+      <textarea id="documentText" name="documentText" rows="20" cols="80" onFocus="this.value=''">Enter your text for analysis.</textarea>
+      <br>
+      <label>Process and output: </label>
+      <input type="button" value="FHIR" name="fhirjson" id="fhirjson"/>
+      <input type="button" value="Text" name="text" id="text"/>
+      <input type="button" value="Property" name="property" id="property"/>
+      <input type="button" value="UMLS" name="umlsJson" id="umlsJson"/>
+      <input type="button" value="CUI" name="cui" id="cui"/>
+      <input type="button" value="XMI" name="xmi" id="xmi"/>
+      <br>
+      <textarea id="resultText" name="resultText" rows="20" cols="80" readonly>Your Result will appear here.</textarea>
+      <br>
+   </body>
 </html>

Modified: ctakes/trunk/ctakes-tiny-rest/src/main/webapp/js/app.js
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/src/main/webapp/js/app.js?rev=1877264&r1=1877263&r2=1877264&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/src/main/webapp/js/app.js (original)
+++ ctakes/trunk/ctakes-tiny-rest/src/main/webapp/js/app.js Fri May  1 16:38:31 2020
@@ -3,14 +3,14 @@ $(document).ready(function() {
          document.getElementById("resultText").innerHTML = "Processing ...";
          try {
             $.ajax({
-				url: myContextPath + "/service/fhirjson",
+				url: myContextPath + "/service/process?format=fhir",
 				type: "POST",
 				crossDomain: true,
 				cache: false,
 				async: true,
 				data: document.getElementById("documentText").value,
 				error: function(xhr, statusText, error) {
-					 document.getElementById("resultText").innerHTML = "Error processing REST call";
+					 document.getElementById("resultText").innerHTML = "Error processing REST call\n" + xhr + "\n" + statusText + "\n" + error;
 				},
 				success: function(response, statusText, xhr) {
 				   document.getElementById("resultText").innerHTML = response;
@@ -24,7 +24,7 @@ $(document).ready(function() {
          document.getElementById("resultText").innerHTML = "Processing ...";
          try {
             $.ajax({
-				url: myContextPath + "/service/text",
+				url: myContextPath + "/service/process?format=pretty",
 				type: "POST",
 				crossDomain: true,
 				cache: false,
@@ -45,7 +45,49 @@ $(document).ready(function() {
          document.getElementById("resultText").innerHTML = "Processing ...";
          try {
             $.ajax({
-				url: myContextPath + "/service/property",
+				url: myContextPath + "/service/process?format=property",
+				type: "POST",
+				crossDomain: true,
+				cache: false,
+				async: true,
+				data: document.getElementById("documentText").value,
+				error: function(xhr, statusText, error) {
+					 document.getElementById("resultText").innerHTML = "Error processing REST call";
+				},
+				success: function(response, statusText, xhr) {
+				   document.getElementById("resultText").innerHTML = response;
+				}
+			})
+        } catch (err) {
+             document.getElementById("resultText").innerHTML = "Error invoking REST call";
+        }
+    });
+     $('#umlsJson').click(function() {
+         document.getElementById("resultText").innerHTML = "Processing ...";
+         try {
+            $.ajax({
+				url: myContextPath + "/service/process?format=umls",
+				type: "POST",
+				crossDomain: true,
+				cache: false,
+				async: true,
+				data: document.getElementById("documentText").value,
+				error: function(xhr, statusText, error) {
+					 document.getElementById("resultText").innerHTML = "Error processing REST call";
+				},
+				success: function(response, statusText, xhr) {
+				   document.getElementById("resultText").innerHTML = response;
+				}
+			})
+        } catch (err) {
+             document.getElementById("resultText").innerHTML = "Error invoking REST call";
+        }
+    });
+     $('#cui').click(function() {
+         document.getElementById("resultText").innerHTML = "Processing ...";
+         try {
+            $.ajax({
+				url: myContextPath + "/service/process?format=cui",
 				type: "POST",
 				crossDomain: true,
 				cache: false,
@@ -66,7 +108,7 @@ $(document).ready(function() {
          document.getElementById("resultText").innerHTML = "Processing ...";
          try {
             $.ajax({
-				url: myContextPath + "/service/xmi",
+				url: myContextPath + "/service/process?format=xmi",
 				type: "POST",
 				crossDomain: true,
 				cache: false,