List of usage examples for org.dom4j Node selectSingleNode
Node selectSingleNode(String xpathExpression);
selectSingleNode
evaluates an XPath expression and returns the result as a single Node
instance.
From source file:io.mashin.oep.hpdl.XMLReadUtils.java
License:Open Source License
public static void initStreamingPropertyFrom(StreamingPropertyElement spe, Node node, String xpath) { Node streamingNode = node.selectSingleNode(xpath); if (streamingNode != null) { initTextPropertyFrom(spe.mapper, streamingNode, "./mapper"); initTextPropertyFrom(spe.reducer, streamingNode, "./reducer"); initTextPropertyFrom(spe.recordReader, streamingNode, "./record-reader"); initTextCollectionFrom(spe.recordReaderMapping, streamingNode, "./record-reader-mapping"); initTextCollectionFrom(spe.env, streamingNode, "./env"); }/* w ww. jav a2 s .c o m*/ }
From source file:io.mashin.oep.hpdl.XMLReadUtils.java
License:Open Source License
public static void initPipesPropertyFrom(PipesPropertyElement ppe, Node node, String xpath) { Node pipesNode = node.selectSingleNode(xpath); if (pipesNode != null) { initTextPropertyFrom(ppe.map, pipesNode, "./map"); initTextPropertyFrom(ppe.reduce, pipesNode, "./reduce"); initTextPropertyFrom(ppe.inputFormat, pipesNode, "./inputformat"); initTextPropertyFrom(ppe.outputFormat, pipesNode, "./outputformat"); initTextPropertyFrom(ppe.partitioner, pipesNode, "./partitioner"); initTextPropertyFrom(ppe.writer, pipesNode, "./writer"); initTextPropertyFrom(ppe.program, pipesNode, "./program"); }/*from w w w . java2 s . c om*/ }
From source file:io.mashin.oep.hpdl.XMLReadUtils.java
License:Open Source License
public static void initSLAPropertyFrom(SLAPropertyElement sla, Node node, String xpath) { Node slaNode = null;/*from w w w. j a v a 2 s.co m*/ try { slaNode = node.selectSingleNode(xpath); } catch (Throwable t) { } if (slaNode != null) { initTextPropertyFrom(sla.appName, slaNode, "./sla:app-name"); initTextPropertyFrom(sla.nominalTime, slaNode, "./sla:nominal-time"); initTextPropertyFrom(sla.shouldStart, slaNode, "./sla:should-start"); initTextPropertyFrom(sla.shouldEnd, slaNode, "./sla:should-end"); initTextPropertyFrom(sla.maxDuration, slaNode, "./sla:max-duration"); initTextPropertyFrom(sla.parentClientId, slaNode, "./sla:parent-client-id"); initTextPropertyFrom(sla.parentSlaId, slaNode, "./sla:parent-sla-id"); initTextPropertyFrom(sla.notificationMsg, slaNode, "./sla:notification-msg"); initTextPropertyFrom(sla.alertEvents, slaNode, "./sla:alert-events"); initTextPropertyFrom(sla.alertContact, slaNode, "./sla:alert-contact"); initTextPropertyFrom(sla.devContact, slaNode, "./sla:dev-contact"); initTextPropertyFrom(sla.qaContact, slaNode, "./sla:qa-contact"); initTextPropertyFrom(sla.seContact, slaNode, "./sla:se-contact"); initTextPropertyFrom(sla.alertFrequency, slaNode, "./sla:alert-frequency"); initTextPropertyFrom(sla.alertPercentage, slaNode, "./sla:alert-percentage"); initTextPropertyFrom(sla.upstreamApps, slaNode, "./sla:upstream-apps"); } }
From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java
License:Mozilla Public License
private String loadExpression(Node calculatedFieldNode) { String expression;/* w ww . java 2s . com*/ expression = null; Node expressionNode = calculatedFieldNode.selectSingleNode(EXPRESSION_TAG); if (expressionNode != null) { expression = expressionNode.getStringValue(); } else { // for back compatibility expression = calculatedFieldNode.getStringValue(); } return expression; }
From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java
License:Mozilla Public License
private List<ModelCalculatedField.Slot> loadSlots(Node calculatedFieldNode) { List<ModelCalculatedField.Slot> slots = new ArrayList<ModelCalculatedField.Slot>(); Node slotBlock = calculatedFieldNode.selectSingleNode(SLOTS_TAG); if (slotBlock != null) { List<Node> slotNodes = slotBlock.selectNodes(SLOT_TAG); for (Node slotNode : slotNodes) { ModelCalculatedField.Slot slot = loadSlot(slotNode); slots.add(slot);/*from w ww.j a v a2 s.c o m*/ } } return slots; }
From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java
License:Mozilla Public License
private String loadDefaultSlotValue(Node calculatedFieldNode) { String defaultSlotValue = null; Node slotBlock = calculatedFieldNode.selectSingleNode(SLOTS_TAG); if (slotBlock != null) { defaultSlotValue = slotBlock.valueOf("@defaultSlotValue"); }// w w w. ja v a 2 s. c om return defaultSlotValue; }
From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.CalculatedFieldsDAOFileImpl.java
License:Mozilla Public License
private ModelCalculatedField.Slot.MappedValuesRangeDescriptor loadRangeDescriptor(Node mappedValuesNode) { ModelCalculatedField.Slot.MappedValuesRangeDescriptor rangeDescriptor = null; Node fomrNode = mappedValuesNode.selectSingleNode(FROM_TAG); String fromValue = fomrNode.valueOf("@value"); Node toNode = mappedValuesNode.selectSingleNode(TO_TAG); String toValue = toNode.valueOf("@value"); rangeDescriptor = new ModelCalculatedField.Slot.MappedValuesRangeDescriptor(fromValue, toValue); String includeValue = null;//w w w . ja v a2s . c o m includeValue = fomrNode.valueOf("@include"); if (includeValue != null && (includeValue.equalsIgnoreCase("TRUE") || includeValue.equalsIgnoreCase("FALSE"))) { rangeDescriptor.setIncludeMinValue(Boolean.parseBoolean(includeValue)); } includeValue = toNode.valueOf("@include"); if (includeValue != null && (includeValue.equalsIgnoreCase("TRUE") || includeValue.equalsIgnoreCase("FALSE"))) { rangeDescriptor.setIncludeMaxValue(Boolean.parseBoolean(includeValue)); } return rangeDescriptor; }
From source file:it.eng.qbe.datasource.configuration.dao.fileimpl.InLineFunctionsDAOFileImpl.java
License:Mozilla Public License
public HashMap<String, InLineFunction> loadInLineFunctions(String dialect) { FileInputStream in;/*w w w. ja va2s . co m*/ InputStream is; Document document; String group; String name; String desc; String nParams; String code; List functionsNodes; Iterator it; Node functionNode; Node dialectNode; logger.debug("IN"); in = null; try { if (getInLineFunctions() != null && getInLineFunctions().size() > 0) { logger.info("Functions for dialect " + dialect + " yet loaded."); return getInLineFunctions(); } is = getClass().getClassLoader().getResourceAsStream(FUNCTIONS_FILE_NAME); Assert.assertNotNull(is, "Input stream cannot be null"); logger.debug("Functions will be loaded from file [" + FUNCTIONS_FILE_NAME + "]"); document = readFile(is); Assert.assertNotNull(document, "Document cannot be null"); functionsNodes = document.selectNodes("//" + ROOT_TAG + "/" + FIELD_TAG + ""); logger.debug("Found [" + functionsNodes.size() + "] functions"); it = functionsNodes.iterator(); while (it.hasNext()) { functionNode = (Node) it.next(); group = functionNode.valueOf("@" + FIELD_TAG_GROUP_ATTR); name = functionNode.valueOf("@" + FIELD_TAG_NAME_ATTR); desc = functionNode.valueOf("@" + FIELD_TAG_DESC_ATTR); nParams = functionNode.valueOf("@" + FIELD_TAG_NPARAMS_ATTR); dialectNode = null; //get the code function only for the dialect managed if (dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_MYSQL)) { dialectNode = functionNode .selectSingleNode(functionNode.getUniquePath() + "/" + FIELD_TAG_MYSQL_DIALECT + ""); } else if (dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_HSQL)) { dialectNode = functionNode .selectSingleNode(functionNode.getUniquePath() + "/" + FIELD_TAG_HQL_DIALECT + ""); } else if (dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_ORACLE) || dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_ORACLE9i10g)) { dialectNode = functionNode .selectSingleNode(functionNode.getUniquePath() + "/" + FIELD_TAG_ORACLE_DIALECT + ""); } else if (dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_INGRES)) { dialectNode = functionNode .selectSingleNode(functionNode.getUniquePath() + "/" + FIELD_TAG_INGRES_DIALECT + ""); } else if (dialect.equalsIgnoreCase(QuerySerializationConstants.DIALECT_POSTGRES)) { dialectNode = functionNode .selectSingleNode(functionNode.getUniquePath() + "/" + FIELD_TAG_POSTGRES_DIALECT + ""); } else { dialectNode = functionNode.selectSingleNode( functionNode.getUniquePath() + "/" + FIELD_TAG_SQLSERVER_DIALECT + ""); } code = ""; if (dialectNode != null) { code = dialectNode.valueOf("@" + FIELD_TAG_CODE_ATTR); } InLineFunction func = new InLineFunction(); func.setDialect(dialect); func.setName(name); func.setGroup(group); func.setDesc(desc); func.setnParams(Integer.valueOf(nParams)); func.setCode(code); addInLineFunction(func); logger.debug("Function [" + mapInLineFunctions.get(func.name) + "] loaded succesfully"); } } catch (Throwable t) { if (t instanceof DAOException) throw (DAOException) t; throw new DAOException( "An unpredicted error occurred while loading functions on file [" + FUNCTIONS_FILE_NAME + "]", t); } finally { if (in != null) { try { in.close(); } catch (IOException e) { throw new DAOException( "Impossible to properly close stream to file file [" + FUNCTIONS_FILE_NAME + "]", e); } } logger.debug("OUT"); } return getInLineFunctions(); }
From source file:it.eng.spagobi.studio.chart.editors.model.chart.BarChartModel.java
License:Mozilla Public License
/** * /*from w w w.j a v a 2 s. co m*/ * @param chartSubType * @param configDocument * @param templateDocument * @throws Exception * * This method read the chart template and returns if it is linkable: it is if config document as a drill tag */ public boolean isSubtypeLinkable(String chartSubType) { // check the type and search for the root String upperCaseNameSl = getType().toUpperCase(); String upperCaseNamePl = upperCaseNameSl + "S"; // Get the node configuration Node specificConfig = configDocument.selectSingleNode( "//" + upperCaseNamePl + "/" + upperCaseNameSl + "[@name='" + chartSubType.trim() + "']"); Node drillNode = specificConfig .selectSingleNode("//" + upperCaseNameSl + "[@name='" + chartSubType + "']/DRILL"); if (drillNode == null) { logger.debug("No lnkable document"); return false; } else { logger.debug("Linkable document"); return true; } }
From source file:it.eng.spagobi.studio.chart.editors.model.chart.ChartModel.java
License:Mozilla Public License
public void fillStyleParameters() throws Exception { logger.debug("Filling style configurations from actual file, otherwise from template"); String upperCaseNameSl = type.toUpperCase(); String upperCaseNamePl = upperCaseNameSl + "S"; logger.debug("Read all styles parameters from config file and record"); Node commonConfig = configDocument .selectSingleNode("//" + upperCaseNamePl + "/" + upperCaseNameSl + "[@name='commons']"); if (commonConfig == null) throw new Exception("No common configuration set"); List allStyles = commonConfig.selectNodes("//STYLES/STYLE"); // Iterate over the styles filling StyleParametersEditors for (Iterator iterator = allStyles.iterator(); iterator.hasNext();) { Element styleEl = (Element) iterator.next(); Style toInsert = new Style(); String nameStyle = styleEl.valueOf("@name"); toInsert.setName(nameStyle);/* w ww . j av a 2 s.com*/ String descriptionStyle = styleEl.valueOf("@description"); if (descriptionStyle == null || descriptionStyle.equalsIgnoreCase("")) { descriptionStyle = nameStyle; } toInsert.setDescription(descriptionStyle); String tooltipStyle = styleEl.valueOf("@tooltip"); toInsert.setTooltip(tooltipStyle); toInsert.setHasFont(true); toInsert.setHasSize(true); toInsert.setHasColor(true); toInsert.setHasOrientation(true); // first I must check wich of these parameters are configurable Node fontNode1 = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='font']"); if (fontNode1 == null) { toInsert.setHasFont(false); } Node colorNode1 = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='color']"); if (colorNode1 == null) { toInsert.setHasFont(false); } Node orientationNode1 = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='orientation']"); if (orientationNode1 == null) { toInsert.setHasOrientation(false); } Node sizeNode1 = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='size']"); if (sizeNode1 == null) { toInsert.setHasSize(false); } // Fill the style values!! boolean useThisDocument = false; Node thisStyleNode = thisDocument .selectSingleNode("//" + type.toUpperCase() + "/" + nameStyle.toUpperCase()); if (thisStyleNode != null) useThisDocument = true; if (toInsert.isHasFont()) { String fontVal = null; if (useThisDocument == true) { fontVal = thisStyleNode.valueOf("@font"); } else { Node fontNode = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='font']"); if (fontNode != null) { fontVal = fontNode.valueOf("@defaultValue"); } } if (fontVal != null) toInsert.setFont(fontVal); } if (toInsert.isHasOrientation()) { String orientationVal = null; if (useThisDocument == true) { orientationVal = thisStyleNode.valueOf("@orientation"); } else { Node orientationNode = commonConfig.selectSingleNode( "//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='orientation']"); if (orientationNode != null) { orientationVal = orientationNode.valueOf("@defaultValue"); } } if (orientationVal != null) toInsert.setOrientation(orientationVal); } if (toInsert.isHasColor()) { String colorVal = null; if (useThisDocument == true) { colorVal = thisStyleNode.valueOf("@color"); } else { Node colorNode = commonConfig.selectSingleNode( "//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='color']"); if (colorNode != null) { colorVal = colorNode.valueOf("@defaultValue"); } } if (colorVal != null) toInsert.setColor(ChartEditor.convertHexadecimalToRGB(colorVal)); } if (toInsert.isHasSize()) { String sizeVal = null; if (useThisDocument == true) { sizeVal = thisStyleNode.valueOf("@size"); } else { Node sizeNode = commonConfig .selectSingleNode("//STYLES/STYLE[@name='" + nameStyle + "']/STYLE_INFO[@name='size']"); if (sizeNode != null) { sizeVal = sizeNode.valueOf("@defaultValue"); } } if (sizeVal != null) { Integer intt = null; try { intt = Integer.valueOf(sizeVal); } catch (Exception e) { intt = 10; } toInsert.setSize(intt); } } styleParametersEditors.put(toInsert.getName(), toInsert); } }