IDEMPIERE-5538 - Add isValid to Drill Rule allow validate parameters with beforesave (#1632)

* IDEMPIERE-5538 - Add isValid to Drill Rule allow validate parameters with beforesave

* IDEMPIERE-5538 - beforeSave, capture process parameters

* IDEMPIERE-5538 - validate only through process

* IDEMPIERE-5538 - isValid check in getByTable method

* IDEMPIERE-5538 - add validation to before save/after delete

* IDEMPIERE-5538 - validate system drill rules

* IDEMPIERE-5538 - fix validation logic

The mandatory validation have to skip the key parameter since it is not loaded from Drill Rule Para.

* IDEMPIERE-5538 - fix Drill Rule window definition

* IDEMPIERE-5538 - bug fix scripts to iD10

* IDEMPIERE-5538 - fix missing read only logic

* IDEMPIERE-5538 - all scripts to iD10
This commit is contained in:
Peter Takács 2023-03-16 12:10:15 +01:00 committed by GitHub
parent 21e4f610eb
commit 47987c0314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 375 additions and 14 deletions

View File

@ -0,0 +1,46 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202301091502_IDEMPIERE-5538.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jan 9, 2023, 3:02:37 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (215738,0,'Valid','Element is valid','The element passed the validation check',200335,'IsValid','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2023-01-09 15:02:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 15:02:36','YYYY-MM-DD HH24:MI:SS'),100,2002,'Y','N','D','N','N','N','Y','8b4d9a1c-ef04-4b39-bab3-d35ebbbaa399','Y',0,'N','N','N')
;
-- Jan 9, 2023, 3:02:49 PM CET
ALTER TABLE AD_Process_DrillRule ADD IsValid CHAR(1) DEFAULT 'N' CHECK (IsValid IN ('Y','N')) NOT NULL
;
-- Jan 9, 2023, 3:03:06 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (207523,'Valid','Element is valid','The element passed the validation check',200308,215738,'Y',1,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-01-09 15:03:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 15:03:06','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','aa4a1aca-cf2c-4754-bbd2-c84ab8b6934c','Y',110,2,2)
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, XPosition=5,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207523
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET SeqNo=110,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206930
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET SeqNo=120,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207109
;
-- Jan 9, 2023, 3:29:30 PM CET
UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2023-01-09 15:29:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207523
;
-- Jan 9, 2023, 4:27:35 PM CET
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,ShowHelp,AD_Process_UU) VALUES (200147,0,0,'Y',TO_TIMESTAMP('2023-01-09 16:27:35','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 16:27:35','YYYY-MM-DD HH24:MI:SS'),100,'Validate','Validate Drill Rule Parameters','Validate the Drill Rule, if all mandatory parameters are set.','N','AD_Process_DrillRule_Validate','N','org.compiere.process.DrillRuleValidate','6','D',0,0,'N','Y','858ac391-3f7e-498d-bbef-caa1ad94e5f6')
;
-- Jan 9, 2023, 4:29:11 PM CET
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,Action,AD_Tab_ID,AD_Process_ID,SeqNo,EntityType) VALUES (0,0,TO_TIMESTAMP('2023-01-09 16:29:10','YYYY-MM-DD HH24:MI:SS'),100,'Validate','Y',200128,'Validate',TO_TIMESTAMP('2023-01-09 16:29:10','YYYY-MM-DD HH24:MI:SS'),100,'N','b739ac8e-704e-4c34-8eab-87e3eb087dba','W',200308,200147,20,'D')
;
-- Jan 9, 2023, 4:31:45 PM CET
UPDATE AD_ToolBarButton SET DisplayLogic='@AD_Client_ID@=@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-01-09 16:31:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200128
;

View File

