[OFBiz] SVN: r6507 - in trunk/framework/webtools: servicedef src/org/ofbiz/webtools webapp/webtools/WEB-INF webapp/webtools/WEB-INF/actions/entity webapp/webtools/datafile webapp/webtools/entity widget

jonesde@svn.ofbiz.org jonesde at svn.ofbiz.org
Mon Jan 16 02:34:57 CST 2006


Author: jonesde
Date: 2006-01-16 02:34:48 -0600 (Mon, 16 Jan 2006)
New Revision: 6507

Modified:
   trunk/framework/webtools/servicedef/services.xml
   trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
   trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityExportAll.bsh
   trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
   trunk/framework/webtools/webapp/webtools/datafile/viewdatafile.jsp
   trunk/framework/webtools/webapp/webtools/entity/EntityExportAll.ftl
   trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp
   trunk/framework/webtools/widget/EntityScreens.xml
Log:
Added patch from Jacopo Cappellato to fix some issues with EE XML importing stuff, plus some improvements as well; Jira #OFBIZ-595

Modified: trunk/framework/webtools/servicedef/services.xml
===================================================================
--- trunk/framework/webtools/servicedef/services.xml	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/servicedef/services.xml	2006-01-16 08:34:48 UTC (rev 6507)
@@ -64,5 +64,12 @@
         <attribute name="filePause" type="Long" mode="IN" optional="true"/>
         <attribute name="messages" type="List" mode="OUT" optional="false"/>
     </service>
+    <service name="entityExportAll" engine="java"
+            location="org.ofbiz.webtools.WebToolsServices" invoke="entityExportAll" auth="true">
+        <description>Exports all entities into xml files</description>
+        <attribute name="outpath" type="String" mode="IN" optional="true"/>
+        <attribute name="txTimeout" type="Integer" mode="IN" optional="true"/>
+        <attribute name="results" type="List" mode="OUT" optional="false"/>
+    </service>
 
 </services>

Modified: trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java	2006-01-16 08:34:48 UTC (rev 6507)
@@ -25,6 +25,8 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.TreeSet;
 import java.util.Locale;
 import java.util.Map;
 import java.io.File;
@@ -32,6 +34,10 @@
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.FileReader;
+import java.io.PrintWriter;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.net.URL;
@@ -49,7 +55,11 @@
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityListIterator;
 import org.ofbiz.entity.util.EntitySaxReader;
+import org.ofbiz.entity.model.ModelReader;
+import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelViewEntity;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -103,16 +113,15 @@
         if (filename != null && filename.length() > 0) {
             try {
                 url = isUrl?new URL(filename):UtilURL.fromFilename(filename);
-            } catch(MalformedURLException e) {
-//                errorMessageList.add("ERROR: " + e.getMessage());
+                InputStream is = url.openStream();
+                ins = new InputSource(is);
+            } catch(MalformedURLException mue) {
+                return ServiceUtil.returnError("ERROR: invalid file name (" + filename + "): " + mue.getMessage());
+            } catch(IOException ioe) {
+                return ServiceUtil.returnError("ERROR reading file name (" + filename + "): " + ioe.getMessage());
+            } catch(Exception exc) {
+                return ServiceUtil.returnError("ERROR: reading file name (" + filename + "): " + exc.getMessage());
             }
-            InputStream is = null;
-            try {
-                is = url.openStream();
-            } catch(IOException e) {
-//                errorMessageList.add("ERROR: " + e.getMessage());
-            }
-            ins = new InputSource(is);
         }
 
         // #############################
@@ -132,7 +141,7 @@
             try {
                 templateReader = new FileReader(fmfilename);
             } catch(FileNotFoundException e) {
-//                errorMessageList.add("ERROR: " + e.getMessage());
+                return ServiceUtil.returnError("ERROR reading template file (" + fmfilename + "): " + e.getMessage());
             }
 
             StringWriter outWriter = new StringWriter();
@@ -152,7 +161,7 @@
                 template.process(fmcontext, outWriter);
                 s = outWriter.toString();
             } catch(Exception ex) {
-//                errorMessageList.add("ERROR: " + ex.getMessage());
+                return ServiceUtil.returnError("ERROR processing template file (" + fmfilename + "): " + ex.getMessage());
             }
         }
 
@@ -176,11 +185,14 @@
                     }
                 }
                 Map outputMap = dispatcher.runSync("parseEntityXmlFile", inputMap);
-                Long numberRead = (Long)outputMap.get("rowProcessed");
-
-                messages.add("Got " + numberRead.longValue() + " entities to write to the datasource.");
+                if (ServiceUtil.isError(outputMap)) {
+                    return ServiceUtil.returnError("ERROR: " + ServiceUtil.getErrorMessage(outputMap));
+                } else {
+                    Long numberRead = (Long)outputMap.get("rowProcessed");
+                    messages.add("Got " + numberRead.longValue() + " entities to write to the datasource.");
+                }
             } catch (Exception ex){
-//                errorMessageList.add("ERROR: " + exc.getMessage());
+                return ServiceUtil.returnError("ERROR parsing Entity Xml file: " + ex.getMessage());
             }
         } else {
             messages.add("No filename/URL or complete XML document specified, doing nothing.");
@@ -326,11 +338,105 @@
             long numberRead = (url != null? reader.parse(url): reader.parse(xmltext));
             rowProcessed = new Long(numberRead);
         } catch (Exception ex){
-            return ServiceUtil.returnError("Error parsing entity xml file: " + ex.getMessage());
+            return ServiceUtil.returnError("Error parsing entity xml file: " + ex.toString());
         }
         // send the notification
         Map resp = UtilMisc.toMap("rowProcessed", rowProcessed);
         return resp;
     }
 
+    public static Map entityExportAll(DispatchContext dctx, Map context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericDelegator delegator = dctx.getDelegator();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Locale locale = (Locale) context.get("locale");
+
+        String outpath = (String)context.get("outpath"); // mandatory
+        Integer txTimeout = (Integer)context.get("txTimeout");
+        if (txTimeout == null) {
+            txTimeout = new Integer(7200);
+        }
+
+        List results = new ArrayList();
+
+        if (outpath != null && outpath.length() > 0) {
+            File outdir = new File(outpath);
+            if (!outdir.exists()) {
+                outdir.mkdir();
+            }
+            if (outdir.isDirectory() && outdir.canWrite()) {
+                
+                Iterator passedEntityNames = null;
+                try {
+                    ModelReader reader = delegator.getModelReader();
+                    Collection ec = reader.getEntityNames();
+                    TreeSet entityNames = new TreeSet(ec);
+                    passedEntityNames = entityNames.iterator();
+                } catch(Exception exc) {
+                    return ServiceUtil.returnError("Error retrieving entity names.");
+                }
+                int fileNumber = 1;
+
+                while (passedEntityNames.hasNext()) { 
+                    long numberWritten = 0;
+                    String curEntityName = (String)passedEntityNames.next();
+                    EntityListIterator values = null;
+
+                    try {
+                        ModelEntity me = delegator.getModelEntity(curEntityName);
+                        if (me instanceof ModelViewEntity) {
+                            results.add("["+fileNumber +"] [vvv] " + curEntityName + " skipping view entity");
+                            continue;
+                        }
+
+                        // some databases don't support cursors, or other problems may happen, so if there is an error here log it and move on to get as much as possible
+                        try {
+                            values = delegator.findListIteratorByCondition(curEntityName, null, null, null, me.getPkFieldNames(), null);
+                        } catch (Exception entityEx) {
+                            results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + entityEx);
+                            continue;
+                        }
+
+                        //Don't bother writing the file if there's nothing
+                        //to put into it
+                        GenericValue value = (GenericValue) values.next();
+                        if (value != null) {
+                            PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, curEntityName +".xml")), "UTF-8")));
+                            writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                            writer.println("<entity-engine-xml>");
+
+                            do {
+                                value.writeXmlText(writer, "");
+                                numberWritten++;
+                            } while ((value = (GenericValue) values.next()) != null);
+                            writer.println("</entity-engine-xml>");
+                            writer.close();
+                            results.add("["+fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records");
+                        } else {
+                            results.add("["+fileNumber +"] [---] " + curEntityName + " has no records, not writing file");
+                        }
+                        values.close();
+                    } catch (Exception ex) {
+                        if (values != null) {
+                            try {
+                                values.close();
+                            } catch(Exception exc) {
+                                //Debug.warning();
+                            }
+                        }
+                        results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + ex);
+                    }
+                    fileNumber++;
+                }
+            } else {
+                results.add("Path not found or no write access.");
+            }
+        } else {
+            results.add("No path specified, doing nothing.");
+        }
+        // send the notification
+        Map resp = UtilMisc.toMap("results", results);
+        return resp;
+    }
+
 }

Modified: trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityExportAll.bsh
===================================================================
--- trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityExportAll.bsh	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/webapp/webtools/WEB-INF/actions/entity/EntityExportAll.bsh	2006-01-16 08:34:48 UTC (rev 6507)
@@ -1,140 +0,0 @@
-/*
- *  Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
- *
- *  Permission is hereby granted, free of charge, to any person obtaining a 
- *  copy of this software and associated documentation files (the "Software"), 
- *  to deal in the Software without restriction, including without limitation 
- *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
- *  and/or sell copies of the Software, and to permit persons to whom the 
- *  Software is furnished to do so, subject to the following conditions:
- *
- *  The above copyright notice and this permission notice shall be included 
- *  in all copies or substantial portions of the Software.
- *
- *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
- *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
- *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
- *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
- *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
- *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
- *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * @author Brian Johnson (bmj at camfour.com)
- * @author David E. Jones (jonesde at ofbiz.org)
- * @author Jacopo Cappellato (tiz at sastau.it)
- */
-
-import org.ofbiz.entity.jdbc.SQLProcessor;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.BufferedWriter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.TreeSet;
-import org.ofbiz.entity.*;
-import org.ofbiz.entity.model.ModelReader;
-import org.ofbiz.entity.model.ModelEntity;
-import org.ofbiz.entity.model.ModelViewEntity;
-import org.ofbiz.entity.model.ModelGroupReader;
-import org.ofbiz.entity.util.EntityListIterator;
-import org.ofbiz.entity.transaction.TransactionUtil;
-
-String outpath = parameters.get("outpath");
-String txTimeoutStr = parameters.get("txTimeout");
-int txTimeout = 7200;
-try {
-    txTimeout = Integer.parseInt(txTimeoutStr);
-} catch (Exception e) {
-}
-
-ModelReader reader = delegator.getModelReader();
-Collection ec = reader.getEntityNames();
-TreeSet entityNames = new TreeSet(ec);
-Collection results = new ArrayList();
-
-int fileNumber = 1;
-long numberWritten = 0;
-
-if (outpath != null) {
-    File outdir = new File(outpath);
-    if(!outdir.exists()) {
-        outdir.mkdir();
-    }
-    if(outdir.isDirectory() && outdir.canWrite()) {
-        Iterator passedEntityNames= entityNames.iterator();
-        
-        while(passedEntityNames.hasNext()) { 
-            numberWritten = 0;
-            String curEntityName = (String)passedEntityNames.next();
-            EntityListIterator values = null;
-            boolean beganTransaction = false;
-            try {
-                beganTransaction = TransactionUtil.begin(txTimeout);
-    
-                try {
-                    ModelEntity me = delegator.getModelEntity(curEntityName);
-                    if (me instanceof ModelViewEntity) {
-                        results.add("["+fileNumber +"] [vvv] " + curEntityName + " skipping view entity");
-                        continue;
-                    }
-                    
-                    // some databases don't support cursors, or other problems may happen, so if there is an error here log it and move on to get as much as possible
-                    try {
-                        values = delegator.findListIteratorByCondition(curEntityName, null, null, null, me.getPkFieldNames(), null);
-                    } catch (Exception entityEx) {
-                        results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + entityEx);
-                        continue;
-                    }
-                    
-                    //Don't bother writing the file if there's nothing
-                    //to put into it
-                    GenericValue value = (GenericValue) values.next();
-                    if (value != null) {
-                        PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, curEntityName +".xml")), "UTF-8")));
-                        writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-                        writer.println("<entity-engine-xml>");
-    
-                        do {
-                            value.writeXmlText(writer, "");
-                            numberWritten++;
-                        } while ((value = (GenericValue) values.next()) != null);
-                        writer.println("</entity-engine-xml>");
-                        writer.close();
-                        results.add("["+fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records");
-                    } else {
-                        results.add("["+fileNumber +"] [---] " + curEntityName + " has no records, not writing file");
-                    }
-                    values.close();
-                } catch (Exception ex) {
-                    if (values != null) {
-                        values.close();
-                    }
-                    results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + ex);
-                }
-            } catch (GenericEntityException e) {
-                String errMsg = "Failure in operation, rolling back transaction";
-                Debug.logError(e, errMsg, "xmldsdumpall.jsp");
-                try {
-                    // only rollback the transaction if we started one...
-                    TransactionUtil.rollback(beganTransaction, errMsg, e);
-                } catch (GenericEntityException e2) {
-                    Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), "xmldsdumpall.jsp");
-                }
-                // after rolling back, rethrow the exception
-                throw e;
-            } finally {
-                // only commit the transaction if we started one... this will throw an exception if it fails
-                TransactionUtil.commit(beganTransaction);
-            }
-            
-            fileNumber++;
-        }
-    }
-}
-
-context.put("results", results);
\ No newline at end of file

