This is an automated email from the ASF dual-hosted git repository.

seanfinan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ctakes.git


The following commit(s) were added to refs/heads/main by this push:
     new fa72585  A bunch of comments for ctakes-web-rest regarding possible 
future development. Moved pom versions from dependencies to properties. 
Refactored CuiResponse to use newer utility code.
fa72585 is described below

commit fa725852f97c86645e1e89ab7f74c5807c74604b
Author: Sean Finan <[email protected]>
AuthorDate: Wed Dec 28 11:38:01 2022 -0500

    A bunch of comments for ctakes-web-rest regarding possible future 
development.
    Moved pom versions from dependencies to properties.
    Refactored CuiResponse to use newer utility code.
---
 ctakes-web-rest/docker/Dockerfile                  | 10 ++++++-
 ctakes-web-rest/pom.xml                            | 23 ++++++++++------
 .../apache/ctakes/rest/service/CuiResponse.java    | 32 ++++++++++++----------
 3 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/ctakes-web-rest/docker/Dockerfile 
b/ctakes-web-rest/docker/Dockerfile
index 2525bb4..6c82ff5 100644
--- a/ctakes-web-rest/docker/Dockerfile
+++ b/ctakes-web-rest/docker/Dockerfile
@@ -1,5 +1,13 @@
 FROM openjdk:8-alpine
-  
+
+## This Dockerfile checks out and builds all of ctakes.  Is there a reason for 
this?
+## If you just checked in some fresh code and can't wait for a jenkins build 
then ok.
+## Otherwise you can just check out the ctakes-web-rest directory and build it 
for the war.
+## You can also add ctakes-web-rest as a dependency in a -dummy- pom with an 
output directory for the war.
+## If you do have brand new code then another tactic is a copy of local source 
into the container, then building.
+## That is more useful for developers who are not ctakes committers.
+## Consider offering multiple dockerfiles.
+
 RUN apk update && \
     apk add --no-cache git openssh ca-certificates openssl wget unzip 
subversion maven
 
diff --git a/ctakes-web-rest/pom.xml b/ctakes-web-rest/pom.xml
index 73f8bc2..bafb54a 100644
--- a/ctakes-web-rest/pom.xml
+++ b/ctakes-web-rest/pom.xml
@@ -14,13 +14,20 @@
                <ctakes.version>5.0.0-SNAPSHOT</ctakes.version>
                
<springframework.version>4.3.12.RELEASE</springframework.version>
                <jackson.version>2.9.7</jackson.version>
+      <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
+      <maven.war.plugin.version>3.2.3</maven.war.plugin.version>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <jettyVersion>9.2.6.v20141205</jettyVersion>
+      <spring.version>4.3.12.RELEASE</spring.version>
+      <uimafit.version>2.4.0</uimafit.version>
+      <uimaj.version>2.10.2</uimaj.version>
+      <servlet.version>2.5</servlet.version>
+      <mysql.connect.version>6.0.6</mysql.connect.version>
        </properties>
        <dependencies>
-<!--      TODO   Exclusions.  See the pom files in dockhand goal/rest/pom/ -->
+<!--      TODO   Any Exclusions?  See the pom files in dockhand goal/rest/pom/ 
-->
       <dependency>
          <groupId>org.apache.ctakes</groupId>
          <artifactId>ctakes-type-system</artifactId>
@@ -141,28 +148,28 @@
       <dependency>
          <groupId>org.apache.uima</groupId>
          <artifactId>uimaj-core</artifactId>
-         <version>2.10.2</version>
+         <version>${uimaj.version}</version>
       </dependency>
         <dependency>
             <groupId>org.apache.uima</groupId>
             <artifactId>uimaj-json</artifactId>
-            <version>2.10.2</version>
+            <version>${uimaj.version}</version>
         </dependency>
       <dependency>
          <groupId>org.apache.uima</groupId>
          <artifactId>uimafit-core</artifactId>
-         <version>2.4.0</version>
+         <version>${uimafit.version}</version>
       </dependency>
                <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
