use of com.sun.star.lang.IllegalArgumentException in project Gargoyle by callakrsos.
the class ValueUtil method createInsertStatement.
/**
* 객체로부터 insert문 스크립트를 리턴
*
* 단 객체가 테이블명 규칙에 준해야한다.
*
*
* ex) TbmUser ::: TBM_USER 테이블을 찾는다. TbpSx ::: Tbp_Sx 테이블을 찾는다. ex) TbmMsMdDVO ::: TBM_MS_MD 테이블을 찾는다.
*
* @작성자 : KYJ
* @작성일 : 2016. 3. 29.
* @param dvo
* @param columns
* @return
* @throws Exception
*/
private static String createInsertStatement(final Object dvo, final List<String> columns) throws Exception {
if (isEmpty(dvo)) {
return "";
}
StringBuffer insertStatement = new StringBuffer();
String tableName = getTableNameByClass(dvo.getClass());
if (isNotEmpty(tableName)) {
if (isNotEmpty(columns)) {
StringBuffer columnsBuffer = new StringBuffer();
StringBuffer valuesBuffer = new StringBuffer();
insertStatement.append("INSERT INTO ").append(tableName).append("\n");
insertStatement.append("(\n");
for (String column : columns) {
try {
String prefixUpperText = getPrefixUpperTextMyEdit(column);
Method declaredMethod = dvo.getClass().getDeclaredMethod("get".concat(prefixUpperText));
if (declaredMethod != null) {
// Object value = declaredMethod.invoke(dvo);
// if (ObjectUtil.isNotEmpty(value)) {
columnsBuffer.append(column).append(",\n");
valuesBuffer.append(":").append(getPrefixLowerTextMyEdit(column)).append("").append(",\n");
// }
}
} catch (NoSuchMethodException e) {
throw e;
}
}
if (columnsBuffer.length() <= 0 || valuesBuffer.length() <= 0) {
return "";
}
columnsBuffer.setLength(columnsBuffer.length() - 2);
valuesBuffer.setLength(valuesBuffer.length() - 2);
insertStatement.append(columnsBuffer.toString());
insertStatement.append(") VALUES (\n");
insertStatement.append(valuesBuffer.toString());
insertStatement.append(")\n");
} else {
throw new IllegalArgumentException("Table name is empty. !");
}
}
return insertStatement.toString();
}
Aggregations