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/07 15:08:59 UTC

svn commit: r1877474 - in /ctakes/trunk: ./ ctakes-distribution/ ctakes-distribution/src/main/assembly/ ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/ ctakes-tiny-rest/ ctakes-web-rest/

Author: seanfinan
Date: Thu May  7 15:08:59 2020
New Revision: 1877474

URL: http://svn.apache.org/viewvc?rev=1877474&view=rev
Log:
Refactoring : extracted BundleParser, BundleReader from fhir readers
TODO : ctakes-web-rest should not contain a complete copy of all ctakes resources.  maven-resources-plugin should be used to copy them.
A major change for ytex-web users:  It is no longer a dependency in ctakes (main) and ctakes-distribution.
Just like ctakes-web-rest and other war modules, it must be built separately.
This is primarily to prevent the constantly broken build, but also because the war is physically separate from the ctakes (main) build.

Added:
    ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleParser.java
    ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleReader.java
Modified:
    ctakes/trunk/ctakes-distribution/pom.xml
    ctakes/trunk/ctakes-distribution/src/main/assembly/bin.xml
    ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirJsonFileReader.java
    ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirXmlFileReader.java
    ctakes/trunk/ctakes-tiny-rest/pom.xml
    ctakes/trunk/ctakes-web-rest/pom.xml
    ctakes/trunk/pom.xml

Modified: ctakes/trunk/ctakes-distribution/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-distribution/pom.xml?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-distribution/pom.xml (original)
+++ ctakes/trunk/ctakes-distribution/pom.xml Thu May  7 15:08:59 2020
@@ -127,13 +127,13 @@
 		<dependency>
 			<groupId>org.apache.ctakes</groupId>
 			<artifactId>ctakes-ytex-uima</artifactId>
-		</dependency>						
-		<dependency>
-			<groupId>org.apache.ctakes</groupId>
-			<artifactId>ctakes-ytex-web</artifactId>
-			<version>${project.version}</version>
-			<classifier>classes</classifier>
 		</dependency>
+		<!--		<dependency>-->
+		<!--			<groupId>org.apache.ctakes</groupId>-->
+		<!--			<artifactId>ctakes-ytex-web</artifactId>-->
+		<!--			<version>${project.version}</version>-->
+		<!--			<classifier>classes</classifier>-->
+		<!--		</dependency>-->
       <dependency>
          <groupId>org.apache.ctakes</groupId>
          <artifactId>ctakes-gui</artifactId>

Modified: ctakes/trunk/ctakes-distribution/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-distribution/src/main/assembly/bin.xml?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-distribution/src/main/assembly/bin.xml (original)
+++ ctakes/trunk/ctakes-distribution/src/main/assembly/bin.xml Thu May  7 15:08:59 2020
@@ -62,7 +62,7 @@
 				<include>org.apache.ctakes:ctakes-utils</include>
 				<include>org.apache.ctakes:ctakes-ytex</include>
 				<include>org.apache.ctakes:ctakes-ytex-uima</include>
-				<include>org.apache.ctakes:ctakes-ytex-web</include>
+				<!--				<include>org.apache.ctakes:ctakes-ytex-web</include>-->
 				<include>org.apache.ctakes:ctakes-examples</include>
 			</includes>
 			
@@ -253,14 +253,14 @@
 			<directoryMode>755</directoryMode>
 		      <includes>
 		        <include>*/desc/**</include>
-		      </includes>			
-		</fileSet>	
-		<fileSet>
-			<directory>../ctakes-ytex-web/src/main/webapp</directory>
-			<outputDirectory>desc/ctakes-ytex-web</outputDirectory>
-			<fileMode>644</fileMode>
-			<directoryMode>755</directoryMode>
+		      </includes>
 		</fileSet>
+		<!--		<fileSet>-->
+		<!--			<directory>../ctakes-ytex-web/src/main/webapp</directory>-->
+		<!--			<outputDirectory>desc/ctakes-ytex-web</outputDirectory>-->
+		<!--			<fileMode>644</fileMode>-->
+		<!--			<directoryMode>755</directoryMode>-->
+		<!--		</fileSet>-->
 		<fileSet>
 			<directory>../ctakes-ytex/scripts</directory>
 			<outputDirectory>bin/ctakes-ytex/scripts</outputDirectory>

Added: ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleParser.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleParser.java?rev=1877474&view=auto
==============================================================================
--- ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleParser.java (added)
+++ ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleParser.java Thu May  7 15:08:59 2020
@@ -0,0 +1,168 @@
+package org.apache.ctakes.fhir.cr;
+
+import org.apache.ctakes.core.util.RelationArgumentUtil;
+import org.apache.ctakes.fhir.element.FhirElementParser;
+import org.apache.ctakes.fhir.resource.*;
+import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
+import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.hl7.fhir.dstu3.model.*;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.hl7.fhir.utilities.xhtml.XhtmlNode;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.ctakes.fhir.element.FhirElementFactory.CTAKES_FHIR_URL;
+import static org.apache.ctakes.fhir.element.FhirElementFactory.RELATION_EXT_PREFIX;
+import static org.apache.ctakes.fhir.resource.AnnotationCreator.ID_NAME_ANNOTATION;
+import static org.apache.ctakes.fhir.resource.BaseTokenCreator.ID_NAME_BASE_TOKEN;
+import static org.apache.ctakes.fhir.resource.IdentifiedAnnotationCreator.ID_NAME_IDENTIFIED_ANNOTATION;
+import static org.apache.ctakes.fhir.resource.ParagraphCreator.ID_NAME_PARAGRAPH;
+import static org.apache.ctakes.fhir.resource.SectionCreator.ID_NAME_SECTION;
+import static org.apache.ctakes.fhir.resource.SentenceCreator.ID_NAME_SENTENCE;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 5/1/2020
+ */
+final public class BundleParser {
+
+   private BundleParser() {
+   }
+
+
+   static public void parseBundle( final JCas jCas, final Bundle bundle ) throws IOException {
+      final CompositionParser compositionParser = new CompositionParser();
+      final SectionParser sectionParser = new SectionParser();
+      final ParagraphParser paragraphParser = new ParagraphParser();
+      final SentenceParser sentenceParser = new SentenceParser();
+      final BaseTokenParser baseTokenParser = new BaseTokenParser();
+      final AnnotationParser annotationParser = new AnnotationParser();
+      final IdentifiedAnnotationParser iaParser = new IdentifiedAnnotationParser();
+      // Build map of resources to annotations, sections, etc.
+      final List<Bundle.BundleEntryComponent> entries = bundle.getEntry();
+      final Map<IBaseResource, Annotation> resourceAnnotations = parseResources( jCas, entries,
+            compositionParser, sectionParser, paragraphParser, sentenceParser, baseTokenParser,
+            annotationParser, iaParser );
+
+      // Go through the (Basic) entries in the map and build relations
+      for ( Map.Entry<IBaseResource, Annotation> resourceAnnotation : resourceAnnotations.entrySet() ) {
+         if ( !Basic.class.isInstance( resourceAnnotation.getKey() ) ) {
+            continue;
+         }
+         final Basic basic = (Basic)resourceAnnotation.getKey();
+         final List<Extension> extensions = basic.getExtension();
+         for ( Extension extension : extensions ) {
+            final String url = extension.getUrl();
+            if ( url.startsWith( CTAKES_FHIR_URL + RELATION_EXT_PREFIX ) ) {
+               final Type type = extension.getValue();
+               if ( type instanceof Reference ) {
+                  final IBaseResource resource = ((Reference)type).getResource();
+                  final Annotation target = resourceAnnotations.get( resource );
+                  if ( target != null ) {
+                     createRelation( jCas, url, resourceAnnotation.getValue(), target );
+                  }
+               }
+            }
+         }
+      }
+
+      // TODO build Map<Integer,Collection<Annotation>> with coref chain index to annotations that belong from the Basic Extensions
+   }
+
+
+   static private Map<IBaseResource, Annotation> parseResources( final JCas jCas,
+                                                                 final List<Bundle.BundleEntryComponent> entries,
+                                                                 final CompositionParser compositionParser,
+                                                                 final SectionParser sectionParser,
+                                                                 final ParagraphParser paragraphParser,
+                                                                 final SentenceParser sentenceParser,
+                                                                 final BaseTokenParser baseTokenParser,
+                                                                 final AnnotationParser annotationParser,
+                                                                 final IdentifiedAnnotationParser iaParser ) {
+      final Map<IBaseResource, Annotation> resourceAnnotations = new HashMap<>( entries.size() );
+      for ( Bundle.BundleEntryComponent entry : entries ) {
+         final IBaseResource resource = entry.getResource();
+         final Annotation annotation = parseResource( jCas, resource,
+               compositionParser, sectionParser, paragraphParser, sentenceParser, baseTokenParser,
+               annotationParser, iaParser );
+         if ( annotation != null ) {
+            resourceAnnotations.put( resource, annotation );
+         }
+      }
+      return resourceAnnotations;
+   }
+
+   static private Annotation parseResource( final JCas jCas,
+                                            final IBaseResource resource,
+                                            final CompositionParser compositionParser,
+                                            final SectionParser sectionParser,
+                                            final ParagraphParser paragraphParser,
+                                            final SentenceParser sentenceParser,
+                                            final BaseTokenParser baseTokenParser,
+                                            final AnnotationParser annotationParser,
+                                            final IdentifiedAnnotationParser iaParser ) {
+      if ( resource instanceof Composition ) {
+         final Narrative narrative = ((Composition)resource).getText();
+         final XhtmlNode html = narrative.getDiv();
+         final String docText = html.allText();
+         jCas.setDocumentText( docText );
+         return null;
+      }
+      Annotation annotation = null;
+      if ( resource instanceof Basic ) {
+         final Basic basic = (Basic)resource;
+         final String idName = FhirElementParser.getIdName( basic.getId() );
+         switch ( idName ) {
+            case ID_NAME_SECTION:
+               annotation = sectionParser.parseResource( jCas, basic );
+               break;
+            case ID_NAME_PARAGRAPH:
+               annotation = paragraphParser.parseResource( jCas, basic );
+               break;
+            case ID_NAME_SENTENCE:
+               annotation = sentenceParser.parseResource( jCas, basic );
+               break;
+            case ID_NAME_BASE_TOKEN:
+               annotation = baseTokenParser.parseResource( jCas, basic );
+               break;
+            case ID_NAME_ANNOTATION:
+               annotation = annotationParser.parseResource( jCas, basic );
+               break;
+            case ID_NAME_IDENTIFIED_ANNOTATION:
+               annotation = iaParser.parseResource( jCas, basic );
+               break;
+         }
+         if ( annotation != null ) {
+            annotation.addToIndexes();
+            return annotation;
+         }
+      }
+      return null;
+   }
+
+   static private void createRelation( final JCas jCas, final String url,
+                                       final Annotation source, final Annotation target ) {
+      if ( source instanceof IdentifiedAnnotation && target instanceof IdentifiedAnnotation ) {
+         final String category = url.substring( (CTAKES_FHIR_URL + RELATION_EXT_PREFIX).length() );
+         final BinaryTextRelation relation
+               = RelationArgumentUtil.createRelation( jCas, (IdentifiedAnnotation)source, (IdentifiedAnnotation)target,
+               category );
+         relation.addToIndexes();
+      }
+   }
+
+
+   // TODO
+   static private void createCoreference( final JCas jCas, Collection<Annotation> marked ) {
+
+   }
+
+
+}
\ No newline at end of file

Added: ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleReader.java?rev=1877474&view=auto
==============================================================================
--- ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleReader.java (added)
+++ ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/BundleReader.java Thu May  7 15:08:59 2020
@@ -0,0 +1,72 @@
+package org.apache.ctakes.fhir.cr;
+
+import ca.uhn.fhir.context.ConfigurationException;
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.parser.DataFormatException;
+import ca.uhn.fhir.parser.IParser;
+import org.hl7.fhir.dstu3.model.Bundle;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+import java.io.*;
+import java.util.logging.Logger;
+
+/**
+ * @author SPF , chip-nlp
+ * @version %I%
+ * @since 5/1/2020
+ */
+final public class BundleReader {
+
+   private BundleReader() {
+   }
+
+   static private final Logger LOGGER = Logger.getLogger( "BundleReader" );
+
+
+   static public Bundle readJsonBundle( final File file ) throws IOException {
+      final FhirContext fhirContext = FhirContext.forDstu3();
+      return readFileBundle( fhirContext.newJsonParser(), file );
+   }
+
+   static public Bundle readJsonBundle( final String text ) throws IOException {
+      IBaseResource baseResource;
+      final FhirContext fhirContext = FhirContext.forDstu3();
+      final IParser jsonParser = fhirContext.newJsonParser();
+      try {
+         baseResource = jsonParser.parseResource( text );
+      } catch ( ConfigurationException | DataFormatException multE ) {
+         throw new IOException( multE );
+      }
+      if ( baseResource == null ) {
+         throw new IOException( "Null Bundle" );
+      }
+      if ( !Bundle.class.isInstance( baseResource ) ) {
+         throw new IOException( "Resource is not a Bundle" );
+      }
+      return (Bundle)baseResource;
+   }
+
+   static public Bundle readXmlBundle( final File file ) throws IOException {
+      final FhirContext fhirContext = FhirContext.forDstu3();
+      return readFileBundle( fhirContext.newXmlParser(), file );
+   }
+
+   static private Bundle readFileBundle( final IParser iParser, final File file ) throws IOException {
+      IBaseResource baseResource;
+      final FhirContext fhirContext = FhirContext.forDstu3();
+      try ( Reader reader = new BufferedReader( new FileReader( file ) ) ) {
+         baseResource = iParser.parseResource( reader );
+      } catch ( IOException | ConfigurationException | DataFormatException multE ) {
+         throw new IOException( "Could not read fhir from " + file.getAbsolutePath(), multE );
+      }
+      if ( baseResource == null ) {
+         throw new IOException( "Null Bundle for file " + file.getAbsolutePath() );
+      }
+      if ( !Bundle.class.isInstance( baseResource ) ) {
+         throw new IOException( "Resource is not a Bundle for file " + file.getAbsolutePath() );
+      }
+      return (Bundle)baseResource;
+   }
+
+
+}

Modified: ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirJsonFileReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirJsonFileReader.java?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirJsonFileReader.java (original)
+++ ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirJsonFileReader.java Thu May  7 15:08:59 2020
@@ -1,38 +1,13 @@
 package org.apache.ctakes.fhir.cr;
 
-import ca.uhn.fhir.context.ConfigurationException;
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.parser.DataFormatException;
-import ca.uhn.fhir.parser.IParser;
 import org.apache.ctakes.core.cr.AbstractFileTreeReader;
 import org.apache.ctakes.core.pipeline.PipeBitInfo;
-import org.apache.ctakes.core.util.RelationArgumentUtil;
-import org.apache.ctakes.fhir.element.FhirElementParser;
-import org.apache.ctakes.fhir.resource.*;
-import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
-import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.log4j.Logger;
 import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.tcas.Annotation;
-import org.hl7.fhir.dstu3.model.*;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.utilities.xhtml.XhtmlNode;
-
-import java.io.*;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.ctakes.fhir.element.FhirElementFactory.CTAKES_FHIR_URL;
-import static org.apache.ctakes.fhir.element.FhirElementFactory.RELATION_EXT_PREFIX;
-import static org.apache.ctakes.fhir.resource.AnnotationCreator.ID_NAME_ANNOTATION;
-import static org.apache.ctakes.fhir.resource.BaseTokenCreator.ID_NAME_BASE_TOKEN;
-import static org.apache.ctakes.fhir.resource.IdentifiedAnnotationCreator.ID_NAME_IDENTIFIED_ANNOTATION;
-import static org.apache.ctakes.fhir.resource.ParagraphCreator.ID_NAME_PARAGRAPH;
-import static org.apache.ctakes.fhir.resource.SectionCreator.ID_NAME_SECTION;
-import static org.apache.ctakes.fhir.resource.SentenceCreator.ID_NAME_SENTENCE;
-import static org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
+import org.hl7.fhir.dstu3.model.Bundle;
+
+import java.io.File;
+import java.io.IOException;
 
 
 /**
@@ -57,139 +32,9 @@ public class FhirJsonFileReader extends
    protected void readFile( final JCas jCas, final File file ) throws IOException {
       jCas.reset();
 
-      final Bundle bundle = readBundle( file );
-
-      final CompositionParser compositionParser = new CompositionParser();
-      final SectionParser sectionParser = new SectionParser();
-      final ParagraphParser paragraphParser = new ParagraphParser();
-      final SentenceParser sentenceParser = new SentenceParser();
-      final BaseTokenParser baseTokenParser = new BaseTokenParser();
-      final AnnotationParser annotationParser = new AnnotationParser();
-      final IdentifiedAnnotationParser iaParser = new IdentifiedAnnotationParser();
-      // Build map of resources to annotations, sections, etc.
-      final List<BundleEntryComponent> entries = bundle.getEntry();
-      final Map<IBaseResource, Annotation> resourceAnnotations = new HashMap<>( entries.size() );
-      for ( BundleEntryComponent entry : entries ) {
-         final IBaseResource resource = entry.getResource();
-         final Annotation annotation = parseResource( jCas, resource,
-               compositionParser, sectionParser, paragraphParser, sentenceParser, baseTokenParser,
-               annotationParser, iaParser );
-         if ( annotation != null ) {
-            resourceAnnotations.put( resource, annotation );
-         }
-      }
-
-      // Go through the (Basic) entries in the map and build relations
-      for ( Map.Entry<IBaseResource, Annotation> resourceAnnotation : resourceAnnotations.entrySet() ) {
-         if ( !Basic.class.isInstance( resourceAnnotation.getKey() ) ) {
-            continue;
-         }
-         final Basic basic = (Basic)resourceAnnotation.getKey();
-         final List<Extension> extensions = basic.getExtension();
-         for ( Extension extension : extensions ) {
-            final String url = extension.getUrl();
-            if ( url.startsWith( CTAKES_FHIR_URL + RELATION_EXT_PREFIX ) ) {
-               final Type type = extension.getValue();
-               if ( type instanceof Reference ) {
-                  final IBaseResource resource = ((Reference)type).getResource();
-                  final Annotation target = resourceAnnotations.get( resource );
-                  if ( target != null ) {
-                     createRelation( jCas, url, resourceAnnotation.getValue(), target );
-                  }
-               }
-            }
-         }
-      }
-
-      // TODO build Map<Integer,Collection<Annotation>> with coref chain index to annotations that belong from the Basic Extensions
-   }
-
-
-   static private void createRelation( final JCas jCas, final String url,
-                                       final Annotation source, final Annotation target ) {
-      if ( source instanceof IdentifiedAnnotation && target instanceof IdentifiedAnnotation ) {
-         final String category = url.substring( (CTAKES_FHIR_URL + RELATION_EXT_PREFIX).length() );
-         final BinaryTextRelation relation
-               = RelationArgumentUtil.createRelation( jCas, (IdentifiedAnnotation)source, (IdentifiedAnnotation)target,
-               category );
-         relation.addToIndexes();
-      }
-   }
-
-
-   // TODO
-   static private void createCoreference( final JCas jCas, Collection<Annotation> marked ) {
-
-   }
-
-
-   static private Annotation parseResource( final JCas jCas,
-                                            final IBaseResource resource,
-                                            final CompositionParser compositionParser,
-                                            final SectionParser sectionParser,
-                                            final ParagraphParser paragraphParser,
-                                            final SentenceParser sentenceParser,
-                                            final BaseTokenParser baseTokenParser,
-                                            final AnnotationParser annotationParser,
-                                            final IdentifiedAnnotationParser iaParser ) {
-      if ( resource instanceof Composition ) {
-         final Narrative narrative = ((Composition)resource).getText();
-         final XhtmlNode html = narrative.getDiv();
-         final String docText = html.allText();
-         jCas.setDocumentText( docText );
-         return null;
-      }
-      Annotation annotation = null;
-      if ( resource instanceof Basic ) {
-         final Basic basic = (Basic)resource;
-         final String idName = FhirElementParser.getIdName( basic.getId() );
-         switch ( idName ) {
-            case ID_NAME_SECTION:
-               annotation = sectionParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_PARAGRAPH:
-               annotation = paragraphParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_SENTENCE:
-               annotation = sentenceParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_BASE_TOKEN:
-               annotation = baseTokenParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_ANNOTATION:
-               annotation = annotationParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_IDENTIFIED_ANNOTATION:
-               annotation = iaParser.parseResource( jCas, basic );
-               break;
-         }
-         if ( annotation != null ) {
-            annotation.addToIndexes();
-            return annotation;
-         }
-      }
-      return null;
-   }
-
+      final Bundle bundle = BundleReader.readJsonBundle( file );
 
-   static private Bundle readBundle( final File file ) throws IOException {
-      IBaseResource baseResource;
-      final FhirContext fhirContext = FhirContext.forDstu3();
-      final IParser jsonParser = fhirContext.newJsonParser();
-      try ( Reader reader = new BufferedReader( new FileReader( file ) ) ) {
-         baseResource = jsonParser.parseResource( reader );
-
-      } catch ( IOException | ConfigurationException | DataFormatException multE ) {
-         LOGGER.error( "Could not read fhir from " + file.getAbsolutePath(), multE );
-         throw new IOException( multE );
-      }
-      if ( baseResource == null ) {
-         throw new IOException( "Null Bundle for file " + file.getAbsolutePath() );
-      }
-      if ( !Bundle.class.isInstance( baseResource ) ) {
-         throw new IOException( "Resource is not a Bundle for file " + file.getAbsolutePath() );
-      }
-      return (Bundle)baseResource;
+      BundleParser.parseBundle( jCas, bundle );
    }
 
 

Modified: ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirXmlFileReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirXmlFileReader.java?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirXmlFileReader.java (original)
+++ ctakes/trunk/ctakes-fhir/src/main/java/org/apache/ctakes/fhir/cr/FhirXmlFileReader.java Thu May  7 15:08:59 2020
@@ -1,37 +1,13 @@
 package org.apache.ctakes.fhir.cr;
 
-import ca.uhn.fhir.context.ConfigurationException;
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.parser.DataFormatException;
-import ca.uhn.fhir.parser.IParser;
 import org.apache.ctakes.core.cr.AbstractFileTreeReader;
 import org.apache.ctakes.core.pipeline.PipeBitInfo;
-import org.apache.ctakes.core.util.RelationArgumentUtil;
-import org.apache.ctakes.fhir.element.FhirElementParser;
-import org.apache.ctakes.fhir.resource.AnnotationParser;
-import org.apache.ctakes.fhir.resource.IdentifiedAnnotationParser;
-import org.apache.ctakes.fhir.resource.SectionParser;
-import org.apache.ctakes.typesystem.type.relation.BinaryTextRelation;
-import org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation;
 import org.apache.log4j.Logger;
 import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.tcas.Annotation;
-import org.hl7.fhir.dstu3.model.*;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.utilities.xhtml.XhtmlNode;
-
-import java.io.*;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.ctakes.fhir.element.FhirElementFactory.CTAKES_FHIR_URL;
-import static org.apache.ctakes.fhir.element.FhirElementFactory.RELATION_EXT_PREFIX;
-import static org.apache.ctakes.fhir.resource.AnnotationCreator.ID_NAME_ANNOTATION;
-import static org.apache.ctakes.fhir.resource.IdentifiedAnnotationCreator.ID_NAME_IDENTIFIED_ANNOTATION;
-import static org.apache.ctakes.fhir.resource.SectionCreator.ID_NAME_SECTION;
-import static org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
+import org.hl7.fhir.dstu3.model.Bundle;
+
+import java.io.File;
+import java.io.IOException;
 
 
 /**
@@ -56,120 +32,10 @@ public class FhirXmlFileReader extends A
    protected void readFile( final JCas jCas, final File file ) throws IOException {
       jCas.reset();
 
-      final Bundle bundle = readBundle( file );
-
-      final SectionParser sectionParser = new SectionParser();
-      final AnnotationParser annotationParser = new AnnotationParser();
-      final IdentifiedAnnotationParser iaParser = new IdentifiedAnnotationParser();
-      // Build map of resources to annotations, sections, etc.
-      final List<BundleEntryComponent> entries = bundle.getEntry();
-      final Map<IBaseResource, Annotation> resourceAnnotations = new HashMap<>( entries.size() );
-      for ( BundleEntryComponent entry : entries ) {
-         final IBaseResource resource = entry.getResource();
-         final Annotation annotation = parseResource( jCas, resource, sectionParser, annotationParser, iaParser );
-         if ( annotation != null ) {
-            resourceAnnotations.put( resource, annotation );
-         }
-      }
-
-      // Go through the (Basic) entries in the map and build relations
-      for ( Map.Entry<IBaseResource, Annotation> resourceAnnotation : resourceAnnotations.entrySet() ) {
-         if ( !Basic.class.isInstance( resourceAnnotation.getKey() ) ) {
-            continue;
-         }
-         final Basic basic = (Basic) resourceAnnotation.getKey();
-         final List<Extension> extensions = basic.getExtension();
-         for ( Extension extension : extensions ) {
-            final String url = extension.getUrl();
-            if ( url.startsWith( CTAKES_FHIR_URL + RELATION_EXT_PREFIX ) ) {
-               final Type type = extension.getValue();
-               if ( type instanceof Reference ) {
-                  final IBaseResource resource = ((Reference) type).getResource();
-                  final Annotation target = resourceAnnotations.get( resource );
-                  if ( target != null ) {
-                     createRelation( jCas, url, resourceAnnotation.getValue(), target );
-                  }
-               }
-            }
-         }
-      }
-
-      // TODO build Map<Integer,Collection<Annotation>> with coref chain index to annotations that belong from the Basic Extensions
-   }
-
-
-   static private void createRelation( final JCas jCas, final String url,
-                                       final Annotation source, final Annotation target ) {
-      if ( source instanceof IdentifiedAnnotation && target instanceof IdentifiedAnnotation ) {
-         final String category = url.substring( (CTAKES_FHIR_URL + RELATION_EXT_PREFIX).length() );
-         final BinaryTextRelation relation
-               = RelationArgumentUtil.createRelation( jCas, (IdentifiedAnnotation) source, (IdentifiedAnnotation) target,
-               category );
-         relation.addToIndexes();
-      }
-   }
-
-
-   // TODO
-   static private void createCoreference( final JCas jCas, Collection<Annotation> marked ) {
-
-   }
-
-
-   static private Annotation parseResource( final JCas jCas,
-                                            final IBaseResource resource,
-                                            final SectionParser sectionParser,
-                                            final AnnotationParser annotationParser,
-                                            final IdentifiedAnnotationParser iaParser ) {
-      if ( resource instanceof Composition ) {
-         final Narrative narrative = ((Composition) resource).getText();
-         final XhtmlNode html = narrative.getDiv();
-         final String docText = html.allText();
-         jCas.setDocumentText( docText );
-         return null;
-      }
-      Annotation annotation = null;
-      if ( resource instanceof Basic ) {
-         final Basic basic = (Basic) resource;
-         final String idName = FhirElementParser.getIdName( basic.getId() );
-         switch ( idName ) {
-            case ID_NAME_SECTION:
-               annotation = sectionParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_ANNOTATION:
-               annotation = annotationParser.parseResource( jCas, basic );
-               break;
-            case ID_NAME_IDENTIFIED_ANNOTATION:
-               annotation = iaParser.parseResource( jCas, basic );
-               break;
-         }
-         if ( annotation != null ) {
-            annotation.addToIndexes();
-            return annotation;
-         }
-      }
-      return null;
-   }
+      final Bundle bundle = BundleReader.readXmlBundle( file );
 
+      BundleParser.parseBundle( jCas, bundle );
 
-   static private Bundle readBundle( final File file ) throws IOException {
-      IBaseResource baseResource;
-      final FhirContext fhirContext = FhirContext.forDstu3();
-      final IParser xmlParser = fhirContext.newXmlParser();
-      try ( Reader reader = new BufferedReader( new FileReader( file ) ) ) {
-         baseResource = xmlParser.parseResource( reader );
-
-      } catch ( IOException | ConfigurationException | DataFormatException multE ) {
-         LOGGER.error( "Could not read fhir from " + file.getAbsolutePath(), multE );
-         throw new IOException( multE );
-      }
-      if ( baseResource == null ) {
-         throw new IOException( "Null Bundle for file " + file.getAbsolutePath() );
-      }
-      if ( !Bundle.class.isInstance( baseResource ) ) {
-         throw new IOException( "Resource is not a Bundle for file " + file.getAbsolutePath() );
-      }
-      return (Bundle) baseResource;
    }
 
 

Modified: ctakes/trunk/ctakes-tiny-rest/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-tiny-rest/pom.xml?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-tiny-rest/pom.xml (original)
+++ ctakes/trunk/ctakes-tiny-rest/pom.xml Thu May  7 15:08:59 2020
@@ -45,11 +45,6 @@
       </dependency>
       <dependency>
          <groupId>org.springframework</groupId>
-         <artifactId>spring-web</artifactId>
-         <version>${springframework.version}</version>
-      </dependency>
-      <dependency>
-         <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <version>${springframework.version}</version>
       </dependency>

Modified: ctakes/trunk/ctakes-web-rest/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-web-rest/pom.xml?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/ctakes-web-rest/pom.xml (original)
+++ ctakes/trunk/ctakes-web-rest/pom.xml Thu May  7 15:08:59 2020
@@ -288,6 +288,34 @@
 					<compilerArgument>-Xlint</compilerArgument>
 				</configuration>
 			</plugin>
+
+         <!--         !!! TODO !!!   This is a snippet from the ctakes-dockhand pom.
+                                     There should not be complete copies of all resources from other modules.
+                                     Instead, those resources should be copied when this artifact is built.
+                                     Doing so saves space and keeps the resources up-to-date.   -->
+         <!--         <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/pom.xml
URL: http://svn.apache.org/viewvc/ctakes/trunk/pom.xml?rev=1877474&r1=1877473&r2=1877474&view=diff
==============================================================================
--- ctakes/trunk/pom.xml (original)
+++ ctakes/trunk/pom.xml Thu May  7 15:08:59 2020
@@ -151,7 +151,6 @@
 	</parent>
 
 	<modules>
-      <!--<module>ctakes-web-rest</module>-->
 		<module>ctakes-gui</module>
 		<module>ctakes-gui-res</module>
 		<module>ctakes-fhir</module>
@@ -202,7 +201,7 @@
 		<module>ctakes-ytex-res</module>
 		<module>ctakes-ytex</module>
 		<module>ctakes-ytex-uima</module>
-		<module>ctakes-ytex-web</module>
+      <!--		<module>ctakes-ytex-web</module>-->
 		<module>ctakes-dictionary-lookup-fast</module>
 		<module>ctakes-dictionary-lookup-fast-res</module>
       <module>ctakes-dockhand</module>
@@ -210,13 +209,6 @@
 	</modules>
 	<dependencyManagement>
 		<dependencies>
-         <!--<dependency>-->
-         <!--<groupId>org.apache.ctakes</groupId>-->
-         <!--<artifactId>-->
-         <!--ctakes-web-rest-->
-         <!--</artifactId>-->
-         <!--<version>${project.version}</version>-->
-         <!--</dependency>-->
 			<!-- cTAKES third party dependency versions -->
 			<!-- <dependency> <groupId>jama</groupId> <artifactId>jama</artifactId>
 				<version>1.0.2</version> </dependency> -->
@@ -813,11 +805,11 @@
 				<artifactId>ctakes-ytex-uima</artifactId>
 				<version>${project.version}</version>
 			</dependency>
-			<dependency>
-				<groupId>org.apache.ctakes</groupId>
-				<artifactId>ctakes-ytex-web</artifactId>
-				<version>${project.version}</version>
-			</dependency>
+         <!--			<dependency>-->
+         <!--				<groupId>org.apache.ctakes</groupId>-->
+         <!--				<artifactId>ctakes-ytex-web</artifactId>-->
+         <!--				<version>${project.version}</version>-->
+         <!--			</dependency>-->
 			<dependency>
 				<groupId>org.apache.ctakes</groupId>
 				<artifactId>