コード例 #1
0
ファイル: BaseSpringApp.java プロジェクト: openhie/os-cr
 public void startup(String[] locations) {
   Context.startup();
   //		Context.authenticate("admin", "admin");
 }
コード例 #2
0
ファイル: FileLoaderManager.java プロジェクト: openhie/os-cr
  public static void main(String[] args) {
    if (args.length < 3) {
      usage();
      System.exit(-1);
    }
    String filename = args[0];
    String loaderAlias = args[1];
    String entityName = args[2];

    java.util.HashMap<String, Object> map = new java.util.HashMap<String, Object>();

    Boolean isImport = Boolean.FALSE;
    if (args.length >= 3 && args[3] != null && args[3].equalsIgnoreCase("true")) {
      isImport = Boolean.TRUE;
    }
    String mappingFile = "";
    if (args.length >= 4 && args[4] != null) {
      mappingFile = args[4];
    }
    Boolean previewOnly = Boolean.FALSE;
    if (args.length > 5 && args[5] != null && args[5].equalsIgnoreCase("true")) {
      previewOnly = Boolean.TRUE;
    }
    log.info("Loading the data file " + filename + " using loader " + loaderAlias);
    Boolean isMassiveInsert = Boolean.FALSE;
    if (args.length >= 6 && args[6] != null && args[6].equalsIgnoreCase("true")) {
      isMassiveInsert = Boolean.TRUE;
    }

    Context.startup();
    Context.authenticate("admin", "admin");
    map.put("context", Context.getApplicationContext());
    map.put(FileLoaderParameters.IS_IMPORT, isImport);
    map.put(FileLoaderParameters.MAPPING_FILE, mappingFile);
    map.put(FileLoaderParameters.ENTITY_NAME, entityName);
    map.put(FileLoaderParameters.PREVIEW_ONLY, previewOnly);
    map.put(FileLoaderParameters.IS_MASSIVE_INSERT, isMassiveInsert);

    BufferedReader bufRead = new BufferedReader(new InputStreamReader(System.in));
    try {
      System.out.println("Press a character to get started.");
      bufRead.readLine();
    } catch (IOException err) {
      System.out.println("Error reading line");
    }

    FileLoaderManager fileLoaderManager = null;
    try {
      fileLoaderManager = new FileLoaderManager();
      fileLoaderManager.setUp(map);
      List<Entity> entities =
          Context.getEntityDefinitionManagerService().findEntitiesByName(entityName);
      if (entities.size() == 0) {
        log.warn("The name of the entity specified is unknown.");
        System.exit(-1);
      }
      fileLoaderManager.loadFile(entities.get(0), filename, loaderAlias);
      try {
        System.out.println("Press a character to shutdown.");
        bufRead.readLine();
      } catch (IOException err) {
        System.out.println("Error reading line");
      }
    } catch (Throwable t) {
      log.error("Got an exception: " + t);
    } finally {
      if (fileLoaderManager != null) {
        fileLoaderManager.shutdown();
      }
    }
  }
コード例 #3
0
ファイル: BaseSpringApp.java プロジェクト: openhie/os-cr
 public void startup() {
   Context.startup();
   //		Context.authenticate("admin", "admin");
 }