@ -0,0 +1,14 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202302281202_IDEMPIERE-5538.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Feb 28, 2023, 12:02:28 PM CET
UPDATE AD_Message SET MsgText='Cannot find any valid Drill Rules for the selected Column.', MsgTip='You can define new definitions in Drill Rule window, then run the ''Validate'' process.',Updated=TO_TIMESTAMP('2023-02-28 12:02:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200762
;
-- Feb 28, 2023, 12:04:40 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','All Drill Rules in System which have at least one Drill Rule Parameter with a mandatory Process Parameter must have the Show Help field set to value ''Show Help''',0,0,'Y',TO_TIMESTAMP('2023-02-28 12:04:39','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-28 12:04:39','YYYY-MM-DD HH24:MI:SS'),100,200823,'DrillParameterTenantCheck','D','c93f3c2c-4d1f-4a13-a41d-05b31402453d')
;

View File

@ -0,0 +1,26 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202303101612_IDEMPIERE-5538.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 10, 2023, 4:12:07 PM CET
UPDATE AD_Column SET IsUpdateable='N',Updated=TO_TIMESTAMP('2023-03-10 16:12:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214733
;
-- Mar 10, 2023, 4:13:51 PM CET
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-10 16:13:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206939
;
-- Mar 10, 2023, 4:13:56 PM CET
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-10 16:13:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206941
;
-- Mar 15, 2023, 1:35:41 PM CET
UPDATE AD_ToolBarButton SET DisplayLogic='@AD_Client_ID@=@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-03-15 13:35:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200123
;
-- Mar 15, 2023, 3:27:28 PM CET
UPDATE AD_Tab SET ReadOnlyLogic='@AD_Client_ID@!@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-03-15 15:27:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=200309
;

View File

@ -0,0 +1,43 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202301091502_IDEMPIERE-5538.sql') FROM dual;
-- Jan 9, 2023, 3:02:37 PM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,IsHtml) VALUES (215738,0,'Valid','Element is valid','The element passed the validation check',200335,'IsValid','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2023-01-09 15:02:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 15:02:36','YYYY-MM-DD HH24:MI:SS'),100,2002,'Y','N','D','N','N','N','Y','8b4d9a1c-ef04-4b39-bab3-d35ebbbaa399','Y',0,'N','N','N')
;
-- Jan 9, 2023, 3:02:49 PM CET
ALTER TABLE AD_Process_DrillRule ADD COLUMN IsValid CHAR(1) DEFAULT 'N' CHECK (IsValid IN ('Y','N')) NOT NULL
;
-- Jan 9, 2023, 3:03:06 PM CET
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (207523,'Valid','Element is valid','The element passed the validation check',200308,215738,'Y',1,120,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2023-01-09 15:03:06','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 15:03:06','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','aa4a1aca-cf2c-4754-bbd2-c84ab8b6934c','Y',110,2,2)
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=100, XPosition=5,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207523
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET SeqNo=110,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206930
;
-- Jan 9, 2023, 3:03:46 PM CET
UPDATE AD_Field SET SeqNo=120,Updated=TO_TIMESTAMP('2023-01-09 15:03:46','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207109
;
-- Jan 9, 2023, 3:29:30 PM CET
UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2023-01-09 15:29:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=207523
;
-- Jan 9, 2023, 4:27:35 PM CET
INSERT INTO AD_Process (AD_Process_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Description,Help,IsReport,Value,IsDirectPrint,Classname,AccessLevel,EntityType,Statistic_Count,Statistic_Seconds,IsBetaFunctionality,ShowHelp,AD_Process_UU) VALUES (200147,0,0,'Y',TO_TIMESTAMP('2023-01-09 16:27:35','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-01-09 16:27:35','YYYY-MM-DD HH24:MI:SS'),100,'Validate','Validate Drill Rule Parameters','Validate the Drill Rule, if all mandatory parameters are set.','N','AD_Process_DrillRule_Validate','N','org.compiere.process.DrillRuleValidate','6','D',0,0,'N','Y','858ac391-3f7e-498d-bbef-caa1ad94e5f6')
;
-- Jan 9, 2023, 4:29:11 PM CET
INSERT INTO AD_ToolBarButton (AD_Client_ID,AD_Org_ID,Created,CreatedBy,ComponentName,IsActive,AD_ToolBarButton_ID,Name,Updated,UpdatedBy,IsCustomization,AD_ToolBarButton_UU,"action",AD_Tab_ID,AD_Process_ID,SeqNo,EntityType) VALUES (0,0,TO_TIMESTAMP('2023-01-09 16:29:10','YYYY-MM-DD HH24:MI:SS'),100,'Validate','Y',200128,'Validate',TO_TIMESTAMP('2023-01-09 16:29:10','YYYY-MM-DD HH24:MI:SS'),100,'N','b739ac8e-704e-4c34-8eab-87e3eb087dba','W',200308,200147,20,'D')
;
-- Jan 9, 2023, 4:31:45 PM CET
UPDATE AD_ToolBarButton SET DisplayLogic='@AD_Client_ID@=@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-01-09 16:31:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200128
;

View File

@ -0,0 +1,11 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202302281202_IDEMPIERE-5538.sql') FROM dual;
-- Feb 28, 2023, 12:02:28 PM CET
UPDATE AD_Message SET MsgText='Cannot find any valid Drill Rules for the selected Column.', MsgTip='You can define new definitions in Drill Rule window, then run the ''Validate'' process.',Updated=TO_TIMESTAMP('2023-02-28 12:02:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200762
;
-- Feb 28, 2023, 12:04:40 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('I','All Drill Rules in System which have at least one Drill Rule Parameter with a mandatory Process Parameter must have the Show Help field set to value ''Show Help''',0,0,'Y',TO_TIMESTAMP('2023-02-28 12:04:39','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2023-02-28 12:04:39','YYYY-MM-DD HH24:MI:SS'),100,200823,'DrillParameterTenantCheck','D','c93f3c2c-4d1f-4a13-a41d-05b31402453d')
;

