Search in sources :

Example 26 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class FunctionFilterOption method doProcessDateAdd.

protected String doProcessDateAdd(String functionExp, int index, Object addedValue, String propertyName, boolean minus) {
    if (addedValue == null) {
        return functionExp;
    }
    if (!isDateTypeColumn()) {
        // if info is null, means e.g. mystic
        String msg = "The column should be Date type for the function e.g. addDay():";
        msg = msg + " column=" + _targetColumnInfo;
        throw new IllegalConditionBeanOperationException(msg);
    }
    if (isDatabaseMySQL()) {
        return doProcessDateAddMySQL(functionExp, index, addedValue, propertyName, minus);
    } else if (isDatabasePostgreSQL()) {
        return doProcessDateAddPostgreSQL(functionExp, index, addedValue, propertyName, minus);
    } else if (isDatabaseOracle()) {
        return doProcessDateAddOracle(functionExp, index, addedValue, propertyName, minus);
    } else if (isDatabaseDB2()) {
        return doProcessDateAddDB2(functionExp, index, addedValue, propertyName, minus);
    } else if (isDatabaseSQLServer()) {
        return doProcessDateAddSQLServer(functionExp, index, addedValue, propertyName, minus);
    } else if (isDatabaseH2()) {
        // same as SQLServer
        return doProcessDateAddSQLServer(functionExp, index, addedValue, propertyName, minus);
    } else {
        String msg = "Unsupported database to the function addXxx(): " + propertyName;
        throw new IllegalConditionBeanOperationException(msg);
    }
}
Also used : IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 27 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ConditionKey method resolveCompoundColumn.

protected ColumnRealName resolveCompoundColumn(ColumnRealName baseRealName, ConditionOption option) {
    if (option == null || !option.hasCompoundColumn()) {
        return baseRealName;
    }
    if (!option.hasStringConnector()) {
        // basically no way
        String msg = "The option should have string connector when compound column is specified: " + option;
        throw new IllegalConditionBeanOperationException(msg);
    }
    final List<SpecifiedColumn> compoundColumnList = option.getCompoundColumnList();
    final List<ColumnRealName> realNameList = new ArrayList<ColumnRealName>();
    // already cipher
    realNameList.add(doResolveCompoundColumnOption(option, baseRealName));
    for (SpecifiedColumn specifiedColumn : compoundColumnList) {
        realNameList.add(doResolveCompoundColumnOption(option, doResolveCompoundColumnCipher(option, specifiedColumn)));
    }
    final OnQueryStringConnector stringConnector = option.getStringConnector();
    final String connected = stringConnector.connect(realNameList.toArray());
    return ColumnRealName.create(null, new ColumnSqlName(connected));
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) ArrayList(java.util.ArrayList) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) OnQueryStringConnector(org.dbflute.dbway.OnQueryStringConnector)

Example 28 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class HpCalcSpecification method throwSpecifiedConditionBeanNotFoundException.

protected void throwSpecifiedConditionBeanNotFoundException() {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the specified condition-bean.");
    br.addItem("Advice");
    br.addElement("You should call specify(cb) before building statements.");
    br.addItem("Specify Query");
    br.addElement(_specifyQuery);
    br.addItem("Calculation List");
    if (!_calculationList.isEmpty()) {
        for (HpCalcElement element : _calculationList) {
            br.addElement(element);
        }
    } else {
        br.addElement("*No calculation");
    }
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 29 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class HpCalcSpecification method throwCalculationColumnRelationUnresolvedException.

protected void throwCalculationColumnRelationUnresolvedException(String targetExp, SpecifiedColumn calculationColumn) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The relation for the calculation column was unresolved.");
    br.addItem("Advice");
    br.addElement("For example, you cannot use relation columns for calculation");
    br.addElement("on set clause of update. (because of relation unresolved)");
    br.addItem("Base ConditionBean");
    br.addElement(_baseCB.getClass().getName());
    br.addItem("Specified Column");
    br.addElement(targetExp);
    br.addItem("Calculation Column");
    br.addElement(calculationColumn);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 30 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class UpdateOption method throwVaryingUpdateSpecifyCalculatonUnsupportedException.

protected void throwVaryingUpdateSpecifyCalculatonUnsupportedException(String columnDbName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("VaryingUpdate with SpecifyCalculation is unsupported.");
    br.addItem("Advice");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    option.self(cb -> {");
    br.addElement("        cb.specify().columnPurchaseCount().plus(1); // *NG");
    br.addElement("    }).multiply(3);");
    br.addElement("  (o):");
    br.addElement("    option.self(cb -> {");
    br.addElement("        cb.specify().columnPurchaseCount();");
    br.addElement("    }).plus(1).multiply(3); // OK");
    br.addItem("Specified Column");
    br.addElement(columnDbName);
    final String msg = br.buildExceptionMessage();
    // because of specified by ConditionBean
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Aggregations

IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)36 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)24 HpMobCaseWhenElement (org.dbflute.cbean.chelper.HpMobCaseWhenElement)3 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)3 DBMeta (org.dbflute.dbmeta.DBMeta)3 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)3 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)3 ArrayList (java.util.ArrayList)2 Method (java.lang.reflect.Method)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Entity (org.dbflute.Entity)1 HpCBPurpose (org.dbflute.cbean.chelper.HpCBPurpose)1 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)1 OrderByClause (org.dbflute.cbean.sqlclause.orderby.OrderByClause)1 OrderByElement (org.dbflute.cbean.sqlclause.orderby.OrderByElement)1 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)1