<commit_before>package gov.va.isaac.mojos.dbBuilder;

import gov.va.isaac.AppContext;

import java.util.List;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.ihtsdo.otf.tcc.api.store.TerminologyStoreDI;
import org.ihtsdo.otf.tcc.model.index.service.IndexerBI;

/**
 * Goal which loads a database from an eConcept file, and generates the indexes.
 * 
 * @goal shutdown-terminology-store
 * 
 * @phase process-sources
 */
public class Shutdown extends AbstractMojo {

  /**
   * true if the mutable database should replace the read-only database after
   * load is complete.
   * 
   * @parameter default-value=true
   * @required
   */
  private boolean moveToReadOnly = true;

  /**
   * Location of the file.
   * 
   * @parameter
   * @required
   */
  private String bdbFolderLocation;

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.maven.plugin.Mojo#execute()
   */
  @Override
  public void execute() throws MojoExecutionException {
    try {
      getLog().info("Shutdown terminology store");
      // ASSUMES setup has run already
      TerminologyStoreDI store =
          AppContext.getService(TerminologyStoreDI.class);
      List<IndexerBI> indexers =
          AppContext.getServiceLocator().getAllServices(IndexerBI.class);

      // Assume this was run with setup and 
      // the process started with mvn clean
      for (IndexerBI indexer : indexers) {
        indexer.setEnabled(true);
      }
      getLog().info("  Batch Indexing");
      store.index();

      getLog().info("  Shutting Down");
      store.shutdown();
      for (IndexerBI indexer : indexers) {
        indexer.closeWriter();
      }

/*      if (moveToReadOnly) {
          Thread.sleep(5000);
        getLog().info("moving mutable to read-only");
        File readOnlyDir = new File(bdbFolderLocation, "read-only");
        FileIO.recursiveDelete(readOnlyDir);
        File mutableDir = new File(bdbFolderLocation, "mutable");
        mutableDir.renameTo(readOnlyDir);
      }
*/      
      getLog().info("Done shutting down terminology store");
    } catch (Exception e) {
      throw new MojoExecutionException("Database build failure", e);
    }
  }
}<commit_msg>comments, put back some code Brian removed (need to ask him about that)<commit_after>package gov.va.isaac.mojos.dbBuilder;

import gov.va.isaac.AppContext;
import java.io.File;
import java.util.List;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.ihtsdo.otf.tcc.api.io.FileIO;
import org.ihtsdo.otf.tcc.api.store.TerminologyStoreDI;
import org.ihtsdo.otf.tcc.model.index.service.IndexerBI;

/**
 * Goal which loads a database from an eConcept file, and generates the indexes.
 * 
 * @goal shutdown-terminology-store
 * 
 * @phase process-sources
 */
public class Shutdown extends AbstractMojo {

  /**
   * true if the mutable database should replace the read-only database after
   * load is complete.
   * 
   * @parameter default-value=true
   * @required
   */
  private boolean moveToReadOnly = true;

  /**
   * Location of the file.
   * 
   * @parameter
   * @required
   */
  private String bdbFolderLocation;

  /*
   * (non-Javadoc)
   * 
   * @see org.apache.maven.plugin.Mojo#execute()
   */
  @Override
  public void execute() throws MojoExecutionException {
    try {
      getLog().info("Shutdown terminology store");
      // ASSUMES setup has run already
      TerminologyStoreDI store =
          AppContext.getService(TerminologyStoreDI.class);
      List<IndexerBI> indexers =
          AppContext.getServiceLocator().getAllServices(IndexerBI.class);

      // Assume this was run with setup and 
      // the process started with mvn clean
      for (IndexerBI indexer : indexers) {
        indexer.setEnabled(true);
      }
      getLog().info("  Batch Indexing");
      store.index();

      getLog().info("  Shutting Down");
      store.shutdown();
      for (IndexerBI indexer : indexers) {
        indexer.closeWriter();
      }

      if (moveToReadOnly) {
        //TODO Ask Brian why he disabled this - probably on a dev call and ask Keith about it too, since it came from him initially.
        //TODO OTF Bug - figure out why on earth we need this arbitrary sleep.
        Thread.sleep(5000);
        getLog().info("moving mutable to read-only");
        File readOnlyDir = new File(bdbFolderLocation, "read-only");
        FileIO.recursiveDelete(readOnlyDir);
        File mutableDir = new File(bdbFolderLocation, "mutable");
        mutableDir.renameTo(readOnlyDir);
      }
      
      getLog().info("Done shutting down terminology store");
    } catch (Exception e) {
      throw new MojoExecutionException("Database build failure", e);
    }
  }
}
{'fraction_non_alphanumeric': 0.10850439882697947, 'fraction_numerical': 0.0016757436112274822, 'mean_word_length': 2.85702746365105, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3018663', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1435, 'n_words': 361}