use of org.dbflute.util.DfReflectionUtil.ReflectionFailureException 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;
}
use of org.dbflute.util.DfReflectionUtil.ReflectionFailureException 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;
}
}
}
use of org.dbflute.util.DfReflectionUtil.ReflectionFailureException in project dbflute-core by dbflute.
the class AbstractConditionQuery method doInvokeHasForeignCQ.
protected boolean doInvokeHasForeignCQ(ConditionQuery cq, String foreignPropertyName) {
assertStringNotNullAndNotTrimmedEmpty("foreignPropertyName", foreignPropertyName);
final String methodName = "hasConditionQuery" + initCap(foreignPropertyName);
final Method method = xhelpGettingCQMethod(cq, methodName, (Class<?>[]) null);
if (method == null) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not found the method for determining a foreign condition query.");
br.addItem("Table");
br.addElement(cq.asTableDbName());
br.addItem("foreignPropertyName");
br.addElement(foreignPropertyName);
br.addItem("methodName");
br.addElement(methodName);
br.addItem("ConditionQuery");
br.addElement(DfTypeUtil.toClassTitle(cq));
final String msg = br.buildExceptionMessage();
throw new ConditionInvokingFailureException(msg);
}
try {
return (Boolean) xhelpInvokingCQMethod(cq, method, (Object[]) null);
} catch (ReflectionFailureException e) {
String msg = "Failed to invoke the method for determining a condition(query):";
msg = msg + " foreignPropertyName=" + foreignPropertyName;
msg = msg + " methodName=" + methodName + " table=" + asTableDbName();
throw new ConditionInvokingFailureException(msg, e);
}
}
use of org.dbflute.util.DfReflectionUtil.ReflectionFailureException in project dbflute-core by dbflute.
the class AbstractConditionQuery method invokeValue.
// ===================================================================================
// Reflection Invoking
// ===================
/**
* {@inheritDoc}
*/
public ConditionValue invokeValue(String columnFlexibleName) {
assertStringNotNullAndNotTrimmedEmpty("columnFlexibleName", columnFlexibleName);
final DBMeta dbmeta = xgetLocalDBMeta();
final String columnCapPropName = initCap(dbmeta.findColumnInfo(columnFlexibleName).getPropertyName());
final String methodName = "xdfget" + columnCapPropName;
final Method method = xhelpGettingCQMethod(this, methodName, (Class<?>[]) null);
if (method == null) {
throwConditionInvokingGetMethodNotFoundException(columnFlexibleName, methodName);
// unreachable
return null;
}
try {
return (ConditionValue) xhelpInvokingCQMethod(this, method, (Object[]) null);
} catch (ReflectionFailureException e) {
throwConditionInvokingGetReflectionFailureException(columnFlexibleName, methodName, e);
// unreachable
return null;
}
}
use of org.dbflute.util.DfReflectionUtil.ReflectionFailureException in project dbflute-core by dbflute.
the class AbstractConditionQuery method doInvokeForeignCQ.
protected ConditionQuery doInvokeForeignCQ(ConditionQuery cq, String foreignPropertyName) {
assertStringNotNullAndNotTrimmedEmpty("foreignPropertyName", foreignPropertyName);
final String methodName = "query" + initCap(foreignPropertyName);
final Method method = xhelpGettingCQMethod(cq, methodName, (Class<?>[]) null);
if (method == null) {
throwConditionInvokingForeignQueryMethodNotFoundException(cq, foreignPropertyName, methodName);
// unreachable
return null;
}
try {
return (ConditionQuery) xhelpInvokingCQMethod(cq, method, (Object[]) null);
} catch (ReflectionFailureException e) {
throwConditionInvokingForeignQueryReflectionFailureException(cq, foreignPropertyName, methodName, e);
// unreachable
return null;
}
}
Aggregations