IDEMPIERE-3971 - process customization

This commit is contained in:
Murilo Habermann Torquato 2019-05-16 09:31:34 -03:00
parent 655c292033
commit 372c531ef7
10 changed files with 4401 additions and 10 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
/******************************************************************************
* Copyright (C) 2019 devCoffee - #3858 *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.model;
import java.util.Properties;
/**
* Process Customization Callout
*
* @author raphael.gildo (devCoffee, www.devcoffee.com.br)
*/
public class CalloutProcessCustomization extends CalloutEngine
{
/**
* @param ctx
* @param WindowNo
* @param mTab
* @param mField
* @param value
* @return
*/
public String process (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if(value == null)
return "";
MProcess pp = new MProcess(ctx, (Integer) value, null);
mTab.setValue("Name", pp.get_Translation("Name"));
mTab.setValue("Description", pp.get_Translation("Description"));
mTab.setValue("Help", pp.get_Translation("Help"));
return NO_ERROR;
} // proc parameter
/**
* @param ctx
* @param WindowNo
* @param mTab
* @param mField
* @param value
* @return
*/
public String processParameter (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
if(value == null)
return "";
MProcessPara pp = new MProcessPara(ctx, (Integer) value, null);
mTab.setValue("Name", pp.get_Translation("Name"));
mTab.setValue("Description", pp.get_Translation("Description"));
mTab.setValue("Help", pp.get_Translation("Help"));
return NO_ERROR;
} // proc parameter
} // CalloutClient

View File

