Esempio 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;
 }
Esempio n. 2
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());
 }