Fixed multi lingual reporting issue

This commit is contained in:
Heng Sin Low 2010-10-26 19:03:16 +08:00
parent fa6dafed7d
commit 6f2f78cd11
5 changed files with 202 additions and 98 deletions

View File

@ -24,12 +24,12 @@ import org.compiere.wf.MWFProcess;
import org.compiere.wf.MWorkflow; import org.compiere.wf.MWorkflow;
/** /**
* *
* @author Low Heng Sin * @author Low Heng Sin
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1757523 ] Server Processes are using Server's context * <li>BF [ 1757523 ] Server Processes are using Server's context
* <li>BF [ 2528297 ] Poor error message on jasper fail * <li>BF [ 2528297 ] Poor error message on jasper fail
* <li>BF [ 2530847 ] Report is displayed even if java process fails * <li>BF [ 2530847 ] Report is displayed even if java process fails
*/ */
public final class ProcessUtil { public final class ProcessUtil {
@ -37,9 +37,9 @@ public final class ProcessUtil {
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(ProcessUtil.class); private static CLogger log = CLogger.getCLogger(ProcessUtil.class);
private ProcessUtil() {} private ProcessUtil() {}
/** /**
* @param processInfo * @param processInfo
* @param ProcedureName * @param ProcedureName
@ -63,7 +63,7 @@ public final class ProcessUtil {
try try
{ {
//hengsin, add trx support, updateable support. //hengsin, add trx support, updateable support.
CallableStatement cstmt = DB.prepareCall(sql, ResultSet.CONCUR_UPDATABLE, trxName); CallableStatement cstmt = DB.prepareCall(sql, ResultSet.CONCUR_UPDATABLE, trxName);
cstmt.setInt(1, processInfo.getAD_PInstance_ID()); cstmt.setInt(1, processInfo.getAD_PInstance_ID());
cstmt.executeUpdate(); cstmt.executeUpdate();
cstmt.close(); cstmt.close();
@ -90,12 +90,12 @@ public final class ProcessUtil {
} }
return true; return true;
} }
@Deprecated @Deprecated
public static boolean startJavaProcess(ProcessInfo pi, Trx trx) { public static boolean startJavaProcess(ProcessInfo pi, Trx trx) {
return startJavaProcess(Env.getCtx(), pi, trx); return startJavaProcess(Env.getCtx(), pi, trx);
} }
/** /**
* @param ctx * @param ctx
* @param pi * @param pi
@ -120,36 +120,49 @@ public final class ProcessUtil {
if (proc.getJasperReport() != null) if (proc.getJasperReport() != null)
className = JASPER_STARTER_CLASS; className = JASPER_STARTER_CLASS;
} }
ProcessCall process = null; ProcessCall process = null;
if (Core.isExtension(className)) { if (Core.isExtension(className)) {
process = Core.getProcess(className); process = Core.getProcess(className);
} }
if (process == null) { if (process == null) {
//Get Class //Get Class
Class<?> processClass = null; Class<?> processClass = null;
//use context classloader if available //use context classloader if available
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) if (classLoader != null)
{
try
{
processClass = classLoader.loadClass(className);
}
catch (ClassNotFoundException ex)
{
log.log(Level.FINE, className, ex);
}
}
if (processClass == null)
{
classLoader = ProcessUtil.class.getClassLoader(); classLoader = ProcessUtil.class.getClassLoader();
try try
{ {
processClass = classLoader.loadClass(className); processClass = classLoader.loadClass(className);
}
catch (ClassNotFoundException ex)
{
log.log(Level.WARNING, className, ex);
pi.setSummary ("ClassNotFound", true);
return false;
}
} }
catch (ClassNotFoundException ex)
{
log.log(Level.WARNING, className, ex);
pi.setSummary ("ClassNotFound", true);
return false;
}
if (processClass == null) { if (processClass == null) {
pi.setSummary("No Instance for " + pi.getClassName(), true); pi.setSummary("No Instance for " + pi.getClassName(), true);
return false; return false;
} }
//Get Process //Get Process
try try
{ {
process = (ProcessCall)processClass.newInstance(); process = (ProcessCall)processClass.newInstance();
@ -159,9 +172,9 @@ public final class ProcessUtil {
log.log(Level.WARNING, "Instance for " + className, ex); log.log(Level.WARNING, "Instance for " + className, ex);
pi.setSummary ("InstanceError", true); pi.setSummary ("InstanceError", true);
return false; return false;
} }
} }
boolean success = false; boolean success = false;
try try
{ {
@ -188,11 +201,11 @@ public final class ProcessUtil {
} }
return success; return success;
} }
public static boolean startScriptProcess(Properties ctx, ProcessInfo pi, Trx trx) { public static boolean startScriptProcess(Properties ctx, ProcessInfo pi, Trx trx) {
String msg = null; String msg = null;
boolean success = true; boolean success = true;
try try
{ {
String cmd = pi.getClassName(); String cmd = pi.getClassName();
MRule rule = MRule.get(ctx, cmd.substring(MRule.SCRIPT_PREFIX.length())); MRule rule = MRule.get(ctx, cmd.substring(MRule.SCRIPT_PREFIX.length()));
@ -201,7 +214,7 @@ public final class ProcessUtil {
pi.setSummary ("ScriptNotFound", true); pi.setSummary ("ScriptNotFound", true);
return false; return false;
} }
if ( ! (rule.getEventType().equals(MRule.EVENTTYPE_Process) if ( ! (rule.getEventType().equals(MRule.EVENTTYPE_Process)
&& rule.getRuleType().equals(MRule.RULETYPE_JSR223ScriptingAPIs))) { && rule.getRuleType().equals(MRule.RULETYPE_JSR223ScriptingAPIs))) {
log.log(Level.WARNING, cmd + " must be of type JSR 223 and event Process"); log.log(Level.WARNING, cmd + " must be of type JSR 223 and event Process");
pi.setSummary ("ScriptNotFound", true); pi.setSummary ("ScriptNotFound", true);
@ -215,7 +228,7 @@ public final class ProcessUtil {
// Method arguments context are A_ // Method arguments context are A_
// Parameter context are P_ // Parameter context are P_
MRule.setContext(engine, ctx, 0); // no window MRule.setContext(engine, ctx, 0); // no window
// now add the method arguments to the engine // now add the method arguments to the engine
engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx); engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx);
if (trx == null) if (trx == null)
trx = Trx.get(pi.getTitle()+"_"+pi.getAD_PInstance_ID(), true); trx = Trx.get(pi.getTitle()+"_"+pi.getAD_PInstance_ID(), true);
@ -258,16 +271,16 @@ public final class ProcessUtil {
} }
} }
engine.put(MRule.ARGUMENTS_PREFIX + "ProcessInfo", pi); engine.put(MRule.ARGUMENTS_PREFIX + "ProcessInfo", pi);
msg = engine.eval(rule.getScript()).toString(); msg = engine.eval(rule.getScript()).toString();
//transaction should rollback if there are error in process //transaction should rollback if there are error in process
if ("@Error@".equals(msg)) if ("@Error@".equals(msg))
success = false; success = false;
// Parse Variables // Parse Variables
msg = Msg.parseTranslation(ctx, msg); msg = Msg.parseTranslation(ctx, msg);
pi.setSummary (msg, !success); pi.setSummary (msg, !success);
} }
catch (Exception e) catch (Exception e)
{ {
@ -278,7 +291,7 @@ public final class ProcessUtil {
if (success) { if (success) {
if (trx != null) if (trx != null)
{ {
try try
{ {
trx.commit(true); trx.commit(true);
} catch (Exception e) } catch (Exception e)
@ -299,7 +312,7 @@ public final class ProcessUtil {
} }
return success; return success;
} }
public static MWFProcess startWorkFlow(Properties ctx, ProcessInfo pi, int AD_Workflow_ID) { public static MWFProcess startWorkFlow(Properties ctx, ProcessInfo pi, int AD_Workflow_ID) {
MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID); MWorkflow wf = MWorkflow.get (ctx, AD_Workflow_ID);
MWFProcess wfProcess = null; MWFProcess wfProcess = null;
@ -322,6 +335,6 @@ public final class ProcessUtil {
public static boolean startJavaProcessWithoutTrxClose(Properties ctx, ProcessInfo pi, Trx trx) { public static boolean startJavaProcessWithoutTrxClose(Properties ctx, ProcessInfo pi, Trx trx) {
return startJavaProcess(ctx, pi, trx, false); return startJavaProcess(ctx, pi, trx, false);
} }
} }

View File

@ -91,7 +91,7 @@ import org.w3c.dom.Element;
* <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332 * <li>https://sourceforge.net/tracker/?func=detail&aid=2947622&group_id=176962&atid=879332
*/ */
public abstract class PO public abstract class PO
implements Serializable, Comparator, Evaluatee implements Serializable, Comparator, Evaluatee, Cloneable
{ {
/** /**
* *
@ -4009,4 +4009,46 @@ public abstract class PO
return false; return false;
} }
@Override
protected Object clone() throws CloneNotSupportedException {
PO clone = (PO) super.clone();
clone.m_trxName = null;
if (m_custom != null)
{
clone.m_custom = new HashMap<String, String>();
clone.m_custom.putAll(m_custom);
}
if (m_newValues != null)
{
clone.m_newValues = new Object[m_newValues.length];
for(int i = 0; i < m_newValues.length; i++)
{
clone.m_newValues[i] = m_newValues[i];
}
}
if (m_oldValues != null)
{
clone.m_oldValues = new Object[m_oldValues.length];
for(int i = 0; i < m_oldValues.length; i++)
{
clone.m_oldValues[i] = m_oldValues[i];
}
}
if (m_IDs != null)
{
clone.m_IDs = new Object[m_IDs.length];
for(int i = 0; i < m_IDs.length; i++)
{
clone.m_IDs[i] = m_IDs[i];
}
}
clone.p_ctx = Env.getCtx();
clone.m_doc = null;
clone.m_lobInfo = null;
clone.m_attachment = null;
clone.m_isReplication = false;
return clone;
}
} // PO } // PO

View File

@ -29,6 +29,7 @@ import javax.sql.RowSet;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.PO;
import org.compiere.model.X_AD_PrintFormat; import org.compiere.model.X_AD_PrintFormat;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -49,7 +50,7 @@ import org.compiere.util.Util;
public class MPrintFormat extends X_AD_PrintFormat public class MPrintFormat extends X_AD_PrintFormat
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 3626220385155526700L; private static final long serialVersionUID = 3626220385155526700L;
@ -64,7 +65,7 @@ public class MPrintFormat extends X_AD_PrintFormat
{ {
super (ctx, AD_PrintFormat_ID, trxName); super (ctx, AD_PrintFormat_ID, trxName);
// Language=[Deutsch,Locale=de_DE,AD_Language=en_US,DatePattern=DD.MM.YYYY,DecimalPoint=false] // Language=[Deutsch,Locale=de_DE,AD_Language=en_US,DatePattern=DD.MM.YYYY,DecimalPoint=false]
m_language = Language.getLoginLanguage(); m_language = Env.getLanguage(ctx);
if (AD_PrintFormat_ID == 0) if (AD_PrintFormat_ID == 0)
{ {
setStandardHeaderFooter(true); setStandardHeaderFooter(true);
@ -74,7 +75,7 @@ public class MPrintFormat extends X_AD_PrintFormat
} }
m_items = getItems(); m_items = getItems();
} // MPrintFormat } // MPrintFormat
/** /**
* Load Constructor * Load Constructor
* @param ctx context * @param ctx context
@ -84,7 +85,7 @@ public class MPrintFormat extends X_AD_PrintFormat
public MPrintFormat (Properties ctx, ResultSet rs, String trxName) public MPrintFormat (Properties ctx, ResultSet rs, String trxName)
{ {
super(ctx, rs, trxName); super(ctx, rs, trxName);
m_language = Language.getLoginLanguage(); m_language = Env.getLanguage(ctx);
m_items = getItems(); m_items = getItems();
} // MPrintFormat } // MPrintFormat
@ -192,7 +193,7 @@ public class MPrintFormat extends X_AD_PrintFormat
// Display restrictions - Passwords, etc. // Display restrictions - Passwords, etc.
+ " AND NOT EXISTS (SELECT * FROM AD_Field f " + " AND NOT EXISTS (SELECT * FROM AD_Field f "
+ "WHERE pfi.AD_Column_ID=f.AD_Column_ID" + "WHERE pfi.AD_Column_ID=f.AD_Column_ID"
+ " AND (f.IsEncrypted='Y' OR f.ObscureType IS NOT NULL))" + " AND (f.IsEncrypted='Y' OR f.ObscureType IS NOT NULL))"
+ "ORDER BY SeqNo"; + "ORDER BY SeqNo";
MRole role = MRole.getDefault(getCtx(), false); MRole role = MRole.getDefault(getCtx(), false);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -260,7 +261,7 @@ public class MPrintFormat extends X_AD_PrintFormat
log.fine("setTranslation #" + no); log.fine("setTranslation #" + no);
} // setTranslation } // setTranslation
/************************************************************************** /**************************************************************************
* Set Standard Header * Set Standard Header
* @param standardHeaderFooter true if std header * @param standardHeaderFooter true if std header
@ -287,7 +288,7 @@ public class MPrintFormat extends X_AD_PrintFormat
super.setIsForm(false); super.setIsForm(false);
} // setIsTableBased } // setIsTableBased
/************************************************************************** /**************************************************************************
* Set Translation View Language. * Set Translation View Language.
* @param language language (checked for base language) * @param language language (checked for base language)
@ -331,7 +332,7 @@ public class MPrintFormat extends X_AD_PrintFormat
} }
} // setTranslationViewQuery } // setTranslationViewQuery
/************************************************************************** /**************************************************************************
* Get Optional TableFormat * Get Optional TableFormat
* @param AD_PrintTableFormat_ID table format * @param AD_PrintTableFormat_ID table format
@ -367,7 +368,7 @@ public class MPrintFormat extends X_AD_PrintFormat
return sb.toString(); return sb.toString();
} // toString } // toString
/************************************************************************** /**************************************************************************
* Load Special data (images, ..). * Load Special data (images, ..).
* To be extended by sub-classes * To be extended by sub-classes
@ -421,7 +422,7 @@ public class MPrintFormat extends X_AD_PrintFormat
* @param AD_PrintFormat_ID 0 or existing PrintFormat * @param AD_PrintFormat_ID 0 or existing PrintFormat
* @return print format * @return print format
*/ */
static public MPrintFormat createFromTable (Properties ctx, static public MPrintFormat createFromTable (Properties ctx,
int AD_Table_ID, int AD_PrintFormat_ID) int AD_Table_ID, int AD_PrintFormat_ID)
{ {
int AD_Client_ID = Env.getAD_Client_ID(ctx); int AD_Client_ID = Env.getAD_Client_ID(ctx);
@ -650,13 +651,13 @@ public class MPrintFormat extends X_AD_PrintFormat
catch (SQLException e) catch (SQLException e)
{ {
s_log.log(Level.SEVERE, "(table) - " + sql, e); s_log.log(Level.SEVERE, "(table) - " + sql, e);
} }
finally { finally {
DB.close(rs, pstmt); DB.close(rs, pstmt);
rs = null; pstmt = null; rs = null; pstmt = null;
} }
} }
// //
MPrintFormatItem[] retValue = new MPrintFormatItem[list.size()]; MPrintFormatItem[] retValue = new MPrintFormatItem[list.size()];
list.toArray(retValue); list.toArray(retValue);
@ -694,18 +695,18 @@ public class MPrintFormat extends X_AD_PrintFormat
* @param fromItems from items * @param fromItems from items
* @param toItems to items * @param toItems to items
*/ */
static private void copyTranslationItems (MPrintFormatItem[] fromItems, static private void copyTranslationItems (MPrintFormatItem[] fromItems,
MPrintFormatItem[] toItems) MPrintFormatItem[] toItems)
{ {
if (fromItems == null || toItems == null) if (fromItems == null || toItems == null)
return; // should not happen return; // should not happen
int counter = 0; int counter = 0;
for (int i = 0; i < fromItems.length; i++) for (int i = 0; i < fromItems.length; i++)
{ {
int fromID = fromItems[i].getAD_PrintFormatItem_ID(); int fromID = fromItems[i].getAD_PrintFormatItem_ID();
int toID = toItems[i].getAD_PrintFormatItem_ID(); int toID = toItems[i].getAD_PrintFormatItem_ID();
StringBuffer sql = new StringBuffer("UPDATE AD_PrintFormatItem_Trl new ") StringBuffer sql = new StringBuffer("UPDATE AD_PrintFormatItem_Trl new ")
// Set // Set
.append("SET (PrintName, PrintNameSuffix, IsTranslated) = ") .append("SET (PrintName, PrintNameSuffix, IsTranslated) = ")
@ -730,7 +731,7 @@ public class MPrintFormat extends X_AD_PrintFormat
s_log.finest("#" + counter); s_log.finest("#" + counter);
} // copyTranslationItems } // copyTranslationItems
/************************************************************************** /**************************************************************************
* Copy existing Definition To Client * Copy existing Definition To Client
* @param ctx context * @param ctx context
@ -738,7 +739,7 @@ public class MPrintFormat extends X_AD_PrintFormat
* @param to_AD_PrintFormat_ID format * @param to_AD_PrintFormat_ID format
* @return print format * @return print format
*/ */
public static MPrintFormat copy (Properties ctx, public static MPrintFormat copy (Properties ctx,
int from_AD_PrintFormat_ID, int to_AD_PrintFormat_ID) int from_AD_PrintFormat_ID, int to_AD_PrintFormat_ID)
{ {
return copy (ctx, from_AD_PrintFormat_ID, to_AD_PrintFormat_ID, -1); return copy (ctx, from_AD_PrintFormat_ID, to_AD_PrintFormat_ID, -1);
@ -751,7 +752,7 @@ public class MPrintFormat extends X_AD_PrintFormat
* @param to_Client_ID to client * @param to_Client_ID to client
* @return print format * @return print format
*/ */
public static MPrintFormat copyToClient (Properties ctx, public static MPrintFormat copyToClient (Properties ctx,
int AD_PrintFormat_ID, int to_Client_ID) int AD_PrintFormat_ID, int to_Client_ID)
{ {
return copy (ctx, AD_PrintFormat_ID, 0, to_Client_ID); return copy (ctx, AD_PrintFormat_ID, 0, to_Client_ID);
@ -769,7 +770,7 @@ public class MPrintFormat extends X_AD_PrintFormat
int to_AD_PrintFormat_ID, int to_Client_ID) int to_AD_PrintFormat_ID, int to_Client_ID)
{ {
s_log.info ("From AD_PrintFormat_ID=" + from_AD_PrintFormat_ID s_log.info ("From AD_PrintFormat_ID=" + from_AD_PrintFormat_ID
+ ", To AD_PrintFormat_ID=" + to_AD_PrintFormat_ID + ", To AD_PrintFormat_ID=" + to_AD_PrintFormat_ID
+ ", To Client_ID=" + to_Client_ID); + ", To Client_ID=" + to_Client_ID);
if (from_AD_PrintFormat_ID == 0) if (from_AD_PrintFormat_ID == 0)
throw new IllegalArgumentException ("From_AD_PrintFormat_ID is 0"); throw new IllegalArgumentException ("From_AD_PrintFormat_ID is 0");
@ -786,8 +787,8 @@ public class MPrintFormat extends X_AD_PrintFormat
} }
// Set Name - Remove TEMPLATE - add copy // Set Name - Remove TEMPLATE - add copy
to.setName(Util.replace(to.getName(), "TEMPLATE", String.valueOf(to_Client_ID))); to.setName(Util.replace(to.getName(), "TEMPLATE", String.valueOf(to_Client_ID)));
to.setName(to.getName() to.setName(to.getName()
+ " " + Msg.getMsg(ctx, "Copy") + " " + Msg.getMsg(ctx, "Copy")
+ " " + to.hashCode()); // unique name + " " + to.hashCode()); // unique name
// //
to.save(); to.save();
@ -823,6 +824,15 @@ public class MPrintFormat extends X_AD_PrintFormat
else else
s_formats.put(key, pf); s_formats.put(key, pf);
} }
if (pf != null)
{
try {
pf = pf.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
return pf; return pf;
} // get } // get
@ -843,7 +853,7 @@ public class MPrintFormat extends X_AD_PrintFormat
sql += "AD_ReportView_ID=?"; sql += "AD_ReportView_ID=?";
else else
sql += "AD_Table_ID=?"; sql += "AD_Table_ID=?";
sql += " ORDER BY IsDefault DESC"; sql += " ORDER BY IsDefault DESC";
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
@ -872,7 +882,7 @@ public class MPrintFormat extends X_AD_PrintFormat
Integer key = new Integer(AD_PrintFormat_ID); Integer key = new Integer(AD_PrintFormat_ID);
s_formats.put(key, null); s_formats.put(key, null);
} // deleteFromCache } // deleteFromCache
//begin vpj-cd e-evolution //begin vpj-cd e-evolution
/** /**
* Get ID of Print Format use Name * Get ID of Print Format use Name
@ -888,10 +898,10 @@ public class MPrintFormat extends X_AD_PrintFormat
return DB.getSQLValue(null, sql, formatName, AD_Table_ID, AD_Client_ID); return DB.getSQLValue(null, sql, formatName, AD_Table_ID, AD_Client_ID);
} }
//end vpj-cd e-evolution //end vpj-cd e-evolution
/** /**
* @param AD_Table_ID * @param AD_Table_ID
* @param AD_Client_ID use -1 to retrieve from all client * @param AD_Client_ID use -1 to retrieve from all client
* @param trxName * @param trxName
*/ */
public static RowSet getAccessiblePrintFormats (int AD_Table_ID, int AD_Client_ID, String trxName) public static RowSet getAccessiblePrintFormats (int AD_Table_ID, int AD_Client_ID, String trxName)
@ -904,7 +914,7 @@ public class MPrintFormat extends X_AD_PrintFormat
{ {
sql = sql + " AND AD_Client_ID = ? "; sql = sql + " AND AD_Client_ID = ? ";
} }
sql = sql + "ORDER BY AD_Client_ID DESC, IsDefault DESC, Name"; // Own First sql = sql + "ORDER BY AD_Client_ID DESC, IsDefault DESC, Name"; // Own First
// //
sql = MRole.getDefault().addAccessSQL ( sql = MRole.getDefault().addAccessSQL (
sql, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); sql, "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
@ -925,11 +935,23 @@ public class MPrintFormat extends X_AD_PrintFormat
DB.close(pstmt); DB.close(pstmt);
pstmt = null; pstmt = null;
} }
return rowSet; return rowSet;
} }
@Override
public MPrintFormat clone() throws CloneNotSupportedException {
MPrintFormat clone = (MPrintFormat) super.clone();
clone.m_items = m_items == null ? null : new MPrintFormatItem[m_items.length];
for(int i = 0; i < m_items.length; i++) {
clone.m_items[i] = m_items[i];
}
clone.m_tFormat = m_tFormat;
clone.m_language = Env.getLanguage(Env.getCtx());
clone.m_translationViewLanguage = null;
return clone;
}
/************************************************************************** /**************************************************************************
* Test * Test
* @param args arga * @param args arga

View File

@ -30,7 +30,7 @@ import java.util.logging.Level;
* </pre> * </pre>
* @author Jorg Janke * @author Jorg Janke
* @version $Id: DisplayType.java,v 1.6 2006/08/30 20:30:44 comdivision Exp $ * @version $Id: DisplayType.java,v 1.6 2006/08/30 20:30:44 comdivision Exp $
* *
* @author Teo Sarca, SC ARHIPAC SERVICE SRL * @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 1810632 ] PricePrecision error in InfoProduct (and similar) * <li>BF [ 1810632 ] PricePrecision error in InfoProduct (and similar)
*/ */
@ -100,8 +100,8 @@ public final class DisplayType
public static final int URL = 40; public static final int URL = 40;
/** Display Type 42 PrinterName */ /** Display Type 42 PrinterName */
public static final int PrinterName = 42; public static final int PrinterName = 42;
// Candidates: // Candidates:
/** /**
* - New Display Type * - New Display Type
INSERT INTO AD_REFERENCE INSERT INTO AD_REFERENCE
@ -130,7 +130,7 @@ public final class DisplayType
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (DisplayType.class); private static CLogger s_log = CLogger.getCLogger (DisplayType.class);
/** /**
* Returns true if (numeric) ID (Table, Search, Account, ..). * Returns true if (numeric) ID (Table, Search, Account, ..).
* (stored as Integer) * (stored as Integer)
@ -155,12 +155,12 @@ public final class DisplayType
*/ */
public static boolean isNumeric(int displayType) public static boolean isNumeric(int displayType)
{ {
if (displayType == Amount || displayType == Number || displayType == CostPrice if (displayType == Amount || displayType == Number || displayType == CostPrice
|| displayType == Integer || displayType == Quantity) || displayType == Integer || displayType == Quantity)
return true; return true;
return false; return false;
} // isNumeric } // isNumeric
/** /**
* Get Default Precision. * Get Default Precision.
* Used for databases who cannot handle dynamic number precision. * Used for databases who cannot handle dynamic number precision.
@ -173,12 +173,12 @@ public final class DisplayType
return 2; return 2;
if (displayType == Number) if (displayType == Number)
return 6; return 6;
if (displayType == CostPrice if (displayType == CostPrice
|| displayType == Quantity) || displayType == Quantity)
return 4; return 4;
return 0; return 0;
} // getDefaultPrecision } // getDefaultPrecision
/** /**
* Returns true, if DisplayType is text (String, Text, TextLong, Memo). * Returns true, if DisplayType is text (String, Text, TextLong, Memo).
@ -187,7 +187,7 @@ public final class DisplayType
*/ */
public static boolean isText(int displayType) public static boolean isText(int displayType)
{ {
if (displayType == String || displayType == Text if (displayType == String || displayType == Text
|| displayType == TextLong || displayType == Memo || displayType == TextLong || displayType == Memo
|| displayType == FilePath || displayType == FileName || displayType == FilePath || displayType == FileName
|| displayType == URL || displayType == PrinterName) || displayType == URL || displayType == PrinterName)
@ -221,7 +221,7 @@ public final class DisplayType
return true; return true;
return false; return false;
} // isLookup } // isLookup
/** /**
* Returns true if DisplayType is a Large Object * Returns true if DisplayType is a Large Object
* @param displayType Display Type * @param displayType Display Type
@ -229,7 +229,7 @@ public final class DisplayType
*/ */
public static boolean isLOB (int displayType) public static boolean isLOB (int displayType)
{ {
if (displayType == Binary if (displayType == Binary
|| displayType == TextLong) || displayType == TextLong)
return true; return true;
return false; return false;
@ -295,7 +295,7 @@ public final class DisplayType
} }
return format; return format;
} // getDecimalFormat } // getDecimalFormat
/************************************************************************** /**************************************************************************
* Return Format for numeric DisplayType * Return Format for numeric DisplayType
* @param displayType Display Type (default Number) * @param displayType Display Type (default Number)
@ -306,7 +306,7 @@ public final class DisplayType
{ {
return getNumberFormat(displayType, language, null); return getNumberFormat(displayType, language, null);
} }
/** /**
* Return Format for numeric DisplayType * Return Format for numeric DisplayType
* @param displayType Display Type * @param displayType Display Type
@ -368,7 +368,7 @@ public final class DisplayType
{ {
Language myLanguage = language; Language myLanguage = language;
if (myLanguage == null) if (myLanguage == null)
myLanguage = Language.getLoginLanguage(); myLanguage = Env.getLanguage(Env.getCtx());
// //
if ( pattern != null && pattern.length() > 0) if ( pattern != null && pattern.length() > 0)
{ {
@ -381,7 +381,7 @@ public final class DisplayType
s_log.log(Level.WARNING, "Invalid date pattern: " + pattern); s_log.log(Level.WARNING, "Invalid date pattern: " + pattern);
} }
} }
if (displayType == DateTime) if (displayType == DateTime)
return myLanguage.getDateTimeFormat(); return myLanguage.getDateTimeFormat();
else if (displayType == Time) else if (displayType == Time)
@ -454,8 +454,8 @@ public final class DisplayType
&& columnName.equals("BinaryData")) && columnName.equals("BinaryData"))
return "BLOB"; return "BLOB";
// ID, CreatedBy/UpdatedBy, Acct // ID, CreatedBy/UpdatedBy, Acct
else if (columnName.endsWith("_ID") else if (columnName.endsWith("_ID")
|| columnName.endsWith("tedBy") || columnName.endsWith("tedBy")
|| columnName.endsWith("_Acct") ) || columnName.endsWith("_Acct") )
return "NUMBER(10)"; return "NUMBER(10)";
else if (fieldLength < 4) else if (fieldLength < 4)
@ -472,7 +472,7 @@ public final class DisplayType
return "NUMBER"; return "NUMBER";
if (displayType == DisplayType.Binary) if (displayType == DisplayType.Binary)
return "BLOB"; return "BLOB";
if (displayType == DisplayType.TextLong if (displayType == DisplayType.TextLong
|| (displayType == DisplayType.Text && fieldLength >= 4000)) || (displayType == DisplayType.Text && fieldLength >= 4000))
return "CLOB"; return "CLOB";
if (displayType == DisplayType.YesNo) if (displayType == DisplayType.YesNo)
@ -481,7 +481,7 @@ public final class DisplayType
if (fieldLength == 1) if (fieldLength == 1)
return "CHAR(" + fieldLength + ")"; return "CHAR(" + fieldLength + ")";
else else
return "NVARCHAR2(" + fieldLength + ")"; return "NVARCHAR2(" + fieldLength + ")";
} }
if (displayType == DisplayType.Color) // this condition is never reached - filtered above in isID if (displayType == DisplayType.Color) // this condition is never reached - filtered above in isID
{ {
@ -499,10 +499,10 @@ public final class DisplayType
} }
if (!DisplayType.isText(displayType)) if (!DisplayType.isText(displayType))
s_log.severe("Unhandled Data Type = " + displayType); s_log.severe("Unhandled Data Type = " + displayType);
return "NVARCHAR2(" + fieldLength + ")"; return "NVARCHAR2(" + fieldLength + ")";
} // getSQLDataType } // getSQLDataType
/** /**
* Get Description * Get Description
* @param displayType display Type * @param displayType display Type
@ -577,5 +577,5 @@ public final class DisplayType
// //
return "UNKNOWN DisplayType=" + displayType; return "UNKNOWN DisplayType=" + displayType;
} // getDescription } // getDescription
} // DisplayType } // DisplayType

View File

@ -70,7 +70,7 @@ public final class Env
private final static ContextProvider clientContextProvider = new DefaultContextProvider(); private final static ContextProvider clientContextProvider = new DefaultContextProvider();
private static List<IEnvEventListener> eventListeners = new ArrayList<IEnvEventListener>(); private static List<IEnvEventListener> eventListeners = new ArrayList<IEnvEventListener>();
/** /**
* @param provider * @param provider
* @deprecated * @deprecated
@ -95,7 +95,7 @@ public final class Env
{ {
return eventListeners.remove(listener); return eventListeners.remove(listener);
} }
/** /**
* Exit System * Exit System
* @param status System exit status (usually 0 for no error) * @param status System exit status (usually 0 for no error)
@ -145,7 +145,7 @@ public final class Env
{ {
listener.onReset(finalCall); listener.onReset(finalCall);
} }
// Clear all Context // Clear all Context
if (finalCall) if (finalCall)
getCtx().clear(); getCtx().clear();
@ -1027,6 +1027,33 @@ public final class Env
return Language.getLoginLanguage(); return Language.getLoginLanguage();
} // getLanguage } // getLanguage
public static ArrayList<String> getSupportedLanguages()
{
ArrayList<String> AD_Languages = new ArrayList<String>();
String sql = "SELECT DISTINCT AD_Language FROM AD_Message_Trl";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
String AD_Language = rs.getString(1);
AD_Languages.add(AD_Language);
}
}
catch (SQLException e)
{
getLogger().log(Level.SEVERE, "", e);
}
finally {
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return AD_Languages;
}
/** /**
* Verify Language. * Verify Language.
* Check that language is supported by the system * Check that language is supported by the system
@ -1176,7 +1203,7 @@ public final class Env
for(IEnvEventListener listener : listeners) for(IEnvEventListener listener : listeners)
{ {
listener.onClearWindowContext(WindowNo); listener.onClearWindowContext(WindowNo);
} }
} // clearWinContext } // clearWinContext
/** /**
@ -1347,7 +1374,7 @@ public final class Env
} }
/*************************************************************************/ /*************************************************************************/
/** /**
* Clean up context for Window (i.e. delete it) * Clean up context for Window (i.e. delete it)
* @param WindowNo window * @param WindowNo window
@ -1536,11 +1563,11 @@ public final class Env
{ {
if(!(key instanceof String)) if(!(key instanceof String))
continue; continue;
Object value = ctx.get(key); Object value = ctx.get(key);
if (!(value instanceof String)) if (!(value instanceof String))
continue; continue;
p.put(key, value); p.put(key, value);
} }
@ -1548,9 +1575,9 @@ public final class Env
} }
/** Window Cache */ /** Window Cache */
private static CCache<Integer,GridWindowVO> s_windowsvo private static CCache<Integer,GridWindowVO> s_windowsvo
= new CCache<Integer,GridWindowVO>("AD_Window", 10); = new CCache<Integer,GridWindowVO>("AD_Window", 10);
/** /**
* Get Window Model * Get Window Model
* *
@ -1572,7 +1599,7 @@ public final class Env
getLogger().info("Cached=" + mWindowVO); getLogger().info("Cached=" + mWindowVO);
} }
} }
// Create Window Model on Client // Create Window Model on Client
if (mWindowVO == null) if (mWindowVO == null)
{ {
@ -1583,7 +1610,7 @@ public final class Env
} // from Client } // from Client
if (mWindowVO == null) if (mWindowVO == null)
return null; return null;
// Check (remote) context // Check (remote) context
if (!mWindowVO.ctx.equals(Env.getCtx())) if (!mWindowVO.ctx.equals(Env.getCtx()))
{ {