IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / Shell script (#891)
* IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / Shell script * IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / Java Shell script -> beanshell/groovy * IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / Remove java class option, fixes for script * IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / rename to ScriptJSR223 * IDEMPIERE-4968 Enable 2Pack to run java class or script (FHCA-3112 FHCA-3113) / add audit information to SQL statements, shell and JSR223 scripts
This commit is contained in:
parent
b15ddeaea0
commit
557c483fc9
|
@ -0,0 +1,75 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- IDEMPIERE-4968 Enable 2Pack to run java class or script
|
||||
-- Sep 17, 2021, 6:07:17 PM CEST
|
||||
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200519,'Script JSR223',50004,'SCJ',0,0,'Y',TO_DATE('2021-09-17 18:07:17','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-17 18:07:17','YYYY-MM-DD HH24:MI:SS'),100,'D','9a9c315b-9af4-4e83-be41-5f5057c13061')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:07:23 PM CEST
|
||||
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200521,'Shell Script',50004,'SH',0,0,'Y',TO_DATE('2021-09-17 18:07:22','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-17 18:07:22','YYYY-MM-DD HH24:MI:SS'),100,'D','48522ab7-f47c-4ee9-a6b3-21fb762b3e1a')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:33 PM CEST
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203542,0,0,'Y',TO_DATE('2021-09-17 18:28:22','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-17 18:28:22','YYYY-MM-DD HH24:MI:SS'),100,'ExecCode','Execution Code',NULL,NULL,'Execution Code','D','54a4baac-9786-446a-bd22-acbe58fedfae')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:47 PM CEST
|
||||
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,FKConstraintType,IsHtml) VALUES (214590,0,'Execution Code',50006,'ExecCode',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_DATE('2021-09-17 18:28:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-17 18:28:47','YYYY-MM-DD HH24:MI:SS'),100,203542,'Y','N','D','N','N','N','Y','4c3a9c23-86bc-4ffe-b3ad-52703d53e5b2','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:50 PM CEST
|
||||
ALTER TABLE AD_Package_Exp_Detail ADD ExecCode CLOB DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:29:54 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206750,'Execution Code',50006,214590,'Y','@Type@=SCJ | @Type@=SH',0,340,0,'N','N','N','N',0,0,'Y',TO_DATE('2021-09-17 18:29:53','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-17 18:29:53','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','f0e80eea-0c09-46a6-b69a-a0a796448e84','Y',340,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:30:23 PM CEST
|
||||
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=330, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=5, NumLines=8, IsToolbarButton=NULL,Updated=TO_DATE('2021-09-17 18:30:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206750
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:30:23 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-09-17 18:30:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50117
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:17:49 PM CEST
|
||||
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,FKConstraintType,IsHtml) VALUES (214591,0,'Execution Code',50004,'ExecCode',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_DATE('2021-09-23 18:17:48','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-23 18:17:48','YYYY-MM-DD HH24:MI:SS'),100,203542,'Y','N','D','N','N','N','Y','19a844b4-e6e2-44eb-ba01-d27b8f10c758','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:17:50 PM CEST
|
||||
ALTER TABLE AD_Package_Imp_Detail ADD ExecCode CLOB DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:19:25 PM CEST
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,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 (214592,0,'Result','Result of the action taken','The Result indicates the result of any action taken on this request.',50004,'Result',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_DATE('2021-09-23 18:19:24','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-23 18:19:24','YYYY-MM-DD HH24:MI:SS'),100,546,'N','N','D','N','N','N','Y','0feb2960-ed0e-4a43-8c0b-8c567b0969b1','Y',0,'N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:19:28 PM CEST
|
||||
ALTER TABLE AD_Package_Imp_Detail ADD Result CLOB DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:01 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206751,'Execution Code',50004,214591,'Y',0,110,0,'N','N','N','N',0,0,'Y',TO_DATE('2021-09-23 18:21:00','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-23 18:21:00','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','5da85957-d2ab-42e0-b8fc-fd7d11a49a07','Y',80,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:07 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206752,'Result','Result of the action taken','The Result indicates the result of any action taken on this request.',50004,214592,'Y',0,120,0,'N','N','N','N',0,0,'Y',TO_DATE('2021-09-23 18:21:07','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-09-23 18:21:07','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','921e0126-c9a7-4029-beb8-930a95b64ef7','Y',90,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=5, NumLines=3, IsToolbarButton=NULL,Updated=TO_DATE('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206751
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=5, NumLines=3, IsToolbarButton=NULL,Updated=TO_DATE('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206752
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204550
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202109171808_IDEMPIERE-4968.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
-- IDEMPIERE-4968 Enable 2Pack to run java class or script
|
||||
-- Sep 17, 2021, 6:07:17 PM CEST
|
||||
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200519,'Script JSR223',50004,'SCJ',0,0,'Y',TO_TIMESTAMP('2021-09-17 18:07:17','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-17 18:07:17','YYYY-MM-DD HH24:MI:SS'),100,'D','9a9c315b-9af4-4e83-be41-5f5057c13061')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:07:23 PM CEST
|
||||
INSERT INTO AD_Ref_List (AD_Ref_List_ID,Name,AD_Reference_ID,Value,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,EntityType,AD_Ref_List_UU) VALUES (200521,'Shell Script',50004,'SH',0,0,'Y',TO_TIMESTAMP('2021-09-17 18:07:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-17 18:07:22','YYYY-MM-DD HH24:MI:SS'),100,'D','48522ab7-f47c-4ee9-a6b3-21fb762b3e1a')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:33 PM CEST
|
||||
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203542,0,0,'Y',TO_TIMESTAMP('2021-09-17 18:28:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-17 18:28:22','YYYY-MM-DD HH24:MI:SS'),100,'ExecCode','Execution Code',NULL,NULL,'Execution Code','D','54a4baac-9786-446a-bd22-acbe58fedfae')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:47 PM CEST
|
||||
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,FKConstraintType,IsHtml) VALUES (214590,0,'Execution Code',50006,'ExecCode',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_TIMESTAMP('2021-09-17 18:28:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-17 18:28:47','YYYY-MM-DD HH24:MI:SS'),100,203542,'Y','N','D','N','N','N','Y','4c3a9c23-86bc-4ffe-b3ad-52703d53e5b2','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:28:50 PM CEST
|
||||
ALTER TABLE AD_Package_Exp_Detail ADD COLUMN ExecCode TEXT DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:29:54 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLogic,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206750,'Execution Code',50006,214590,'Y','@Type@=SCJ | @Type@=SH',0,340,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-09-17 18:29:53','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-17 18:29:53','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','f0e80eea-0c09-46a6-b69a-a0a796448e84','Y',340,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:30:23 PM CEST
|
||||
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=330, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=5, NumLines=8, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-09-17 18:30:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206750
|
||||
;
|
||||
|
||||
-- Sep 17, 2021, 6:30:23 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=340, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-09-17 18:30:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=50117
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:17:49 PM CEST
|
||||
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,FKConstraintType,IsHtml) VALUES (214591,0,'Execution Code',50004,'ExecCode',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_TIMESTAMP('2021-09-23 18:17:48','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-23 18:17:48','YYYY-MM-DD HH24:MI:SS'),100,203542,'Y','N','D','N','N','N','Y','19a844b4-e6e2-44eb-ba01-d27b8f10c758','Y',0,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:17:50 PM CEST
|
||||
ALTER TABLE AD_Package_Imp_Detail ADD COLUMN ExecCode TEXT DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:19:25 PM CEST
|
||||
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,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 (214592,0,'Result','Result of the action taken','The Result indicates the result of any action taken on this request.',50004,'Result',0,'N','N','N','N','N',0,'N',36,0,0,'Y',TO_TIMESTAMP('2021-09-23 18:19:24','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-23 18:19:24','YYYY-MM-DD HH24:MI:SS'),100,546,'N','N','D','N','N','N','Y','0feb2960-ed0e-4a43-8c0b-8c567b0969b1','Y',0,'N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:19:28 PM CEST
|
||||
ALTER TABLE AD_Package_Imp_Detail ADD COLUMN Result TEXT DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:01 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206751,'Execution Code',50004,214591,'Y',0,110,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-09-23 18:21:00','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-23 18:21:00','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','5da85957-d2ab-42e0-b8fc-fd7d11a49a07','Y',80,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:07 PM CEST
|
||||
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,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,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField,IsQuickForm) VALUES (206752,'Result','Result of the action taken','The Result indicates the result of any action taken on this request.',50004,214592,'Y',0,120,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-09-23 18:21:07','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-09-23 18:21:07','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','921e0126-c9a7-4029-beb8-930a95b64ef7','Y',90,1,1,1,'N','N','N','N')
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=5, NumLines=3, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206751
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ColumnSpan=5, NumLines=3, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206752
|
||||
;
|
||||
|
||||
-- Sep 23, 2021, 6:21:45 PM CEST
|
||||
UPDATE AD_Field SET SeqNo=0, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-09-23 18:21:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204550
|
||||
;
|
||||
|
||||
SELECT register_migration_script('202109171808_IDEMPIERE-4968.sql') FROM dual
|
||||
;
|
||||
|
|
@ -412,6 +412,15 @@ public interface I_AD_Package_Exp_Detail
|
|||
/** Get Destination_FileName */
|
||||
public String getDestination_FileName();
|
||||
|
||||
/** Column name ExecCode */
|
||||
public static final String COLUMNNAME_ExecCode = "ExecCode";
|
||||
|
||||
/** Set Execution Code */
|
||||
public void setExecCode (String ExecCode);
|
||||
|
||||
/** Get Execution Code */
|
||||
public String getExecCode();
|
||||
|
||||
/** Column name File_Directory */
|
||||
public static final String COLUMNNAME_File_Directory = "File_Directory";
|
||||
|
||||
|
|
|
@ -144,6 +144,15 @@ public interface I_AD_Package_Imp_Detail
|
|||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name ExecCode */
|
||||
public static final String COLUMNNAME_ExecCode = "ExecCode";
|
||||
|
||||
/** Set Execution Code */
|
||||
public void setExecCode (String ExecCode);
|
||||
|
||||
/** Get Execution Code */
|
||||
public String getExecCode();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
|
@ -183,6 +192,19 @@ public interface I_AD_Package_Imp_Detail
|
|||
*/
|
||||
public int getRecord_ID();
|
||||
|
||||
/** Column name Result */
|
||||
public static final String COLUMNNAME_Result = "Result";
|
||||
|
||||
/** Set Result.
|
||||
* Result of the action taken
|
||||
*/
|
||||
public void setResult (String Result);
|
||||
|
||||
/** Get Result.
|
||||
* Result of the action taken
|
||||
*/
|
||||
public String getResult();
|
||||
|
||||
/** Column name Success */
|
||||
public static final String COLUMNNAME_Success = "Success";
|
||||
|
||||
|
|
|
@ -87,10 +87,6 @@ public class MPackageExpDetail extends X_AD_Package_Exp_Detail
|
|||
String type = getType();
|
||||
if (TYPE_ApplicationOrModule.equals(type)) {
|
||||
return getAD_Menu_ID();
|
||||
} else if (TYPE_Data.equals(type)) {
|
||||
return 0;
|
||||
} else if (TYPE_DataSingle.equals(type)) {
|
||||
return 0;
|
||||
} else if (TYPE_DynamicValidationRule.equals(type)) {
|
||||
return getAD_Val_Rule_ID();
|
||||
} else if (TYPE_Form.equals(type)) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20210917L;
|
||||
private static final long serialVersionUID = 20210923L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Package_Exp_Detail (Properties ctx, int AD_Package_Exp_Detail_ID, String trxName)
|
||||
|
@ -735,6 +735,20 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta
|
|||
return (String)get_Value(COLUMNNAME_Destination_FileName);
|
||||
}
|
||||
|
||||
/** Set Execution Code.
|
||||
@param ExecCode Execution Code */
|
||||
public void setExecCode (String ExecCode)
|
||||
{
|
||||
set_Value (COLUMNNAME_ExecCode, ExecCode);
|
||||
}
|
||||
|
||||
/** Get Execution Code.
|
||||
@return Execution Code */
|
||||
public String getExecCode ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ExecCode);
|
||||
}
|
||||
|
||||
/** Set File_Directory.
|
||||
@param File_Directory File_Directory */
|
||||
public void setFile_Directory (String File_Directory)
|
||||
|
@ -920,8 +934,6 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta
|
|||
|
||||
/** Type AD_Reference_ID=50004 */
|
||||
public static final int TYPE_AD_Reference_ID=50004;
|
||||
/** Workbench = B */
|
||||
public static final String TYPE_Workbench = "B";
|
||||
/** Data = D */
|
||||
public static final String TYPE_Data = "D";
|
||||
/** Data Single = DS */
|
||||
|
@ -950,6 +962,10 @@ public class X_AD_Package_Exp_Detail extends PO implements I_AD_Package_Exp_Deta
|
|||
public static final String TYPE_Reference = "REF";
|
||||
/** Role = S */
|
||||
public static final String TYPE_Role = "S";
|
||||
/** Script JSR223 = SCJ */
|
||||
public static final String TYPE_ScriptJSR223 = "SCJ";
|
||||
/** Shell Script = SH */
|
||||
public static final String TYPE_ShellScript = "SH";
|
||||
/** SQL Statement = SQL */
|
||||
public static final String TYPE_SQLStatement = "SQL";
|
||||
/** SQL Mandatory = SQM */
|
||||
|
|
|
@ -30,7 +30,7 @@ public class X_AD_Package_Imp_Detail extends PO implements I_AD_Package_Imp_Deta
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20210917L;
|
||||
private static final long serialVersionUID = 20210923L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Package_Imp_Detail (Properties ctx, int AD_Package_Imp_Detail_ID, String trxName)
|
||||
|
@ -198,6 +198,20 @@ public class X_AD_Package_Imp_Detail extends PO implements I_AD_Package_Imp_Deta
|
|||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Execution Code.
|
||||
@param ExecCode Execution Code */
|
||||
public void setExecCode (String ExecCode)
|
||||
{
|
||||
set_Value (COLUMNNAME_ExecCode, ExecCode);
|
||||
}
|
||||
|
||||
/** Get Execution Code.
|
||||
@return Execution Code */
|
||||
public String getExecCode ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ExecCode);
|
||||
}
|
||||
|
||||
/** Set Name.
|
||||
@param Name
|
||||
Alphanumeric identifier of the entity
|
||||
|
@ -238,6 +252,23 @@ public class X_AD_Package_Imp_Detail extends PO implements I_AD_Package_Imp_Deta
|
|||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Result.
|
||||
@param Result
|
||||
Result of the action taken
|
||||
*/
|
||||
public void setResult (String Result)
|
||||
{
|
||||
set_ValueNoCheck (COLUMNNAME_Result, Result);
|
||||
}
|
||||
|
||||
/** Get Result.
|
||||
@return Result of the action taken
|
||||
*/
|
||||
public String getResult ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Result);
|
||||
}
|
||||
|
||||
/** Set Success.
|
||||
@param Success Success */
|
||||
public void setSuccess (String Success)
|
||||
|
|
|
@ -228,6 +228,14 @@
|
|||
class="org.adempiere.pipo2.handler.InfoWindowAccessElementHandler"
|
||||
id="AD_InfoWindow_Access">
|
||||
</handler>
|
||||
<handler
|
||||
class="org.adempiere.pipo2.handler.ShellScriptElementHandler"
|
||||
id="ShellScript">
|
||||
</handler>
|
||||
<handler
|
||||
class="org.adempiere.pipo2.handler.ScriptJSR223ElementHandler"
|
||||
id="ScriptJSR223">
|
||||
</handler>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -89,7 +89,7 @@ public class SQLMandatoryElementHandler extends AbstractElementHandler {
|
|||
stmt = null;
|
||||
}
|
||||
}
|
||||
logImportDetail (ctx, impDetail, 1, "SQLMandatory",count,"Execute");
|
||||
logImportDetail (ctx, impDetail, 1, "SQLMandatory",count,"Execute", sql, String.valueOf(count));
|
||||
ctx.packIn.getNotifier().addSuccessLine("-> " + sql);
|
||||
// Cache Reset when deleting records via SQL
|
||||
if (sql.toLowerCase().startsWith("delete from ")) {
|
||||
|
@ -102,7 +102,7 @@ public class SQLMandatoryElementHandler extends AbstractElementHandler {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
ctx.packIn.getNotifier().addFailureLine("SQL Mandatory failed, error (" + e.getLocalizedMessage() + "):");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLMandatory",-1,"Execute");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLMandatory",-1,"Execute", sql, e.getLocalizedMessage());
|
||||
ctx.packIn.getNotifier().addFailureLine("-> " + sql);
|
||||
log.log(Level.SEVERE,"SQLMandatory", e);
|
||||
throw new AdempiereException(e);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
|
|||
stmt = null;
|
||||
}
|
||||
}
|
||||
logImportDetail (ctx, impDetail, 1, "SQLStatement",count,"Execute");
|
||||
logImportDetail (ctx, impDetail, 1, "SQLStatement",count,"Execute", sql, String.valueOf(count));
|
||||
ctx.packIn.getNotifier().addSuccessLine("-> " + sql);
|
||||
// Cache Reset when deleting records via SQL
|
||||
if (sql.toLowerCase().startsWith("delete from ")) {
|
||||
|
@ -117,7 +117,7 @@ public class SQLStatementElementHandler extends AbstractElementHandler {
|
|||
savepoint = null;
|
||||
}
|
||||
ctx.packIn.getNotifier().addFailureLine("SQL statement failed but ignored, error (" + e.getLocalizedMessage() + "): ");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLStatement",-1,"Execute");
|
||||
logImportDetail (ctx, impDetail, 0, "SQLStatement",-1,"Execute", sql, e.getLocalizedMessage());
|
||||
ctx.packIn.getNotifier().addFailureLine("-> " + sql);
|
||||
log.log(Level.SEVERE,"SQLStatement", e);
|
||||
} finally {
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/***********************************************************************
|
||||
* 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: *
|
||||
* - Carlos Ruiz - globalqss *
|
||||
* Sponsored by FH *
|
||||
**********************************************************************/
|
||||
|
||||
package org.adempiere.pipo2.handler;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptException;
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.pipo2.AbstractElementHandler;
|
||||
import org.adempiere.pipo2.Element;
|
||||
import org.adempiere.pipo2.ElementHandler;
|
||||
import org.adempiere.pipo2.PIPOContext;
|
||||
import org.adempiere.pipo2.PackOut;
|
||||
import org.adempiere.pipo2.PackoutItem;
|
||||
import org.compiere.model.MPackageExpDetail;
|
||||
import org.compiere.model.MRule;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.util.Env;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class ScriptJSR223ElementHandler extends AbstractElementHandler implements ElementHandler {
|
||||
|
||||
private static final String SCRIPT_JSR223 = "ScriptJSR223";
|
||||
|
||||
@Override
|
||||
public void startElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, "", 0);
|
||||
|
||||
String script = getStringValue(element, SCRIPT_JSR223);
|
||||
|
||||
String engineName = "beanshell"; // the default
|
||||
if (script.contains("@script:")) {
|
||||
Pattern pattern = Pattern.compile(".*@script:\\b(.*)\\b.*");
|
||||
Matcher matcher = pattern.matcher(script);
|
||||
matcher.find();
|
||||
if (matcher.groupCount() > 0)
|
||||
engineName = matcher.group(1);
|
||||
}
|
||||
if (engineName == null ||
|
||||
(! (engineName.equals("groovy")
|
||||
|| engineName.equals("beanshell")))) {
|
||||
throw new AdempiereException("Script engine not supported, just groovy and beanshell");
|
||||
}
|
||||
ScriptEngine engine = Core.getScriptEngine(engineName);
|
||||
engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx.ctx);
|
||||
engine.put(MRule.ARGUMENTS_PREFIX + "Trx", ctx.trx);
|
||||
engine.put(MRule.ARGUMENTS_PREFIX + "TrxName", ctx.trx.getTrxName());
|
||||
engine.put(MRule.ARGUMENTS_PREFIX + "AD_Client_ID", Env.getAD_Client_ID(ctx.ctx));
|
||||
engine.put(MRule.ARGUMENTS_PREFIX + "AD_User_ID", Env.getAD_User_ID(ctx.ctx));
|
||||
|
||||
String msg = null;
|
||||
try {
|
||||
msg = engine.eval(script).toString();
|
||||
} catch (ScriptException e) {
|
||||
ctx.packIn.getNotifier().addFailureLine("Script JSR223 failed, error (" + e.getLocalizedMessage() + "):");
|
||||
logImportDetail(ctx, impDetail, 0, SCRIPT_JSR223, -1, "Execute", script, e.getLocalizedMessage() + "\n -> " + msg);
|
||||
ctx.packIn.getNotifier().addFailureLine("-> " + msg);
|
||||
log.log(Level.SEVERE, SCRIPT_JSR223, e);
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
|
||||
logImportDetail(ctx, impDetail, 1, SCRIPT_JSR223, 0, "Execute", script, msg);
|
||||
ctx.packIn.getNotifier().addSuccessLine("out -> " + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
}
|
||||
|
||||
public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
|
||||
String execCode = Env.getContext(ctx.ctx, MPackageExpDetail.COLUMNNAME_ExecCode);
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
addTypeName(atts, "custom");
|
||||
document.startElement("","",SCRIPT_JSR223,atts);
|
||||
createShellScriptBinding(document, execCode);
|
||||
document.endElement("","",SCRIPT_JSR223);
|
||||
}
|
||||
|
||||
private void createShellScriptBinding( TransformerHandler document, String execCode) throws SAXException {
|
||||
document.startElement("","",SCRIPT_JSR223, new AttributesImpl());
|
||||
char [] contents = execCode.toCharArray();
|
||||
document.startCDATA();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endCDATA();
|
||||
document.endElement("","",SCRIPT_JSR223);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId)
|
||||
throws Exception {
|
||||
PackoutItem detail = packout.getCurrentPackoutItem();
|
||||
Env.setContext(packout.getCtx().ctx, MPackageExpDetail.COLUMNNAME_ExecCode, (String)detail.getProperty(MPackageExpDetail.COLUMNNAME_ExecCode));
|
||||
this.create(packout.getCtx(), packoutHandler);
|
||||
packout.getCtx().ctx.remove(MPackageExpDetail.COLUMNNAME_ExecCode);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/***********************************************************************
|
||||
* 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: *
|
||||
* - Carlos Ruiz - globalqss *
|
||||
* Sponsored by FH *
|
||||
**********************************************************************/
|
||||
|
||||
package org.adempiere.pipo2.handler;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.xml.transform.sax.TransformerHandler;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.pipo2.AbstractElementHandler;
|
||||
import org.adempiere.pipo2.Element;
|
||||
import org.adempiere.pipo2.ElementHandler;
|
||||
import org.adempiere.pipo2.PIPOContext;
|
||||
import org.adempiere.pipo2.PackOut;
|
||||
import org.adempiere.pipo2.PackoutItem;
|
||||
import org.compiere.model.MPackageExpDetail;
|
||||
import org.compiere.model.X_AD_Package_Imp_Detail;
|
||||
import org.compiere.util.Env;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
public class ShellScriptElementHandler extends AbstractElementHandler implements ElementHandler {
|
||||
|
||||
private static final String SHELL_SCRIPT = "ShellScript";
|
||||
private Path m_tmpfile = null;
|
||||
|
||||
@Override
|
||||
public void startElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
String script = getStringValue(element, SHELL_SCRIPT);
|
||||
// create a temporary file with the contents of the script
|
||||
Set<PosixFilePermission> fp = PosixFilePermissions.fromString("rwx------");
|
||||
try {
|
||||
m_tmpfile = Files.createTempFile("2PackShellScript_", ".sh", PosixFilePermissions.asFileAttribute(fp));
|
||||
Files.write(m_tmpfile, script.getBytes());
|
||||
} catch (IOException e) {
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
|
||||
X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, "", 0);
|
||||
|
||||
// Execute temporary bash file
|
||||
int exitCode = -1;
|
||||
StringBuilder out = new StringBuilder();
|
||||
StringBuilder err = new StringBuilder();
|
||||
try {
|
||||
String line;
|
||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||
processBuilder.command(m_tmpfile.toString());
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||
// read the output from the command
|
||||
while ((line = stdInput.readLine()) != null)
|
||||
out.append(line);
|
||||
// read any errors from the attempted command
|
||||
while ((line = stdError.readLine()) != null)
|
||||
err.append(line);
|
||||
exitCode = process.waitFor();
|
||||
}
|
||||
catch (IOException | InterruptedException e) {
|
||||
ctx.packIn.getNotifier().addFailureLine("Shell Script failed, error (" + e.getLocalizedMessage() + "):");
|
||||
logImportDetail(ctx, impDetail, 0, SHELL_SCRIPT, exitCode, "Execute", script, e.getLocalizedMessage() + "\nout -> " + out.toString() + "\nerr -> " + err.toString());
|
||||
if (out.length() > 0) ctx.packIn.getNotifier().addFailureLine("out -> " + out.toString());
|
||||
if (err.length() > 0) ctx.packIn.getNotifier().addFailureLine("err -> " + err.toString());
|
||||
log.log(Level.SEVERE, SHELL_SCRIPT, e);
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
if (out.length() > 0 && log.isLoggable(Level.INFO)) log.info("Executed Shell Script with stdout: " + out.toString());
|
||||
if (err.length() > 0 && log.isLoggable(Level.WARNING)) log.warning("Executed Shell Script with stderr: " + err.toString());
|
||||
if (exitCode != 0) {
|
||||
logImportDetail(ctx, impDetail, 0, SHELL_SCRIPT, exitCode, "Execute", script, "exitCode -> " + exitCode + "\nout -> " + out.toString() + "\nerr -> " + err.toString());
|
||||
if (out.length() > 0) ctx.packIn.getNotifier().addFailureLine("out -> " + out.toString());
|
||||
if (err.length() > 0) ctx.packIn.getNotifier().addFailureLine("err -> " + err.toString());
|
||||
throw new AdempiereException("Failed execution of shell script");
|
||||
}
|
||||
logImportDetail(ctx, impDetail, 1, SHELL_SCRIPT, exitCode, "Execute", script, "exitCode -> " + exitCode + "\nout -> " + out.toString() + "\nerr -> " + err.toString());
|
||||
if (out.length() > 0) ctx.packIn.getNotifier().addSuccessLine("out -> " + out.toString());
|
||||
if (err.length() > 0) ctx.packIn.getNotifier().addSuccessLine("err -> " + err.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(PIPOContext ctx, Element element) throws SAXException {
|
||||
}
|
||||
|
||||
public void create(PIPOContext ctx, TransformerHandler document) throws SAXException {
|
||||
String execCode = Env.getContext(ctx.ctx, MPackageExpDetail.COLUMNNAME_ExecCode);
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
addTypeName(atts, "custom");
|
||||
document.startElement("","",SHELL_SCRIPT,atts);
|
||||
createShellScriptBinding(document, execCode);
|
||||
document.endElement("","",SHELL_SCRIPT);
|
||||
}
|
||||
|
||||
private void createShellScriptBinding( TransformerHandler document, String execCode) throws SAXException {
|
||||
document.startElement("","",SHELL_SCRIPT, new AttributesImpl());
|
||||
char [] contents = execCode.toCharArray();
|
||||
document.startCDATA();
|
||||
document.characters(contents,0,contents.length);
|
||||
document.endCDATA();
|
||||
document.endElement("","",SHELL_SCRIPT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler, int recordId)
|
||||
throws Exception {
|
||||
PackoutItem detail = packout.getCurrentPackoutItem();
|
||||
Env.setContext(packout.getCtx().ctx, MPackageExpDetail.COLUMNNAME_ExecCode, (String)detail.getProperty(MPackageExpDetail.COLUMNNAME_ExecCode));
|
||||
this.create(packout.getCtx(), packoutHandler);
|
||||
packout.getCtx().ctx.remove(MPackageExpDetail.COLUMNNAME_ExecCode);
|
||||
}
|
||||
|
||||
}
|
|
@ -93,11 +93,34 @@ public abstract class AbstractElementHandler implements ElementHandler {
|
|||
*/
|
||||
public void logImportDetail (PIPOContext ctx, X_AD_Package_Imp_Detail detail, int success, String objectName, int objectID,
|
||||
String action) throws SAXException{
|
||||
String result = success == 1 ? "Success" : "Failure";
|
||||
logImportDetail (ctx, detail, success, objectName, objectID, action, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write results to log and records in history table
|
||||
*
|
||||
* @param ctx
|
||||
* @param success
|
||||
* @param detail
|
||||
* @param objectName
|
||||
* @param objectID
|
||||
* @param action
|
||||
* @param execCode
|
||||
* @param result
|
||||
* @throws SAXException
|
||||
*
|
||||
*/
|
||||
public void logImportDetail (PIPOContext ctx, X_AD_Package_Imp_Detail detail, int success, String objectName, int objectID,
|
||||
String action, String execCode, String result) throws SAXException{
|
||||
String msgSuccess = success == 1 ? "Success" : "Failure";
|
||||
|
||||
detail.setName(objectName);
|
||||
detail.setAction(action);
|
||||
detail.setSuccess(result);
|
||||
detail.setSuccess(msgSuccess);
|
||||
if (execCode != null)
|
||||
detail.setExecCode(execCode);
|
||||
if (result != null)
|
||||
detail.setResult(result);
|
||||
if (objectID >= 0)
|
||||
detail.setRecord_ID(objectID);
|
||||
ctx.packIn.addImportDetail(detail);
|
||||
|
|
|
@ -196,6 +196,10 @@ public class PackOutProcess extends SvrProcess
|
|||
return I_AD_EntityType.Table_Name;
|
||||
else if (X_AD_Package_Exp_Detail.TYPE_InfoWindow.equals(type))
|
||||
return I_AD_InfoWindow.Table_Name;
|
||||
else if (X_AD_Package_Exp_Detail.TYPE_ShellScript.equals(type))
|
||||
return "ShellScript";
|
||||
else if (X_AD_Package_Exp_Detail.TYPE_ScriptJSR223.equals(type))
|
||||
return "ScriptJSR223";
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -208,6 +212,8 @@ public class PackOutProcess extends SvrProcess
|
|||
} else if (MPackageExpDetail.TYPE_SQLStatement.equals(type) || MPackageExpDetail.TYPE_SQLMandatory.equals(type)) {
|
||||
properties.put(SQLElementParameters.SQL_STATEMENT, dtl.getSQLStatement());
|
||||
properties.put(SQLElementParameters.DB_TYPE, dtl.getDBType());
|
||||
} else if (MPackageExpDetail.TYPE_ShellScript.equals(type) || MPackageExpDetail.TYPE_ScriptJSR223.equals(type)) {
|
||||
properties.put(MPackageExpDetail.COLUMNNAME_ExecCode, dtl.getExecCode());
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue