details: https://code.openbravo.com/erp/devel/pi/rev/b78d862f32f3
changeset: 32671:b78d862f32f3
user: Carlos Aristu <carlos.aristu <at> openbravo.com>
date: Tue Sep 12 13:15:31 2017 +0200
summary: related to bug 36763: last update not updated when removing
description
The last updated information is now updated when the description of an
existing attachment is cleared. This was not happening before, because the
record in the OBUIAPP_Parameter_Value table was removed when the value to be
assigned is null
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
| 27 +++++++--
1 files changed, 19 insertions(+), 8 deletions(-)
diffs (50 lines):
diff -r 89a723abed26 -r b78d862f32f3
modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
Tue Sep 12 10:18:16 2017 +0200
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/AttachImplementationManager.java
Tue Sep 12 13:15:31 2017 +0200
@@ -516,9 +516,15 @@
String strValue = "";
if (value == null || (value instanceof String &&
StringUtils.isEmpty((String) value))) {
- // There is no value for this parameter. Remove metadataStoredValue
from Database.
metadataValues.put(strMetadataId, null);
- OBDal.getInstance().remove(metadataStoredValue);
+ // There is no value for this parameter. Just do not create it if is
new or set its value to
+ // null if it already existed in order to keep the correct last
updated information of the
+ // attachment
+ if (metadataStoredValue.isNewOBObject()) {
+ OBDal.getInstance().remove(metadataStoredValue);
+ } else {
+ ParameterUtils.setParameterValue(metadataStoredValue,
getJSONValue(""));
+ }
} else {
String strReferenceId = parameter.getReference().getId();
if (REFERENCE_LIST.equals(strReferenceId)) {
@@ -561,12 +567,8 @@
} else {
strValue = value.toString();
}
- JSONObject jsonValue = new JSONObject();
- try {
- jsonValue.put("value", strValue);
- } catch (JSONException ignore) {
- }
- ParameterUtils.setParameterValue(metadataStoredValue, jsonValue);
+
+ ParameterUtils.setParameterValue(metadataStoredValue,
getJSONValue(strValue));
metadataValues.put(strMetadataId,
ParameterUtils.getParameterValue(metadataStoredValue));
}
OBDal.getInstance().save(metadataStoredValue);
@@ -581,4 +583,13 @@
return metadataValues;
}
+
+ private JSONObject getJSONValue(String value) {
+ JSONObject jsonValue = new JSONObject();
+ try {
+ jsonValue.put("value", value);
+ } catch (JSONException ignore) {
+ }
+ return jsonValue;
+ }
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits