@@ -4350,6 +4350,51 @@ public void opensearchDocumentSerializer(JsonGenerator jgen, Shepherd myShepherd
43504350 }
43514351 }
43524352
4353+ public void opensearchIndexDeep ()
4354+ throws IOException {
4355+ this .opensearchIndex ();
4356+
4357+ final String encId = this .getId ();
4358+ ExecutorService executor = Executors .newFixedThreadPool (4 );
4359+ Runnable rn = new Runnable () {
4360+ public void run () {
4361+ Shepherd bgShepherd = new Shepherd ("context0" );
4362+ bgShepherd .setAction ("Encounter.opensearchIndexDeep_" + encId );
4363+ bgShepherd .beginDBTransaction ();
4364+ try {
4365+ Encounter enc = bgShepherd .getEncounter (encId );
4366+ if ((enc == null ) || !enc .hasMarkedIndividual ()) {
4367+ // bgShepherd.rollbackAndClose();
4368+ executor .shutdown ();
4369+ return ;
4370+ }
4371+ MarkedIndividual indiv = enc .getIndividual ();
4372+ System .out .println ("opensearchIndexDeep() background indexing indiv " +
4373+ indiv .getId () + " via enc " + encId );
4374+ try {
4375+ indiv .opensearchIndex ();
4376+ } catch (Exception ex ) {
4377+ System .out .println ("opensearchIndexDeep() background indexing " +
4378+ indiv .getId () + " FAILED: " + ex .toString ());
4379+ ex .printStackTrace ();
4380+ }
4381+ } catch (Exception e ) {
4382+ System .out .println ("opensearchIndexDeep() backgrounding Encounter " + encId +
4383+ " hit an exception." );
4384+ e .printStackTrace ();
4385+ } finally {
4386+ bgShepherd .rollbackAndClose ();
4387+ }
4388+ System .out .println ("opensearchIndexDeep() backgrounding Encounter " + encId +
4389+ " finished." );
4390+ executor .shutdown ();
4391+ }
4392+ };
4393+ System .out .println ("opensearchIndexDeep() begin backgrounding indiv for " + this );
4394+ executor .execute (rn );
4395+ System .out .println ("opensearchIndexDeep() [foreground] finished for Encounter " + encId );
4396+ }
4397+
43534398 // given a doc from opensearch, can user access it?
43544399 public static boolean opensearchAccess (org .json .JSONObject doc , User user ,
43554400 Shepherd myShepherd ) {
0 commit comments