Search in sources :

Example 11 with IllegalArgumentException

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();
}
Also used : Method(java.lang.reflect.Method) IllegalArgumentException(com.sun.star.lang.IllegalArgumentException)

Aggregations

IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)11 PropertyVetoException (com.sun.star.beans.PropertyVetoException)6 UnknownPropertyException (com.sun.star.beans.UnknownPropertyException)6 XPropertySet (com.sun.star.beans.XPropertySet)6 WrappedTargetException (com.sun.star.lang.WrappedTargetException)6 DisposedException (com.sun.star.lang.DisposedException)4 XTextContent (com.sun.star.text.XTextContent)4 IOException (java.io.IOException)4 Point (com.sun.star.awt.Point)3 IllegalTypeException (com.sun.star.beans.IllegalTypeException)3 NotRemoveableException (com.sun.star.beans.NotRemoveableException)3 PropertyExistException (com.sun.star.beans.PropertyExistException)3 BootstrapException (com.sun.star.comp.helper.BootstrapException)3 NoSuchElementException (com.sun.star.container.NoSuchElementException)3 XNamed (com.sun.star.container.XNamed)3 XTextCursor (com.sun.star.text.XTextCursor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 MalformedURLException (java.net.MalformedURLException)3 ArrayList (java.util.ArrayList)3 UndefinedParagraphFormatException (org.jabref.logic.openoffice.UndefinedParagraphFormatException)3