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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
Aggregations