Search in sources :

Example 6 with ConditionInvokingFailureException

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

the class AbstractConditionQuery method throwConditionInvokingForeignQueryReflectionFailureException.

protected void throwConditionInvokingForeignQueryReflectionFailureException(ConditionQuery cq, String foreignPropertyName, String methodName, ReflectionFailureException cause) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Failed to invoke the method for setting a condition(query).");
    br.addItem("Table");
    br.addElement(asTableDbName());
    br.addItem("foreignPropertyName");
    br.addElement(foreignPropertyName);
    br.addItem("Method");
    br.addElement(methodName);
    final String msg = br.buildExceptionMessage();
    throw new ConditionInvokingFailureException(msg, cause);
}
Also used : ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Example 7 with ConditionInvokingFailureException

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

the class AbstractConditionQuery method throwConditionInvokingOrderMethodNotFoundException.

protected void throwConditionInvokingOrderMethodNotFoundException(String columnFlexibleName, boolean isAsc, String methodName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the method for adding the order-by condition.");
    br.addItem("Table");
    br.addElement(asTableDbName());
    br.addItem("columnFlexibleName");
    br.addElement(columnFlexibleName);
    br.addItem("isAsc");
    br.addElement(isAsc);
    br.addItem("Method");
    br.addElement(methodName);
    final String msg = br.buildExceptionMessage();
    throw new ConditionInvokingFailureException(msg);
}
Also used : ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Example 8 with ConditionInvokingFailureException

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

the class AbstractConditionQuery method throwConditionInvokingOrderReflectionFailureException.

protected void throwConditionInvokingOrderReflectionFailureException(String columnFlexibleName, boolean isAsc, String methodName, ReflectionFailureException cause) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Failed to invoke the method for setting the order-by condition.");
    br.addItem("Table");
    br.addElement(asTableDbName());
    br.addItem("columnFlexibleName");
    br.addElement(columnFlexibleName);
    br.addItem("isAsc");
    br.addElement(isAsc);
    br.addItem("Method");
    br.addElement(methodName);
    final String msg = br.buildExceptionMessage();
    throw new ConditionInvokingFailureException(msg, cause);
}
Also used : ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder)

Example 9 with ConditionInvokingFailureException

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

the class AbstractConditionBean method invokeSetupSelect.

// ===================================================================================
// Reflection Invoking
// ===================
/**
 * {@inheritDoc}
 */
public void invokeSetupSelect(String foreignPropertyNamePath) {
    assertStringNotNullAndNotTrimmedEmpty("foreignPropertyNamePath", foreignPropertyNamePath);
    final String delimiter = ".";
    Object currentObj = this;
    String remainder = foreignPropertyNamePath;
    int count = 0;
    boolean last = false;
    while (true) {
        final int deimiterIndex = remainder.indexOf(delimiter);
        final String propertyName;
        if (deimiterIndex < 0) {
            propertyName = remainder;
            last = true;
        } else {
            propertyName = remainder.substring(0, deimiterIndex);
            remainder = remainder.substring(deimiterIndex + delimiter.length(), remainder.length());
        }
        final Class<?> targetType = currentObj.getClass();
        final String methodName = (count == 0 ? "setupSelect_" : "with") + initCap(propertyName);
        final Method method = xhelpGettingCBChainMethod(targetType, methodName, (Class<?>[]) null);
        if (method == null) {
            String msg = "Not found the method for setupSelect:";
            msg = msg + " foreignPropertyNamePath=" + foreignPropertyNamePath;
            msg = msg + " targetType=" + targetType + " methodName=" + methodName;
            throw new ConditionInvokingFailureException(msg);
        }
        try {
            currentObj = DfReflectionUtil.invoke(method, currentObj, (Object[]) null);
        } catch (ReflectionFailureException e) {
            String msg = "Failed to invoke the method:";
            msg = msg + " foreignPropertyNamePath=" + foreignPropertyNamePath;
            msg = msg + " targetType=" + targetType + " methodName=" + methodName;
            throw new ConditionInvokingFailureException(msg, e);
        }
        ++count;
        if (last) {
            break;
        }
    }
}
Also used : ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) Method(java.lang.reflect.Method) ReflectionFailureException(org.dbflute.util.DfReflectionUtil.ReflectionFailureException)

Example 10 with ConditionInvokingFailureException

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

the class AbstractConditionBean method invokeSpecifyColumn.

/**
 * {@inheritDoc}
 */
public SpecifiedColumn invokeSpecifyColumn(String columnPropertyPath) {
    final String delimiter = ".";
    Object currentObj = localSp();
    String remainder = columnPropertyPath;
    boolean last = false;
    while (true) {
        final int deimiterIndex = remainder.indexOf(delimiter);
        final String propertyName;
        if (deimiterIndex < 0) {
            // hard to get relation DB meta so plain name
            propertyName = remainder;
            last = true;
        } else {
            propertyName = remainder.substring(0, deimiterIndex);
            remainder = remainder.substring(deimiterIndex + delimiter.length(), remainder.length());
        }
        final Class<?> targetType = currentObj.getClass();
        final String methodName = (last ? "column" : "specify") + initCap(propertyName);
        final Method method = xhelpGettingCBChainMethod(targetType, methodName, (Class<?>[]) null);
        if (method == null) {
            String msg = "Not found the method for SpecifyColumn:";
            msg = msg + " columnPropertyPath=" + columnPropertyPath + " targetType=" + targetType + " methodName=" + methodName;
            throw new ConditionInvokingFailureException(msg);
        }
        try {
            currentObj = DfReflectionUtil.invoke(method, currentObj, (Object[]) null);
        } catch (ReflectionFailureException e) {
            String msg = "Failed to invoke the method:";
            msg = msg + " columnPropertyPath=" + columnPropertyPath + " targetType=" + targetType + " methodName=" + methodName;
            throw new ConditionInvokingFailureException(msg, e);
        }
        if (last) {
            break;
        }
    }
    return (SpecifiedColumn) currentObj;
}
Also used : ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) Method(java.lang.reflect.Method) ReflectionFailureException(org.dbflute.util.DfReflectionUtil.ReflectionFailureException) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn)

Aggregations

ConditionInvokingFailureException (org.dbflute.exception.ConditionInvokingFailureException)10 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)8 Method (java.lang.reflect.Method)3 ReflectionFailureException (org.dbflute.util.DfReflectionUtil.ReflectionFailureException)3 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)1