details: https://code.openbravo.com/erp/devel/pi/rev/d615b5db09cd
changeset: 23853:d615b5db09cd
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Fri Jun 20 15:59:37 2014 +0200
summary: fixed bug 26914: Process Definition fail if they don't have a single
grid param
-Do not assume 1st param is a grid
-Do not assume there is a grid at all
-Do not do the conversion if there are several grids
-In case of failure don't do the conversion but continue the flow
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
| 46 ++++++++-
1 files changed, 40 insertions(+), 6 deletions(-)
diffs (72 lines):
diff -r 032fb3d55363 -r d615b5db09cd
modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
Fri Jun 20 11:42:57 2014 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/process/BaseProcessActionHandler.java
Fri Jun 20 15:59:37 2014 +0200
@@ -32,6 +32,7 @@
import org.openbravo.client.application.ProcessAccess;
import org.openbravo.client.kernel.BaseActionHandler;
import org.openbravo.client.kernel.KernelConstants;
+import org.openbravo.dal.core.DalUtil;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
@@ -50,6 +51,8 @@
private static final Logger log =
Logger.getLogger(BaseProcessActionHandler.class);
+ private static final String GRID_REFERENCE_ID =
"FF80818132D8F0F30132D9BC395D0038";
+
@Override
protected final JSONObject execute(Map<String, Object> parameters, String
content) {
@@ -95,14 +98,45 @@
Process process = OBDal.getInstance().get(Process.class, processId);
String updatedContent = content;
if (process.isGridlegacy()) {
+ log.warn("Process "
+ + process.getName()
+ + " is marked as Grid Legacy, you should consider migrating it to
prevent parameter conversion");
+
JSONObject jsonRequest = new JSONObject(content);
if (!jsonRequest.isNull("_params")) {
- JSONObject jsonparams = jsonRequest.getJSONObject("_params");
- String gridParamName = jsonparams.names().getString(0);
- JSONObject jsongrid = jsonparams.getJSONObject(gridParamName);
- jsonRequest.put("_selection", jsongrid.getJSONArray("_selection"));
- jsonRequest.put("_allRows", jsongrid.getJSONArray("_allRows"));
- updatedContent = jsonRequest.toString();
+ try {
+ Parameter gridParameter = null;
+ boolean shouldConvert = false;
+ for (Parameter param : process.getOBUIAPPParameterList()) {
+ if
(GRID_REFERENCE_ID.equals(DalUtil.getId(param.getReference()))) {
+ if (gridParameter != null) {
+ log.error("Error while trying to conver parameters to legacy
mode. There are more than one grid parameter. Not converting it.");
+ shouldConvert = false;
+ } else {
+ gridParameter = param;
+ shouldConvert = true;
+ }
+ }
+ }
+
+ if (gridParameter == null) {
+ log.info("There is no grid parameter in proces " +
process.getName()
+ + ". No conversion is needed so Grid Legacy can be safelly
unflagged.");
+ }
+
+ if (shouldConvert) {
+ JSONObject jsonparams = jsonRequest.getJSONObject("_params");
+ if (jsonparams.has(gridParameter.getDBColumnName())
+ && !jsonparams.isNull(gridParameter.getDBColumnName())) {
+ JSONObject jsongrid =
jsonparams.getJSONObject(gridParameter.getDBColumnName());
+ jsonRequest.put("_selection",
jsongrid.getJSONArray("_selection"));
+ jsonRequest.put("_allRows", jsongrid.getJSONArray("_allRows"));
+ }
+ updatedContent = jsonRequest.toString();
+ }
+ } catch (Exception e) {
+ log.error("Error while converting parameters. Sending them without
conversion", e);
+ }
}
}
return doExecute(parameters, updatedContent);
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits