IDEMPIERE-177
AD_Language and name for entry made optional Caching best matching entry for UserDefWin
This commit is contained in:
parent
8ff43d60e9
commit
80194f7a37
|
@ -73,21 +73,11 @@ UPDATE AD_Column SET DefaultValue='''''',Updated=TO_DATE('2010-08-09 20:52:43','
|
|||
ALTER TABLE AD_UserDef_Field MODIFY DisplayLogic NVARCHAR2(2000) DEFAULT ''
|
||||
;
|
||||
|
||||
-- Aug 9, 2010 8:52:50 PM CEST
|
||||
-- Default comment for updating dictionary
|
||||
ALTER TABLE AD_UserDef_Field MODIFY DisplayLogic NULL
|
||||
;
|
||||
|
||||
-- Aug 9, 2010 8:55:45 PM CEST
|
||||
-- Default comment for updating dictionary
|
||||
ALTER TABLE AD_UserDef_Field MODIFY DefaultValue NVARCHAR2(2000) DEFAULT ''
|
||||
;
|
||||
|
||||
-- Aug 9, 2010 8:55:45 PM CEST
|
||||
-- Default comment for updating dictionary
|
||||
ALTER TABLE AD_UserDef_Field MODIFY DefaultValue NULL
|
||||
;
|
||||
|
||||
-- Mar 5, 2012 2:16:34 PM CET
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET Callout='org.compiere.model.CalloutWindowCustomization.window',Updated=TO_TIMESTAMP('2012-03-05 14:16:34','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6395
|
||||
|
@ -175,3 +165,23 @@ INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTran
|
|||
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=200003
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:11:59 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2012-04-03 15:11:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6396
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:13:25 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2012-04-03 15:13:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6399
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:15:11 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2012-04-03 15:15:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6381
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:16:32 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2012-04-03 15:16:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6346
|
||||
;
|
||||
|
||||
|
|
|
@ -175,3 +175,23 @@ INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTran
|
|||
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=200003
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:11:59 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2012-04-03 15:11:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6396
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:13:25 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2012-04-03 15:13:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6399
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:15:11 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2012-04-03 15:15:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6381
|
||||
;
|
||||
|
||||
-- Apr 3, 2012 3:16:32 PM CEST
|
||||
-- IDEMPIERE-177 Window Customization
|
||||
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2012-04-03 15:16:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=6346
|
||||
;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.compiere.util.DB;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* User overrides for field model
|
||||
* @author Dirk Niemeyer, action42 GmbH
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -32,7 +32,7 @@ public class MUserDefField extends X_AD_UserDef_Field
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 20120403114400L;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,14 @@ public class MUserDefField extends X_AD_UserDef_Field
|
|||
super (ctx, rs, trxName);
|
||||
} // MyModelExample
|
||||
|
||||
|
||||
/**
|
||||
* Get matching MUserDefField related to current field and user definition for window and tab
|
||||
* @param ctx
|
||||
* @param AD_Field_ID
|
||||
* @param AD_Tab_ID
|
||||
* @param AD_Window_ID
|
||||
* @return
|
||||
*/
|
||||
public static MUserDefField get (Properties ctx, int AD_Field_ID, int AD_Tab_ID, int AD_Window_ID )
|
||||
{
|
||||
|
||||
|
|
|
@ -23,16 +23,17 @@ import org.compiere.util.DB;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* User overrides for tab model
|
||||
* @author Dirk Niemeyer, action 42 GmbH
|
||||
* @version $Id$
|
||||
*
|
||||
*/
|
||||
public class MUserDefTab extends X_AD_UserDef_Tab
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 20120403111900L;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
|
@ -44,7 +45,7 @@ public class MUserDefTab extends X_AD_UserDef_Tab
|
|||
public MUserDefTab (Properties ctx, int ID, String trxName)
|
||||
{
|
||||
super (ctx, ID, trxName);
|
||||
} // MyModelExample
|
||||
} // MUserDefTab
|
||||
|
||||
/**
|
||||
* Optional Load Constructor.
|
||||
|
@ -59,9 +60,15 @@ public class MUserDefTab extends X_AD_UserDef_Tab
|
|||
public MUserDefTab (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MyModelExample
|
||||
|
||||
} // MUserDefTab
|
||||
|
||||
/**
|
||||
* Get matching MUserDefTab related to current tab and user definition for window
|
||||
* @param ctx
|
||||
* @param AD_Tab_ID
|
||||
* @param AD_UserDefWin_ID
|
||||
* @return
|
||||
*/
|
||||
public static MUserDefTab getMatch (Properties ctx, int AD_Tab_ID, int AD_UserDefWin_ID )
|
||||
{
|
||||
|
||||
|
@ -102,6 +109,13 @@ public class MUserDefTab extends X_AD_UserDef_Tab
|
|||
return retValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get matching MUserDefTab related to current tab and window
|
||||
* @param ctx
|
||||
* @param AD_Tab_ID
|
||||
* @param AD_Window_ID
|
||||
* @return
|
||||
*/
|
||||
public static MUserDefTab get (Properties ctx, int AD_Tab_ID, int AD_Window_ID) {
|
||||
|
||||
MUserDefWin userdefWin = MUserDefWin.getBestMatch(ctx, AD_Window_ID);
|
||||
|
@ -112,4 +126,4 @@ public class MUserDefTab extends X_AD_UserDef_Tab
|
|||
|
||||
}
|
||||
|
||||
} // MyModelExample
|
||||
} // MUserDefTab
|
||||
|
|
|
@ -18,21 +18,23 @@ import java.sql.*;
|
|||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
*
|
||||
* User overrides for window model
|
||||
* @author Dirk Niemeyer, action42 GmbH
|
||||
* @version $Id$
|
||||
*
|
||||
*/
|
||||
public class MUserDefWin extends X_AD_UserDef_Win
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 20120403122300L;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
|
@ -44,7 +46,7 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
public MUserDefWin (Properties ctx, int ID, String trxName)
|
||||
{
|
||||
super (ctx, ID, trxName);
|
||||
} // MyModelExample
|
||||
} // MUserDefWin
|
||||
|
||||
/**
|
||||
* Optional Load Constructor.
|
||||
|
@ -59,9 +61,14 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
public MUserDefWin (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
} // MyModelExample
|
||||
|
||||
} // MUserDefWin
|
||||
|
||||
/**
|
||||
* Get all MUserDefWin entries related to window
|
||||
* @param ctx context
|
||||
* @param window_ID window
|
||||
* @return Array of MUserDefWin for window
|
||||
*/
|
||||
private static MUserDefWin[] getAll (Properties ctx, int window_ID )
|
||||
{
|
||||
|
||||
|
@ -70,7 +77,8 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
StringBuffer sql = new StringBuffer("SELECT * "
|
||||
+ " FROM AD_UserDef_Win w "
|
||||
+ " WHERE w.AD_Window_ID=? AND w.IsActive='Y' "
|
||||
+ " AND w.AD_Language=? "
|
||||
// limit to current login language or no specific language
|
||||
+ " AND (w.AD_Language=? OR w.AD_Language IS NULL)"
|
||||
+ " AND w.AD_Client_ID=? ");
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
@ -108,8 +116,21 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get best matching MUserDefWin for current window
|
||||
* the best match is cached
|
||||
* @param ctx
|
||||
* @param window_ID
|
||||
* @return best matching MUserDefWin
|
||||
*/
|
||||
public static MUserDefWin getBestMatch (Properties ctx, int window_ID)
|
||||
{
|
||||
// Check Cache
|
||||
Integer key = new Integer(window_ID);
|
||||
MUserDefWin retValue = (MUserDefWin)s_cache.get(key);
|
||||
if (retValue != null)
|
||||
return retValue;
|
||||
|
||||
// parameters
|
||||
final int AD_Org_ID = Env.getAD_Org_ID(ctx);
|
||||
//final int anyOrg = 0;
|
||||
|
@ -158,6 +179,10 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
weight[i] = -1;
|
||||
}
|
||||
}
|
||||
// prefer if related to current login language
|
||||
if (weight[i] > -1 && candidates[i].getAD_Language().equalsIgnoreCase(Env.getAD_Language(ctx))) {
|
||||
weight[i] = weight[i] + 8;
|
||||
}
|
||||
// others are implicit
|
||||
}
|
||||
|
||||
|
@ -171,10 +196,15 @@ public class MUserDefWin extends X_AD_UserDef_Win
|
|||
}
|
||||
|
||||
if (weight[maxindex] > -1) {
|
||||
return candidates[maxindex];
|
||||
retValue=candidates[maxindex];
|
||||
s_cache.put(key, retValue);
|
||||
return retValue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Cache of selected MUserDefWin entries **/
|
||||
private static CCache<Integer,MUserDefWin> s_cache = new CCache<Integer,MUserDefWin>("AD_UserDef_Win", 3); // 3 weights
|
||||
|
||||
} // MUserDefWin
|
||||
|
|
Loading…
Reference in New Issue