IDEMPIERE-4900 SQL statement added as an option to define WF Next Nod… (#981)

* IDEMPIERE-4900 SQL statement added as an option to define WF Next Node Condition

Base on pull request 813 (Anton Mostovenko) and patch from
IDEMPIERE-1832 (Deepak Pansheriya)

* IDEMPIERE-4900 SQL statement added as an option to define WF Next Node Condition

Incorporate patch from carlos

* IDEMPIERE-4900 SQL statement added as an option to define WF Next Node Condition

Incorporate patch from Carlos
This commit is contained in:
hengsin 2021-11-17 19:06:42 +08:00 committed by GitHub
parent a1cef5b0fd
commit 5ccd54caf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 433 additions and 10 deletions

View File

@ -0,0 +1,161 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Aug 2, 2021, 3:42:37 PM MSK
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,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 (214567,0,'SQLStatement',706,'SQLStatement',4000,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2021-08-02 15:42:36','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-08-02 15:42:36','YYYY-MM-DD HH24:MI:SS'),100,50028,'Y','N','D','N','N','N','Y','a3885450-50d5-41b6-a7f4-8cd4bcc9e465','Y',0,'N','N','N')
;
-- Aug 2, 2021, 3:42:44 PM MSK
ALTER TABLE AD_WF_NextCondition ADD SQLStatement VARCHAR2(4000 CHAR) DEFAULT NULL
;
-- Aug 2, 2021, 3:42:59 PM MSK
INSERT INTO AD_Field (AD_Field_ID,Name,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,ColumnSpan) VALUES (206737,'SQLStatement',644,214567,'Y',4000,130,'N','N','N','N',0,0,'Y',TO_DATE('2021-08-02 15:42:58','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-08-02 15:42:58','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','f78eaea8-558a-4d74-8c50-26c59468c3a2','Y',130,5)
;
-- Aug 2, 2021, 3:43:09 PM MSK
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2021-08-02 15:43:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Aug 2, 2021, 3:43:35 PM MSK
UPDATE AD_Field SET DisplayLogic='@SQLStatement@=''''&@Operation@!''SQ''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-08-02 15:43:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10101
;
-- Aug 2, 2021, 3:44:18 PM MSK
UPDATE AD_Field SET DisplayLogic='@AD_Column_ID@=0|@Operation@=''SQ''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-08-02 15:44:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Aug 2, 2021, 3:45:00 PM MSK
UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2021-08-02 15:45:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11579
;
-- Aug 2, 2021, 3:45:05 PM MSK
ALTER TABLE AD_WF_NextCondition MODIFY AD_Column_ID NUMBER(10) DEFAULT NULL
;
-- Aug 2, 2021, 3:45:05 PM MSK
ALTER TABLE AD_WF_NextCondition MODIFY AD_Column_ID NULL
;
INSERT INTO AD_Message
(MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID)
VALUES ('E','Please enter read-only SQL expression or statement',200259,'D','49c3be7e-16de-46ff-a2a9-f9411a6a4982','SQLReadOnly','Y',
TO_DATE('2021-11-14 17:45:57','YYYY-MM-DD HH24:MI:SS'),100,100,TO_DATE('2021-11-14 17:45:57','YYYY-MM-DD HH24:MI:SS'),0,0)
;
UPDATE AD_Column SET IsMandatory='N',
MandatoryLogic='@Operation@!''SQ''&@SQLStatement@=''''',Updated=TO_DATE('2021-11-14 17:47:52','YYYY-MM-DD HH24:MI:SS'),
UpdatedBy=100 WHERE AD_Column_ID=11579
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10102
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=10,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10094
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=20,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10105
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=30,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10095
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=40,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10096
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=50,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10098
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10103
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10102
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10094
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10105
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10095
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10096
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10098
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10103
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=getDate(), UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Nov 15, 2021, 10:43:47 AM MYT
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_DATE('2021-11-15 10:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Element SET Name='SQL Expression/Statement', PrintName='SQL Expression/Statement',Updated=TO_DATE('2021-11-15 10:50:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=50028
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Column SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Process_Para SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, AD_Element_ID=50028 WHERE UPPER(ColumnName)='SQLSTATEMENT' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Process_Para SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028 AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_InfoColumn SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028 AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Field SET Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=50028) AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_PrintFormatItem SET PrintName='SQL Expression/Statement', Name='SQL Expression/Statement' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=50028)
;
-- Nov 15, 2021, 11:21:22 AM MYT
UPDATE AD_Column SET ReadOnlyLogic='@#ShowAdvanced@!''Y''',Updated=TO_DATE('2021-11-15 11:21:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214567
;
SELECT register_migration_script('202111141400_IDEMPIERE-4900.sql') FROM dual
;

View File

@ -0,0 +1,158 @@
-- Aug 2, 2021, 3:42:37 PM MSK
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,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 (214567,0,'SQLStatement',706,'SQLStatement',4000,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2021-08-02 15:42:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-08-02 15:42:36','YYYY-MM-DD HH24:MI:SS'),100,50028,'Y','N','D','N','N','N','Y','a3885450-50d5-41b6-a7f4-8cd4bcc9e465','Y',0,'N','N','N')
;
-- Aug 2, 2021, 3:42:44 PM MSK
ALTER TABLE AD_WF_NextCondition ADD COLUMN SQLStatement VARCHAR(4000) DEFAULT NULL
;
-- Aug 2, 2021, 3:42:59 PM MSK
INSERT INTO AD_Field (AD_Field_ID,Name,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,ColumnSpan) VALUES (206737,'SQLStatement',644,214567,'Y',4000,130,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-08-02 15:42:58','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-08-02 15:42:58','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','f78eaea8-558a-4d74-8c50-26c59468c3a2','Y',130,5)
;
-- Aug 2, 2021, 3:43:09 PM MSK
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-08-02 15:43:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Aug 2, 2021, 3:43:35 PM MSK
UPDATE AD_Field SET DisplayLogic='@SQLStatement@=''''&@Operation@!''SQ''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-08-02 15:43:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10101
;
-- Aug 2, 2021, 3:44:18 PM MSK
UPDATE AD_Field SET DisplayLogic='@AD_Column_ID@=0|@Operation@=''SQ''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-08-02 15:44:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Aug 2, 2021, 3:45:00 PM MSK
UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2021-08-02 15:45:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11579
;
-- Aug 2, 2021, 3:45:05 PM MSK
INSERT INTO t_alter_column values('ad_wf_nextcondition','AD_Column_ID','NUMERIC(10)',null,'NULL')
;
-- Aug 2, 2021, 3:45:05 PM MSK
INSERT INTO t_alter_column values('ad_wf_nextcondition','AD_Column_ID',null,'NULL',null)
;
INSERT INTO AD_Message
(MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,Created,AD_Client_ID,AD_Org_ID)
VALUES ('E','Please enter read-only SQL expression or statement',200259,'D','49c3be7e-16de-46ff-a2a9-f9411a6a4982','SQLReadOnly','Y',
TO_TIMESTAMP('2021-11-14 17:45:57','YYYY-MM-DD HH24:MI:SS'),100,100,TO_TIMESTAMP('2021-11-14 17:45:57','YYYY-MM-DD HH24:MI:SS'),0,0)
;
UPDATE AD_Column SET IsMandatory='N',
MandatoryLogic='@Operation@!''SQ''&@SQLStatement@=''''',Updated=TO_TIMESTAMP('2021-11-14 17:47:52','YYYY-MM-DD HH24:MI:SS'),
UpdatedBy=100 WHERE AD_Column_ID=11579
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=0,IsDisplayed='N', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10102
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=10,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10094
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=20,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10105
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=30,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10095
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=40,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10096
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=50,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10098
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=60,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10103
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=70,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:43:08 AM MYT
UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10102
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10094
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10105
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10095
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10096
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10098
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10103
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:43:22 AM MYT
UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y', Updated=statement_timestamp(), UpdatedBy=100 WHERE AD_Field_ID=206737
;
-- Nov 15, 2021, 10:43:47 AM MYT
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-11-15 10:43:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10104
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Element SET Name='SQL Expression/Statement', PrintName='SQL Expression/Statement',Updated=TO_TIMESTAMP('2021-11-15 10:50:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=50028
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Column SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Process_Para SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, AD_Element_ID=50028 WHERE UPPER(ColumnName)='SQLSTATEMENT' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Process_Para SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028 AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_InfoColumn SET ColumnName='SQLStatement', Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Element_ID=50028 AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_Field SET Name='SQL Expression/Statement', Description=NULL, Help=NULL, Placeholder=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=50028) AND IsCentrallyMaintained='Y'
;
-- Nov 15, 2021, 10:50:21 AM MYT
UPDATE AD_PrintFormatItem SET PrintName='SQL Expression/Statement', Name='SQL Expression/Statement' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=50028)
;
-- Nov 15, 2021, 11:21:22 AM MYT
UPDATE AD_Column SET ReadOnlyLogic='@#ShowAdvanced@!''Y''',Updated=TO_TIMESTAMP('2021-11-15 11:21:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214567
;
SELECT register_migration_script('202111141400_IDEMPIERE-4900.sql') FROM dual
;

View File

@ -199,6 +199,15 @@ public interface I_AD_WF_NextCondition
*/
public int getSeqNo();
/** Column name SQLStatement */
public static final String COLUMNNAME_SQLStatement = "SQLStatement";
/** Set SQLStatement */
public void setSQLStatement (String SQLStatement);
/** Get SQLStatement */
public String getSQLStatement();
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";

View File

@ -31,7 +31,7 @@ public class X_AD_WF_NextCondition extends PO implements I_AD_WF_NextCondition,
/**
*
*/
private static final long serialVersionUID = 20210917L;
private static final long serialVersionUID = 20211114L;
/** Standard Constructor */
public X_AD_WF_NextCondition (Properties ctx, int AD_WF_NextCondition_ID, String trxName)
@ -39,7 +39,6 @@ public class X_AD_WF_NextCondition extends PO implements I_AD_WF_NextCondition,
super (ctx, AD_WF_NextCondition_ID, trxName);
/** if (AD_WF_NextCondition_ID == 0)
{
setAD_Column_ID (0);
setAD_WF_NextCondition_ID (0);
setAD_WF_NodeNext_ID (0);
// @4|AD_WF_NodeNext_ID@
@ -279,6 +278,20 @@ public class X_AD_WF_NextCondition extends PO implements I_AD_WF_NextCondition,
return ii.intValue();
}
/** Set SQLStatement.
@param SQLStatement SQLStatement */
public void setSQLStatement (String SQLStatement)
{
set_Value (COLUMNNAME_SQLStatement, SQLStatement);
}
/** Get SQLStatement.
@return SQLStatement */
public String getSQLStatement ()
{
return (String)get_Value(COLUMNNAME_SQLStatement);
}
/** Set Search Key.
@param Value
Search key for the record in the format required - must be unique

View File

@ -2599,4 +2599,21 @@ public final class DB
{
return getDatabase().intersectClauseForCSV(columnName, csv);
}
/**
*
* @param sql
* @return true if it is select sql statement
*/
public static boolean isSelectStatement(String sql) {
String removeComments = "/\\*(?:.|[\\n\\r])*?\\*/";
String removeQuotedStrings = "'(?:.|[\\n\\r])*?'";
String removeLeadingSpaces = "^\\s+";
String cleanSql = sql.toLowerCase().replaceAll(removeComments, "").replaceAll(removeQuotedStrings, "").replaceFirst(removeLeadingSpaces, "");
if(cleanSql.matches("^select\s.*$") && !cleanSql.contains(";"))
return true;
else
return false;
}
} // DB

View File

@ -17,12 +17,16 @@
package org.compiere.wf;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import org.compiere.model.PO;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.idempiere.cache.ImmutablePOSupport;
import org.compiere.model.X_AD_WF_NextCondition;
@ -40,7 +44,7 @@ public class MWFNextCondition extends X_AD_WF_NextCondition implements Immutable
/**
*
*/
private static final long serialVersionUID = 1694467559057544172L;
private static final long serialVersionUID = 3119863973003103716L;
/**
* Default Constructor
@ -115,14 +119,42 @@ public class MWFNextCondition extends X_AD_WF_NextCondition implements Immutable
*/
public boolean evaluate (MWFActivity activity)
{
if (getAD_Column_ID() == 0)
throw new IllegalStateException("No Column defined - " + this);
return evaluate(activity.getPO());
} // evaluate
/**
* Evaluate Condition
* @param po PO
* @return true if true
*/
protected boolean evaluate (PO po)
{
if (getAD_Column_ID() == 0 && Util.isEmpty(getSQLStatement(), true))
throw new IllegalStateException("No Column and SQL Statement defined - " + this);
PO po = activity.getPO();
if (po == null || po.get_ID() == 0)
throw new IllegalStateException("Could not evaluate " + po + " - " + this);
//
Object valueObj = po.get_ValueOfColumn(getAD_Column_ID());
if (getOperation().equals(OPERATION_Sql)) {
String sqlStatement = getSQLStatement();
if (Util.isEmpty(getSQLStatement(), true))
return false;
if (sqlStatement.indexOf("@") >= 0)
sqlStatement = Env.parseVariable(sqlStatement, po, po.get_TrxName(), false);
String result = DB.getSQLValueStringEx(po.get_TrxName(), sqlStatement);
return "true".equalsIgnoreCase(result) || "y".equalsIgnoreCase(result);
}
//
Object valueObj = null;
if (!Util.isEmpty(getSQLStatement(), true)) {
try {
valueObj = getColumnSQLValue(po);
} catch (SQLException e) {
throw new RuntimeException("Could not get result from column sql: " + getSQLStatement(), e);
}
} else {
valueObj = po.get_ValueOfColumn(getAD_Column_ID());
}
if (valueObj == null)
valueObj = "";
String value1 = getDecodedValue(getValue(), po); // F3P: added value decoding
@ -133,8 +165,6 @@ public class MWFNextCondition extends X_AD_WF_NextCondition implements Immutable
value2 = "";
String resultStr = "PO:{" + valueObj + "} " + getOperation() + " Condition:{" + value1 + "}";
if (getOperation().equals(OPERATION_Sql))
throw new IllegalArgumentException("SQL Operator not implemented yet: " + resultStr);
if (getOperation().equals(OPERATION_X))
resultStr += "{" + value2 + "}";
@ -343,4 +373,39 @@ public class MWFNextCondition extends X_AD_WF_NextCondition implements Immutable
return this;
}
/**
* Get value from Column SQL (SQLStatement) instead of from AD_Column_ID
* @param po
* @return Value from Column SQL
* @throws SQLException
*/
private Object getColumnSQLValue(PO po) throws SQLException {
String columnSQL = getSQLStatement();
if (columnSQL.indexOf("@") >= 0) {
columnSQL = Env.parseVariable(columnSQL, po, po.get_TrxName(), false);
}
String tableName = po.get_TableName();
String pkName = po.get_KeyColumns() != null && po.get_KeyColumns().length==1 ? po.get_KeyColumns()[0] : po.getUUIDColumnName();
String resultSql = String.format("SELECT (%s) FROM %s WHERE %s = ?", columnSQL, tableName, pkName);
try (PreparedStatement pstmt = DB.prepareStatement(resultSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, po.get_TrxName())) {
if (pkName.endsWith("_UU"))
pstmt.setString(1, po.get_ValueAsString(po.getUUIDColumnName()));
else
pstmt.setInt(1, po.get_ID());
ResultSet rs = pstmt.executeQuery();
if (rs.next())
return rs.getObject(1);
}
return null;
}
@Override
protected boolean beforeSave(boolean newRecord) {
if (!Util.isEmpty(getSQLStatement(), true)) {
setAD_Column_ID(0);
}
return true;
}
} // MWFNextCondition