public static boolean setProjectionDefault(Object flavor, String tableName, ValMap map) { if (ProfileManager.transportsLoaded()) { String xpath = ProfileManager.transportsSelector + flavorSelector(flavor); Element element = selectElement(ProfileManager.transports, xpath); if (element != null && notNullOrEmpty(tableName)) { Element el = ProfileManager.transports.createElement("PROJECTION"); try { BidiMultiMap projection = (BidiMultiMap) map.get("projection"); xmlSerialize(projection, el, null); el.setAttribute("version", "" + map.get("version")); el.setAttribute("table", tableName); } catch (Exception e) { Log.e(TAG, "setDefaultProjection", e); return false; } NodeList nodes = evaluateXPath(element, "." + projectionSelector(tableName)); if (nodes != null && nodes.getLength() > 0) { Node node = nodes.item(0); node.getParentNode().replaceChild(el, node); } else element.appendChild(el); ProfileManager.saveTransports(); return true; } } return false; }
public static ValMap getProjectionDefault(Object flavor, String tableName) { ValMap map = vmap(); if (ProfileManager.transportsLoaded()) { String xpath = ProfileManager.transportsSelector + flavorSelector(flavor); Element element = selectElement(ProfileManager.transports, xpath); if (element != null) { NodeList nodes = evaluateXPath(element, "." + projectionSelector(tableName)); if (nodes != null && nodes.getLength() > 0) { element = (Element) nodes.item(0); try { map.put("table", tableName); map.put("version", toInt(-1, element.getAttribute("version"))); map.put("projection", xmlDeserialize(element, null)); } catch (Exception e) { Log.e(TAG, "getDefaultProjection", e); } } } } return map; }