Search in sources :

Example 31 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class Column method getForeignTableNameCommaStringWithHtmlHref.

public String getForeignTableNameCommaStringWithHtmlHref() {
    // mainly for SchemaHTML
    final StringBuilder sb = new StringBuilder();
    final DfDocumentProperties prop = getProperties().getDocumentProperties();
    final DfSchemaHtmlBuilder schemaHtmlBuilder = new DfSchemaHtmlBuilder(prop);
    final String delimiter = ",<br>";
    final List<ForeignKey> foreignKeyList = getForeignKeyList();
    final int size = foreignKeyList.size();
    if (size == 0) {
        return "&nbsp;";
    }
    for (int i = 0; i < size; i++) {
        final ForeignKey fk = foreignKeyList.get(i);
        final Table foreignTable = fk.getForeignTable();
        sb.append(schemaHtmlBuilder.buildRelatedTableLink(fk, foreignTable, delimiter));
    }
    sb.delete(0, delimiter.length());
    return sb.toString();
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties) DfSchemaHtmlBuilder(org.dbflute.logic.doc.schemahtml.DfSchemaHtmlBuilder)

Example 32 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class Column method getPrimaryKeyTitleForSchemaHtml.

public String getPrimaryKeyTitleForSchemaHtml() {
    final DfDocumentProperties prop = getProperties().getDocumentProperties();
    final String value = prop.resolveAttributeForSchemaHtml(_primaryKeyName);
    if (value == null) {
        return "";
    }
    final Table table = getTable();
    final String title;
    if (table.isUseSequence()) {
        final String sequenceName = table.getDefinedSequenceName();
        final BigDecimal minimumValue = table.getSequenceMinimumValue();
        final StringBuilder optionSb = new StringBuilder();
        if (minimumValue != null) {
            if (optionSb.length() > 0) {
                optionSb.append(",");
            }
            optionSb.append("minimum(" + minimumValue + ")");
        }
        final BigDecimal maximumValue = table.getSequenceMaximumValue();
        if (maximumValue != null) {
            if (optionSb.length() > 0) {
                optionSb.append(",");
            }
            optionSb.append("maximum(" + maximumValue + ")");
        }
        final Integer incrementSize = table.getSequenceIncrementSize();
        if (incrementSize != null) {
            if (optionSb.length() > 0) {
                optionSb.append(",");
            }
            optionSb.append("increment(" + incrementSize + ")");
        }
        final Integer cacheSize = table.getSequenceCacheSize();
        if (cacheSize != null) {
            if (optionSb.length() > 0) {
                optionSb.append(",");
            }
            optionSb.append("dfcache(" + cacheSize + ")");
        }
        if (optionSb.length() > 0) {
            optionSb.insert(0, ":");
        }
        title = _primaryKeyName + " :: sequence=" + sequenceName + optionSb;
    } else {
        title = _primaryKeyName;
    }
    return " title=\"" + prop.resolveAttributeForSchemaHtml(title) + "\"";
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties) BigDecimal(java.math.BigDecimal)

Example 33 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class Column method getUniqueKeyTitleForSchemaHtml.

public String getUniqueKeyTitleForSchemaHtml() {
    if (!isUnique()) {
        return "";
    }
    final StringBuilder sb = new StringBuilder();
    final List<Unique> uniqueList = getTable().getUniqueList();
    for (Unique unique : uniqueList) {
        if (!unique.hasSameColumn(this)) {
            continue;
        }
        final String uniqueKeyName = unique.getName();
        sb.append(sb.length() > 0 ? ", " : "");
        if (uniqueKeyName != null && uniqueKeyName.trim().length() > 0) {
            sb.append(uniqueKeyName).append("(");
        } else {
            sb.append("(");
        }
        final Map<Integer, String> indexColumnMap = unique.getIndexColumnMap();
        final Set<Entry<Integer, String>> entrySet = indexColumnMap.entrySet();
        final StringBuilder oneUniqueSb = new StringBuilder();
        for (Entry<Integer, String> entry : entrySet) {
            final String columnName = entry.getValue();
            if (oneUniqueSb.length() > 0) {
                oneUniqueSb.append(", ");
            }
            oneUniqueSb.append(columnName);
        }
        sb.append(oneUniqueSb);
        sb.append(")");
    }
    final DfDocumentProperties prop = getProperties().getDocumentProperties();
    final String title = prop.resolveAttributeForSchemaHtml(sb.toString());
    return title != null ? " title=\"" + title + "\"" : "";
}
Also used : Entry(java.util.Map.Entry) DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Example 34 with DfDocumentProperties

use of org.dbflute.properties.DfDocumentProperties in project dbflute-core by dbflute.

the class Column method getAlias.

/**
 * Get the alias of the column.
 * @return The column alias as String. (NotNull, EmptyAllowed: when no alias)
 */
public String getAlias() {
    final DfDocumentProperties prop = getProperties().getDocumentProperties();
    final String comment = _plainComment;
    if (comment != null) {
        final String alias = prop.extractAliasFromDbComment(comment);
        if (alias != null) {
            return alias;
        }
    }
    return "";
}
Also used : DfDocumentProperties(org.dbflute.properties.DfDocumentProperties)

Aggregations

DfDocumentProperties (org.dbflute.properties.DfDocumentProperties)34 DfSchemaHtmlBuilder (org.dbflute.logic.doc.schemahtml.DfSchemaHtmlBuilder)4 Map (java.util.Map)3 DfColumnListToStringBuilder (org.dbflute.logic.generate.column.DfColumnListToStringBuilder)3 Entry (java.util.Map.Entry)2 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BigDecimal (java.math.BigDecimal)1 DfBuildProperties (org.dbflute.DfBuildProperties)1 JavaPropertiesProperty (org.dbflute.helper.jprop.JavaPropertiesProperty)1 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)1 DfLanguageGrammar (org.dbflute.logic.generate.language.grammar.DfLanguageGrammar)1 DfBasicProperties (org.dbflute.properties.DfBasicProperties)1