예제 #1
0
 public static OCommandRequest selectCommandBuilder(
     String from, boolean count, QueryParams criteria) throws SqlInjectionException {
   OGraphDatabase db = DbHelper.getConnection();
   OCommandRequest command =
       db.command(
           new OSQLSynchQuery<ODocument>(selectQueryBuilder(from, count, criteria))
               .setFetchPlan(fetchPlan.replace("?", criteria.getDepth().toString())));
   if (!command.isIdempotent()) throw new SqlInjectionException();
   Logger.debug("commandBuilder: ");
   Logger.debug("  " + criteria.toString());
   Logger.debug("  " + command.toString());
   return command;
 }
예제 #2
0
  public static void populateDB(OGraphDatabase db) throws IOException {
    Logger.info("Populating the db...");
    InputStream is;
    if (Play.application().isProd()) is = Play.application().resourceAsStream(SCRIPT_FILE_NAME);
    else is = new FileInputStream(Play.application().getFile("conf/" + SCRIPT_FILE_NAME));
    List<String> script = IOUtils.readLines(is, "UTF-8");
    is.close();

    for (String line : script) {
      Logger.debug(line);
      if (!line.startsWith("--") && !line.trim().isEmpty()) { // skip comments
        db.command(new OCommandSQL(line.replace(';', ' '))).execute();
      }
    }
    Logger.info("...done");
  }