Modified: trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
===================================================================
--- trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml	2006-01-16 08:34:48 UTC (rev 6507)
@@ -382,8 +382,11 @@
         <response name="success" type="view" value="EntitySQLProcessor"/>
         <response name="error" type="view" value="EntitySQLProcessor"/>
     </request-map>
-    <request-map uri="EntityExportAll">
+
+    <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"/>
+        <event type="service" path="" invoke="entityExportAll"/>
         <response name="success" type="view" value="EntityExportAll"/>
         <response name="error" type="view" value="EntityExportAll"/>
     </request-map>

Modified: trunk/framework/webtools/webapp/webtools/datafile/viewdatafile.jsp
===================================================================
--- trunk/framework/webtools/webapp/webtools/datafile/viewdatafile.jsp	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/webapp/webtools/datafile/viewdatafile.jsp	2006-01-16 08:34:48 UTC (rev 6507)
@@ -51,6 +51,14 @@
   try { definitionUrl = definitionIsUrl?new URL(definitionLoc):UtilURL.fromFilename(definitionLoc); }
   catch (java.net.MalformedURLException e) { messages.add(e.getMessage()); }
 
+  Iterator definitionNames = null;
+  if (definitionUrl != null) {
+    ModelDataFileReader reader = ModelDataFileReader.getModelDataFileReader(definitionUrl);
+    if (reader != null) {
+        definitionNames = ((Collection)reader.getDataFileNames()).iterator();
+    }
+  }
+  
   DataFile dataFile = null;
   if (dataFileUrl != null && definitionUrl != null && definitionName != null && definitionName.length() > 0) {
     try { dataFile = DataFile.readFile(dataFileUrl, definitionUrl, definitionName); }
@@ -81,9 +89,22 @@
 <hr>
 <%if(security.hasPermission("DATAFILE_MAINT", session)) {%>
   <form method="post" action="<ofbiz:url>/viewdatafile</ofbiz:url>">
+    <div class="tabletext">Definition Filename or URL: <input name="DEFINITION_LOCATION" class="inputBox" type="text" size="60" value="<%=UtilFormatOut.checkNull(definitionLoc)%>"> Is URL?:<INPUT type="checkbox" name="DEFINITION_IS_URL" <%=definitionIsUrl?"checked":""%>></div>
+    <div class="tabletext">Data File Definition Name: 
+    <% if (definitionNames != null) {
+        %><select name="DEFINITION_NAME" class="selectBox">
+          <option value=""></option>
+        <%
+        while (definitionNames.hasNext()) {
+            String oneDefinitionName = (String)definitionNames.next();
+            boolean isSelected = definitionName != null && definitionName.equals(oneDefinitionName);
+            %><option value="<%=oneDefinitionName%>" <%=(isSelected? "selected": "")%>><%=oneDefinitionName%></option><%
+        }
+        %></select><%
+    } else {%>
+    <input name="DEFINITION_NAME" type="text" class="inputBox" size="30" value="<%=UtilFormatOut.checkNull(definitionName)%>"></div>
+    <% } %>
     <div class="tabletext">Data Filename or URL: <input name="DATAFILE_LOCATION" type="text" class="inputBox" size="60" value="<%=UtilFormatOut.checkNull(dataFileLoc)%>"> Is URL?:<INPUT type="checkbox" name="DATAFILE_IS_URL" <%=dataFileIsUrl?"checked":""%>></div>
-    <div class="tabletext">Definition Filename or URL: <input name="DEFINITION_LOCATION" class="inputBox" type="text" size="60" value="<%=UtilFormatOut.checkNull(definitionLoc)%>"> Is URL?:<INPUT type="checkbox" name="DEFINITION_IS_URL" <%=definitionIsUrl?"checked":""%>></div>
-    <div class="tabletext">Data File Definition Name: <input name="DEFINITION_NAME" type="text" class="inputBox" size="30" value="<%=UtilFormatOut.checkNull(definitionName)%>"></div>
     <div class="tabletext">Save to file: <input name="DATAFILE_SAVE" type="text" class="inputBox" size="60" value="<%=UtilFormatOut.checkNull(dataFileSave)%>"/></div>
     <div class="tabletext">Save to entity xml file: <input name="ENTITYXML_FILE_SAVE" type="text" class="inputBox" size="60" value="<%=UtilFormatOut.checkNull(entityXmlFileSave)%>"></div>
     <div><input type="submit" value="Run"></div>

Modified: trunk/framework/webtools/webapp/webtools/entity/EntityExportAll.ftl
===================================================================
--- trunk/framework/webtools/webapp/webtools/entity/EntityExportAll.ftl	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/webapp/webtools/entity/EntityExportAll.ftl	2006-01-16 08:34:48 UTC (rev 6507)
@@ -43,7 +43,7 @@
 <hr>
 
 <div class="head2">Export:</div>
-<form method="post" action="<@ofbizUrl>EntityExportAll</@ofbizUrl>">
+<form method="post" action="<@ofbizUrl>entityExportAll</@ofbizUrl>">
     <div class="tabletext">Output Directory: <input type="text" class="inputBox" size="60" name="outpath" value="${outpath?if_exists}"></div>
     <div class="tabletext">TX Timeout Seconds (for each entity): <input type="text" size="6" value="${txTimeout?default('7200')}" name="txTimeout"/></div>
     <br/>

Modified: trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp
===================================================================
--- trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp	2006-01-16 08:34:48 UTC (rev 6507)
@@ -255,39 +255,42 @@
                     continue;
                 }
                 values = delegator.findListIteratorByCondition(curEntityName, null, null, null, me.getPkFieldNames(), efo);
+                boolean isFirst = true;
+                PrintWriter writer = null;
+                int fileSplitNumber = 1;
+                GenericValue value = null;
+                while ((value = (GenericValue) values.next()) != null) {
+                    //Don't bother writing the file if there's nothing
+                    //to put into it
+                    if (isFirst) {
+                        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName +".xml")), "UTF-8")));
+                        writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                        writer.println("<entity-engine-xml>");
+                        isFirst = false;
+                    }
+                    value.writeXmlText(writer, "");
+                    numberWritten++;
 
