IDEMPIERE-4622 Cross Tenant UserDefInfo, Role (#503)
* IDEMPIERE-4622 Cross Tenant UserDefInfo, Role
This commit is contained in:
parent
3f29970844
commit
ba63dc4960
|
@ -26,7 +26,9 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
|
@ -45,7 +47,7 @@ public class MUserDefInfo extends X_AD_UserDef_Info {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 5611033457579880793L;
|
private static final long serialVersionUID = 5611033457579880793L;
|
||||||
|
|
||||||
private volatile static List<MUserDefInfo> m_fullList = null;
|
private static final Map<Integer, List<MUserDefInfo>> m_fullMap = new HashMap<Integer, List<MUserDefInfo>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
|
@ -80,17 +82,25 @@ public class MUserDefInfo extends X_AD_UserDef_Info {
|
||||||
*/
|
*/
|
||||||
private static MUserDefInfo[] getAll (Properties ctx, int infowindow_ID )
|
private static MUserDefInfo[] getAll (Properties ctx, int infowindow_ID )
|
||||||
{
|
{
|
||||||
if (m_fullList == null) {
|
List<MUserDefInfo> fullList = null;
|
||||||
m_fullList = new Query(ctx, MUserDefInfo.Table_Name, "IsActive='Y'", null).list();
|
synchronized (m_fullMap) {
|
||||||
|
fullList = m_fullMap.get(Env.getAD_Client_ID(ctx));
|
||||||
|
if (fullList == null) {
|
||||||
|
fullList = new Query(ctx, MUserDefInfo.Table_Name, null, null)
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setClient_ID()
|
||||||
|
.list();
|
||||||
|
m_fullMap.put(Env.getAD_Client_ID(ctx), fullList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_fullList.size() == 0) {
|
if (fullList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MUserDefInfo> list = new ArrayList<MUserDefInfo>();
|
List<MUserDefInfo> list = new ArrayList<MUserDefInfo>();
|
||||||
|
|
||||||
for (MUserDefInfo udw : m_fullList) {
|
for (MUserDefInfo udw : fullList) {
|
||||||
if (udw.getAD_InfoWindow_ID() == infowindow_ID
|
if (udw.getAD_InfoWindow_ID() == infowindow_ID
|
||||||
&& udw.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
&& udw.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
||||||
&& (udw.getAD_Language() == null || udw.getAD_Language().equals(Env.getAD_Language(ctx)))
|
&& (udw.getAD_Language() == null || udw.getAD_Language().equals(Env.getAD_Language(ctx)))
|
||||||
|
@ -209,13 +219,17 @@ public class MUserDefInfo extends X_AD_UserDef_Info {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeSave(boolean newRecord) {
|
protected boolean beforeSave(boolean newRecord) {
|
||||||
m_fullList = null;
|
synchronized (m_fullMap) {
|
||||||
|
m_fullMap.remove(getAD_Client_ID());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeDelete() {
|
protected boolean beforeDelete() {
|
||||||
m_fullList = null;
|
synchronized (m_fullMap) {
|
||||||
|
m_fullMap.remove(getAD_Client_ID());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,15 @@ package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.idempiere.cache.ImmutablePOSupport;
|
|
||||||
import org.idempiere.cache.ImmutablePOCache;
|
import org.idempiere.cache.ImmutablePOCache;
|
||||||
|
import org.idempiere.cache.ImmutablePOSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model class for Process Customizations
|
* Model class for Process Customizations
|
||||||
|
@ -34,7 +36,7 @@ public class MUserDefProc extends X_AD_UserDef_Proc implements ImmutablePOSuppor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1599140293008534080L;
|
private static final long serialVersionUID = 1599140293008534080L;
|
||||||
private volatile static List<MUserDefProc> m_fullList = null;
|
private static final Map<Integer, List<MUserDefProc>> m_fullMap = new HashMap<Integer, List<MUserDefProc>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ctx
|
* @param ctx
|
||||||
|
@ -86,17 +88,25 @@ public class MUserDefProc extends X_AD_UserDef_Proc implements ImmutablePOSuppor
|
||||||
|
|
||||||
private static MUserDefProc[] getAll (Properties ctx, int processID)
|
private static MUserDefProc[] getAll (Properties ctx, int processID)
|
||||||
{
|
{
|
||||||
if (m_fullList == null) {
|
List<MUserDefProc> fullList = null;
|
||||||
m_fullList = new Query(ctx, MUserDefProc.Table_Name, "IsActive='Y'", null).list();
|
synchronized (m_fullMap) {
|
||||||
|
fullList = m_fullMap.get(Env.getAD_Client_ID(ctx));
|
||||||
|
if (fullList == null) {
|
||||||
|
fullList = new Query(ctx, MUserDefProc.Table_Name, null, null)
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setClient_ID()
|
||||||
|
.list();
|
||||||
|
m_fullMap.put(Env.getAD_Client_ID(ctx), fullList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_fullList.size() == 0) {
|
if (fullList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MUserDefProc> list = new ArrayList<MUserDefProc>();
|
List<MUserDefProc> list = new ArrayList<MUserDefProc>();
|
||||||
|
|
||||||
for (MUserDefProc udp : m_fullList) {
|
for (MUserDefProc udp : fullList) {
|
||||||
if (udp.getAD_Process_ID() == processID
|
if (udp.getAD_Process_ID() == processID
|
||||||
&& udp.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
&& udp.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
||||||
&& (udp.getAD_Language() == null || udp.getAD_Language().equals(Env.getAD_Language(ctx)))
|
&& (udp.getAD_Language() == null || udp.getAD_Language().equals(Env.getAD_Language(ctx)))
|
||||||
|
@ -225,13 +235,17 @@ public class MUserDefProc extends X_AD_UserDef_Proc implements ImmutablePOSuppor
|
||||||
throw new AdempiereException("Esta personalização de processo já possui parametros configurados.");
|
throw new AdempiereException("Esta personalização de processo já possui parametros configurados.");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fullList = null;
|
synchronized (m_fullMap) {
|
||||||
|
m_fullMap.remove(getAD_Client_ID());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean beforeDelete() {
|
protected boolean beforeDelete() {
|
||||||
m_fullList = null;
|
synchronized (m_fullMap) {
|
||||||
|
m_fullMap.remove(getAD_Client_ID());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,9 +62,9 @@ public class MUserRoles extends X_AD_User_Roles
|
||||||
*/
|
*/
|
||||||
public static MUserRoles[] getOfUser (Properties ctx, int AD_User_ID)
|
public static MUserRoles[] getOfUser (Properties ctx, int AD_User_ID)
|
||||||
{
|
{
|
||||||
final String whereClause = I_AD_User_Roles.COLUMNNAME_AD_User_ID+"=?";
|
final String whereClause = I_AD_User_Roles.COLUMNNAME_AD_User_ID+"=? AND AD_Client_ID IN (0, ?)";
|
||||||
List<MUserRoles> list = new Query(ctx,I_AD_User_Roles.Table_Name,whereClause,null)
|
List<MUserRoles> list = new Query(ctx,I_AD_User_Roles.Table_Name,whereClause,null)
|
||||||
.setParameters(AD_User_ID)
|
.setParameters(new Object[]{AD_User_ID, Env.getAD_Client_ID(ctx)})
|
||||||
.list();
|
.list();
|
||||||
MUserRoles[] retValue = new MUserRoles[list.size ()];
|
MUserRoles[] retValue = new MUserRoles[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
|
|
Loading…
Reference in New Issue