Search in sources :

Example 16 with Column

use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.

the class DfColumnListToStringBuilder method getColumnJavaNameCommaString.

public static String getColumnJavaNameCommaString(List<Column> columnList) {
    validateColumnList(columnList);
    String result = "";
    for (Column column : columnList) {
        final String name = column.getJavaName();
        if ("".equals(result)) {
            result = name;
        } else {
            result = result + ", " + name;
        }
    }
    return result;
}
Also used : Column(org.apache.torque.engine.database.model.Column)

Example 17 with Column

use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.

the class DfColumnListToStringBuilder method getColumnOrderByString.

public static String getColumnOrderByString(List<Column> columnList, String sortString) {
    validateColumnList(columnList);
    final StringBuilder sb = new StringBuilder();
    for (Column column : columnList) {
        final String name = column.getName();
        if ("".equals(sb.toString())) {
            sb.append(name).append(" ").append(sortString);
        } else {
            sb.append(", ").append(name).append(" ").append(sortString);
        }
    }
    return sb.toString();
}
Also used : Column(org.apache.torque.engine.database.model.Column)

Example 18 with Column

use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.

the class DfColumnListToStringBuilder method doGetColumnArgsAssertString.

private static String doGetColumnArgsAssertString(List<Column> columnList, boolean initCap) {
    validateColumnList(columnList);
    final StringBuilder sb = new StringBuilder();
    for (Iterator<Column> ite = columnList.iterator(); ite.hasNext(); ) {
        final Column pk = (Column) ite.next();
        final String uncapitalisedJavaName = pk.getUncapitalisedJavaName();
        sb.append(initCap ? "A" : "a").append("ssertObjectNotNull(\"");
        sb.append(uncapitalisedJavaName).append("\", ");
        sb.append(uncapitalisedJavaName).append(");");
    }
    return sb.toString();
}
Also used : Column(org.apache.torque.engine.database.model.Column)

Example 19 with Column

use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.

the class DfColumnListToStringBuilder method getColumnDispValueString.

public static String getColumnDispValueString(List<Column> columnList, String getterPrefix) {
    validateColumnList(columnList);
    String result = "";
    for (Column column : columnList) {
        final String javaName = column.getJavaName();
        final String getterString = getterPrefix + javaName + "()";
        if ("".equals(result)) {
            result = getterString;
        } else {
            result = result + " + \"-\" + " + getterString;
        }
    }
    return result;
}
Also used : Column(org.apache.torque.engine.database.model.Column)

Example 20 with Column

use of org.apache.torque.engine.database.model.Column in project dbflute-core by dbflute.

the class DfSPolicyTableStatementChecker method doEvaluateColumnThenItemValue.

