use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.
the class Column method fromXML.
/**
* Deserialise this PageConfig instance from the specified XML stream.
*
* @param xml
*/
public void fromXML(DashboardsConfigElement config, String xml) {
try {
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(xml));
Element rootElement = document.getRootElement();
// walk the pages found in xml
Iterator itrPages = rootElement.elementIterator(ELEMENT_PAGE);
while (itrPages.hasNext()) {
Element pageElement = (Element) itrPages.next();
String layoutId = pageElement.attributeValue(ATTR_LAYOUTID);
LayoutDefinition layoutDef = config.getLayoutDefinition(layoutId);
if (layoutDef != null) {
// found the layout now build the page and read the columns
Page page = new Page(pageElement.attributeValue(ATTR_ID), layoutDef);
Iterator itrColumns = pageElement.elementIterator(ELEMENT_COLUMN);
while (itrColumns.hasNext()) {
Column column = new Column();
// read and resolve the dashlet definitions for this column
Element columnElement = (Element) itrColumns.next();
Iterator itrDashlets = columnElement.elementIterator(ELEMENT_DASHLET);
while (itrDashlets.hasNext()) {
String dashletId = ((Element) itrDashlets.next()).attributeValue(ATTR_REFID);
DashletDefinition dashletDef = config.getDashletDefinition(dashletId);
if (dashletDef != null) {
column.addDashlet(dashletDef);
} else if (logger.isWarnEnabled()) {
logger.warn("Failed to resolve Dashboard Dashlet Definition ID: " + dashletId);
}
}
// add the column of dashlets to the page
page.addColumn(column);
}
// add the page to this config instance
this.addPage(page);
} else if (logger.isWarnEnabled()) {
logger.warn("Failed to resolve Dashboard Layout Definition ID: " + layoutId);
}
}
} catch (DocumentException docErr) {
// if we cannot parse, then we simply revert to default
}
}
Aggregations