Merged release-1.0c into release-2.0

This commit is contained in:
Heng Sin Low 2013-11-21 20:47:23 +08:00
commit 2065fbff22
3 changed files with 35 additions and 4 deletions

View File

@ -191,8 +191,14 @@ public class DataEngine
return null;
}
if (format.isTranslationView() && tableName.toLowerCase().endsWith("_v")) // _vt not just _v
{
boolean hasVT = DB.isTableOrViewExists(tableName+"t");
if (hasVT)
{
tableName += "t";
format.setTranslationViewQuery (query);
}
}
//
PrintData pd = getPrintDataInfo (ctx, format, query, reportName, tableName);
if (pd == null)

View File

@ -1244,6 +1244,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
if (format == null)
return null;
//
format.setTranslationLanguage(format.getLanguage());
//
PrintInfo info = new PrintInfo (pi);
info.setAD_Table_ID(AD_Table_ID);
@ -1507,7 +1509,6 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
// Get Format & Data
MPrintFormat format = MPrintFormat.get (ctx, AD_PrintFormat_ID, false);
format.setLanguage(language); // BP Language if Multi-Lingual
// if (!Env.isBaseLanguage(language, DOC_TABLES[type]))
format.setTranslationLanguage(language);
// query
MQuery query = new MQuery(format.getAD_Table_ID());

View File

@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -2329,4 +2330,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