use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method parser.
public Table parser(String file) throws TableTagParseException {
Table table = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
SchemaFactory schfactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
schfactory.setErrorHandler(null);
Schema schema = schfactory.newSchema(new StreamSource(MifosResourceUtil.getClassPathResourceAsURIString(FilePaths.CUSTOMTABLETAGXSD)));
factory.setNamespaceAware(false);
factory.setValidating(false);
factory.setSchema(schema);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(null);
Document document = builder.parse(MifosResourceUtil.getClassPathResourceAsURIString(file));
table = createTable(document);
} catch (Exception e) {
throw new TableTagParseException(e);
}
return table;
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method createTable.
protected Table createTable(Document document) throws TableTagParseException {
NodeList tableNode = document.getChildNodes();
if (tableNode.getLength() == 0) {
throw new TableTagParseException(tableNode.toString());
}
Table table = new Table();
table.setHeaderDetails(createHeaderDetails(tableNode.item(0)));
table.setRow(createRow(tableNode.item(0)));
return table;
}
use of org.mifos.framework.exceptions.TableTagParseException in project head by mifos.
the class TableTagParser method createColumnDetails.
protected ColumnDetails createColumnDetails(Node column) throws TableTagParseException {
NodeList columnDetailsNodeList = ((Element) column).getElementsByTagName(TableTagConstants.COLUMNDETAILS);
if (columnDetailsNodeList.getLength() == 0) {
throw new TableTagParseException(columnDetailsNodeList.toString());
}
ColumnDetails columnDetails = new ColumnDetails();
columnDetails.setRowStyle(columnDetailsNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.ROWSTYLE).getNodeValue());
columnDetails.setColWidth(columnDetailsNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.COLWIDTH).getNodeValue());
columnDetails.setAlign(columnDetailsNodeList.item(0).getAttributes().getNamedItem(TableTagConstants.ALIGN).getNodeValue());
return columnDetails;
}
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[rowNodeList.getLength()];
for (int i = 0; i < rowNodeList.getLength(); i++) {
row[i] = new Row();
row[i].setColumn(createColumn(rowNodeList.item(i)));
row[i].setTdrequired((rowNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.TDREQUIRED).getNodeValue()));
row[i].setSuppressrow((rowNodeList.item(i).getAttributes().getNamedItem(TableTagConstants.SUPRESSROW).getNodeValue()));
}
return row;
}
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(TableTagConstants.UNEXPECTED_ERROR);
}
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].setDisplayname(createDisplayName(columnNodeList.item(i)));
column[i].setParameters(createParameters(columnNodeList.item(i)));
if ("link".equals(column[i].getType())) {
if (null == column[i].getAction()) {
throw new TableTagParseException(TableTagConstants.UNEXPECTED_ERROR);
}
}
}
return column;
}
Aggregations