IDEMPIERE-3852 Export zip button (pack out) has error for tabs beyond third level (FHCA-815)
This commit is contained in:
parent
46bdae37d7
commit
33b8b505d7
|
@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ public class GenericPOElementHandler extends AbstractElementHandler {
|
||||||
|
|
||||||
for (int i = 1; i < components.length; i++) {
|
for (int i = 1; i < components.length; i++) {
|
||||||
String tables[] = components[i].split("[>]");
|
String tables[] = components[i].split("[>]");
|
||||||
exportDetail(ctx, document, po, 0, tables);
|
exportDetail(ctx, document, po, tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
|
@ -209,19 +210,19 @@ public class GenericPOElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportDetail(PIPOContext ctx, TransformerHandler document, GenericPO parent, int index, String[] tables) {
|
private void exportDetail(PIPOContext ctx, TransformerHandler document, GenericPO parent, String[] tables) {
|
||||||
|
String mainTable = tables[0];
|
||||||
AttributesImpl atts = new AttributesImpl();
|
AttributesImpl atts = new AttributesImpl();
|
||||||
tables[index] = tables[index].trim();
|
String sql = "SELECT * FROM " + mainTable + " WHERE " + parent.get_TableName() + "_ID = ?";
|
||||||
String sql = "SELECT * FROM " + tables[index] + " WHERE " + parent.get_TableName() + "_ID = ?";
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
sql = MRole.getDefault().addAccessSQL(sql, tables[index], true, true);
|
sql = MRole.getDefault().addAccessSQL(sql, mainTable, true, true);
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, parent.get_ID());
|
pstmt.setInt(1, parent.get_ID());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
GenericPO po = new GenericPO(tables[index], ctx.ctx, rs, getTrxName(ctx));
|
GenericPO po = new GenericPO(mainTable, ctx.ctx, rs, getTrxName(ctx));
|
||||||
int AD_Client_ID = po.getAD_Client_ID();
|
int AD_Client_ID = po.getAD_Client_ID();
|
||||||
if (AD_Client_ID != Env.getAD_Client_ID(ctx.ctx))
|
if (AD_Client_ID != Env.getAD_Client_ID(ctx.ctx))
|
||||||
continue;
|
continue;
|
||||||
|
@ -237,12 +238,12 @@ public class GenericPOElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
verifyPackOutRequirement(po);
|
verifyPackOutRequirement(po);
|
||||||
List<String> excludes = defaultExcludeList(tables[index]);
|
List<String> excludes = defaultExcludeList(mainTable);
|
||||||
addTypeName(atts, "table");
|
addTypeName(atts, "table");
|
||||||
document.startElement("", "", tables[index], atts);
|
document.startElement("", "", mainTable, atts);
|
||||||
PoExporter filler = new PoExporter(ctx, document, po);
|
PoExporter filler = new PoExporter(ctx, document, po);
|
||||||
filler.export(excludes, true);
|
filler.export(excludes, true);
|
||||||
ctx.packOut.getCtx().ctx.put("Table_Name",tables[index]);
|
ctx.packOut.getCtx().ctx.put("Table_Name",mainTable);
|
||||||
try {
|
try {
|
||||||
new CommonTranslationHandler().packOut(ctx.packOut,document,null,po.get_ID());
|
new CommonTranslationHandler().packOut(ctx.packOut,document,null,po.get_ID());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -250,11 +251,27 @@ public class GenericPOElementHandler extends AbstractElementHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=index+1; i<tables.length; i++) {
|
for (int i=1; i<tables.length; i++) {
|
||||||
exportDetail(ctx, document, po, 0, new String[] {tables[i]});
|
if (tables[i].startsWith("+")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<String> detTablesArr = new ArrayList<String>();
|
||||||
|
for (int j=i; j<tables.length; j++) {
|
||||||
|
if (j == i) {
|
||||||
|
detTablesArr.add(tables[j]);
|
||||||
|
} else {
|
||||||
|
if (tables[j].startsWith("+")) {
|
||||||
|
detTablesArr.add(tables[j].substring(1));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] detTables = detTablesArr.toArray(new String[0]);
|
||||||
|
exportDetail(ctx, document, po, detTables);
|
||||||
}
|
}
|
||||||
if (createElement) {
|
if (createElement) {
|
||||||
document.endElement("","",tables[index]);
|
document.endElement("","",mainTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -72,7 +72,11 @@ public class GridTab2PackExporter implements IGridTabExporter {
|
||||||
if (child.getTableName().toLowerCase().endsWith("_trl")) // ignore trl tabs as they are exported as translation
|
if (child.getTableName().toLowerCase().endsWith("_trl")) // ignore trl tabs as they are exported as translation
|
||||||
continue;
|
continue;
|
||||||
if (child.getTabLevel() > gridTab.getTabLevel()+1) {
|
if (child.getTabLevel() > gridTab.getTabLevel()+1) {
|
||||||
sql = sql.append(">").append(child.getTableName());
|
int level = child.getTabLevel() - gridTab.getTabLevel() - 1;
|
||||||
|
String sep = ">";
|
||||||
|
for (int i = 1; i < level; i++)
|
||||||
|
sep += "+";
|
||||||
|
sql = sql.append(sep).append(child.getTableName());
|
||||||
} else {
|
} else {
|
||||||
sql = sql.append(";").append(child.getTableName());
|
sql = sql.append(";").append(child.getTableName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ public class ExportAction implements EventListener<Event>
|
||||||
chkSelectionTab.setAttribute("tabBinding", child);
|
chkSelectionTab.setAttribute("tabBinding", child);
|
||||||
vlayout.appendChild(chkSelectionTab);
|
vlayout.appendChild(chkSelectionTab);
|
||||||
chkSelectionTabForExport.add(chkSelectionTab);
|
chkSelectionTabForExport.add(chkSelectionTab);
|
||||||
|
chkSelectionTab.addEventListener(Events.ON_CHECK, this);
|
||||||
isHasSelectionTab = true;
|
isHasSelectionTab = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +236,26 @@ public class ExportAction implements EventListener<Event>
|
||||||
panel.hideBusyMask();
|
panel.hideBusyMask();
|
||||||
}else if (event.getTarget().equals(cboType) && event.getName().equals(Events.ON_SELECT)) {
|
}else if (event.getTarget().equals(cboType) && event.getName().equals(Events.ON_SELECT)) {
|
||||||
displayExportTabSelection();
|
displayExportTabSelection();
|
||||||
|
}else if (event.getTarget() instanceof Checkbox) {
|
||||||
|
// A child is not exportable without its parent
|
||||||
|
Checkbox cbSel = (Checkbox) event.getTarget();
|
||||||
|
GridTab gtSel = (GridTab)cbSel.getAttribute("tabBinding");
|
||||||
|
boolean found = false;
|
||||||
|
for (Checkbox cb : chkSelectionTabForExport) {
|
||||||
|
if (cb == cbSel) {
|
||||||
|
found = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GridTab gt = (GridTab)cb.getAttribute("tabBinding");
|
||||||
|
if (found) {
|
||||||
|
if (gt.getTabLevel() > gtSel.getTabLevel()) {
|
||||||
|
cb.setChecked(cbSel.isChecked());
|
||||||
|
cb.setEnabled(cbSel.isChecked());
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}else if (event.getName().equals("onExporterException")){
|
}else if (event.getName().equals("onExporterException")){
|
||||||
FDialog.error(0, winExportFile, "FileInvalidExtension");
|
FDialog.error(0, winExportFile, "FileInvalidExtension");
|
||||||
winExportFile.onClose();
|
winExportFile.onClose();
|
||||||
|
|
Loading…
Reference in New Issue