Ejemplo n.º 1
0
 protected Table setupSql2EntityRelatedTable(
     String entityName,
     DfCustomizeEntityInfo entityInfo,
     Map<String, DfColumnMeta> metaMap,
     String columnName,
     Column column,
     String pkRelatedTableName) {
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   final String sql2EntityRelatedTableName = columnMeta.getSql2EntityRelatedTableName();
   Table relatedTable = getRelatedTable(sql2EntityRelatedTableName); // first attack
   if (relatedTable == null) {
     if (pkRelatedTableName != null) { // second attack using PK-related
       relatedTable = getRelatedTable(pkRelatedTableName);
       if (relatedTable == null) {
         throwTableRelatedPrimaryKeyNotFoundException(
             entityName, entityInfo, pkRelatedTableName, columnName);
       }
     } else {
       return null;
     }
   } else {
     if (pkRelatedTableName != null) {
       if (!Srl.equalsFlexible(sql2EntityRelatedTableName, pkRelatedTableName)) {
         throwTableRelatedPrimaryKeyDifferentException(
             entityName, entityInfo, sql2EntityRelatedTableName, pkRelatedTableName, columnName);
       }
     }
   }
   column.setSql2EntityRelatedTable(relatedTable);
   return relatedTable;
 }
Ejemplo n.º 2
0
 protected void setupColumnSizeContainsDigit(
     Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   final int columnSize = columnMeta.getColumnSize();
   final int decimalDigits = columnMeta.getDecimalDigits();
   column.setupColumnSize(columnSize, decimalDigits);
 }
Ejemplo n.º 3
0
 protected String setupSql2EntityForcedJavaNative(
     String entityName,
     DfCustomizeEntityInfo entityInfo,
     final Map<String, DfColumnMeta> metaMap,
     String columnName,
     final Column column) {
   final DfColumnMeta metaInfo = metaMap.get(columnName);
   final String sql2EntityForcedJavaNative = metaInfo.getSql2EntityForcedJavaNative();
   column.setSql2EntityForcedJavaNative(sql2EntityForcedJavaNative);
   return sql2EntityForcedJavaNative;
 }
Ejemplo n.º 4
0
 protected void setupColumnComment(
     Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   final String sql2EntityRelatedTableName = columnMeta.getSql2EntityRelatedTableName();
   final Table relatedTable = getRelatedTable(sql2EntityRelatedTableName);
   String relatedComment = null;
   if (relatedTable != null) {
     final String relatedColumnName = columnMeta.getSql2EntityRelatedColumnName();
     final Column relatedColumn = relatedTable.getColumn(relatedColumnName);
     if (relatedColumn != null) {
       relatedComment = relatedColumn.getPlainComment();
     }
   }
   // the meta has its select column comment
   final String selectColumnComment = columnMeta.getColumnComment();
   final String commentMark = "// ";
   final String delimiter = getAliasDelimiterInDbComment();
   final StringBuilder sb = new StringBuilder();
   if (Srl.is_NotNull_and_NotTrimmedEmpty(relatedComment)) {
     sb.append(relatedComment);
     if (Srl.is_NotNull_and_NotTrimmedEmpty(selectColumnComment)) { // both exist
       if (Srl.is_NotNull_and_NotTrimmedEmpty(delimiter)) { // use alias option
         if (relatedComment.contains(delimiter)) { // resolved in related comment
           sb.append(ln()).append(commentMark).append(selectColumnComment);
         } else { // unresolved yet
           if (isDbCommentOnAliasBasis()) { // related comment is alias
             sb.append(delimiter);
           } else { // related comment is description
             sb.append(ln());
           }
           sb.append(commentMark).append(selectColumnComment);
         }
       } else { // no alias option
         sb.append(ln()).append(commentMark).append(selectColumnComment);
       }
     }
   } else { // not found related comment
     if (Srl.is_NotNull_and_NotTrimmedEmpty(selectColumnComment)) {
       if (Srl.is_NotNull_and_NotTrimmedEmpty(delimiter)) { // use alias option
         if (isDbCommentOnAliasBasis()) {
           // select column comment is treated as description
           sb.append(delimiter);
         }
       }
       sb.append(commentMark).append(selectColumnComment);
     }
   }
   column.setPlainComment(sb.toString());
 }
Ejemplo n.º 5
0
 protected String getColumnTorqueType(DfColumnMeta columnMeta) {
   if (columnMeta.isProcedureParameter() && !_columnHandler.hasMappingJdbcType(columnMeta)) {
     // unknown type of procedure parameter should be treated as Object
     return TypeMap.OTHER;
   } else {
     return _columnHandler.getColumnJdbcType(columnMeta);
   }
 }
Ejemplo n.º 6
0
 protected void setupDbType(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   final String dbTypeName;
   final String plainName = columnMeta.getDbTypeName();
   if (Srl.contains(plainName, ".")) { // basically for ARRAY and STRUCT type
     final String catalogSchema = Srl.substringLastFront(plainName, ".");
     final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalogSchema);
     if (unifiedSchema.isMainSchema()) {
       dbTypeName = Srl.substringLastRear(plainName, ".");
     } else {
       dbTypeName = plainName;
     }
   } else {
     dbTypeName = plainName;
   }
   column.setDbType(dbTypeName);
 }
Ejemplo n.º 7
0
 protected Column setupSql2EntityRelatedColumn(
     String entityName,
     DfCustomizeEntityInfo entityInfo,
     Table relatedTable,
     Map<String, DfColumnMeta> metaMap,
     String columnName,
     Column column) {
   if (relatedTable == null) {
     return null;
   }
   final DfColumnMeta metaInfo = metaMap.get(columnName);
   final String sql2EntityRelatedColumnName = metaInfo.getSql2EntityRelatedColumnName();
   final Column relatedColumn = relatedTable.getColumn(sql2EntityRelatedColumnName);
   if (relatedColumn == null) {
     return null;
   }
   column.setSql2EntityRelatedColumn(relatedColumn);
   return column;
 }
Ejemplo n.º 8
0
 protected void setupNotNull(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
   // basically not meta data so false, true might be from select column specification
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   column.setNotNull(columnMeta.isRequired());
 }