use of org.apache.cayenne.ConfigurationException in project cayenne by apache.
the class UpgradeHandler_V8 method processDataMapDom.
@Override
public void processDataMapDom(UpgradeUnit upgradeUnit) {
Element dataMap = upgradeUnit.getDocument().getDocumentElement();
dataMap.setAttribute("xmlns", "http://cayenne.apache.org/schema/8/modelMap");
dataMap.setAttribute("xsi:schemaLocation", "http://cayenne.apache.org/schema/8/modelMap " + "http://cayenne.apache.org/schema/8/modelMap.xsd");
dataMap.setAttribute("project-version", getVersion());
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList queryNodes;
try {
queryNodes = (NodeList) xpath.evaluate("/data-map/query", upgradeUnit.getDocument(), XPathConstants.NODESET);
} catch (Exception ex) {
return;
}
for (int j = 0; j < queryNodes.getLength(); j++) {
Element queryElement = (Element) queryNodes.item(j);
String factory = queryElement.getAttribute("factory");
if (factory == null || factory.isEmpty()) {
continue;
}
String queryType;
switch(factory) {
case "org.apache.cayenne.map.SelectQueryBuilder":
queryType = QueryDescriptor.SELECT_QUERY;
break;
case "org.apache.cayenne.map.SQLTemplateBuilder":
queryType = QueryDescriptor.SQL_TEMPLATE;
break;
case "org.apache.cayenne.map.EjbqlBuilder":
queryType = QueryDescriptor.EJBQL_QUERY;
break;
case "org.apache.cayenne.map.ProcedureQueryBuilder":
queryType = QueryDescriptor.PROCEDURE_QUERY;
break;
default:
throw new ConfigurationException("Unknown query factory: " + factory);
}
queryElement.setAttribute("type", queryType);
queryElement.removeAttribute("factory");
}
}
Aggregations