コード例 #1
0
 // ===================================================================================
 //                                                                           Procedure
 //                                                                           =========
 protected void setupProcedure() {
   try {
     final DfProcedurePmbSetupper setupper = createProcedurePmbSetupper();
     setupper.setupProcedure();
     final Map<String, String> exceptionInfoMap = _sql2entityMeta.getExceptionInfoMap();
     exceptionInfoMap.putAll(setupper.getContinuedFailureMessageMap());
   } catch (SQLException e) {
     throwProcedureSetupFailureException(e);
   }
 }
コード例 #2
0
 protected void showParameterBean() {
   _log.info("* * * * * * * * *");
   _log.info("* ParameterBean *");
   _log.info("* * * * * * * * *");
   final StringBuilder logSb = new StringBuilder();
   final Map<String, DfPmbMetaData> pmbMetaDataMap = _sql2entityMeta.getPmbMetaDataMap();
   for (Entry<String, DfPmbMetaData> pmbEntry : pmbMetaDataMap.entrySet()) {
     final DfPmbMetaData pmbMetaData = pmbEntry.getValue();
     logSb.append(pmbMetaData.getClassName());
     if (pmbMetaData.hasSuperClassDefinition()) {
       logSb.append(" extends ").append(pmbMetaData.getSuperClassName());
     }
     if (pmbMetaData.isRelatedToProcedure()) {
       logSb.append(" (procedure");
       if (pmbMetaData.isProcedureRefCustomizeEntity()) {
         logSb.append(" with customize-entity");
       }
       logSb.append(")").append(ln());
       final Map<String, DfProcedureColumnMeta> propertyNameColumnInfoMap =
           pmbMetaData.getPropertyNameColumnInfoMap();
       for (Entry<String, DfProcedureColumnMeta> columnEntry :
           propertyNameColumnInfoMap.entrySet()) {
         final DfProcedureColumnMeta columnInfo = columnEntry.getValue();
         logSb.append("  ").append(columnInfo.getColumnNameDisp());
         logSb.append(ln());
       }
     } else {
       if (pmbMetaData.isTypedParameterBean()) {
         logSb.append(" ").append(pmbMetaData.buildTypedDisp());
       }
       logSb.append(ln());
       final Map<String, String> propertyNameTypeMap = pmbMetaData.getPropertyNameTypeMap();
       final Map<String, String> propertyOptionMap = pmbMetaData.getPropertyNameOptionMap();
       for (Entry<String, String> propEntry : propertyNameTypeMap.entrySet()) {
         final String propertyName = propEntry.getKey();
         final String propertyType = propEntry.getValue();
         logSb.append("  ").append(propertyType).append(" ").append(propertyName);
         final String optionDef = propertyOptionMap.get(propertyName);
         if (Srl.is_NotNull_and_NotTrimmedEmpty(optionDef)) {
           logSb.append(":").append(optionDef);
         }
         logSb.append(ln());
       }
     }
     logSb.append(ln());
   }
   if (logSb.length() > 0) {
     _log.info(ln() + logSb.toString().trim());
   }
 }
コード例 #3
0
 protected void handleException() {
   final Map<String, String> exceptionInfoMap = _sql2entityMeta.getExceptionInfoMap();
   if (exceptionInfoMap.isEmpty()) {
     return;
   }
   final Set<String> nameSet = exceptionInfoMap.keySet();
   final StringBuilder sb = new StringBuilder();
   for (String name : nameSet) {
     final String exceptionInfo = exceptionInfoMap.get(name);
     sb.append("[" + name + "]");
     final boolean containsLn = Srl.contains(exceptionInfo, ln());
     sb.append(containsLn ? ln() : " ");
     sb.append(exceptionInfo);
     sb.append(containsLn ? ln() : "").append(ln());
   }
   _log.warn("/* * * * * * * * * * * * * * * * * {Warning Exception}");
   _log.warn(ln() + sb.toString().trim());
   _log.warn("* * * * * * * * * */");
   _log.warn(" ");
 }
コード例 #4
0
  // ===================================================================================
  //                                                                  Prepare Generation
  //                                                                  ==================
  @Override
  public Context initControlContext() throws Exception {
    _log.info("");
    _log.info("...Preparing generation of customize-entities and parameter-beans");
    _log.info("* * * * * * * * * *");
    _log.info("* CustomizeEntity *");
    _log.info("* * * * * * * * * *");
    final StringBuilder logSb = new StringBuilder();

    final Database database = _database;
    database.setSql2EntitySchemaData(_schemaData);
    database.setPmbMetaDataMap(_sql2entityMeta.getPmbMetaDataMap());
    database.setSkipDeleteOldClass(isSkipDeleteOldClass());

    final Map<String, DfCustomizeEntityInfo> entityInfoMap = _sql2entityMeta.getEntityInfoMap();
    final Set<String> entityNameSet = entityInfoMap.keySet();
    for (String entityName : entityNameSet) {
      final DfCustomizeEntityInfo entityInfo = entityInfoMap.get(entityName);
      final Map<String, DfColumnMeta> metaMap = entityInfo.getColumnMap();
      final DfOutsideSqlFile outsideSqlFile = entityInfo.getOutsideSqlFile();

      final Table tbl = new Table();
      tbl.setSql2EntityCustomize(true);
      if (outsideSqlFile != null) { // basically true but checked just in case
        tbl.setSql2EntitySqlFile(outsideSqlFile);
      }
      tbl.setName(entityInfo.getTableDbName());
      if (!entityInfo.needsJavaNameConvert()) {
        tbl.suppressJavaNameConvert(); // basically here (except STRUCT type)
      }
      if (entityInfo.hasNestedCustomizeEntity()) {
        tbl.setSql2EntityCustomizeHasNested(true); // basically when STRUCT type
      }
      if (entityInfo.isAdditionalSchema()) {
        tbl.setUnifiedSchema(entityInfo.getAdditionalSchema()); // basically when STRUCT type
      }
      tbl.setSql2EntityTypeSafeCursor(entityInfo.isCursorHandling());
      buildCustomizeEntityTitle(logSb, entityName, entityInfo);

      final StringKeyMap<String> pkMap = getPrimaryKeyMap(entityInfo);
      final boolean allCommonColumn = hasAllCommonColumn(metaMap);
      final Set<String> columnNameSet = metaMap.keySet();
      for (String columnName : columnNameSet) {
        final Column column = new Column();
        setupColumnName(columnName, column);

        // an element removed from pkMap if true
        // and a table name related to primary key is returned
        final String pkRelatedTableName = setupPrimaryKey(pkMap, entityName, columnName, column);

        setupTorqueType(metaMap, columnName, column, allCommonColumn);
        setupDbType(metaMap, columnName, column);
        setupNotNull(metaMap, columnName, column);
        setupColumnSizeContainsDigit(metaMap, columnName, column);
        setupColumnComment(metaMap, columnName, column);
        setupSql2EntityElement(
            entityName, entityInfo, metaMap, columnName, column, pkRelatedTableName, logSb);
        tbl.addColumn(column);
      }
      if (!pkMap.isEmpty()) { // if not-removed columns exist
        throwPrimaryKeyNotFoundException(entityName, pkMap, columnNameSet);
      }

      if (entityInfo.isScalarHandling()) {
        // it does not generate an only-one-column entity
        tbl.setDatabase(database); // one-way love for utility (just in case)
        processScalarHandling(entityInfo, tbl);
      } else if (entityInfo.isDomainHandling()) {
        // it does not generate an customize-entity
        tbl.setDatabase(database); // one-way love for utility (just in case)
        processDomainHandling(entityInfo, tbl);
      } else {
        // initialize a class name of the entity for typed parameter-bean
        database.addTable(tbl); // should be before getting names
        entityInfo.setEntityClassName(tbl.getExtendedEntityClassName());
        entityInfo.setImmutableClassName(tbl.getImmutableExtendedEntityClassName());
      }
      logSb.append(ln());
    }
    final String databaseType = getDatabaseTypeFacadeProp().getTargetDatabase();
    final AppData appData = new AppData(databaseType);
    appData.addDatabase(database);

    showCustomizeEntity(logSb);
    showParameterBean();

    final VelocityContext context = createVelocityContext(appData);
    return context;
  }
コード例 #5
0
 protected DfProcedurePmbSetupper createProcedurePmbSetupper() {
   final Map<String, DfCustomizeEntityInfo> entityInfoMap = _sql2entityMeta.getEntityInfoMap();
   final Map<String, DfPmbMetaData> pmbMetaDataMap = _sql2entityMeta.getPmbMetaDataMap();
   return new DfProcedurePmbSetupper(getDataSource(), entityInfoMap, pmbMetaDataMap, _database);
 }