-                //Don't bother writing the file if there's nothing
-                //to put into it
-                if (values.hasNext()) {
-                    PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName +".xml")), "UTF-8")));
-                    writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-                    writer.println("<entity-engine-xml>");
-                    int fileSplitNumber = 1;
+                    // split into small files
+                    if ((maxRecordsPerFile > 0) && (numberWritten % maxRecordsPerFile == 0)) {
+                        fileSplitNumber++;
+                        // close the file
+                        writer.println("</entity-engine-xml>");
+                        writer.close();
 
-                    GenericValue value = null;
-                    while ((value = (GenericValue) values.next()) != null) {
-                        value.writeXmlText(writer, "");
-                        numberWritten++;
+                        // create a new file
+                        String splitNumStr = UtilFormatOut.formatPaddedNumber((long) fileSplitNumber, 3);
+                        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName + "_" + splitNumStr +".xml")), "UTF-8")));
+                        writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+                        writer.println("<entity-engine-xml>");
+                    }
 
-                        // split into small files
-                        if ((maxRecordsPerFile > 0) && (numberWritten % maxRecordsPerFile == 0)) {
-                            fileSplitNumber++;
-                            // close the file
-                            writer.println("</entity-engine-xml>");
-                            writer.close();
+                    if (numberWritten % 500 == 0 || numberWritten == 1) {
+                       Debug.log("Records written [" + curEntityName + "]: " + numberWritten);
+                    }
 
-                            // create a new file
-                            String splitNumStr = UtilFormatOut.formatPaddedNumber((long) fileSplitNumber, 3);
-                            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outdir, fileName + "_" + splitNumStr +".xml")), "UTF-8")));
-                            writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-                            writer.println("<entity-engine-xml>");
-                        }
-
-                        if (numberWritten % 500 == 0 || numberWritten == 1) {
-                           Debug.log("Records written [" + curEntityName + "]: " + numberWritten);
-                        }
-
-                    }
+                }
+                if (writer != null) {
                     writer.println("</entity-engine-xml>");
                     writer.close();
                     String thisResult = "["+fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records";

Modified: trunk/framework/webtools/widget/EntityScreens.xml
===================================================================
--- trunk/framework/webtools/widget/EntityScreens.xml	2006-01-16 08:32:17 UTC (rev 6506)
+++ trunk/framework/webtools/widget/EntityScreens.xml	2006-01-16 08:34:48 UTC (rev 6507)
@@ -63,8 +63,7 @@
                 <set field="title" value="XML Export from DataSource(s)"/>
                 <set field="titleProperty" value="PageTitleEntityExportAll"/>
                 <set field="parameters.TRANSACTION_TIMEOUT" value="7200"/>
-                
-                <script location="component://webtools/webapp/webtools/WEB-INF/actions/entity/EntityExportAll.bsh"/>
+                <set field="results" from-field="parameters.results"/>
             </actions>
             <widgets>
                 <decorator-screen name="main" location="component://webtools/widget/CommonScreens.xml">



More information about the Svn mailing list