View File

@ -0,0 +1,23 @@
-- IDEMPIERE-5538
SELECT register_migration_script('202303101612_IDEMPIERE-5538.sql') FROM dual;
-- Mar 10, 2023, 4:12:07 PM CET
UPDATE AD_Column SET IsUpdateable='N',Updated=TO_TIMESTAMP('2023-03-10 16:12:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214733
;
-- Mar 10, 2023, 4:13:51 PM CET
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-10 16:13:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206939
;
-- Mar 10, 2023, 4:13:56 PM CET
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2023-03-10 16:13:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206941
;
-- Mar 15, 2023, 1:35:41 PM CET
UPDATE AD_ToolBarButton SET DisplayLogic='@AD_Client_ID@=@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-03-15 13:35:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200123
;
-- Mar 15, 2023, 3:27:28 PM CET
UPDATE AD_Tab SET ReadOnlyLogic='@AD_Client_ID@!@#AD_Client_ID@',Updated=TO_TIMESTAMP('2023-03-15 15:27:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=200309
;

View File

@ -0,0 +1,67 @@
/**********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Peter Takacs, Cloudempiere *
**********************************************************************/
package org.compiere.process;
import org.compiere.model.MProcessDrillRule;
import org.compiere.util.Msg;
/**
* Validate Drill Rule Parameters
*
* @author Peter Takacs, Cloudempiere
*/
@org.adempiere.base.annotation.Process
public class DrillRuleValidate extends SvrProcess
{
/** Drill Rule */
private int p_AD_Process_DrillRule_ID = 0;
/**
* Prepare
*/
protected void prepare ()
{
p_AD_Process_DrillRule_ID = getRecord_ID();
} // prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt ()
throws Exception
{
MProcessDrillRule drillRule = new MProcessDrillRule(getCtx(), p_AD_Process_DrillRule_ID, null);
drillRule.validate();
drillRule.saveEx();
if(getAD_Client_ID() == 0 && drillRule.hasMandatoryProcessPara()
&& !MProcessDrillRule.SHOWHELP_ShowHelp.equalsIgnoreCase(drillRule.getShowHelp())) {
return "@NotValid@" + ": " + Msg.getMsg(getCtx(), "DrillParameterTenantCheck");
}
return drillRule.isValid() ? "@OK@" : "@NotValid@";
}
}

View File

@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair;
/** Generated Interface for AD_Process_DrillRule
* @author iDempiere (generated)
* @version Release 10
* @version Release 11
*/
public interface I_AD_Process_DrillRule
{
@ -193,6 +193,19 @@ public interface I_AD_Process_DrillRule
*/
public boolean isActive();
/** Column name IsValid */
public static final String COLUMNNAME_IsValid = "IsValid";
/** Set Valid.
* Element is valid
*/
public void setIsValid (boolean IsValid);
/** Get Valid.
* Element is valid
*/
public boolean isValid();
/** Column name Name */
public static final String COLUMNNAME_Name = "Name";

View File

@ -30,6 +30,7 @@ import java.util.List;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.idempiere.cache.ImmutableIntPOCache;
import org.idempiere.cache.ImmutablePOSupport;
@ -135,10 +136,9 @@ public class MProcessDrillRule extends X_AD_Process_DrillRule implements Immutab
*/
public static MProcessDrillRule[] getByTable(Properties ctx, int AD_Table_ID, String trxName) {
String whereClause = " AD_Table_ID = ? ";
String whereClause = " AD_Table_ID = ? AND IsValid = 'Y' AND " + MProcessDrillRule.Table_Name + "." + MProcessDrillRule.COLUMNNAME_AD_Client_ID + " IN (0,?)";
List<MProcessDrillRule> processDrillRules = new Query(ctx, MProcessDrillRule.Table_Name, whereClause, trxName)
.setParameters(AD_Table_ID)
.setClient_ID()
.setParameters(AD_Table_ID, Env.getAD_Client_ID(ctx))
.setOnlyActiveRecords(true)
.list();
@ -154,13 +154,12 @@ public class MProcessDrillRule extends X_AD_Process_DrillRule implements Immutab
*/
public static MProcessDrillRule[] getByColumnName(Properties ctx, String columnName, String trxName) {
String whereClause = "";
String whereClause = " IsValid = 'Y' AND " + MProcessDrillRule.Table_Name + "." + MProcessDrillRule.COLUMNNAME_AD_Client_ID + " IN (0,?)";
List<MProcessDrillRule> processDrillRules = new Query(ctx, MProcessDrillRule.Table_Name, whereClause, trxName)
.addJoinClause(" INNER JOIN AD_Process_Para pp ON "
+ MProcessDrillRule.Table_Name + "." + MProcessDrillRule.COLUMNNAME_AD_Process_Para_ID + " = pp." + MProcessPara.COLUMNNAME_AD_Process_Para_ID
+ " AND " + MProcessPara.COLUMNNAME_ColumnName + " = ?")
.setParameters(columnName)
.setClient_ID()
.setParameters(columnName, Env.getAD_Client_ID(ctx))
.setOnlyActiveRecords(true)
.list();
@ -178,9 +177,10 @@ public class MProcessDrillRule extends X_AD_Process_DrillRule implements Immutab
setAD_Table_ID(reportView.getAD_Table_ID());
}
}
validate();
return super.beforeSave(newRecord);
}
/**
* Get Parameters
* @param reload reload
@ -211,4 +211,58 @@ public class MProcessDrillRule extends X_AD_Process_DrillRule implements Immutab
makeImmutable();
return this;
}
/**
* Are all mandatory parameters defined among the Drill Rule Parameters
* @return true - all mandatory parameters are set; false - at least one mandatory parameter is not set
*/
private boolean allMandatoryParaSet() {
boolean isValid = false;
MProcess process = new MProcess(Env.getCtx(), getAD_Process_ID(), get_TrxName());
for(MProcessPara processPara : process.getParameters()) {
if(processPara.isMandatory() && processPara.getAD_Process_Para_ID() != getAD_Process_Para_ID()) {
for(MProcessDrillRulePara drillRulePara : getParameters(true)) {
if(drillRulePara.getAD_Process_Para_ID() == processPara.getAD_Process_Para_ID()) {
String defPara = drillRulePara.getParameterDefault();
String defParaTo = drillRulePara.getParameterToDefault();
isValid = (processPara.isRange() && (!Util.isEmpty(defPara)) || (!Util.isEmpty(defParaTo))) ||
(!processPara.isRange() && (!Util.isEmpty(defPara)));
break;
}
}
if(!isValid)
return false;
isValid = false;
}
}
return true;
}
/**
* Has any Drill Rule Parameters with a mandatory Process Parameter
* @return boolean true if has at least one Drill Rule Parameter with a mandatory Process Parameter
*/
public boolean hasMandatoryProcessPara() {
MProcess process = new MProcess(Env.getCtx(), getAD_Process_ID(), null);
for(MProcessPara processPara : process.getParameters()) {
if(processPara.isMandatory())
return true;
}
return false;
}
/**
* Validate Drill Rule - set IsValid
*/
public void validate() {
if(getAD_Client_ID() == 0 && hasMandatoryProcessPara() && !SHOWHELP_ShowHelp.equalsIgnoreCase(getShowHelp())) {
setIsValid(false);
}
else if(SHOWHELP_ShowHelp.equalsIgnoreCase(getShowHelp())) {
setIsValid(true);
}
else {
setIsValid(allMandatoryParaSet());
}
}
}

View File

@ -58,6 +58,8 @@ public class MProcessDrillRulePara extends X_AD_Process_DrillRule_Para implement
/** Parameter Column Name */
private MProcessPara m_parameter = null;
/** Parent */
private MProcessDrillRule m_parent = null;
/**
@ -95,4 +97,33 @@ public class MProcessDrillRulePara extends X_AD_Process_DrillRule_Para implement
public void setParentID(int id) {
setAD_Process_DrillRule_ID(id);
}
/**
* Get Parent
* @return parent
*/
public MProcessDrillRule getParent()
{
if (m_parent == null)
m_parent = new MProcessDrillRule(getCtx(), getAD_Process_DrillRule_ID(), get_TrxName());
return m_parent;
} // getParent
@Override
protected boolean afterSave(boolean newRecord, boolean success) {
if(success) {
getParent().validate();
getParent().saveEx(get_TrxName());
}
return super.afterSave(newRecord, success);
}
@Override
protected boolean afterDelete (boolean success) {
if(success) {
getParent().validate();
getParent().saveEx(get_TrxName());
}
return super.afterDelete(success);
}
}

