From a1d58852ed86bc1f146e4988384ff624fa54ff4a Mon Sep 17 00:00:00 2001 From: PeterTakacs300 <93127072+PeterTakacs300@users.noreply.github.com> Date: Thu, 31 Mar 2022 14:59:45 +0200 Subject: [PATCH] IDEMPIERE-4753 Make printing filename configurable (#1251) * IDEMPIERE-4753 Make printing filename configurable * IDEMPIERE-4753 - Jasper report * IDEMPIERE-4753 - fix NPE --- .../oracle/202203151632_IDEMPIERE-4753.sql | 86 +++++++++++++++++++ .../202203151632_IDEMPIERE-4753.sql | 83 ++++++++++++++++++ .../org/compiere/model/I_AD_PrintFormat.java | 19 ++-- .../src/org/compiere/model/I_AD_Process.java | 45 ++++++---- .../org/compiere/model/X_AD_PrintFormat.java | 19 +++- .../src/org/compiere/model/X_AD_Process.java | 85 ++++++++++-------- .../src/org/compiere/print/ReportEngine.java | 50 +++++++++-- .../org/compiere/print/ServerReportCtl.java | 2 + .../src/org/compiere/tools/FileUtil.java | 76 +++++++++++++++- .../report/jasper/ReportStarter.java | 12 ++- .../webui/desktop/DashboardController.java | 3 +- .../webui/window/ZkReportViewer.java | 10 +-- 12 files changed, 413 insertions(+), 77 deletions(-) create mode 100644 migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql create mode 100644 migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql diff --git a/migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql b/migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql new file mode 100644 index 0000000000..81fd766bb7 --- /dev/null +++ b/migration/iD10/oracle/202203151632_IDEMPIERE-4753.sql @@ -0,0 +1,86 @@ +-- IDEMPIERE-4753 + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jun 2, 2021, 12:04:43 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203512,0,0,'Y',TO_DATE('2021-06-02 12:04:43','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-02 12:04:43','YYYY-MM-DD HH24:MI:SS'),100,'FileNamePattern','File Name Pattern','File Name Pattern','D','09e87361-0597-43b4-9378-8afa29bc83ed') +; + +-- Jun 2, 2021, 12:10:55 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 (214497,0,'File Name Pattern',493,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2021-06-02 12:10:55','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-02 12:10:55','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','N','D','N','N','N','Y','7bc2b0a2-c57f-41ae-b287-711dbeaa9192','Y',0,'N','N','N','N') +; + +-- Jun 2, 2021, 12:10:59 PM CEST +ALTER TABLE AD_PrintFormat ADD FileNamePattern VARCHAR2(255 CHAR) DEFAULT NULL +; + +-- Jun 2, 2021, 12:11:48 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 (214498,0,'File Name Pattern',284,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2021-06-02 12:11:47','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-02 12:11:47','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','N','D','N','N','N','Y','b04cde1b-4791-4e5d-a270-ad1e526f77a0','Y',0,'N','N','N','N') +; + +-- Jun 2, 2021, 12:11:51 PM CEST +ALTER TABLE AD_Process ADD FileNamePattern VARCHAR2(255 CHAR) DEFAULT NULL +; + +-- Jun 2, 2021, 12:12:27 PM CEST +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 (206663,'File Name Pattern',425,214497,'Y',255,260,'N','N','N','N',0,0,'Y',TO_DATE('2021-06-02 12:12:26','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-02 12:12:26','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','0a554010-53a1-4b18-b66f-9333f72960f7','Y',260,5) +; + +-- Jun 2, 2021, 12:13:21 PM CEST +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 (206664,'File Name Pattern',245,214498,'Y',255,280,'N','N','N','N',0,0,'Y',TO_DATE('2021-06-02 12:13:21','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-06-02 12:13:21','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','79eafd94-0fa6-4419-908c-1781f5edea58','Y',250,5) +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3703 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2534 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10235 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56497 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3278 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3219 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5849 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206664 +; + +-- Mar 15, 2022, 4:32:32 PM CET +UPDATE AD_Column SET IsTranslated='Y',Updated=TO_TIMESTAMP('2022-03-15 16:32:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214497 +; + +-- Mar 15, 2022, 4:32:50 PM CET +ALTER TABLE AD_PrintFormat MODIFY FileNamePattern VARCHAR2(255 CHAR) DEFAULT NULL +; + +-- Mar 15, 2022, 4:36:11 PM CET +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 (214714,0,'File Name Pattern',200130,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2022-03-15 16:36:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-15 16:36:11','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','Y','D','N','N','N','Y','b60bf16e-e25c-42cb-95ba-9fc88bd3eb0d','Y',10,'N','N','N','N') +; + +-- Mar 16, 2022, 8:16:42 AM CET +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 (206916,'File Name Pattern',200143,214714,'Y',0,90,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-03-16 08:16:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-16 08:16:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','269e9f00-8ed2-4887-afc0-aee484f4ade6','Y',80,1,1,1,'N','N','N','N') +; + +-- Mar 16, 2022, 8:22:24 AM CET +ALTER TABLE AD_PrintFormat_Trl ADD FileNamePattern VARCHAR2(255 CHAR) DEFAULT NULL +; + +SELECT register_migration_script('202203151632_IDEMPIERE-4753.sql') FROM dual; diff --git a/migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql b/migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql new file mode 100644 index 0000000000..e103ca7754 --- /dev/null +++ b/migration/iD10/postgresql/202203151632_IDEMPIERE-4753.sql @@ -0,0 +1,83 @@ +-- IDEMPIERE-4753 + +-- Jun 2, 2021, 12:04:43 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203512,0,0,'Y',TO_TIMESTAMP('2021-06-02 12:04:43','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-02 12:04:43','YYYY-MM-DD HH24:MI:SS'),100,'FileNamePattern','File Name Pattern','File Name Pattern','D','09e87361-0597-43b4-9378-8afa29bc83ed') +; + +-- Jun 2, 2021, 12:10:55 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 (214497,0,'File Name Pattern',493,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2021-06-02 12:10:55','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-02 12:10:55','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','N','D','N','N','N','Y','7bc2b0a2-c57f-41ae-b287-711dbeaa9192','Y',0,'N','N','N','N') +; + +-- Jun 2, 2021, 12:10:59 PM CEST +ALTER TABLE AD_PrintFormat ADD COLUMN FileNamePattern VARCHAR(255) DEFAULT NULL +; + +-- Jun 2, 2021, 12:11:48 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 (214498,0,'File Name Pattern',284,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2021-06-02 12:11:47','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-02 12:11:47','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','N','D','N','N','N','Y','b04cde1b-4791-4e5d-a270-ad1e526f77a0','Y',0,'N','N','N','N') +; + +-- Jun 2, 2021, 12:11:51 PM CEST +ALTER TABLE AD_Process ADD COLUMN FileNamePattern VARCHAR(255) DEFAULT NULL +; + +-- Jun 2, 2021, 12:12:27 PM CEST +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 (206663,'File Name Pattern',425,214497,'Y',255,260,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-06-02 12:12:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-02 12:12:26','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','0a554010-53a1-4b18-b66f-9333f72960f7','Y',260,5) +; + +-- Jun 2, 2021, 12:13:21 PM CEST +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 (206664,'File Name Pattern',245,214498,'Y',255,280,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2021-06-02 12:13:21','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-06-02 12:13:21','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','79eafd94-0fa6-4419-908c-1781f5edea58','Y',250,5) +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3703 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2534 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10235 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=170, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56497 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=180, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3278 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=190, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=3219 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET SeqNo=200, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5849 +; + +-- Jun 2, 2021, 12:13:59 PM CEST +UPDATE AD_Field SET IsDisplayed='Y', SeqNo=210, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-06-02 12:13:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206664 +; + +-- Mar 15, 2022, 4:32:32 PM CET +UPDATE AD_Column SET IsTranslated='Y',Updated=TO_TIMESTAMP('2022-03-15 16:32:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=214497 +; + +-- Mar 15, 2022, 4:32:50 PM CET +INSERT INTO t_alter_column values('ad_printformat','FileNamePattern','VARCHAR(255)',null,'NULL') +; + +-- Mar 15, 2022, 4:36:11 PM CET +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 (214714,0,'File Name Pattern',200130,'FileNamePattern',255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2022-03-15 16:36:11','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-15 16:36:11','YYYY-MM-DD HH24:MI:SS'),100,203512,'Y','Y','D','N','N','N','Y','b60bf16e-e25c-42cb-95ba-9fc88bd3eb0d','Y',10,'N','N','N','N') +; + +-- Mar 16, 2022, 8:16:42 AM CET +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 (206916,'File Name Pattern',200143,214714,'Y',0,90,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2022-03-16 08:16:42','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2022-03-16 08:16:42','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','269e9f00-8ed2-4887-afc0-aee484f4ade6','Y',80,1,1,1,'N','N','N','N') +; + +-- Mar 16, 2022, 8:22:24 AM CET +ALTER TABLE AD_PrintFormat_Trl ADD COLUMN FileNamePattern VARCHAR(255) DEFAULT NULL +; + +SELECT register_migration_script('202203151632_IDEMPIERE-4753.sql') FROM dual; diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormat.java b/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormat.java index ebaf2cd01c..b96036308f 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormat.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormat.java @@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair; /** Generated Interface for AD_PrintFormat * @author iDempiere (generated) - * @version Release 9 + * @version Release 10 */ public interface I_AD_PrintFormat { @@ -44,8 +44,8 @@ public interface I_AD_PrintFormat /** Column name AD_Client_ID */ public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; - /** Get Client. - * Client/Tenant for this installation. + /** Get Tenant. + * Tenant for this installation. */ public int getAD_Client_ID(); @@ -53,12 +53,12 @@ public interface I_AD_PrintFormat public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; /** Set Organization. - * Organizational entity within client + * Organizational entity within tenant */ public void setAD_Org_ID (int AD_Org_ID); /** Get Organization. - * Organizational entity within client + * Organizational entity within tenant */ public int getAD_Org_ID(); @@ -238,6 +238,15 @@ public interface I_AD_PrintFormat */ public String getDescription(); + /** Column name FileNamePattern */ + public static final String COLUMNNAME_FileNamePattern = "FileNamePattern"; + + /** Set File Name Pattern */ + public void setFileNamePattern (String FileNamePattern); + + /** Get File Name Pattern */ + public String getFileNamePattern(); + /** Column name FooterMargin */ public static final String COLUMNNAME_FooterMargin = "FooterMargin"; diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_Process.java b/org.adempiere.base/src/org/compiere/model/I_AD_Process.java index 51dc69c698..cc80696d8f 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_Process.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_Process.java @@ -22,7 +22,7 @@ import org.compiere.util.KeyNamePair; /** Generated Interface for AD_Process * @author iDempiere (generated) - * @version Release 9 + * @version Release 10 */ public interface I_AD_Process { @@ -41,24 +41,11 @@ public interface I_AD_Process /** Load Meta Data */ - /** Column name AccessLevel */ - public static final String COLUMNNAME_AccessLevel = "AccessLevel"; - - /** Set Data Access Level. - * Access Level required - */ - public void setAccessLevel (String AccessLevel); - - /** Get Data Access Level. - * Access Level required - */ - public String getAccessLevel(); - /** Column name AD_Client_ID */ public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; - /** Get Client. - * Client/Tenant for this installation. + /** Get Tenant. + * Tenant for this installation. */ public int getAD_Client_ID(); @@ -92,12 +79,12 @@ public interface I_AD_Process public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; /** Set Organization. - * Organizational entity within client + * Organizational entity within tenant */ public void setAD_Org_ID (int AD_Org_ID); /** Get Organization. - * Organizational entity within client + * Organizational entity within tenant */ public int getAD_Org_ID(); @@ -168,6 +155,19 @@ public interface I_AD_Process public org.compiere.model.I_AD_Workflow getAD_Workflow() throws RuntimeException; + /** Column name AccessLevel */ + public static final String COLUMNNAME_AccessLevel = "AccessLevel"; + + /** Set Data Access Level. + * Access Level required + */ + public void setAccessLevel (String AccessLevel); + + /** Get Data Access Level. + * Access Level required + */ + public String getAccessLevel(); + /** Column name AllowMultipleExecution */ public static final String COLUMNNAME_AllowMultipleExecution = "AllowMultipleExecution"; @@ -264,6 +264,15 @@ public interface I_AD_Process */ public String getExecutionType(); + /** Column name FileNamePattern */ + public static final String COLUMNNAME_FileNamePattern = "FileNamePattern"; + + /** Set File Name Pattern */ + public void setFileNamePattern (String FileNamePattern); + + /** Get File Name Pattern */ + public String getFileNamePattern(); + /** Column name Help */ public static final String COLUMNNAME_Help = "Help"; diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormat.java b/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormat.java index eb63fe823e..a42df963be 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormat.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormat.java @@ -23,7 +23,7 @@ import org.compiere.util.KeyNamePair; /** Generated Model for AD_PrintFormat * @author iDempiere (generated) - * @version Release 9 - $Id$ */ + * @version Release 10 - $Id$ */ @org.adempiere.base.Model(table="AD_PrintFormat") public class X_AD_PrintFormat extends PO implements I_AD_PrintFormat, I_Persistent { @@ -31,7 +31,7 @@ public class X_AD_PrintFormat extends PO implements I_AD_PrintFormat, I_Persiste /** * */ - private static final long serialVersionUID = 20220116L; + private static final long serialVersionUID = 20220315L; /** Standard Constructor */ public X_AD_PrintFormat (Properties ctx, int AD_PrintFormat_ID, String trxName) @@ -404,6 +404,21 @@ public class X_AD_PrintFormat extends PO implements I_AD_PrintFormat, I_Persiste return (String)get_Value(COLUMNNAME_Description); } + /** Set File Name Pattern. + @param FileNamePattern File Name Pattern + */ + public void setFileNamePattern (String FileNamePattern) + { + set_Value (COLUMNNAME_FileNamePattern, FileNamePattern); + } + + /** Get File Name Pattern. + @return File Name Pattern */ + public String getFileNamePattern() + { + return (String)get_Value(COLUMNNAME_FileNamePattern); + } + /** Set Footer Margin. @param FooterMargin Margin of the Footer in 1/72 of an inch */ diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_Process.java b/org.adempiere.base/src/org/compiere/model/X_AD_Process.java index 83621dbaa3..2491aaf52c 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_Process.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_Process.java @@ -23,7 +23,7 @@ import org.compiere.util.KeyNamePair; /** Generated Model for AD_Process * @author iDempiere (generated) - * @version Release 9 - $Id$ */ + * @version Release 10 - $Id$ */ @org.adempiere.base.Model(table="AD_Process") public class X_AD_Process extends PO implements I_AD_Process, I_Persistent { @@ -31,7 +31,7 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent /** * */ - private static final long serialVersionUID = 20220116L; + private static final long serialVersionUID = 20220315L; /** Standard Constructor */ public X_AD_Process (Properties ctx, int AD_Process_ID, String trxName) @@ -39,8 +39,8 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent super (ctx, AD_Process_ID, trxName); /** if (AD_Process_ID == 0) { - setAccessLevel (null); setAD_Process_ID (0); + setAccessLevel (null); setEntityType (null); // @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual setIsBetaFunctionality (false); @@ -56,8 +56,8 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent super (ctx, AD_Process_ID, trxName, virtualColumns); /** if (AD_Process_ID == 0) { - setAccessLevel (null); setAD_Process_ID (0); + setAccessLevel (null); setEntityType (null); // @SQL=SELECT CASE WHEN '@P|AdempiereSys:N@'='Y' THEN 'D' ELSE get_sysconfig('DEFAULT_ENTITYTYPE','U',0,0) END FROM Dual setIsBetaFunctionality (false); @@ -95,37 +95,6 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent return sb.toString(); } - /** AccessLevel AD_Reference_ID=5 */ - public static final int ACCESSLEVEL_AD_Reference_ID=5; - /** Organization = 1 */ - public static final String ACCESSLEVEL_Organization = "1"; - /** Client only = 2 */ - public static final String ACCESSLEVEL_ClientOnly = "2"; - /** Client+Organization = 3 */ - public static final String ACCESSLEVEL_ClientPlusOrganization = "3"; - /** System only = 4 */ - public static final String ACCESSLEVEL_SystemOnly = "4"; - /** System+Client = 6 */ - public static final String ACCESSLEVEL_SystemPlusClient = "6"; - /** All = 7 */ - public static final String ACCESSLEVEL_All = "7"; - /** Set Data Access Level. - @param AccessLevel Access Level required - */ - public void setAccessLevel (String AccessLevel) - { - - set_Value (COLUMNNAME_AccessLevel, AccessLevel); - } - - /** Get Data Access Level. - @return Access Level required - */ - public String getAccessLevel() - { - return (String)get_Value(COLUMNNAME_AccessLevel); - } - public org.compiere.model.I_AD_CtxHelp getAD_CtxHelp() throws RuntimeException { return (org.compiere.model.I_AD_CtxHelp)MTable.get(getCtx(), org.compiere.model.I_AD_CtxHelp.Table_ID) @@ -302,6 +271,37 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent return ii.intValue(); } + /** AccessLevel AD_Reference_ID=5 */ + public static final int ACCESSLEVEL_AD_Reference_ID=5; + /** Organization = 1 */ + public static final String ACCESSLEVEL_Organization = "1"; + /** Client only = 2 */ + public static final String ACCESSLEVEL_ClientOnly = "2"; + /** Client+Organization = 3 */ + public static final String ACCESSLEVEL_ClientPlusOrganization = "3"; + /** System only = 4 */ + public static final String ACCESSLEVEL_SystemOnly = "4"; + /** System+Client = 6 */ + public static final String ACCESSLEVEL_SystemPlusClient = "6"; + /** All = 7 */ + public static final String ACCESSLEVEL_All = "7"; + /** Set Data Access Level. + @param AccessLevel Access Level required + */ + public void setAccessLevel (String AccessLevel) + { + + set_Value (COLUMNNAME_AccessLevel, AccessLevel); + } + + /** Get Data Access Level. + @return Access Level required + */ + public String getAccessLevel() + { + return (String)get_Value(COLUMNNAME_AccessLevel); + } + /** AllowMultipleExecution AD_Reference_ID=200158 */ public static final int ALLOWMULTIPLEEXECUTION_AD_Reference_ID=200158; /** Disallow multiple executions = N */ @@ -415,6 +415,21 @@ public class X_AD_Process extends PO implements I_AD_Process, I_Persistent return (String)get_Value(COLUMNNAME_ExecutionType); } + /** Set File Name Pattern. + @param FileNamePattern File Name Pattern + */ + public void setFileNamePattern (String FileNamePattern) + { + set_Value (COLUMNNAME_FileNamePattern, FileNamePattern); + } + + /** Get File Name Pattern. + @return File Name Pattern */ + public String getFileNamePattern() + { + return (String)get_Value(COLUMNNAME_FileNamePattern); + } + /** Set Comment/Help. @param Help Comment or Hint */ diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index e71eb4a828..7cfdfab408 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -39,7 +39,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -100,6 +102,7 @@ import org.compiere.print.layout.PrintDataEvaluatee; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoParameter; import org.compiere.process.ServerProcessCtl; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; @@ -199,6 +202,7 @@ public class ReportEngine implements PrintServiceAttributeListener m_printFormat = pf; m_info = info; m_trxName = trxName; + initName(); setQuery(query); // loads Data } // ReportEngine @@ -232,6 +236,8 @@ public class ReportEngine implements PrintServiceAttributeListener private boolean m_summary = false; + private String m_name = null; + /** * store all column has same css rule into a list * for IDEMPIERE-2640 @@ -364,13 +370,43 @@ public class ReportEngine implements PrintServiceAttributeListener return m_layout; } // getLayout + /** + * Initialize Report Name + */ + public void initName() + { + Language language = m_printFormat.getLanguage(); + String processFileNamePattern = m_printFormat.get_Translation("FileNamePattern", language.getAD_Language()); + if (m_info.getAD_Process_ID()>0) { + MProcess process = new MProcess(Env.getCtx(), m_info.getAD_Process_ID(), m_trxName); + if (process !=null && !Util.isEmpty(process.getFileNamePattern())) { + processFileNamePattern = process.getFileNamePattern(); + } + } + + if(Util.isEmpty(processFileNamePattern)) { + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String dt = sdf.format(cal.getTime()); + + m_name = m_printFormat.get_Translation("Name") + "_" + dt; + + + } else { + m_name = FileUtil.parseTitle(m_ctx, processFileNamePattern, m_info.getAD_Table_ID(), m_info.getRecord_ID(), m_windowNo, m_trxName); + } + } // initName + /** * Get PrintFormat (Report) Name * @return name */ public String getName() { - return m_printFormat.get_Translation("Name"); + if (m_name==null) + initName(); + return m_name; } // getName /** @@ -1422,7 +1458,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile (makePrefix(getName()), ".pdf"); + file = FileUtil.createTempFile (makePrefix(getName()), ".pdf"); } catch (IOException e) { @@ -1453,7 +1489,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile (makePrefix(getName()), ".html"); + file = FileUtil.createTempFile (makePrefix(getName()), ".html"); } catch (IOException e) { @@ -1484,7 +1520,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile (makePrefix(getName()), ".csv"); + file = FileUtil.createTempFile (makePrefix(getName()), ".csv"); } catch (IOException e) { @@ -1515,7 +1551,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile (makePrefix(getName()), ".xls"); + file = FileUtil.createTempFile (makePrefix(getName()), ".xls"); } catch (IOException e) { @@ -1553,7 +1589,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile (makePrefix(getName()), ".xlsx"); + file = FileUtil.createTempFile (makePrefix(getName()), ".xlsx"); } catch (IOException e) { @@ -1584,7 +1620,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) try { if (file == null) - file = File.createTempFile ("ReportEngine", ".pdf"); + file = FileUtil.createTempFile ("ReportEngine", ".pdf"); fileName = file.getAbsolutePath(); uri = file.toURI(); if (file.exists()) diff --git a/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java b/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java index 9d3c20d0c6..7fe3e90d6f 100644 --- a/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java +++ b/org.adempiere.base/src/org/compiere/print/ServerReportCtl.java @@ -158,6 +158,7 @@ public class ServerReportCtl { public static boolean runJasperProcess(int Record_ID, ReportEngine re, boolean IsDirectPrint, String printerName, ProcessInfo pi) { MPrintFormat format = re.getPrintFormat(); ProcessInfo jasperProcessInfo = new ProcessInfo ("", format.getJasperProcess_ID()); + PrintInfo printInfo = re.getPrintInfo(); if (pi != null) { jasperProcessInfo.setPrintPreview(pi.isPrintPreview()); jasperProcessInfo.setIsBatch(pi.isBatch()); @@ -165,6 +166,7 @@ public class ServerReportCtl { jasperProcessInfo.setPrintPreview( !IsDirectPrint ); } jasperProcessInfo.setRecord_ID ( Record_ID ); + jasperProcessInfo.setTable_ID(printInfo.getAD_Table_ID()); ArrayList jasperPrintParams = new ArrayList(); ProcessInfoParameter pip; if (printerName!=null && printerName.trim().length()>0) { diff --git a/org.adempiere.base/src/org/compiere/tools/FileUtil.java b/org.adempiere.base/src/org/compiere/tools/FileUtil.java index 90f006d378..55c162f133 100644 --- a/org.adempiere.base/src/org/compiere/tools/FileUtil.java +++ b/org.adempiere.base/src/org/compiere/tools/FileUtil.java @@ -32,9 +32,13 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Properties; import org.adempiere.exceptions.AdempiereException; +import org.adempiere.model.GenericPO; import org.compiere.model.MAttachment; +import org.compiere.model.MTable; +import org.compiere.model.PO; import org.compiere.util.Env; import org.compiere.util.Util; @@ -431,12 +435,78 @@ public class FileUtil SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String dt = sdf.format(cal.getTime()); String cleanName = subject.replaceAll("[ &/]", ""); - String localFile = System.getProperty("java.io.tmpdir") - + System.getProperty("file.separator") + cleanName + "_" + dt + "_" + Env.getContext(Env.getCtx(), Env.AD_SESSION_ID) - + extension; + String dir = System.getProperty("java.io.tmpdir") + + System.getProperty("file.separator") + "rpttmp_" + dt + "_" + Env.getContext(Env.getCtx(), Env.AD_SESSION_ID) + System.getProperty("file.separator"); + String localFile = dir + + cleanName + extension; + new File(dir ).mkdirs(); return localFile; } + /** + * + * @param title + * @param table_ID + * @param record_ID + * @param ctx + * @param m_WindowNo + * @param trxName + * @return + */ + public static String parseTitle(Properties ctx, String title, int table_ID, int record_ID, int m_WindowNo, String trxName) { + if (title.contains("@") && record_ID>0 && table_ID>0) { + MTable table=new MTable(ctx,table_ID,trxName ); + PO po = new GenericPO(table.getTableName(), ctx, record_ID, trxName); + title=Env.parseVariable(title, po, trxName, true); + } + else + title= Env.parseContext (ctx, m_WindowNo, title, + true, true); + return title; + } + + public static File createTempFile(String prefix, String suffix, File directory) throws IOException + { + if (prefix.length() < 3) { + throw new IllegalArgumentException("Prefix string \"" + prefix + + "\" too short: length must be at least 3"); + } + if (suffix == null) + suffix = ".tmp"; + + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String dt = sdf.format(cal.getTime()); + String tmpdirname = (directory != null) ? directory.getCanonicalPath() : System.getProperty("java.io.tmpdir"); + tmpdirname += System.getProperty("file.separator") + "rpttmp_" + dt + "_" + Env.getContext(Env.getCtx(), Env.AD_SESSION_ID) + System.getProperty("file.separator"); + + File tmpdir = new File(tmpdirname); + tmpdir.mkdirs(); + + String fileName = prefix + suffix; + + SecurityManager sm = System.getSecurityManager(); + File f = new File(tmpdirname, fileName); + + if (sm != null) { + try { + sm.checkWrite(f.getPath()); + } catch (SecurityException se) { + // don't reveal temporary directory location + if (directory == null) + throw new SecurityException("Unable to create temporary file"); + throw se; + } + } + + return f; + } + + public static File createTempFile(String prefix, String suffix) throws IOException + { + return createTempFile(prefix, suffix, null); + } + /** * * @param path diff --git a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java index 8031b0ad81..0b1b55a88c 100644 --- a/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java +++ b/org.adempiere.report.jasper/src/org/adempiere/report/jasper/ReportStarter.java @@ -64,6 +64,7 @@ import org.compiere.process.ClientProcess; import org.compiere.process.ProcessCall; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoParameter; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -394,7 +395,15 @@ public class ReportStarter implements ProcessCall, ClientProcess printerName = printFormat.getPrinterName(); } } - + if (pi.getAD_Process_ID()>0) { + MProcess process = new MProcess(Env.getCtx(), processInfo.getAD_Process_ID(), processInfo.getTransactionName()); + Language language = printFormat.getLanguage(); + String processFileNamePattern = printFormat.get_Translation("FileNamePattern", language.getAD_Language()); + if (process !=null && !Util.isEmpty(processFileNamePattern)) { + String filename=FileUtil.parseTitle(Env.getCtx(), processFileNamePattern, pi.getTable_ID(), Record_ID, 0, trxName); + pi.setTitle(filename); + } + } params.put(CURRENT_LANG, currLang.getAD_Language()); params.put(JRParameter.REPORT_LOCALE, currLang.getLocale()); params.put(COLUMN_LOOKUP, new ColumnLookup(currLang)); @@ -443,6 +452,7 @@ public class ReportStarter implements ProcessCall, ClientProcess params.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); JRBaseFiller filler = JRFiller.createFiller(jasperReportContext, jasperReport); JasperPrint jasperPrint = filler.fill(params, conn); + jasperPrint.setName(pi.getTitle()); recordCounts = filler.getVariableValue(JRVariable.REPORT_COUNT); if (!processInfo.isExport()) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java index 314e7bd2ba..a7c915411e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DashboardController.java @@ -64,6 +64,7 @@ import org.compiere.model.MProcessPara; import org.compiere.model.MSysConfig; import org.compiere.print.ReportEngine; import org.compiere.process.ProcessInfo; +import org.compiere.tools.FileUtil; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; @@ -888,7 +889,7 @@ public class DashboardController implements EventListener { public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception { ReportEngine re = runReport(AD_Process_ID, parameters); - File file = File.createTempFile(re.getName(), ".html"); + File file = FileUtil.createTempFile(re.getName(), ".html"); re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", SessionManager.getAppDesktop().getComponent().getUuid())); return new AMedia(re.getName(), "html", "text/html", file, false); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 31dd97bb37..baa4d4ae48 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -275,7 +275,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab if (prefix.length() < 3) prefix += "_".repeat(3-prefix.length()); if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "Path="+path + " Prefix="+prefix); - File file = File.createTempFile(prefix, "."+PDF_FILE_EXT, new File(path)); + File file = FileUtil.createTempFile(prefix, "."+PDF_FILE_EXT, new File(path)); m_reportEngine.createPDF(file); return new AMedia(file.getName(), PDF_FILE_EXT, PDF_MIME_TYPE, file, true); } catch (Exception e) { @@ -293,7 +293,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab if (prefix.length() < 3) prefix += "_".repeat(3-prefix.length()); if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "Path="+path + " Prefix="+prefix); - File file = File.createTempFile(prefix, "."+HTML_FILE_EXT, new File(path)); + File file = FileUtil.createTempFile(prefix, "."+HTML_FILE_EXT, new File(path)); String contextPath = Executions.getCurrent().getContextPath(); m_reportEngine.createHTML(file, false, m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextPath, "rp", getUuid())); return new AMedia(file.getName(), HTML_FILE_EXT, HTML_MIME_TYPE, file, false); @@ -312,7 +312,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab if (prefix.length() < 3) prefix += "_".repeat(3-prefix.length()); if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "Path="+path + " Prefix="+prefix); - File file = File.createTempFile(prefix, "."+EXCEL_FILE_EXT, new File(path)); + File file = FileUtil.createTempFile(prefix, "."+EXCEL_FILE_EXT, new File(path)); m_reportEngine.createXLS(file, m_reportEngine.getPrintFormat().getLanguage()); return new AMedia(file.getName(), EXCEL_FILE_EXT, EXCEL_MIME_TYPE, file, true); } catch (Exception e) { @@ -331,7 +331,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab { log.log(Level.FINE, "Path="+path + " Prefix="+prefix); } - File file = File.createTempFile(prefix, "."+CSV_FILE_EXT, new File(path)); + File file = FileUtil.createTempFile(prefix, "."+CSV_FILE_EXT, new File(path)); m_reportEngine.createCSV(file, ',', AEnv.getLanguage(Env.getCtx())); return new AMedia(file.getName(), CSV_FILE_EXT, CSV_MIME_TYPE, file, false); } catch (Exception e) { @@ -350,7 +350,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab { log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix); } - File file = File.createTempFile(prefix, "."+EXCEL_XML_FILE_EXT, new File(path)); + File file = FileUtil.createTempFile(prefix, "."+EXCEL_XML_FILE_EXT, new File(path)); m_reportEngine.createXLSX(file, m_reportEngine.getPrintFormat().getLanguage()); return new AMedia(file.getName(), EXCEL_XML_FILE_EXT, EXCEL_XML_MIME_TYPE, file, true); } catch (Exception e) {