public void processByClass(Class clazz, boolean isDelete)
     throws Exception, FileNotFoundException {
   Generator g = getGenerator();
   GeneratorModel m = GeneratorModelUtils.newGeneratorModel("clazz", new JavaClass(clazz));
   PrintUtils.printBeginProcess("JavaClass:" + clazz.getSimpleName(), isDelete);
   processByGeneratorModel(isDelete, g, m);
 }
Example #2
0
 @Test
 public void testgetRecordFromLine() {
   assertTrue(
       PrintUtils.getRecordFromLine(
                   "Brak obowiązkowej wartości pola BENEFICIARY_CODE / BCTRPTYDTLS_BNFCRYID_ID dla rekordu 1173122")
               .compareTo("1173122")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine("Klient jest niepoprawny dla rekordu 1173122")
               .compareTo("1173122")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine("Klient jest niepoprawny dla rekordu 1173124")
               .compareTo("1173124")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine("Klient jest niepoprawny dla rekordu 866955")
               .compareTo("866955")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine(
                   "Brak obowiązkowej wartości pola BENEFICIARY_CODE / BCTRPTYDTLS_BNFCRYID_ID dla rekordu 1173114")
               .compareTo("1173114")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine(
                   "Brak obowiązkowej wartości pola BENEFICIARY_CODE / BCTRPTYDTLS_BNFCRYID_ID dla rekordu ")
               .compareTo("")
           == 0);
   assertTrue(
       PrintUtils.getRecordFromLine(
                   "Brak obowiązkowej wartości pola BENEFICIARY_CODE / BCTRPTYDTLS_BNFCRYID_ID dla rekordu")
               .compareTo("")
           == 0);
 }
 private void processByGeneratorModel(boolean isDelete, Generator g, GeneratorModel m)
     throws Exception, FileNotFoundException {
   try {
     if (isDelete) g.deleteBy(m.templateModel, m.filePathModel);
     else g.generateBy(m.templateModel, m.filePathModel);
   } catch (GeneratorException ge) {
     PrintUtils.printExceptionsSumary(
         ge.getMessage(), getGenerator().getOutRootDir(), ge.getExceptions());
     throw ge;
   }
 }
 public void processByAllTable(boolean isDelete) throws Exception {
   List<Table> tables = TableFactory.getInstance().getAllTables();
   List exceptions = new ArrayList();
   for (int i = 0; i < tables.size(); i++) {
     try {
       processByTable(getGenerator(), tables.get(i), isDelete);
     } catch (GeneratorException ge) {
       exceptions.addAll(ge.getExceptions());
     }
   }
   PrintUtils.printExceptionsSumary("", getGenerator().getOutRootDir(), exceptions);
   if (!exceptions.isEmpty()) {
     throw new GeneratorException("batch generate by all table occer error", exceptions);
   }
 }
 public void processByTable(String tableName, boolean isDelete) throws Exception {
   if ("*".equals(tableName)) {
     if (isDelete) deleteByAllTable();
     else generateByAllTable();
     return;
   }
   Generator g = getGenerator();
   Table table = TableFactory.getInstance().getTable(tableName);
   try {
     processByTable(g, table, isDelete);
   } catch (GeneratorException ge) {
     PrintUtils.printExceptionsSumary(
         ge.getMessage(), getGenerator().getOutRootDir(), ge.getExceptions());
     throw ge;
   }
 }
  private void handleAddFeedPost(Request request, HttpServletResponse httpServletResponse)
      throws Exception {
    LOG.info("adding feed");
    User user = userHelpers.getUser(request);

    try {
      if (user == null) {
        LOG.error("User not found");
        return;
      }

      String url = request.getParameter(PARAM_NEW_FEED_URL);
      // ttt1 add some validation; probably best try to actually get data, set the title, ...
      if (url == null || url.equals("")) {
        LOG.error("New feed not specified");
        // ttt1 show some error
        return;
      }

      MessageDigest digest = MessageDigest.getInstance("MD5");
      String feedId = PrintUtils.byteArrayAsUrlString(digest.digest(url.getBytes("UTF-8")));
      feedId = feedId.substring(0, Config.getConfig().feedIdSize);

      Feed feed = feedDb.get(feedId);
      if (feed == null) {
        feed = new Feed(feedId, url);
        feedDb.add(feed);
      }

      if (user.feedIds.contains(feedId)) {
        LOG.error(String.format("Trying to add existing feed %s to user %s", feedId, user));
      } else {
        user.feedIds.add(feedId);
        userDb.updateFeeds(user);
      }
    } finally {
      httpServletResponse.sendRedirect(PATH_FEED_ADMIN);
    }
  }
 public static void printAllTableNames() throws Exception {
   PrintUtils.printAllTableNames(TableFactory.getInstance().getAllTables());
 }
 public void processByTable(Generator g, Table table, boolean isDelete) throws Exception {
   GeneratorModel m = GeneratorModelUtils.newGeneratorModel("table", table);
   PrintUtils.printBeginProcess(table.getSqlName() + " => " + table.getClassName(), isDelete);
   if (isDelete) g.deleteBy(m.templateModel, m.filePathModel);
   else g.generateBy(m.templateModel, m.filePathModel);
 }
 public void processBySql(Sql sql, boolean isDelete) throws Exception {
   Generator g = getGenerator();
   GeneratorModel m = GeneratorModelUtils.newGeneratorModel("sql", sql);
   PrintUtils.printBeginProcess("sql:" + sql.getSourceSql(), isDelete);
   processByGeneratorModel(isDelete, g, m);
 }