details: https://code.openbravo.com/erp/devel/pi/rev/5eec20fefc1c
changeset: 18170:5eec20fefc1c
user: Martin Taal <martin.taal <at> openbravo.com>
date: Tue Oct 09 11:13:33 2012 +0200
summary: Fixes issue 21498: Wrong CSV when you export the window "Sales
Invoice Payment Plan"
Also support extra properties/property paths in csv export, changed csv field
property name computation to accomodate property path fields.
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
| 3 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
| 1 +
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
| 62 +++++----
3 files changed, 40 insertions(+), 26 deletions(-)
diffs (151 lines):
diff -r dcd825463870 -r 5eec20fefc1c
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
Mon Oct 08 16:33:35 2012 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
Tue Oct 09 11:13:33 2012 +0200
@@ -634,7 +634,7 @@
// be presented with a save-as dialog.
// Parameters:
// * {{{exportProperties}}} defines different properties used for
controlling the export, currently only the
- // exportProperties.exportFormat is supported (which is defaulted to csv).
+ // exportProperties.exportAs and exportProperties._extraProperties are
supported (which is defaulted to csv).
// * {{{data}}} the parameters to post to the server, in addition the filter
criteria of the grid are posted.
exportData: function (exportProperties, data) {
var d = data || {},
@@ -654,6 +654,7 @@
// never do count for export
exportAs: expProp.exportAs || 'csv',
viewState: expProp.viewState,
+ _extraProperties: expProp._extraProperties,
tab: expProp.tab,
exportToFile: true,
_textMatchStyle: 'substring',
diff -r dcd825463870 -r 5eec20fefc1c
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
Mon Oct 08 16:33:35 2012 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
Tue Oct 09 11:13:33 2012 +0200
@@ -220,6 +220,7 @@
var requestProperties = {
exportAs: 'csv',
exportDisplay: 'download',
+ _extraProperties: this.view && this.view.dataSource &&
this.view.dataSource.requestProperties.params._extraProperties,
params: {
exportToFile: true
},
diff -r dcd825463870 -r 5eec20fefc1c
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
---
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
Mon Oct 08 16:33:35 2012 +0200
+++
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
Tue Oct 09 11:13:33 2012 +0200
@@ -333,28 +333,39 @@
// Now we calculate ref lists and nice property names
final String userLanguageId =
OBContext.getOBContext().getLanguage().getId();
if (entity != null) {
+ final Map<String, Property> properties = new HashMap<String,
Property>();
for (Property prop : entity.getProperties()) {
if (!fieldProperties.contains(prop.getName())) {
continue;
}
+ properties.put(prop.getName(), prop);
+ }
+ for (String fieldProperty : fieldProperties) {
+ if (fieldProperty.contains(DalUtil.FIELDSEPARATOR)) {
+ properties.put(fieldProperty,
DalUtil.getPropertyFromPath(entity, fieldProperty));
+ }
+ }
+
+ for (String propKey : properties.keySet()) {
+ final Property prop = properties.get(propKey);
Column col = OBDal.getInstance().get(Column.class,
prop.getColumnId());
if (prop.isAuditInfo()) {
Element element = null;
- if ("creationDate".equals(prop.getName())) {
+ if ("creationDate".equals(propKey)) {
element = OBViewUtil.createdElement;
- } else if ("createdBy".equals(prop.getName())) {
+ } else if ("createdBy".equals(propKey)) {
element = OBViewUtil.createdByElement;
- } else if ("updated".equals(prop.getName())) {
+ } else if ("updated".equals(propKey)) {
element = OBViewUtil.updatedElement;
- } else if ("updatedBy".equals(prop.getName())) {
+ } else if ("updatedBy".equals(propKey)) {
element = OBViewUtil.updatedByElement;
}
if (element != null) {
- niceFieldProperties.put(prop.getName(),
+ niceFieldProperties.put(propKey,
OBViewUtil.getLabel(element,
element.getADElementTrlList()));
} else {
- niceFieldProperties.put(prop.getName(), col.getName());
+ niceFieldProperties.put(propKey, col.getName());
}
} else if (parameters.get("tab") != null &&
!parameters.get("tab").equals("")) {
Tab tab = OBDal.getInstance().get(Tab.class,
parameters.get("tab"));
@@ -362,21 +373,31 @@
if (field.getColumn() == null ||
!field.getColumn().getId().equals(col.getId())) {
continue;
}
- niceFieldProperties.put(prop.getName(), field.getName());
+ niceFieldProperties.put(propKey, field.getName());
for (FieldTrl fieldTrl : field.getADFieldTrlList()) {
if (fieldTrl.getLanguage().getId().equals(userLanguageId)) {
- niceFieldProperties.put(prop.getName(),
fieldTrl.getName());
+ niceFieldProperties.put(propKey, fieldTrl.getName());
}
}
}
} else {
- niceFieldProperties.put(prop.getName(), col.getName());
+ niceFieldProperties.put(propKey, col.getName());
}
UIDefinition uiDef =
UIDefinitionController.getInstance().getUIDefinition(col.getId());
if (uiDef instanceof NumberUIDefinition) {
- formats.put(prop.getName(),
+ formats.put(propKey,
Utility.getFormat(vars, ((NumberUIDefinition)
uiDef).getFormat()));
}
+
+ // We also store the date properties
+ if (prop.isDate()) {
+ dateCols.add(propKey);
+ } else if (prop.isDatetime()) {
+ dateTimeCols.add(propKey);
+ } else if (prop.isPrimitive() && prop.isNumericType()) {
+ numericCols.add(propKey);
+ }
+
if (!(prop.getDomainType() instanceof EnumerateDomainType)) {
continue;
}
@@ -400,19 +421,8 @@
final Object[] row = (Object[]) o;
reflists.put(row[0].toString(), row[1].toString());
}
- refListCols.add(prop.getName());
- refLists.put(prop.getName(), reflists);
- }
-
- // We also store the date properties
- for (Property prop : entity.getProperties()) {
- if (prop.isDate()) {
- dateCols.add(prop.getName());
- } else if (prop.isDatetime()) {
- dateTimeCols.add(prop.getName());
- } else if (prop.isPrimitive() && prop.isNumericType()) {
- numericCols.add(prop.getName());
- }
+ refListCols.add(propKey);
+ refLists.put(propKey, reflists);
}
}
if (fieldProperties.size() > 0) {
@@ -421,8 +431,10 @@
if (i > 0) {
writer.append(fieldSeparator);
}
-
writer.append("\"").append(niceFieldProperties.get(fieldProperties.get(i)))
- .append("\"");
+ if (niceFieldProperties.get(fieldProperties.get(i)) != null) {
+
writer.append("\"").append(niceFieldProperties.get(fieldProperties.get(i)))
+ .append("\"");
+ }
}
propertiesWritten = true;
}
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits