Search in sources :

Example 6 with TableTagParseException

use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.

the class TableTagParser method createRow.

protected Row createRow(Node table) throws TableTagParseException {
    NodeList rowNodeList = ((Element) table).getElementsByTagName(TableTagConstants.ROW);
    if (rowNodeList.getLength() == 0) {
        throw new TableTagParseException(rowNodeList.toString());
    }
    Row row = new Row();
    row.setTotWidth((rowNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.TOTWIDTH).getNodeValue()));
    row.setBottomLineRequired((rowNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.BOTTOMLINEREQUIRED).getNodeValue()));
    row.setColumn(createColumn(rowNodeList.item(0)));
    return row;
}
Also used : TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 7 with TableTagParseException

use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.

the class TableTagParser method createActionParams.

protected ActionParam[] createActionParams(Node linkDetail) throws TableTagParseException {
    NodeList actionParamNodeList = ((Element) linkDetail).getElementsByTagName(TableTagConstants.ACTIONPARAM);
    if (actionParamNodeList.getLength() == 0) {
        throw new TableTagParseException(actionParamNodeList.toString());
    }
    ActionParam[] actionParam = new ActionParam[actionParamNodeList.getLength()];
    for (int i = 0; i < actionParamNodeList.getLength(); i++) {
        actionParam[i] = new ActionParam();
        actionParam[i].setName(actionParamNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.NAME).getNodeValue());
        actionParam[i].setValueType(actionParamNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.VALUETYPE).getNodeValue());
        if (!actionParam[i].getValueType().equalsIgnoreCase(TableTagConstants.INBUILD)) {
            actionParam[i].setValue(actionParamNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.VALUE).getNodeValue());
        }
    }
    return actionParam;
}
Also used : TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 8 with TableTagParseException

use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.

the class TableTagParser method createColumn.

protected Column[] createColumn(Node row) throws TableTagParseException {
    NodeList columnNodeList = ((Element) row).getElementsByTagName(TableTagConstants.COLUMN);
    if (columnNodeList.getLength() == 0) {
        throw new TableTagParseException(columnNodeList.toString());
    }
    Column[] column = new Column[columnNodeList.getLength()];
    for (int i = 0; i < columnNodeList.getLength(); i++) {
        column[i] = new Column();
        setColumnAttributes(column[i], columnNodeList.item(i).getAttributes());
        column[i].setColumnDetials(createColumnDetails(columnNodeList.item(i)));
        if (TableTagConstants.LINK.equalsIgnoreCase(column[i].getColumnType())) {
            column[i].setLinkDetails(createLinkDetails(columnNodeList.item(i)));
        }
    }
    return column;
}
Also used : TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 9 with TableTagParseException

use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.

the class TableTagParser method createLinkDetails.

protected LinkDetails createLinkDetails(Node column) throws TableTagParseException {
    NodeList linkDetailsNodeList = ((Element) column).getElementsByTagName(TableTagConstants.LINKDETAILS);
    if (linkDetailsNodeList.getLength() == 0) {
        throw new TableTagParseException(linkDetailsNodeList.toString());
    }
    LinkDetails linkDetails = new LinkDetails();
    if (linkDetailsNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.ACTION).getNodeValue() == null) {
        throw new TableTagParseException(linkDetailsNodeList.toString());
    }
    linkDetails.setAction(linkDetailsNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.ACTION).getNodeValue());
    linkDetails.setActionParam(createActionParams(linkDetailsNodeList.item(0)));
    return linkDetails;
}
Also used : TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 10 with TableTagParseException

use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.

the class Column method getTableColumn.

public void getTableColumn(StringBuilder tableInfo, Object obj, Locale locale, Locale mfiLocale, int glMode) throws TableTagParseException {
    Method[] methods = obj.getClass().getMethods();
    for (Method method : methods) {
        if (method.getName().equalsIgnoreCase("get".concat(getValue()))) {
            try {
                String total = String.valueOf(method.invoke(obj, new Object[] {}));
                Pattern pattern = Pattern.compile("(total|debit|credi|installment|principal|interest|feesWithMiscFee|loanAmount|amount|runningBalance|feesWithMiscFee)");
                Matcher matcher = pattern.matcher(getValue());
                Pattern isNumber = Pattern.compile("^((\\d)+(\\.(\\d)+))?$");
                Matcher numberMatcher = isNumber.matcher(total);
                if (matcher.find() || numberMatcher.find()) {
                    total = ConversionUtil.formatNumber(total);
                }
                if (getValue().equalsIgnoreCase("Glcode")) {
                    Method declaredMethod = obj.getClass().getMethod("getGlname", null);
                    String glName = String.valueOf(declaredMethod.invoke(obj, new Object[] {}));
                    if (glMode == 1) {
                        total = total + " - " + glName;
                    } else if (glMode == 2) {
                        total = glName + " (" + total + ")";
                    } else if (glMode == 3) {
                        total = glName;
                    }
                }
                tableInfo.append(total);
            } catch (IllegalAccessException e) {
                throw new TableTagParseException(e);
            } catch (InvocationTargetException ex) {
                throw new TableTagParseException(ex);
            } catch (SecurityException e) {
                throw new TableTagParseException(e);
            } catch (NoSuchMethodException e) {
                throw new TableTagParseException(e);
            }
        }
        if (method.getName().equalsIgnoreCase("setLocale") && locale != null) {
            try {
                Object[] argumentLocale = new Object[] { locale };
                method.invoke(obj, argumentLocale);
            } catch (IllegalAccessException e) {
                throw new TableTagParseException(e);
            } catch (InvocationTargetException ex) {
                throw new TableTagParseException(ex);
            }
        }
        if (method.getName().equalsIgnoreCase("setMfiLocale") && mfiLocale != null) {
            try {
                Object[] argumentLocale = new Object[] { mfiLocale };
                method.invoke(obj, argumentLocale);
            } catch (IllegalAccessException e) {
                throw new TableTagParseException(e);
            } catch (InvocationTargetException ex) {
                throw new TableTagParseException(ex);
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) TableTagParseException(org.mifos.framework.exceptions.TableTagParseException) Matcher(java.util.regex.Matcher) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

TableTagParseException (org.mifos.framework.exceptions.TableTagParseException)15 NodeList (org.w3c.dom.NodeList)10 Element (org.w3c.dom.Element)9 IOException (java.io.IOException)2 List (java.util.List)2 JspException (javax.servlet.jsp.JspException)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)2 Document (org.w3c.dom.Document)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 JspWriter (javax.servlet.jsp.JspWriter)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1