[OFBiz] SVN: r6916 - trunk/framework/webtools/webapp/webtools/entity
jonesde@svn.ofbiz.org
jonesde at svn.ofbiz.org
Fri Mar 3 15:14:08 CST 2006
Author: jonesde
Date: 2006-03-03 15:14:05 -0600 (Fri, 03 Mar 2006)
New Revision: 6916
Modified:
trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp
trunk/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp
Log:
Applied patch from Andrew Sykes (plus formatting cleanups) to implement new from/thru date feature for exporting data that was updated with a certain time range
Modified: trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp
===================================================================
--- trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp 2006-03-03 20:35:25 UTC (rev 6915)
+++ trunk/framework/webtools/webapp/webtools/entity/xmldsdump.jsp 2006-03-03 21:14:05 UTC (rev 6916)
@@ -39,6 +39,8 @@
String maxRecStr = request.getParameter("maxrecords");
String entitySyncId = request.getParameter("entitySyncId");
String[] entityName = request.getParameterValues("entityName");
+ String entityFrom = request.getParameter("entityFrom");
+ String entityThru = request.getParameter("entityThru");
// get the max records per file setting and convert to a int
int maxRecordsPerFile = 0;
@@ -166,10 +168,28 @@
}
boolean checkAll = "true".equals(request.getParameter("checkAll"));
boolean tobrowser = request.getParameter("tobrowser")!=null?true:false;
+
+ EntityExpr entityFromCond = null;
+ EntityExpr entityThruCond = null;
+ EntityExpr entityDateCond = null;
+ if (UtilValidate.isNotEmpty(entityFrom)) {
+ entityFromCond = new EntityExpr("lastUpdatedTxStamp", EntityComparisonOperator.GREATER_THAN, entityFrom);
+ }
+ if (UtilValidate.isNotEmpty(entityThru)) {
+ entityThruCond = new EntityExpr("lastUpdatedTxStamp", EntityComparisonOperator.LESS_THAN, entityThru);
+ }
+ if ((entityFromCond!=null) && (entityThruCond!=null)) {
+ entityDateCond = new EntityExpr(entityFromCond, EntityJoinOperator.AND, entityThruCond);
+ } else if(entityFromCond!=null) {
+ entityDateCond = entityFromCond;
+ } else if(entityThruCond!=null) {
+ entityDateCond = entityThruCond;
+ }
+
%>
-<%if (tobrowser) {%>
-<%
+<%if (tobrowser) {
session.setAttribute("xmlrawdump_entitylist", entityName);
+ session.setAttribute("entityDateCond", entityDateCond);
%>
<div class="head1">XML Export from DataSource(s)</div>
<div class="tabletext">This page can be used to export data from the database. The exported documents will have a root tag of "<entity-engine-xml>".</div>
@@ -188,7 +208,7 @@
int numberOfEntities = passedEntityNames.size();
long numberWritten = 0;
-
+
// single file
if(filename != null && filename.length() > 0 && numberOfEntities > 0) {
PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF-8")));
@@ -200,7 +220,7 @@
boolean beganTransaction = TransactionUtil.begin(3600);
try {
String curEntityName = (String)i.next();
- EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, null, null, null, UtilMisc.toList("-createdTxStamp"), efo);
+ EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, entityDateCond, null, null, UtilMisc.toList("-createdTxStamp"), efo);
GenericValue value = null;
long curNumberWritten = 0;
@@ -254,7 +274,7 @@
results.add("["+fileNumber +"] [vvv] " + curEntityName + " skipping view entity");
continue;
}
- values = delegator.findListIteratorByCondition(curEntityName, null, null, null, me.getPkFieldNames(), efo);
+ values = delegator.findListIteratorByCondition(curEntityName, entityDateCond, null, null, me.getPkFieldNames(), efo);
boolean isFirst = true;
PrintWriter writer = null;
int fileSplitNumber = 1;
@@ -341,10 +361,20 @@
<hr/>
<div class="head2">Export:</div>
- <form method="post" action="<ofbiz:url>/xmldsdump</ofbiz:url>">
+ <form method="post" action="<ofbiz:url>/xmldsdump</ofbiz:url>" name="entityExport">
<div class="tabletext">Output Directory : <input type="text" class="inputBox" size="60" name="outpath" value="<%=UtilFormatOut.checkNull(outpath)%>"/></div>
<div class="tabletext">Max Records Per File : <input type="text" class="inputBox" size="10" name="maxrecords"/></div>
<div class="tabletext">Single Filename : <input type="text" class="inputBox" size="60" name="filename" value="<%=UtilFormatOut.checkNull(filename)%>"/></div>
+
+ <div class="tabletext">Records Updated Since :
+ <input type="text" class="inputBox" size="25" name="entityFrom" />
+ <a href="javascript:call_cal(document.entityExport.entityFrom, null);"><img src='/images/cal.gif' width='16' height='16' border='0' alt='Click here For Calendar'></a>
+ </div>
+ <div class="tabletext">Records Updated Before :
+ <input type="text" class="inputBox" size="25" name="entityThru" />
+ <a href="javascript:call_cal(document.entityExport.entityThru, null);"><img src='/images/cal.gif' width='16' height='16' border='0' alt='Click here For Calendar'></a>
+ </div>
+
<div class="tabletext">OR Out to Browser: <input type="checkbox" name="tobrowser" <%=tobrowser?"checked":""%>></div>
<br/>
<div class="tabletext">Entity Names:</div>
Modified: trunk/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp
===================================================================
--- trunk/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp 2006-03-03 20:35:25 UTC (rev 6915)
+++ trunk/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp 2006-03-03 21:14:05 UTC (rev 6916)
@@ -21,10 +21,12 @@
*
* @author David E. Jones (jonesde at ofbiz.org)
* @version 1.0
---%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><%
+--%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.condition.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><%
if(security.hasPermission("ENTITY_MAINT", session)) {
String[] entityName = (String[]) session.getAttribute("xmlrawdump_entitylist");
session.removeAttribute("xmlrawdump_entitylist");
+ EntityExpr entityDateCond = (EntityExpr) session.getAttribute("entityDateCond");
+ session.removeAttribute("entityDateCond");
if (entityName != null) {
ModelReader reader = delegator.getModelReader();
@@ -59,7 +61,7 @@
Iterator i = passedEntityNames.iterator();
while(i.hasNext()) {
String curEntityName = (String)i.next();
- EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, null, null, null);
+ EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, entityDateCond, null, null);
GenericValue value = null;
while ((value = (GenericValue) values.next()) != null) {
More information about the Svn
mailing list