You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2013/09/06 10:03:34 UTC
svn commit: r1520505 - in /ofbiz/trunk/framework/webtools: config/
webapp/webtools/WEB-INF/ webapp/webtools/WEB-INF/actions/entity/
webapp/webtools/entity/ widget/
Author: hansbak
Date: Fri Sep 6 08:03:34 2013
New Revision: 1520505
URL: http://svn.apache.org/r1520505
Log:
added a new menu item in webtools: 'programmable export' where interactively a groovy program can be entered to export specifc records from the database. In order to apply some global changes for re-import
Added:
ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy (with props)
ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl (with props)
Modified:
ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.xml
ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
ofbiz/trunk/framework/webtools/widget/EntityScreens.xml
ofbiz/trunk/framework/webtools/widget/Menus.xml
ofbiz/trunk/framework/webtools/widget/MiscForms.xml
Modified: ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.xml?rev=1520505&r1=1520504&r2=1520505&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.xml (original)
+++ ofbiz/trunk/framework/webtools/config/WebtoolsUiLabels.xml Fri Sep 6 08:03:34 2013
@@ -627,6 +627,9 @@
<value xml:lang="zh">æµè§æ¥å¿</value>
<value xml:lang="zh_TW">ç覽æ¥èª</value>
</property>
+ <property key="PageTitleProgramExport">
+ <value xml:lang="en">Programmable Export</value>
+ </property>
<property key="PageTitleRunService">
<value xml:lang="de">Dienst starten</value>
<value xml:lang="en">Run Service</value>
Added: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy?rev=1520505&view=auto
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy (added)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy Fri Sep 6 08:03:34 2013
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.base.util.*
+import org.w3c.dom.Document;
+
+import org.codehaus.groovy.control.customizers.ImportCustomizer;
+import org.codehaus.groovy.control.CompilerConfiguration;
+import org.codehaus.groovy.control.MultipleCompilationErrorsException;
+import org.codehaus.groovy.control.ErrorCollector;
+
+String groovyProgram = null;
+recordValues = [];
+errMsgList = [];
+
+if (UtilValidate.isEmpty(parameters.groovyProgram)) {
+
+ groovyProgram = '''
+// Use the List variable recordValues to fill it with GenericValue maps.
+// full groovy syntaxt is available
+
+// examples:
+recordValues.add(delegator.findOne("Content", ["contentId": "BLOGROOTBIGAL"], false));
+recordValues.add(delegator.findOne("Content", ["contentId": "BLOGROOTMADMAX"], false));
+'''
+ parameters.groovyProgram = groovyProgram;
+} else {
+ groovyProgram = parameters.groovyProgram;
+}
+
+// Add imports for script.
+def importCustomizer = new ImportCustomizer()
+importCustomizer.addImport("org.ofbiz.entity.GenericValue");
+importCustomizer.addImport("org.ofbiz.entity.model.ModelEntity");
+def configuration = new CompilerConfiguration()
+configuration.addCompilationCustomizers(importCustomizer)
+
+Binding binding = new Binding();
+binding.setVariable("delegator", delegator);
+binding.setVariable("recordValues", recordValues);
+
+ClassLoader loader = Thread.currentThread().getContextClassLoader();
+def shell = new GroovyShell(loader, binding, configuration);
+
+if (UtilValidate.isNotEmpty(groovyProgram)) {
+ try {
+ shell.parse(groovyProgram);
+ shell.evaluate(groovyProgram)
+ recordValues = shell.getVariable("recordValues");
+ xmlDoc = GenericValue.makeXmlDocument(recordValues);
+ context.put("xmlDoc", xmlDoc);
+ } catch(MultipleCompilationErrorsException e) {
+ request.setAttribute("_ERROR_MESSAGE_", e);
+ return;
+ } catch(groovy.lang.MissingPropertyException e) {
+ request.setAttribute("_ERROR_MESSAGE_", e);
+ return;
+ } catch(IllegalArgumentException e) {
+ request.setAttribute("_ERROR_MESSAGE_", e);
+ return;
+ }
+}
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=1520505&r1=1520504&r2=1520505&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml Fri Sep 6 08:03:34 2013
@@ -385,6 +385,11 @@ under the License.
</request-map>
<!-- Entity Export/Import requests -->
+ <request-map uri="ProgramExport">
+ <security https="true" auth="true"/>
+ <response name="success" type="view" value="ProgramExport"/>
+ <response name="error" type="view" value="ProgramExport"/>'
+ </request-map>
<request-map uri="EntityExportAll"><security https="true" auth="true"/><response name="success" type="view" value="EntityExportAll"/><response name="error" type="view" value="EntityExportAll"/></request-map>
<request-map uri="entityExportAll">
<security https="true" auth="true"/>
@@ -686,6 +691,7 @@ under the License.
<view-map name="EntitySQLProcessor" page="component://webtools/widget/EntityScreens.xml#EntitySQLProcessor" type="screen"/>
<view-map name="ConnectionPoolStatus" page="component://webtools/widget/EntityScreens.xml#ConnectionPoolStatus" type="screen"/>
<view-map name="EntityExportAll" page="component://webtools/widget/EntityScreens.xml#EntityExportAll" type="screen"/>
+ <view-map name="ProgramExport" page="component://webtools/widget/EntityScreens.xml#ProgramExport" type="screen"/>
<view-map name="EntityImportDir" page="component://webtools/widget/EntityScreens.xml#EntityImportDir" type="screen"/>
<view-map name="EntityImport" page="component://webtools/widget/EntityScreens.xml#EntityImport" type="screen"/>
<view-map name="EntityImportReaders" page="component://webtools/widget/EntityScreens.xml#EntityImportReaders" type="screen"/>
Added: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl?rev=1520505&view=auto
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl (added)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl Fri Sep 6 08:03:34 2013
@@ -0,0 +1,36 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+
+<div class="screenlet">
+ <div class="screenlet">
+ <div class="screenlet-title-bar">
+ <h3>${uiLabelMap.WebtoolsEntityXMLRepresentation}</h3>
+ </div>
+ <div class="screenlet-body">
+ <p>
+ <#if xmlDoc?has_content>
+ ${Static["org.ofbiz.base.util.UtilXml"].writeXmlDocument(xmlDoc)?replace("\n", "<br />")?replace(" ", " ")}
+ </#if>
+ </p>
+ </div>
+ </div>
+ <br class="clear"/>
+</div>
+
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl
------------------------------------------------------------------------------
svn:keywords = Date Rev Author URL Id
Propchange: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ProgramExport.ftl
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ofbiz/trunk/framework/webtools/widget/EntityScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/EntityScreens.xml?rev=1520505&r1=1520504&r2=1520505&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/widget/EntityScreens.xml (original)
+++ ofbiz/trunk/framework/webtools/widget/EntityScreens.xml Fri Sep 6 08:03:34 2013
@@ -66,6 +66,29 @@ under the License.
</widgets>
</section>
</screen>
+ <screen name="ProgramExport">
+ <section>
+ <actions>
+ <set field="titleProperty" value="PageTitleEntityExportAll"/>
+ <set field="tabButtonItem" value="programExport"/>
+ <script location="component://webtools/webapp/webtools/WEB-INF/actions/entity/ProgramExport.groovy"/>
+ </actions>
+ <widgets>
+ <decorator-screen name="CommonImportExportDecorator" location="${parameters.mainDecoratorLocation}">
+ <decorator-section name="body">
+ <screenlet>
+ <include-form name="ProgramExport" location="component://webtools/widget/MiscForms.xml"/>
+ </screenlet>
+ <screenlet>
+ <platform-specific>
+ <html><html-template location="component://webtools/webapp/webtools/entity/ProgramExport.ftl"/></html>
+ </platform-specific>
+ </screenlet>
+ </decorator-section>
+ </decorator-screen>
+ </widgets>
+ </section>
+ </screen>
<screen name="EntityImportDir">
<section>
<actions>
Modified: ofbiz/trunk/framework/webtools/widget/Menus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/Menus.xml?rev=1520505&r1=1520504&r2=1520505&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/widget/Menus.xml (original)
+++ ofbiz/trunk/framework/webtools/widget/Menus.xml Fri Sep 6 08:03:34 2013
@@ -90,6 +90,9 @@ under the License.
<menu-item name="entityExportAll" title="${uiLabelMap.PageTitleEntityExportAll}">
<link target="EntityExportAll"/>
</menu-item>
+ <menu-item name="programExport" title="${uiLabelMap.PageTitleProgramExport}">
+ <link target="ProgramExport"/>
+ </menu-item>
<menu-item name="entityImport" title="${uiLabelMap.PageTitleEntityImport}">
<link target="EntityImport"/>
</menu-item>
Modified: ofbiz/trunk/framework/webtools/widget/MiscForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/widget/MiscForms.xml?rev=1520505&r1=1520504&r2=1520505&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/widget/MiscForms.xml (original)
+++ ofbiz/trunk/framework/webtools/widget/MiscForms.xml Fri Sep 6 08:03:34 2013
@@ -20,6 +20,13 @@ under the License.
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
+ <form name="ProgramExport" type="single" target="ProgramExport" default-map-name="parameters">
+ <field name="groovyProgram" widget-style="required" tooltip="${uiLabelMap.CommonRequired}">
+ <textarea cols="120" rows="10" />
+ </field>
+ <field name="submitButton" title="${uiLabelMap.CommonRun}"><submit button-type="button"/></field>
+ </form>
+
<form name="LayoutDemoForm" type="single" target="${demoTargetUrl}" default-map-name="demoMap">
<field name="name" title="${uiLabelMap.CommonName}" widget-style="required" tooltip="${uiLabelMap.CommonRequired}">
<text />