From 25e965cb2e5a24b2b88ef819e33cf5a72b9554bc Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Fri, 6 Jan 2017 10:54:20 +0000 Subject: [PATCH] Implemented: New implementation of Birt. Easier user possibility of report creation (OFBIZ-6919) This are a non functional changes not yet used OOTB. They are only intended to ease the sync between the svn trunk repo and the github branch (using a fork) So still a WIP... git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1777586 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/config/ContentEntityLabels.xml | 5 ++- .../content/minilang/data/DataServices.xml | 17 ++++++++++ .../content/servicedef/services_data.xml | 19 ++++++++++++ .../content/data/DataResourceWorker.java | 31 +++++++++++++++++-- .../entitydef/content-entitymodel.xml | 5 ++- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/applications/content/config/ContentEntityLabels.xml b/applications/content/config/ContentEntityLabels.xml index 102ad85776..12620fd4f4 100644 --- a/applications/content/config/ContentEntityLabels.xml +++ b/applications/content/config/ContentEntityLabels.xml @@ -1,6 +1,5 @@ + + + + + + + + + + + + + + + + + diff --git a/applications/content/servicedef/services_data.xml b/applications/content/servicedef/services_data.xml index a7ae150f8f..d16d1bf7b5 100644 --- a/applications/content/servicedef/services_data.xml +++ b/applications/content/servicedef/services_data.xml @@ -117,6 +117,25 @@ + + Create a ElectronicText with Form code + + + + + + + + + Update a ElectronicText with Form code + + + + + + Remove ElectronicText diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java index eac98f284b..338de6bcb8 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java @@ -747,13 +747,38 @@ public class DataResourceWorker implements org.apache.ofbiz.widget.content.Data } else { throw new GeneralException("The dataResource file [" + dataResourceId + "] could not be found"); } - } catch (SAXException e) { - throw new GeneralException("Error rendering Screen template", e); - } catch (ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { throw new GeneralException("Error rendering Screen template", e); } catch (TemplateException e) { throw new GeneralException("Error creating Screen renderer", e); } + } else if ("FORM_COMBINED".equals(dataTemplateTypeId)){ + try { + Map context = UtilGenerics.checkMap(templateContext.get("globalContext")); + context.put("locale", locale); + context.put("simpleEncoder", UtilCodec.getEncoder(UtilProperties.getPropertyValue("widget", "screen.encoder"))); + HttpServletRequest request = (HttpServletRequest) context.get("request"); + HttpServletResponse response = (HttpServletResponse) context.get("response"); + ModelForm modelForm = null; + ModelReader entityModelReader = delegator.getModelReader(); + String formText = getDataResourceText(dataResource, targetMimeTypeId, locale, templateContext, delegator, cache); + Document formXml = UtilXml.readXmlDocument(formText, true, true); + Map modelFormMap = FormFactory.readFormDocument(formXml, entityModelReader, dispatcher.getDispatchContext(), null); + + if (UtilValidate.isNotEmpty(modelFormMap)) { + Map.Entry entry = modelFormMap.entrySet().iterator().next(); // get first entry, only one form allowed per file + modelForm = entry.getValue(); + } + MacroFormRenderer renderer = new MacroFormRenderer(formrenderer, request, response); + FormRenderer formRenderer = new FormRenderer(modelForm, renderer); + formRenderer.render(out, context); + } catch (SAXException | ParserConfigurationException e) { + throw new GeneralException("Error rendering Screen template", e); + } catch (TemplateException e) { + throw new GeneralException("Error creating Screen renderer", e); + } catch (Exception e) { + throw new GeneralException("Error rendering Screen template", e); + } } else { throw new GeneralException("The dataTemplateTypeId [" + dataTemplateTypeId + "] is not yet supported"); } diff --git a/applications/datamodel/entitydef/content-entitymodel.xml b/applications/datamodel/entitydef/content-entitymodel.xml index 9c65095c20..3d72769d91 100644 --- a/applications/datamodel/entitydef/content-entitymodel.xml +++ b/applications/datamodel/entitydef/content-entitymodel.xml @@ -148,6 +148,7 @@ under the License. @@ -159,9 +160,7 @@ under the License. - - Deprecated : use customMethod pattern instead of. Kept for backward compatibility - + Deprecated : use customMethod pattern instead. Kept for backward compatibility