-                       <version>6.0.6</version>
+                       <version>${mysql.connect.version}</version>
                </dependency>
 
                <dependency>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
-                       <version>2.5</version>
+                       <version>${servlet.version}</version>
                        <scope>provided</scope>
                </dependency>
                <dependency>
@@ -227,7 +234,7 @@
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-war-plugin</artifactId>
-            <version>3.2.3</version>
+            <version>${maven.war.plugin.version}</version>
             <configuration>
                <warName>ctakes-web-rest</warName>
                <outputDirectory>${project.build.directory}</outputDirectory>
@@ -236,7 +243,7 @@
 
          <plugin>
                                <artifactId>maven-compiler-plugin</artifactId>
-                               <version>2.4</version>
+                               
<version>${maven.compiler.plugin.version}</version>
                                <configuration>
                                        <source>1.8</source>
                                        <target>1.8</target>
diff --git 
a/ctakes-web-rest/src/main/java/org/apache/ctakes/rest/service/CuiResponse.java 
b/ctakes-web-rest/src/main/java/org/apache/ctakes/rest/service/CuiResponse.java
index 5786933..8def380 100644
--- 
a/ctakes-web-rest/src/main/java/org/apache/ctakes/rest/service/CuiResponse.java
+++ 
b/ctakes-web-rest/src/main/java/org/apache/ctakes/rest/service/CuiResponse.java
@@ -18,20 +18,22 @@
  */
 package org.apache.ctakes.rest.service;
 
+import org.apache.ctakes.core.util.annotation.OntologyConceptUtil;
+import org.apache.ctakes.typesystem.type.refsem.OntologyConcept;
 import org.apache.ctakes.typesystem.type.refsem.UmlsConcept;
 import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
-import org.apache.uima.fit.util.JCasUtil;
 import org.apache.uima.jcas.tcas.Annotation;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Created by tmill on 12/20/18.
  */
 public class CuiResponse {
+    // TODO - We don't seem to be returning relations (etc.) anywhere, so why 
does the war contain so many modules?
+    // TODO - consider having multiple return types available.  see 
ctakes-tiny-rest service/response/* and
+    //  service/TinyController.
+    // TODO - consider an additional json such as UmlsJsonFormatter.
     final private String _type;
     public int begin;
     public int end;
@@ -46,17 +48,19 @@ public class CuiResponse {
         text = annotation.getCoveredText();
 
         if(annotation instanceof IdentifiedAnnotation) {
-            IdentifiedAnnotation ia = (IdentifiedAnnotation) annotation;
+            final IdentifiedAnnotation ia = (IdentifiedAnnotation) annotation;
             polarity = ia.getPolarity();
-            if(ia.getOntologyConceptArr() != null) {
-                for (UmlsConcept concept : 
JCasUtil.select(ia.getOntologyConceptArr(), UmlsConcept.class)) {
-                    Map<String, String> atts = new HashMap<>();
-                    atts.put("codingScheme", concept.getCodingScheme());
-                    atts.put("cui", concept.getCui());
-                    atts.put("code", concept.getCode() == null ? "n/a" : 
concept.getCode());
-                    atts.put("tui", concept.getTui());
-                    conceptAttributes.add(atts);
+            final Collection<OntologyConcept> concepts
+                  = OntologyConceptUtil.getOntologyConcepts( ia );
+            for ( OntologyConcept concept : concepts ) {
+                final Map<String,String> attributes = new HashMap<>();
+                attributes.put( "codingScheme", concept.getCodingScheme() );
+                attributes.put( "code", concept.getCode() == null ? "n/a" : 
concept.getCode() );
+                if ( concept instanceof UmlsConcept ) {
+                    attributes.put( "cui", ( (UmlsConcept) concept ).getCui() 
);
+                    attributes.put("tui", ( (UmlsConcept) concept ).getTui() );
                 }
+                conceptAttributes.add( attributes );
             }
         }
     }

Reply via email to