View File

@ -22,7 +22,7 @@ import java.util.Properties;
/** Generated Model for AD_Process_DrillRule
* @author iDempiere (generated)
* @version Release 10 - $Id$ */
* @version Release 11 - $Id$ */
@org.adempiere.base.Model(table="AD_Process_DrillRule")
public class X_AD_Process_DrillRule extends PO implements I_AD_Process_DrillRule, I_Persistent
{
@ -30,7 +30,7 @@ public class X_AD_Process_DrillRule extends PO implements I_AD_Process_DrillRule
/**
*
*/
private static final long serialVersionUID = 20221224L;
private static final long serialVersionUID = 20230109L;
/** Standard Constructor */
public X_AD_Process_DrillRule (Properties ctx, int AD_Process_DrillRule_ID, String trxName)
@ -41,6 +41,8 @@ public class X_AD_Process_DrillRule extends PO implements I_AD_Process_DrillRule
setAD_Process_DrillRule_ID (0);
setAD_Process_ID (0);
setAD_Process_Para_ID (0);
setIsValid (false);
// N
setName (null);
} */
}
@ -54,6 +56,8 @@ public class X_AD_Process_DrillRule extends PO implements I_AD_Process_DrillRule
setAD_Process_DrillRule_ID (0);
setAD_Process_ID (0);
setAD_Process_Para_ID (0);
setIsValid (false);
// N
setName (null);
} */
}
@ -277,6 +281,29 @@ public class X_AD_Process_DrillRule extends PO implements I_AD_Process_DrillRule
return (String)get_Value(COLUMNNAME_Description);
}
/** Set Valid.
@param IsValid Element is valid
*/
public void setIsValid (boolean IsValid)
{
set_Value (COLUMNNAME_IsValid, Boolean.valueOf(IsValid));
}
/** Get Valid.
@return Element is valid
*/
public boolean isValid()
{
Object oo = get_Value(COLUMNNAME_IsValid);
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
*/

View File

@ -137,6 +137,9 @@ public class WProcessParameter implements IFormController {
}
}
poPara.saveEx();
if(tableName.equalsIgnoreCase(MProcessDrillRule.Table_Name)) {
((MProcessDrillRule)po).validate();
}
}
}
}