protected String doEvaluateColumnThenItemValue(DfSPolicyStatement statement, DfSPolicyThenPart thenPart, Table table, Function<String, String> violationCall) {
    final String thenItem = thenPart.getThenItem();
    final String thenValue = thenPart.getThenValue();
    final boolean notThenValue = thenPart.isNotThenValue();
    if (thenItem.equalsIgnoreCase("tableName")) {
        // e.g. tableName is prefix:CLS_
        final String tableName = toComparingTableName(table);
        if (!isHitExp(statement, tableName, toTableNameComparingThenValue(table, thenValue)) == !notThenValue) {
            return violationCall.apply(tableName);
        }
    } else if (thenItem.equalsIgnoreCase("alias")) {
        // e.g. alias is suffix:History
        final String alias = table.getAlias();
        if (!isHitExp(statement, alias, toAliasComparingThenValue(table, thenValue)) == !notThenValue) {
            return violationCall.apply(alias);
        }
    } else if (thenItem.equalsIgnoreCase("comment")) {
        // e.g. comment is contain:SEA
        final String comment = table.getComment();
        if (!isHitExp(statement, comment, thenValue) == !notThenValue) {
            return violationCall.apply(comment);
        }
    } else if (thenItem.equalsIgnoreCase("pkName")) {
        // e.g. pkName is prefix:PK_
        if (table.hasPrimaryKey()) {
            final List<Column> columnList = table.getPrimaryKey();
            // same name if compound
            final Column pk = columnList.get(0);
            final String pkName = pk.getPrimaryKeyName();
            final String comparingThenValue = toConstraintNameComparingThenValue(table, thenValue, columnList);
            if (!isHitExp(statement, pkName, comparingThenValue) == !notThenValue) {
                final String disp = pkName + (pk.isAdditionalPrimaryKey() ? ADDITIONAL_SUFFIX : "");
                return violationCall.apply(disp);
            }
        }
    } else if (thenItem.equalsIgnoreCase("fkName")) {
        // e.g. fkName is prefix:FK_
        for (ForeignKey fk : table.getForeignKeyList()) {
            final String fkName = fk.getName();
            final String comparingThenValue = toConstraintNameComparingThenValue(table, thenValue, fk.getLocalColumnList());
            if (!isHitExp(statement, fkName, comparingThenValue) == !notThenValue) {
                final String disp = fkName + (fk.isAdditionalForeignKey() ? ADDITIONAL_SUFFIX : "");
                return violationCall.apply(disp);
            }
        }
    } else if (thenItem.equalsIgnoreCase("uniqueName")) {
        // e.g. uniqueName is prefix:UQ_
        for (Unique uq : table.getUniqueList()) {
            final String uqName = uq.getName();
            final String comparingThenValue = toConstraintNameComparingThenValue(table, thenValue, uq.getColumnList());
            if (!isHitExp(statement, uqName, comparingThenValue)) {
                final String disp = uqName + (uq.isAdditional() ? ADDITIONAL_SUFFIX : "");
                return violationCall.apply(disp);
            }
        }
    } else if (thenItem.equalsIgnoreCase("indexName")) {
        // e.g. indexName is prefix:IX_
        for (Index ix : table.getIndexList()) {
            final String ixName = ix.getName();
            final String comparingThenValue = toConstraintNameComparingThenValue(table, thenValue, ix.getColumnList());
            if (!isHitExp(statement, ixName, comparingThenValue) == !notThenValue) {
                return violationCall.apply(ixName);
            }
        }
    } else if (thenItem.equalsIgnoreCase("pk_columnName")) {
        return determinePkSomethingThenValue(statement, table, violationCall, thenValue, notThenValue, pk -> toComparingColumnName(pk));
    } else if (thenItem.equalsIgnoreCase("pk_dbType") || thenItem.equalsIgnoreCase("pkDbType")) {
        // for compatible
        return determinePkSomethingThenValue(statement, table, violationCall, thenValue, notThenValue, pk -> pk.getDbType());
    } else if (thenItem.equalsIgnoreCase("pk_size")) {
        return determinePkSomethingThenValue(statement, table, violationCall, thenValue, notThenValue, pk -> pk.getColumnSize());
    } else if (thenItem.equalsIgnoreCase("pk_dbType_with_size")) {
        // e.g. char(3)
        return determinePkSomethingThenValue(statement, table, violationCall, thenValue, notThenValue, pk -> toComparingDbTypeWithSize(pk));
    } else {
        throwSchemaPolicyCheckIllegalIfThenStatementException(statement, "Unknown then-item: " + thenItem);
    }
    // no violation
    return null;
}
Also used : DfSPolicyStatement(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement) DfSPolicyThenClause(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyThenClause) Column(org.apache.torque.engine.database.model.Column) DfSPolicyThenPart(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyThenPart) DfSPolicyIfPart(org.dbflute.logic.doc.spolicy.parsed.DfSPolicyStatement.DfSPolicyIfPart) DfSPolicyFirstDateSecretary(org.dbflute.logic.doc.spolicy.secretary.DfSPolicyFirstDateSecretary) DfSPolicyLogicalSecretary(org.dbflute.logic.doc.spolicy.secretary.DfSPolicyLogicalSecretary) Function(java.util.function.Function) ForeignKey(org.apache.torque.engine.database.model.ForeignKey) List(java.util.List) Unique(org.apache.torque.engine.database.model.Unique) Index(org.apache.torque.engine.database.model.Index) Table(org.apache.torque.engine.database.model.Table) DfSPolicyResult(org.dbflute.logic.doc.spolicy.result.DfSPolicyResult) Srl(org.dbflute.util.Srl) Column(org.apache.torque.engine.database.model.Column) List(java.util.List) Unique(org.apache.torque.engine.database.model.Unique) Index(org.apache.torque.engine.database.model.Index) ForeignKey(org.apache.torque.engine.database.model.ForeignKey)

Aggregations

Column (org.apache.torque.engine.database.model.Column)50 Table (org.apache.torque.engine.database.model.Table)16 List (java.util.List)10 Map (java.util.Map)8 ForeignKey (org.apache.torque.engine.database.model.ForeignKey)8 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)6 Database (org.apache.torque.engine.database.model.Database)5 DfBuildProperties (org.dbflute.DfBuildProperties)4 DfDataRow (org.dbflute.helper.dataset.DfDataRow)4 DfDataTable (org.dbflute.helper.dataset.DfDataTable)4 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)4 DfLanguageDependency (org.dbflute.logic.generate.language.DfLanguageDependency)4 Function (java.util.function.Function)3 File (java.io.File)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Predicate (java.util.function.Predicate)2