IDEMPIERE-1510 Exception when closing Report Wizard ( ticket #1003516 )
This commit is contained in:
parent
90a17a7753
commit
c8f9f36295
|
@ -191,8 +191,14 @@ public class DataEngine
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (format.isTranslationView() && tableName.toLowerCase().endsWith("_v")) // _vt not just _v
|
if (format.isTranslationView() && tableName.toLowerCase().endsWith("_v")) // _vt not just _v
|
||||||
tableName += "t";
|
{
|
||||||
format.setTranslationViewQuery (query);
|
boolean hasVT = DB.isTableOrViewExists(tableName+"t");
|
||||||
|
if (hasVT)
|
||||||
|
{
|
||||||
|
tableName += "t";
|
||||||
|
format.setTranslationViewQuery (query);
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
PrintData pd = getPrintDataInfo (ctx, format, query, reportName, tableName);
|
PrintData pd = getPrintDataInfo (ctx, format, query, reportName, tableName);
|
||||||
if (pd == null)
|
if (pd == null)
|
||||||
|
|
|
@ -1244,6 +1244,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
if (format == null)
|
if (format == null)
|
||||||
return null;
|
return null;
|
||||||
//
|
//
|
||||||
|
format.setTranslationLanguage(format.getLanguage());
|
||||||
|
//
|
||||||
PrintInfo info = new PrintInfo (pi);
|
PrintInfo info = new PrintInfo (pi);
|
||||||
info.setAD_Table_ID(AD_Table_ID);
|
info.setAD_Table_ID(AD_Table_ID);
|
||||||
|
|
||||||
|
@ -1507,8 +1509,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
// Get Format & Data
|
// Get Format & Data
|
||||||
MPrintFormat format = MPrintFormat.get (ctx, AD_PrintFormat_ID, false);
|
MPrintFormat format = MPrintFormat.get (ctx, AD_PrintFormat_ID, false);
|
||||||
format.setLanguage(language); // BP Language if Multi-Lingual
|
format.setLanguage(language); // BP Language if Multi-Lingual
|
||||||
// if (!Env.isBaseLanguage(language, DOC_TABLES[type]))
|
format.setTranslationLanguage(language);
|
||||||
format.setTranslationLanguage(language);
|
|
||||||
// query
|
// query
|
||||||
MQuery query = new MQuery(format.getAD_Table_ID());
|
MQuery query = new MQuery(format.getAD_Table_ID());
|
||||||
query.addRestriction(DOC_IDS[type], MQuery.EQUAL, Record_ID);
|
query.addRestriction(DOC_IDS[type], MQuery.EQUAL, Record_ID);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.FileOutputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.CallableStatement;
|
import java.sql.CallableStatement;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -2319,4 +2320,27 @@ public final class DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tableName
|
||||||
|
* @return true if table or view with name=tableName exists in db
|
||||||
|
*/
|
||||||
|
public static boolean isTableOrViewExists(String tableName) {
|
||||||
|
Connection conn = getConnectionRO();
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
DatabaseMetaData metadata = conn.getMetaData();
|
||||||
|
rs = metadata.getTables(null, null, (DB.isPostgreSQL() ? tableName.toLowerCase() : tableName.toUpperCase()), null);
|
||||||
|
if (rs.next()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
DB.close(rs);
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // DB
|
} // DB
|
||||||
|
|
Loading…
Reference in New Issue