NodeList attribList;
NodeList listDefs;
Element listElement;
Element attribElement;
StaticList sList = null;
DynamicList dList = null;
ListItem item;
// Inicializa el contenedor de listas
HashMap<String, List> lists = new HashMap<String, List>();
// Comprueba si existe la definici�n
attribList = doc.getElementsByTagName(DataServiceProperties.XML_TAG_DATALISTS);
if (attribList.getLength() < 1)
{
return lists;
}
// Carga las listas est�ticas
listDefs = doc.getElementsByTagName(DataServiceProperties.XML_TAG_STATICLIST);
for (int pidx = 0; pidx < listDefs.getLength(); pidx++)
{
listNode = listDefs.item(pidx);
if (listNode.getNodeType() == Node.ELEMENT_NODE)
{
listElement = (Element) listNode;
sList = new StaticList(listElement.getAttribute(DataServiceProperties.XML_ATT_ID));
attribList = listElement.getElementsByTagName(DataServiceProperties.XML_TAG_STATICLISTITEM);
for (int aidx = 0; aidx < attribList.getLength(); aidx++)
{
attribNode = attribList.item(aidx);
if (attribNode.getNodeType() == Node.ELEMENT_NODE)
{
attribElement = (Element) attribNode;
item = new ListItem(attribElement.getAttribute(DataServiceProperties.XML_ATT_VALUE),
attribElement.getAttribute(DataServiceProperties.XML_ATT_TITLE));
if (!StringUtils.isNullOrEmptyTrim(attribElement.getAttribute(DataServiceProperties.XML_ATT_DEFAULTVALUE)))
{
item.setDefault(attribElement.getAttribute(DataServiceProperties.XML_ATT_DEFAULTVALUE).equals("true") ||
attribElement.getAttribute(DataServiceProperties.XML_ATT_DEFAULTVALUE).equals("1"));
}
sList.addListItem(item);
}
}
lists.put(sList.getId(), sList);
}
}
// Carga las listas din�micas SQL
listDefs = doc.getElementsByTagName(DataServiceProperties.XML_TAG_DYNAMICLIST);
for (int pidx = 0; pidx < listDefs.getLength(); pidx++)
{
listNode = listDefs.item(pidx);
if (listNode.getNodeType() == Node.ELEMENT_NODE)
{
listElement = (Element) listNode;
dList = new DynamicList(listElement.getAttribute(DataServiceProperties.XML_ATT_ID));
dList.setConnection(listElement.getAttribute(DataServiceProperties.XML_ATT_CONNECTION));
dList.setValueFieldName(listElement.getAttribute(DataServiceProperties.XML_ATT_VALUE));
dList.setTitleFieldName(listElement.getAttribute(DataServiceProperties.XML_ATT_TITLE));
attribList = listElement.getElementsByTagName(DataServiceProperties.XML_TAG_SQLSTATEMENT);
if (attribList.getLength() > 0)
{
attribNode = attribList.item(0);
dList.setSqlStatement(attribNode.getFirstChild().getNodeValue());
lists.put(dList.getId(), dList);
}
}
}
return lists;