@ -386,6 +386,28 @@ public class GridFieldVO implements Serializable
{ {
CLogger.get().log(Level.SEVERE, "createParameter", e); CLogger.get().log(Level.SEVERE, "createParameter", e);
} }
//devCoffee - #3858
if(vo.IsDisplayed) {
MUserDefProcParameter userDef = MUserDefProcParameter.get(ctx, vo.AD_Column_ID, vo.AD_Process_ID_Of_Panel);
if(userDef != null) {
if(userDef.getName() != null)
vo.Header = userDef.getName();
if(userDef.getDescription() != null)
vo.Description = userDef.getDescription();
if(userDef.getHelp() != null)
vo.Help = userDef.getHelp();
if(userDef.getReadOnlyLogic() != null)
vo.ReadOnlyLogic = userDef.getReadOnlyLogic();
if(userDef.getDefaultValue() != null)
vo.DefaultValue = userDef.getDefaultValue();
if(userDef.getDisplayLogic() != null)
vo.DisplayLogic = userDef.getDisplayLogic();
if(userDef.getMandatoryLogic() != null)
vo.MandatoryLogic = userDef.getMandatoryLogic();
vo.IsDisplayed = userDef.isDisplayed();
}
}
//fim devCoffee - 3858
// //
vo.initFinish(); vo.initFinish();
if (vo.DefaultValue2 == null) if (vo.DefaultValue2 == null)
@ -444,16 +466,16 @@ public class GridFieldVO implements Serializable
/** /**
* Create parameter for infoWindow * Create parameter for infoWindow
* @param ctx * @param ctx ctx
* @param WindowNo * @param WindowNo WindowNo
* @param AD_Column_ID * @param AD_Column_ID AD_Column_ID
* @param ColumnName * @param ColumnName ColumnName
* @param Name * @param Name Name
* @param AD_Reference_ID * @param AD_Reference_ID AD_Reference_ID
* @param AD_Reference_Value_ID * @param AD_Reference_Value_ID AD_Reference_Value_ID
* @param IsMandatory * @param IsMandatory IsMandatory
* @param IsEncrypted * @param IsEncrypted IsEncrypted
* @return * @return GridFieldV0 v0
*/ */
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int WindowIDOfPanel, int infoWindowID, public static GridFieldVO createParameter (Properties ctx, int WindowNo, int WindowIDOfPanel, int infoWindowID,
int AD_Column_ID, String ColumnName, String Name, int AD_Reference_ID, int AD_Reference_Value_ID, int AD_Column_ID, String ColumnName, String Name, int AD_Reference_ID, int AD_Reference_Value_ID,

View File

@ -0,0 +1,254 @@
/******************************************************************************
* Product: BrERP Gestão Empresarial Completa (http://brerp.org) *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_UserDef_Proc
* @author iDempiere (generated)
* @version Release 5.1
*/
public interface I_AD_UserDef_Proc
{
/** TableName=AD_UserDef_Proc */
public static final String Table_Name = "AD_UserDef_Proc";
/** AD_Table_ID=200232 */
public static final int Table_ID = 200232;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Language */
public static final String COLUMNNAME_AD_Language = "AD_Language";
/** Set Language.
* Language for this entity
*/
public void setAD_Language (String AD_Language);
/** Get Language.
* Language for this entity
*/
public String getAD_Language();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_Process_ID */
public static final String COLUMNNAME_AD_Process_ID = "AD_Process_ID";
/** Set Process.
* Process or Report
*/
public void setAD_Process_ID (int AD_Process_ID);
/** Get Process.
* Process or Report
*/
public int getAD_Process_ID();
public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException;
/** Column name AD_Role_ID */
public static final String COLUMNNAME_AD_Role_ID = "AD_Role_ID";
/** Set Role.
* Responsibility Role
*/
public void setAD_Role_ID (int AD_Role_ID);
/** Get Role.
* Responsibility Role
*/
public int getAD_Role_ID();
public org.compiere.model.I_AD_Role getAD_Role() throws RuntimeException;
/** Column name AD_UserDef_Proc_ID */
public static final String COLUMNNAME_AD_UserDef_Proc_ID = "AD_UserDef_Proc_ID";
/** Set User defined Process.
* Primary Key : User defined Process
*/
public void setAD_UserDef_Proc_ID (int AD_UserDef_Proc_ID);
/** Get User defined Process.
* Primary Key : User defined Process
*/
public int getAD_UserDef_Proc_ID();
/** Column name AD_UserDef_Proc_UU */
public static final String COLUMNNAME_AD_UserDef_Proc_UU = "AD_UserDef_Proc_UU";
/** Set AD_UserDef_Proc_UU */
public void setAD_UserDef_Proc_UU (String AD_UserDef_Proc_UU);
/** Get AD_UserDef_Proc_UU */
public String getAD_UserDef_Proc_UU();
/** Column name AD_User_ID */
public static final String COLUMNNAME_AD_User_ID = "AD_User_ID";
/** Set User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID);
/** Get User/Contact.
* User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID();
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name Description */
public static final String COLUMNNAME_Description = "Description";
/** Set Description.
* Optional short description of the record
*/
public void setDescription (String Description);
/** Get Description.
* Optional short description of the record
*/
public String getDescription();
/** Column name Help */
public static final String COLUMNNAME_Help = "Help";
/** Set Comment/Help.
* Comment or Hint
*/
public void setHelp (String Help);
/** Get Comment/Help.
* Comment or Hint
*/
public String getHelp();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsDefault */
public static final String COLUMNNAME_IsDefault = "IsDefault";
/** Set Default.
* Default value
*/
public void setIsDefault (boolean IsDefault);
/** Get Default.
* Default value
*/
public boolean isDefault();
/** Column name IsUserUpdateable */
public static final String COLUMNNAME_IsUserUpdateable = "IsUserUpdateable";
/** Set User updatable.
* The field can be updated by the user
*/
public void setIsUserUpdateable (boolean IsUserUpdateable);
/** Get User updatable.
* The field can be updated by the user
*/
public boolean isUserUpdateable();
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";
/** Set Name.
* Alphanumeric identifier of the entity
*/
public void setName (String Name);
/** Get Name.
* Alphanumeric identifier of the entity
*/
public String getName();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,272 @@
/******************************************************************************
* Product: BrERP Gestão Empresarial Completa (http://brerp.org) *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.model;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_UserDef_Proc_Parameter
* @author iDempiere (generated)
* @version Release 5.1
*/
public interface I_AD_UserDef_Proc_Parameter
{
/** TableName=AD_UserDef_Proc_Parameter */
public static final String Table_Name = "AD_UserDef_Proc_Parameter";
/** AD_Table_ID=200233 */
public static final int Table_ID = 200233;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
/** Load Meta Data */
/** Column name AD_Client_ID */
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
/** Get Client.
* Client/Tenant for this installation.
*/
public int getAD_Client_ID();
/** Column name AD_Org_ID */
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
/** Set Organization.
* Organizational entity within client
*/
public void setAD_Org_ID (int AD_Org_ID);
/** Get Organization.
* Organizational entity within client
*/
public int getAD_Org_ID();
/** Column name AD_Process_Para_ID */
public static final String COLUMNNAME_AD_Process_Para_ID = "AD_Process_Para_ID";
/** Set Process Parameter */
public void setAD_Process_Para_ID (int AD_Process_Para_ID);
/** Get Process Parameter */
public int getAD_Process_Para_ID();
public org.compiere.model.I_AD_Process_Para getAD_Process_Para() throws RuntimeException;
/** Column name AD_UserDef_Proc_ID */
public static final String COLUMNNAME_AD_UserDef_Proc_ID = "AD_UserDef_Proc_ID";
/** Set User defined Process.
* Primary Key : User defined Process
*/
public void setAD_UserDef_Proc_ID (int AD_UserDef_Proc_ID);
/** Get User defined Process.
* Primary Key : User defined Process
*/
public int getAD_UserDef_Proc_ID();
public org.compiere.model.I_AD_UserDef_Proc getAD_UserDef_Proc() throws RuntimeException;
/** Column name AD_UserDef_Proc_Parameter_ID */
public static final String COLUMNNAME_AD_UserDef_Proc_Parameter_ID = "AD_UserDef_Proc_Parameter_ID";
/** Set AD_UserDef_Proc_Parameter_ID.
* Primary Key : User defined Process Parameter
*/
public void setAD_UserDef_Proc_Parameter_ID (int AD_UserDef_Proc_Parameter_ID);
/** Get AD_UserDef_Proc_Parameter_ID.
* Primary Key : User defined Process Parameter
*/
public int getAD_UserDef_Proc_Parameter_ID();
/** Column name AD_UserDef_Proc_Parameter_UU */
public static final String COLUMNNAME_AD_UserDef_Proc_Parameter_UU = "AD_UserDef_Proc_Parameter_UU";
/** Set AD_UserDef_Proc_Parameter_UU */
public void setAD_UserDef_Proc_Parameter_UU (String AD_UserDef_Proc_Parameter_UU);
/** Get AD_UserDef_Proc_Parameter_UU */
public String getAD_UserDef_Proc_Parameter_UU();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";
/** Get Created.
* Date this record was created
*/
public Timestamp getCreated();
/** Column name CreatedBy */
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
/** Get Created By.
* User who created this records
*/
public int getCreatedBy();
/** Column name DefaultValue */
public static final String COLUMNNAME_DefaultValue = "DefaultValue";
/** Set Default Logic.
* Default value hierarchy, separated by ;
*/
public void setDefaultValue (String DefaultValue);
/** Get Default Logic.
* Default value hierarchy, separated by ;
*/
public String getDefaultValue();
/** Column name Description */
public static final String COLUMNNAME_Description = "Description";
/** Set Description.
* Optional short description of the record
*/
public void setDescription (String Description);
/** Get Description.
* Optional short description of the record
*/
public String getDescription();
/** Column name DisplayLogic */
public static final String COLUMNNAME_DisplayLogic = "DisplayLogic";
/** Set Display Logic.
* If the Field is displayed, the result determines if the field is actually displayed
*/
public void setDisplayLogic (String DisplayLogic);
/** Get Display Logic.
* If the Field is displayed, the result determines if the field is actually displayed
*/
public String getDisplayLogic();
/** Column name Help */
public static final String COLUMNNAME_Help = "Help";
/** Set Comment/Help.
* Comment or Hint
*/
public void setHelp (String Help);
/** Get Comment/Help.
* Comment or Hint
*/
public String getHelp();
/** Column name IsActive */
public static final String COLUMNNAME_IsActive = "IsActive";
/** Set Active.
* The record is active in the system
*/
public void setIsActive (boolean IsActive);
/** Get Active.
* The record is active in the system
*/
public boolean isActive();
/** Column name IsDisplayed */
public static final String COLUMNNAME_IsDisplayed = "IsDisplayed";
/** Set Displayed.
* Determines, if this field is displayed
*/
public void setIsDisplayed (boolean IsDisplayed);
/** Get Displayed.
* Determines, if this field is displayed
*/
public boolean isDisplayed();
/** Column name IsReadOnly */
public static final String COLUMNNAME_IsReadOnly = "IsReadOnly";
/** Set Read Only.
* Field is read only
*/
public void setIsReadOnly (boolean IsReadOnly);
/** Get Read Only.
* Field is read only
*/
public boolean isReadOnly();
/** Column name MandatoryLogic */
public static final String COLUMNNAME_MandatoryLogic = "MandatoryLogic";
/** Set Mandatory Logic */
public void setMandatoryLogic (String MandatoryLogic);
/** Get Mandatory Logic */
public String getMandatoryLogic();
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";
/** Set Name.
* Alphanumeric identifier of the entity
*/
public void setName (String Name);
/** Get Name.
* Alphanumeric identifier of the entity
*/
public String getName();
/** Column name ReadOnlyLogic */
public static final String COLUMNNAME_ReadOnlyLogic = "ReadOnlyLogic";
/** Set Read Only Logic.
* Logic to determine if field is read only (applies only when field is read-write)
*/
public void setReadOnlyLogic (String ReadOnlyLogic);
/** Get Read Only Logic.
* Logic to determine if field is read only (applies only when field is read-write)
*/
public String getReadOnlyLogic();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
/** Get Updated.
* Date this record was updated
*/
public Timestamp getUpdated();
/** Column name UpdatedBy */
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
/** Get Updated By.
* User who updated this records
*/
public int getUpdatedBy();
}

View File

@ -0,0 +1,209 @@
/******************************************************************************
* Copyright (C) 2019 devCoffee - #3858 *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.model;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.CCache;
import org.compiere.util.Env;
/**
* Model class for Process Customizations
*
* @author raphael.gildo (devCoffee, www.devcoffee.com.br)
*
*/
public class MUserDefProc extends X_AD_UserDef_Proc {
/**
*
*/
private static final long serialVersionUID = 2564901065651870698L;
private volatile static List<MUserDefProc> m_fullList = null;
/**
* @param ctx
* @param AD_UserDef_Proc_ID
* @param trxName
*/
public MUserDefProc(Properties ctx, int AD_UserDef_Proc_ID, String trxName) {
super(ctx, AD_UserDef_Proc_ID, trxName);
// TODO Auto-generated constructor stub
}
/**
* @param ctx
* @param rs
* @param trxName
*/
public MUserDefProc(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
// TODO Auto-generated constructor stub
}
private static MUserDefProc[] getAll (Properties ctx, int processID)
{
if (m_fullList == null) {
m_fullList = new Query(ctx, MUserDefProc.Table_Name, "IsActive='Y'", null).list();
}
if (m_fullList.size() == 0) {
return null;
}
List<MUserDefProc> list = new ArrayList<MUserDefProc>();
for (MUserDefProc udp : m_fullList) {
if (udp.getAD_Process_ID() == processID
&& udp.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
&& (udp.getAD_Language() == null || udp.getAD_Language().equals(Env.getAD_Language(ctx)))
) {
list.add(udp);
}
}
if (list.size() == 0)
return null;
return list.toArray(new MUserDefProc[list.size()]);
}
public static MUserDefProc getBestMatch (Properties ctx, int AD_Process_ID)
{
final int AD_Org_ID = Env.getAD_Org_ID(ctx);
final int AD_Role_ID = Env.getAD_Role_ID(ctx);
final int AD_User_ID = Env.getAD_User_ID(ctx);
//Check Cache
String key = new StringBuilder().append(AD_Process_ID).append("_")
.append(Env.getAD_Client_ID(ctx)).append("_")
.append(Env.getAD_Language(ctx)).append("_")
.append(AD_Org_ID).append("_")
.append(AD_Role_ID).append("_")
.append(AD_User_ID)
.toString();
if (s_cache.containsKey(key))
return s_cache.get(key);
//candidates
MUserDefProc[] candidates = getAll(ctx, AD_Process_ID);
if (candidates == null) {
s_cache.put(key, null);
return null;
}
final int size = candidates.length;
int[] weight = new int[size];
// this user + this role + this org => weight = 7
// this user + this role + any org => weight = 6
// this user + any role + this org => weight = 5
// this user + any role + any org => weight = 4
// any user + this role + this org => weight = 3
// any user + this role + any org => weight = 2
// any user + any role + this org => weight = 1
// any user + any role + any org => weight = 0
// other user or other role or other org => weight = -1 and thus ruled out
for (int i=0; i < size; i++)
{
weight[i] = 0;
if (candidates[i].getAD_User_ID() > 0) {
if (candidates[i].getAD_User_ID() == AD_User_ID) {
weight[i] = weight[i] + 4;
} else {
weight[i] = -1;
}
}
if (weight[i] > -1 && candidates[i].getAD_Role_ID() > 0) {
if (candidates[i].getAD_Role_ID() == AD_Role_ID) {
weight[i] = weight[i] + 2;
} else {
weight[i] = -1;
}
}
if (weight[i] > -1 && candidates[i].getAD_Org_ID() > 0) {
if (candidates[i].getAD_Org_ID() == AD_Org_ID) {
weight[i] = weight[i] + 1;
} else {
weight[i] = -1;
}
}
// prefer if related to current login language
if (weight[i] > -1 && Env.getAD_Language(ctx).equalsIgnoreCase(candidates[i].getAD_Language())) {
weight[i] = weight[i] + 8;
}
// others are implicit
}
int maximum = weight[0]; // start with the first value
int maxindex = 0;
for (int i=0; i<weight.length; i++) {
if (weight[i] > maximum) {
maximum = weight[i]; // new maximum
maxindex = i;
}
}
if (weight[maxindex] > -1) {
MUserDefProc retValue = null;
retValue = candidates[maxindex];
s_cache.put(key, retValue);
return retValue;
} else {
s_cache.put(key, null);
return null;
}
}
//Cache of selected MUserDefProc entries **/
private static CCache<String, MUserDefProc> s_cache = new CCache<String, MUserDefProc>(Table_Name, 3); // 3 weights
@Override
protected boolean beforeSave(boolean newRecord) {
String whereClause = "AD_UserDef_Proc_ID!=" + get_ID();
List<MUserDefProc> records = new Query(getCtx(), MUserDefProc.Table_Name, whereClause, get_TrxName()).list();
if(records.size() > 0){
for(MUserDefProc record : records){
if(record.getAD_Org_ID() == getAD_Org_ID()
&& record.getAD_Role_ID() == getAD_Role_ID()
&& record.getAD_User_ID() == getAD_User_ID()
&& record.getAD_Process_ID() == getAD_Process_ID()){
throw new AdempiereException("Personalização de processo já existe: " + record.getName() + " - ID: " + record.get_ID());
}
}
}
if(!newRecord){
MUserDefProc old = (MUserDefProc) new Query(getCtx(), MUserDefProc.Table_Name, "AD_UserDef_Proc_ID=" + get_ID(), get_TrxName()).first();
records = new Query(getCtx(), MUserDefProcParameter.Table_Name, "AD_UserDef_Proc_ID=" + get_ID(), get_TrxName()).list();
if(records.size() > 0 && old.getAD_Process_ID() != getAD_Process_ID())
throw new AdempiereException("Esta personalização de processo já possui parametros configurados.");
}
m_fullList = null;
return true;
}
@Override
protected boolean beforeDelete() {
m_fullList = null;
return true;
}
}

View File

@ -0,0 +1,101 @@
/******************************************************************************
* Copyright (C) 2019 devCoffee - #3858 *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
/**
* Model class for Process Parameter Customizations
*
* @author raphael.gildo (devCoffee, www.devcoffee.com.br)
*
*/
public class MUserDefProcParameter extends X_AD_UserDef_Proc_Parameter {
/**
*
*/
private static final long serialVersionUID = -203142278687451678L;
/**
* @param ctx
* @param AD_UserDef_Proc_Parameter_ID
* @param trxName
*/
public MUserDefProcParameter(Properties ctx, int AD_UserDef_Proc_Parameter_ID, String trxName) {
super(ctx, AD_UserDef_Proc_Parameter_ID, trxName);
// TODO Auto-generated constructor stub
}
/**
* @param ctx
* @param rs
* @param trxName
*/
public MUserDefProcParameter(Properties ctx, ResultSet rs, String trxName) {
super(ctx, rs, trxName);
// TODO Auto-generated constructor stub
}
public static MUserDefProcParameter get (Properties ctx, int AD_Field_ID, int AD_Process_ID)
{
MUserDefProc userdefProc = MUserDefProc.getBestMatch(ctx, AD_Process_ID);
if (userdefProc == null)
return null;
MUserDefProcParameter retValue = null;
StringBuilder sql = new StringBuilder("SELECT * "
+ " FROM AD_UserDef_Proc_Parameter f "
+ " WHERE f.AD_Process_Para_ID=? AND f.IsActive='Y' "
+ " AND f.AD_UserDef_Proc_ID=? ");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
// create statement
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, AD_Field_ID);
pstmt.setInt(2, userdefProc.getAD_UserDef_Proc_ID());
// get data
rs = pstmt.executeQuery();
if (rs.next())
{
retValue = new MUserDefProcParameter(ctx, rs, null);
}
}
catch (SQLException ex)
{
CLogger.get().log(Level.SEVERE, sql.toString(), ex);
return null;
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
}
}

View File

@ -0,0 +1,312 @@
/******************************************************************************
* Product: BrERP Gestão Empresarial Completa (http://brerp.org) *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
/** Generated Model for AD_UserDef_Proc
* @author BrERP Gestão Empresarial Completa (generated)
* @version Release 5.1 - $Id$ */
public class X_AD_UserDef_Proc extends PO implements I_AD_UserDef_Proc, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20171124L;
/** Standard Constructor */
public X_AD_UserDef_Proc (Properties ctx, int AD_UserDef_Proc_ID, String trxName)
{
super (ctx, AD_UserDef_Proc_ID, trxName);
/** if (AD_UserDef_Proc_ID == 0)
{
setAD_Process_ID (0);
setAD_UserDef_Proc_ID (0);
} */
}
/** Load Constructor */
public X_AD_UserDef_Proc (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_AD_UserDef_Proc[")
.append(get_ID()).append("]");
return sb.toString();
}
/** AD_Language AD_Reference_ID=106 */
public static final int AD_LANGUAGE_AD_Reference_ID=106;
/** Set Language.
@param AD_Language
Language for this entity
*/
public void setAD_Language (String AD_Language)
{
set_Value (COLUMNNAME_AD_Language, AD_Language);
}
/** Get Language.
@return Language for this entity
*/
public String getAD_Language ()
{
return (String)get_Value(COLUMNNAME_AD_Language);
}
public org.compiere.model.I_AD_Process getAD_Process() throws RuntimeException
{
return (org.compiere.model.I_AD_Process)MTable.get(getCtx(), org.compiere.model.I_AD_Process.Table_Name)
.getPO(getAD_Process_ID(), get_TrxName()); }
/** Set Process.
@param AD_Process_ID
Process or Report
*/
public void setAD_Process_ID (int AD_Process_ID)
{
if (AD_Process_ID < 1)
set_Value (COLUMNNAME_AD_Process_ID, null);
else
set_Value (COLUMNNAME_AD_Process_ID, Integer.valueOf(AD_Process_ID));
}
/** Get Process.
@return Process or Report
*/
public int getAD_Process_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Process_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_AD_Role getAD_Role() throws RuntimeException
{
return (org.compiere.model.I_AD_Role)MTable.get(getCtx(), org.compiere.model.I_AD_Role.Table_Name)
.getPO(getAD_Role_ID(), get_TrxName()); }
/** Set Role.
@param AD_Role_ID
Responsibility Role
*/
public void setAD_Role_ID (int AD_Role_ID)
{
if (AD_Role_ID < 0)
set_Value (COLUMNNAME_AD_Role_ID, null);
else
set_Value (COLUMNNAME_AD_Role_ID, Integer.valueOf(AD_Role_ID));
}
/** Get Role.
@return Responsibility Role
*/
public int getAD_Role_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Role_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set User defined Process.
@param AD_UserDef_Proc_ID
Primary Key : User defined Process
*/
public void setAD_UserDef_Proc_ID (int AD_UserDef_Proc_ID)
{
if (AD_UserDef_Proc_ID < 1)
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_ID, null);
else
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_ID, Integer.valueOf(AD_UserDef_Proc_ID));
}
/** Get User defined Process.
@return Primary Key : User defined Process
*/
public int getAD_UserDef_Proc_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_UserDef_Proc_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set AD_UserDef_Proc_UU.
@param AD_UserDef_Proc_UU AD_UserDef_Proc_UU */
public void setAD_UserDef_Proc_UU (String AD_UserDef_Proc_UU)
{
set_Value (COLUMNNAME_AD_UserDef_Proc_UU, AD_UserDef_Proc_UU);
}
/** Get AD_UserDef_Proc_UU.
@return AD_UserDef_Proc_UU */
public String getAD_UserDef_Proc_UU ()
{
return (String)get_Value(COLUMNNAME_AD_UserDef_Proc_UU);
}
public org.compiere.model.I_AD_User getAD_User() throws RuntimeException
{
return (org.compiere.model.I_AD_User)MTable.get(getCtx(), org.compiere.model.I_AD_User.Table_Name)
.getPO(getAD_User_ID(), get_TrxName()); }
/** Set User/Contact.
@param AD_User_ID
User within the system - Internal or Business Partner Contact
*/
public void setAD_User_ID (int AD_User_ID)
{
if (AD_User_ID < 1)
set_Value (COLUMNNAME_AD_User_ID, null);
else
set_Value (COLUMNNAME_AD_User_ID, Integer.valueOf(AD_User_ID));
}
/** Get User/Contact.
@return User within the system - Internal or Business Partner Contact
*/
public int getAD_User_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_User_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Description.
@param Description
Optional short description of the record
*/
public void setDescription (String Description)
{
set_Value (COLUMNNAME_Description, Description);
}
/** Get Description.
@return Optional short description of the record
*/
public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Comment/Help.
@param Help
Comment or Hint
*/
public void setHelp (String Help)
{
set_Value (COLUMNNAME_Help, Help);
}
/** Get Comment/Help.
@return Comment or Hint
*/
public String getHelp ()
{
return (String)get_Value(COLUMNNAME_Help);
}
/** Set Default.
@param IsDefault
Default value
*/
public void setIsDefault (boolean IsDefault)
{
set_Value (COLUMNNAME_IsDefault, Boolean.valueOf(IsDefault));
}
/** Get Default.
@return Default value
*/
public boolean isDefault ()
{
Object oo = get_Value(COLUMNNAME_IsDefault);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set User updatable.
@param IsUserUpdateable
The field can be updated by the user
*/
public void setIsUserUpdateable (boolean IsUserUpdateable)
{
set_Value (COLUMNNAME_IsUserUpdateable, Boolean.valueOf(IsUserUpdateable));
}
/** Get User updatable.
@return The field can be updated by the user
*/
public boolean isUserUpdateable ()
{
Object oo = get_Value(COLUMNNAME_IsUserUpdateable);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Name.
@param Name
Alphanumeric identifier of the entity
*/
public void setName (String Name)
{
set_Value (COLUMNNAME_Name, Name);
}
/** Get Name.
@return Alphanumeric identifier of the entity
*/
public String getName ()
{
return (String)get_Value(COLUMNNAME_Name);
}
}

View File

@ -0,0 +1,336 @@
/******************************************************************************
* Product: BrERP Gestão Empresarial Completa (http://brerp.org) *
* Copyright (C) 1999-2012 ComPiere, Inc. All Rights Reserved. *
* This program is free software, you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY, without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program, if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/** Generated Model - DO NOT CHANGE */
package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.util.KeyNamePair;
/** Generated Model for AD_UserDef_Proc_Parameter
* @author BrERP Gestão Empresarial Completa (generated)
* @version Release 5.1 - $Id$ */
public class X_AD_UserDef_Proc_Parameter extends PO implements I_AD_UserDef_Proc_Parameter, I_Persistent
{
/**
*
*/
private static final long serialVersionUID = 20171129L;
/** Standard Constructor */
public X_AD_UserDef_Proc_Parameter (Properties ctx, int AD_UserDef_Proc_Parameter_ID, String trxName)
{
super (ctx, AD_UserDef_Proc_Parameter_ID, trxName);
/** if (AD_UserDef_Proc_Parameter_ID == 0)
{
setAD_Process_Para_ID (0);
setAD_UserDef_Proc_ID (0);
setAD_UserDef_Proc_Parameter_ID (0);
} */
}
/** Load Constructor */
public X_AD_UserDef_Proc_Parameter (Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs, trxName);
}
/** AccessLevel
* @return 3 - Client - Org
*/
protected int get_AccessLevel()
{
return accessLevel.intValue();
}
/** Load Meta Data */
protected POInfo initPO (Properties ctx)
{
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
return poi;
}
public String toString()
{
StringBuffer sb = new StringBuffer ("X_AD_UserDef_Proc_Parameter[")
.append(get_ID()).append("]");
return sb.toString();
}
public org.compiere.model.I_AD_Process_Para getAD_Process_Para() throws RuntimeException
{
return (org.compiere.model.I_AD_Process_Para)MTable.get(getCtx(), org.compiere.model.I_AD_Process_Para.Table_Name)
.getPO(getAD_Process_Para_ID(), get_TrxName()); }
/** Set Process Parameter.
@param AD_Process_Para_ID Process Parameter */
public void setAD_Process_Para_ID (int AD_Process_Para_ID)
{
if (AD_Process_Para_ID < 1)
set_Value (COLUMNNAME_AD_Process_Para_ID, null);
else
set_Value (COLUMNNAME_AD_Process_Para_ID, Integer.valueOf(AD_Process_Para_ID));
}
/** Get Process Parameter.
@return Process Parameter */
public int getAD_Process_Para_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Process_Para_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_AD_UserDef_Proc getAD_UserDef_Proc() throws RuntimeException
{
return (org.compiere.model.I_AD_UserDef_Proc)MTable.get(getCtx(), org.compiere.model.I_AD_UserDef_Proc.Table_Name)
.getPO(getAD_UserDef_Proc_ID(), get_TrxName()); }
/** Set User defined Process.
@param AD_UserDef_Proc_ID
Primary Key : User defined Process
*/
public void setAD_UserDef_Proc_ID (int AD_UserDef_Proc_ID)
{
if (AD_UserDef_Proc_ID < 1)
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_ID, null);
else
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_ID, Integer.valueOf(AD_UserDef_Proc_ID));
}
/** Get User defined Process.
@return Primary Key : User defined Process
*/
public int getAD_UserDef_Proc_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_UserDef_Proc_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set AD_UserDef_Proc_Parameter_ID.
@param AD_UserDef_Proc_Parameter_ID
Primary Key : User defined Process Parameter
*/
public void setAD_UserDef_Proc_Parameter_ID (int AD_UserDef_Proc_Parameter_ID)
{
if (AD_UserDef_Proc_Parameter_ID < 1)
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_Parameter_ID, null);
else
set_ValueNoCheck (COLUMNNAME_AD_UserDef_Proc_Parameter_ID, Integer.valueOf(AD_UserDef_Proc_Parameter_ID));
}
/** Get AD_UserDef_Proc_Parameter_ID.
@return Primary Key : User defined Process Parameter
*/
public int getAD_UserDef_Proc_Parameter_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_UserDef_Proc_Parameter_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set AD_UserDef_Proc_Parameter_UU.
@param AD_UserDef_Proc_Parameter_UU AD_UserDef_Proc_Parameter_UU */
public void setAD_UserDef_Proc_Parameter_UU (String AD_UserDef_Proc_Parameter_UU)
{
set_Value (COLUMNNAME_AD_UserDef_Proc_Parameter_UU, AD_UserDef_Proc_Parameter_UU);
}
/** Get AD_UserDef_Proc_Parameter_UU.
@return AD_UserDef_Proc_Parameter_UU */
public String getAD_UserDef_Proc_Parameter_UU ()
{
return (String)get_Value(COLUMNNAME_AD_UserDef_Proc_Parameter_UU);
}
/** Set Default Logic.
@param DefaultValue
Default value hierarchy, separated by ;
*/
public void setDefaultValue (String DefaultValue)
{
set_Value (COLUMNNAME_DefaultValue, DefaultValue);
}
/** Get Default Logic.
@return Default value hierarchy, separated by ;
*/
public String getDefaultValue ()
{
return (String)get_Value(COLUMNNAME_DefaultValue);
}
/** Set Description.
@param Description
Optional short description of the record
*/
public void setDescription (String Description)
{
set_Value (COLUMNNAME_Description, Description);
}
/** Get Description.
@return Optional short description of the record
*/
public String getDescription ()
{
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Display Logic.
@param DisplayLogic
If the Field is displayed, the result determines if the field is actually displayed
*/
public void setDisplayLogic (String DisplayLogic)
{
set_Value (COLUMNNAME_DisplayLogic, DisplayLogic);
}
/** Get Display Logic.
@return If the Field is displayed, the result determines if the field is actually displayed
*/
public String getDisplayLogic ()
{
return (String)get_Value(COLUMNNAME_DisplayLogic);
}
/** Set Comment/Help.
@param Help
Comment or Hint
*/
public void setHelp (String Help)
{
set_Value (COLUMNNAME_Help, Help);
}
/** Get Comment/Help.
@return Comment or Hint
*/
public String getHelp ()
{
return (String)get_Value(COLUMNNAME_Help);
}
/** Set Displayed.
@param IsDisplayed
Determines, if this field is displayed
*/
public void setIsDisplayed (boolean IsDisplayed)
{
set_Value (COLUMNNAME_IsDisplayed, Boolean.valueOf(IsDisplayed));
}
/** Get Displayed.
@return Determines, if this field is displayed
*/
public boolean isDisplayed ()
{
Object oo = get_Value(COLUMNNAME_IsDisplayed);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Read Only.
@param IsReadOnly
Field is read only
*/
public void setIsReadOnly (boolean IsReadOnly)
{
set_Value (COLUMNNAME_IsReadOnly, Boolean.valueOf(IsReadOnly));
}
/** Get Read Only.
@return Field is read only
*/
public boolean isReadOnly ()
{
Object oo = get_Value(COLUMNNAME_IsReadOnly);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Mandatory Logic.
@param MandatoryLogic Mandatory Logic */
public void setMandatoryLogic (String MandatoryLogic)
{
set_Value (COLUMNNAME_MandatoryLogic, MandatoryLogic);
}
/** Get Mandatory Logic.
@return Mandatory Logic */
public String getMandatoryLogic ()
{
return (String)get_Value(COLUMNNAME_MandatoryLogic);
}
/** Set Name.
@param Name
Alphanumeric identifier of the entity
*/
public void setName (String Name)
{
set_Value (COLUMNNAME_Name, Name);
}
/** Get Name.
@return Alphanumeric identifier of the entity
*/
public String getName ()
{
return (String)get_Value(COLUMNNAME_Name);
}
/** Get Record ID/ColumnName
@return ID/ColumnName pair
*/
public KeyNamePair getKeyNamePair()
{
return new KeyNamePair(get_ID(), getName());
}
/** Set Read Only Logic.
@param ReadOnlyLogic
Logic to determine if field is read only (applies only when field is read-write)
*/
public void setReadOnlyLogic (String ReadOnlyLogic)
{
set_Value (COLUMNNAME_ReadOnlyLogic, ReadOnlyLogic);
}
/** Get Read Only Logic.
@return Logic to determine if field is read only (applies only when field is read-write)
*/
public String getReadOnlyLogic ()
{
return (String)get_Value(COLUMNNAME_ReadOnlyLogic);
}
}