View File

@ -590,7 +590,8 @@ public class DrillReportCtl {
+ " (=" + value + "=) " + value.getClass().getName());
}
// Mandatory check
if(processPara.isMandatory() && Util.isEmpty(sPara.getParameterDefault())) {
if(processPara.isMandatory() && Util.isEmpty(sPara.getParameterDefault())
&& !MProcessDrillRule.SHOWHELP_ShowHelp.equalsIgnoreCase(processDrillRule.getShowHelp())) {
if((!processPara.isRange()) || (processPara.isRange() && Util.isEmpty(sPara.getParameterToDefault())))
throw new AdempiereException(Msg.parseTranslation(Env.getCtx(), "@FillMandatoryDrillRulePara@"));
}
@ -607,9 +608,11 @@ public class DrillReportCtl {
} // Drill Rule Parameter loop
// Mandatory check
for(MProcessPara unsetProcessPara : processParasExclDrillRuleParas) {
if(unsetProcessPara.isMandatory()) {
throw new AdempiereException(Msg.parseTranslation(Env.getCtx(), "@FillMandatoryDrillRulePara@"));
if(!MProcessDrillRule.SHOWHELP_ShowHelp.equalsIgnoreCase(processDrillRule.getShowHelp())) {
for(MProcessPara unsetProcessPara : processParasExclDrillRuleParas) {
if(unsetProcessPara.isMandatory()) {
throw new AdempiereException(Msg.parseTranslation(Env.getCtx(), "@FillMandatoryDrillRulePara@"));
}
}
}
pi.setParameter(iParams.toArray(new ProcessInfoParameter[0]));