public static String writeDocument(Document doc, boolean prettyPrint) { StringWriter writer = new StringWriter(); writeDocument(doc, prettyPrint, writer); return writer.toString(); }
private File writeDocument(Document doc) { File file = new File(dir, "orm.xml"); log.info("Creating file " + file); OutputStream os = null; try { os = new FileOutputStream(file); Dom4j.writeDocument(doc, true, os); } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(os); } return file; }
@Override public void commit() { if (modified && root != null) { String xml = Dom4j.writeDocument(root.getDocument(), true); getSettingsClient().setSetting(name, xml); modified = false; } }
Dom4j.writeDocument(result.getDocument(), true, writer); log.trace("Resulting template:\n" + writer.toString());
/** * Converts filter conditions tree to filter xml * @param conditions conditions tree * @param valueProperty Describes what parameter value will be serialized to xml: current value or default one * @return filter xml */ @Override @Nullable public String getXml(ConditionsTree conditions, Param.ValueProperty valueProperty) { String xml = null; if (conditions != null && !conditions.getRootNodes().isEmpty()) { Document document = DocumentHelper.createDocument(); Element root = document.addElement("filter"); Element element = root.addElement("and"); for (Node<AbstractCondition> node : conditions.getRootNodes()) { recursiveToXml(node, element, valueProperty); } xml = Dom4j.writeDocument(document, true); } log.trace("toXML: {}", xml); return xml; }
@Override public void setSettings(Presentation p, Element e) { p = getPresentation(p.getId()); if (p != null) { p.setXml(Dom4j.writeDocument(e.getDocument(), false)); modify(p); } }
public void updateMethodParameters(List<MethodParameterInfo> params) { Document doc = DocumentHelper.createDocument(); Element paramsEl = doc.addElement("params"); for (MethodParameterInfo param : params) { Element paramEl = paramsEl.addElement("param"); paramEl.addAttribute("type", param.getType().getName()); paramEl.addAttribute("name", param.getName()); paramEl.setText(param.getValue() != null ? param.getValue().toString() : ""); } setMethodParamsXml(Dom4j.writeDocument(doc, true)); }
try { os = new FileOutputStream(outFileName); Dom4j.writeDocument(doc, true, os); } catch (IOException e) { throw new RuntimeException(e);
protected void commit() { Presentations presentations = component.getPresentations(); Document doc = DocumentHelper.createDocument(); doc.setRootElement(doc.addElement("presentation")); component.saveSettings(doc.getRootElement()); String xml = Dom4j.writeDocument(doc, false); presentation.setXml(xml); presentation.setName(nameField.getValue()); presentation.setAutoSave(autoSaveField.getValue()); presentation.setDefault(defaultField.getValue()); User user = sessionSource.getUserSession().getCurrentOrSubstitutedUser(); boolean userOnly = !allowGlobalPresentations || !BooleanUtils.isTrue(globalField.getValue()); presentation.setUser(userOnly ? user : null); if (log.isTraceEnabled()) { log.trace(String.format("XML: %s", Dom4j.writeDocument(doc, true))); } if (isNew) { presentations.add(presentation); } else { presentations.modify(presentation); } presentations.commit(); addCloseListener(e -> { if (isNew) { component.applyPresentation(presentation.getId()); } }); }
newSetting.setValue(Dom4j.writeDocument(doc, true)); } catch (Exception e) { newSetting.setValue(currSetting.getValue());
public static String generateSetFilter(Set ids, String entityClass, String componentId, String entityAlias) { Document document = DocumentHelper.createDocument(); Element root = DocumentHelper.createElement("filter"); Element or = root.addElement("and"); Element condition = or.addElement("c"); condition.addAttribute("name", "set"); condition.addAttribute("inExpr", "true"); condition.addAttribute("hidden", "true"); condition.addAttribute("locCaption", "Set filter"); condition.addAttribute("entityAlias", entityAlias); condition.addAttribute("class", entityClass); condition.addAttribute("type", ConditionType.CUSTOM.name()); String listOfId = createIdsString(ids); String randomName = RandomStringUtils.randomAlphabetic(10); condition.addText(entityAlias + ".id in :component$" + componentId + "." + randomName); Element param = condition.addElement("param"); param.addAttribute("name", "component$" + componentId + "." + randomName); param.addAttribute("isFoldersFilterEntitiesSet", "true"); param.addText(listOfId); document.add(root); return Dom4j.writeDocument(document, true); }