public static void main(String[] args) {
    setupContext();
    RegenerateTaxonLabelSetsInterface rt =
        (RegenerateTaxonLabelSetsInterface) ContextManager.getBean("regenerateTaxonLabelSets");

    GetOpts<UnixOptions> go = new GetOpts<UnixOptions>(new UnixOptions("tm"));
    UnixOptions opts = go.getOpts(args);

    // Kind of silly to convert the IDs to strings just to convert them back to numbers again...
    if (args.length == 0) {
      Collection<Study> allStudies = rt.getStudyHome().findAll(Study.class);
      List<String> newArgs = new LinkedList<String>();
      for (Study s : allStudies) newArgs.add(s.getId().toString());
      args = newArgs.toArray(args);
    }

    for (String arg : args) {
      Long id = Long.parseLong(arg);
      System.err.println("Processing study " + id);

      Set<TaxonLabelSet> newSets =
          rt.createTaxonLabelSets(id, opts.getBoolOpt("t"), opts.getBoolOpt("m"));
      rt.getTlHome().flush();
      /*
      			 * Do this another time, just destroy all sets that should be garbage-collected
      			for (TaxonLabelSet tlSet : oldSets) {
      				tlHome.deletePersist(tlSet);	// XXX Should be taxonLabelSetHome
      			}
      //			tlHome.flush();    // XXX Should be taxonLabelSetHome

      			 */

      String sets = newSets.size() == 1 ? "set" : "sets";
      System.err.println(
          "  Rebuilt " + newSets.size() + " taxon label " + sets + " for study " + id);
    }
  }