diff --git a/.classpath b/.classpath index a81a7e3bad..0c7ff55404 100644 --- a/.classpath +++ b/.classpath @@ -138,5 +138,6 @@ + diff --git a/base/.classpath b/base/.classpath index 5614471424..60ef3fcef5 100644 --- a/base/.classpath +++ b/base/.classpath @@ -23,6 +23,7 @@ + diff --git a/base/build.xml b/base/build.xml index 5112f12526..c1a02a9fda 100644 --- a/base/build.xml +++ b/base/build.xml @@ -31,6 +31,7 @@ + diff --git a/base/src/org/compiere/model/AdempiereProcessor2.java b/base/src/org/compiere/model/AdempiereProcessor2.java new file mode 100644 index 0000000000..3b3d17dbf6 --- /dev/null +++ b/base/src/org/compiere/model/AdempiereProcessor2.java @@ -0,0 +1,28 @@ +/****************************************************************************** + * Copyright (C) 2010 Low Heng Sin * + * Copyright (C) 2010 Idalica Corporation * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.compiere.model; + +/** + * + * @author hengsin + * + */ +public interface AdempiereProcessor2 { + /** + * @return true if previous DateNextRun should be use as base to calculate the new + * DateNextRun value. False to follow the legacy behaviour where current + * server time is use as the base to the new DateNextRun value. + */ + public boolean isIgnoreProcessingTime(); +} diff --git a/base/src/org/compiere/model/I_AD_Scheduler.java b/base/src/org/compiere/model/I_AD_Scheduler.java index d7e50513d4..d5dc593a02 100644 --- a/base/src/org/compiere/model/I_AD_Scheduler.java +++ b/base/src/org/compiere/model/I_AD_Scheduler.java @@ -106,6 +106,19 @@ public interface I_AD_Scheduler */ public int getCreatedBy(); + /** Column name CronPattern */ + public static final String COLUMNNAME_CronPattern = "CronPattern"; + + /** Set Cron Scheduling Pattern. + * Cron pattern to define when the process should be invoked. + */ + public void setCronPattern (String CronPattern); + + /** Get Cron Scheduling Pattern. + * Cron pattern to define when the process should be invoked. + */ + public String getCronPattern(); + /** Column name DateLastRun */ public static final String COLUMNNAME_DateLastRun = "DateLastRun"; @@ -184,6 +197,19 @@ public interface I_AD_Scheduler */ public boolean isActive(); + /** Column name IsIgnoreProcessingTime */ + public static final String COLUMNNAME_IsIgnoreProcessingTime = "IsIgnoreProcessingTime"; + + /** Set Ignore Processing Time. + * Do not include processing time for the DateNextRun calculation + */ + public void setIsIgnoreProcessingTime (boolean IsIgnoreProcessingTime); + + /** Get Ignore Processing Time. + * Do not include processing time for the DateNextRun calculation + */ + public boolean isIgnoreProcessingTime(); + /** Column name KeepLogDays */ public static final String COLUMNNAME_KeepLogDays = "KeepLogDays"; diff --git a/base/src/org/compiere/model/MScheduler.java b/base/src/org/compiere/model/MScheduler.java index 0e438fd725..1998162097 100644 --- a/base/src/org/compiere/model/MScheduler.java +++ b/base/src/org/compiere/model/MScheduler.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -16,6 +16,8 @@ *****************************************************************************/ package org.compiere.model; +import it.sauronsoftware.cron4j.SchedulingPattern; + import java.sql.ResultSet; import java.sql.Timestamp; import java.util.List; @@ -27,18 +29,17 @@ import org.compiere.util.DB; /** * Scheduler Model - * + * * @author Jorg Janke * @version $Id: MScheduler.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ */ public class MScheduler extends X_AD_Scheduler - implements AdempiereProcessor + implements AdempiereProcessor, AdempiereProcessor2 { /** * */ - private static final long serialVersionUID = 1887276680441074725L; - + private static final long serialVersionUID = 6563650236096742870L; /** * Get Active @@ -54,7 +55,7 @@ public class MScheduler extends X_AD_Scheduler list.toArray (retValue); return retValue; } // getActive - + /** * Standard Constructor * @param ctx context @@ -94,7 +95,7 @@ public class MScheduler extends X_AD_Scheduler private MSchedulerPara[] m_parameter = null; /** Process Recipients */ private MSchedulerRecipient[] m_recipients = null; - + /** * Get Server ID * @return id @@ -141,7 +142,7 @@ public class MScheduler extends X_AD_Scheduler if (getKeepLogDays() < 1) return 0; String sql = "DELETE AD_SchedulerLog " - + "WHERE AD_Scheduler_ID=" + getAD_Scheduler_ID() + + "WHERE AD_Scheduler_ID=" + getAD_Scheduler_ID() + " AND (Created+" + getKeepLogDays() + ") < SysDate"; int no = DB.executeUpdateEx(sql, get_TrxName()); return no; @@ -155,7 +156,7 @@ public class MScheduler extends X_AD_Scheduler { return MProcess.get(getCtx(), getAD_Process_ID()); } // getProcess - + /** * Get Parameters * @param reload reload @@ -175,7 +176,7 @@ public class MScheduler extends X_AD_Scheduler list.toArray(m_parameter); return m_parameter; } // getParameter - + /** * Get Recipients * @param reload reload @@ -195,7 +196,7 @@ public class MScheduler extends X_AD_Scheduler list.toArray(m_recipients); return m_recipients; } // getRecipients - + /** * Get Recipient AD_User_IDs * @return array of user IDs @@ -233,13 +234,13 @@ public class MScheduler extends X_AD_Scheduler // return list.toArray(new Integer[list.size()]); } // getRecipientAD_User_IDs - + /** * Before Save * @param newRecord new * @return true */ - protected boolean beforeSave(boolean newRecord) + protected boolean beforeSave(boolean newRecord) { // Set Schedule Type & Frequencies if (SCHEDULETYPE_Frequency.equals(getScheduleType())) @@ -248,22 +249,23 @@ public class MScheduler extends X_AD_Scheduler setFrequencyType(FREQUENCYTYPE_Day); if (getFrequency() < 1) setFrequency(1); + setCronPattern(null); } - else if (SCHEDULETYPE_MonthDay.equals(getScheduleType())) + else if (SCHEDULETYPE_CronSchedulingPattern.equals(getScheduleType())) { - if (getMonthDay() < 1 || getMonthDay() > 31) - setMonthDay(1); - } - else // SCHEDULETYPE_WeekDay - { - if (getScheduleType() == null) - setScheduleType(SCHEDULETYPE_WeekDay); - if (getWeekDay() == null) - setWeekDay(WEEKDAY_Monday); + String pattern = getCronPattern(); + if (pattern != null && pattern.trim().length() > 0) + { + if (!SchedulingPattern.validate(pattern)) + { + log.saveError("Error", "InvalidCronPattern"); + return false; + } + } } return true; } // beforeSave - + /** * String Representation * @return info @@ -274,5 +276,5 @@ public class MScheduler extends X_AD_Scheduler sb.append (get_ID ()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString - + } // MScheduler diff --git a/base/src/org/compiere/model/X_AD_Scheduler.java b/base/src/org/compiere/model/X_AD_Scheduler.java index 07dfcdc7b7..84d8ac2c78 100644 --- a/base/src/org/compiere/model/X_AD_Scheduler.java +++ b/base/src/org/compiere/model/X_AD_Scheduler.java @@ -31,7 +31,7 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent /** * */ - private static final long serialVersionUID = 20090915L; + private static final long serialVersionUID = 20100219L; /** Standard Constructor */ public X_AD_Scheduler (Properties ctx, int AD_Scheduler_ID, String trxName) @@ -41,8 +41,6 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent { setAD_Process_ID (0); setAD_Scheduler_ID (0); - setFrequency (0); - setFrequencyType (null); setKeepLogDays (0); // 7 setName (null); @@ -131,6 +129,23 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent return ii.intValue(); } + /** Set Cron Scheduling Pattern. + @param CronPattern + Cron pattern to define when the process should be invoked. + */ + public void setCronPattern (String CronPattern) + { + set_Value (COLUMNNAME_CronPattern, CronPattern); + } + + /** Get Cron Scheduling Pattern. + @return Cron pattern to define when the process should be invoked. + */ + public String getCronPattern () + { + return (String)get_Value(COLUMNNAME_CronPattern); + } + /** Set Date last run. @param DateLastRun Date the process was last run. @@ -228,6 +243,30 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent return (String)get_Value(COLUMNNAME_FrequencyType); } + /** Set Ignore Processing Time. + @param IsIgnoreProcessingTime + Do not include processing time for the DateNextRun calculation + */ + public void setIsIgnoreProcessingTime (boolean IsIgnoreProcessingTime) + { + set_Value (COLUMNNAME_IsIgnoreProcessingTime, Boolean.valueOf(IsIgnoreProcessingTime)); + } + + /** Get Ignore Processing Time. + @return Do not include processing time for the DateNextRun calculation + */ + public boolean isIgnoreProcessingTime () + { + Object oo = get_Value(COLUMNNAME_IsIgnoreProcessingTime); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + /** Set Days to keep Log. @param KeepLogDays Number of days to keep the log entries @@ -322,6 +361,8 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent public static final String SCHEDULETYPE_WeekDay = "W"; /** Month Day = M */ public static final String SCHEDULETYPE_MonthDay = "M"; + /** Cron Scheduling Pattern = C */ + public static final String SCHEDULETYPE_CronSchedulingPattern = "C"; /** Set Schedule Type. @param ScheduleType Type of schedule diff --git a/migration/354a-trunk/oracle/667_FR2956390_SchedulerEnhancement.sql b/migration/354a-trunk/oracle/667_FR2956390_SchedulerEnhancement.sql new file mode 100644 index 0000000000..5138167db9 --- /dev/null +++ b/migration/354a-trunk/oracle/667_FR2956390_SchedulerEnhancement.sql @@ -0,0 +1,160 @@ +-- Feb 19, 2010 5:22:38 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54123,0,'IsIgnoreProcessingTime',TO_DATE('2010-02-19 17:22:35','YYYY-MM-DD HH24:MI:SS'),100,'Do not include processing time for the DateNextRun calculation','D','When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Ignore Processing Time','Ignore Proccessing Time',TO_DATE('2010-02-19 17:22:35','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:22:38 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54123 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Feb 19, 2010 5:26:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54124,0,'CronPattern',TO_DATE('2010-02-19 17:26:04','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.','D','Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Cron Scheduling Pattern','Cron Scheduling Pattern',TO_DATE('2010-02-19 17:26:04','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:26:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54124 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Feb 19, 2010 5:29:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,59028,54123,0,20,688,'IsIgnoreProcessingTime',TO_DATE('2010-02-19 17:29:09','YYYY-MM-DD HH24:MI:SS'),100,'N','Do not include processing time for the DateNextRun calculation','D',1,'When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Ignore Processing Time',0,TO_DATE('2010-02-19 17:29:09','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Feb 19, 2010 5:29:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=59028 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) +; + +-- Feb 19, 2010 5:29:16 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +ALTER TABLE AD_Scheduler ADD IsIgnoreProcessingTime CHAR(1) DEFAULT 'N' CHECK (IsIgnoreProcessingTime IN ('Y','N')) +; + +-- Feb 19, 2010 5:46:42 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,59029,54124,0,10,688,'CronPattern',TO_DATE('2010-02-19 17:46:38','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.','D',255,'Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Cron Scheduling Pattern',0,TO_DATE('2010-02-19 17:46:38','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Feb 19, 2010 5:46:42 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=59029 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) +; + +-- Feb 19, 2010 5:46:46 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +ALTER TABLE AD_Scheduler ADD CronPattern NVARCHAR2(255) DEFAULT NULL +; + +-- Feb 19, 2010 5:47:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2010-02-19 17:47:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11247 +; + +-- Feb 19, 2010 5:47:18 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_DATE('2010-02-19 17:47:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11255 +; + +-- Feb 19, 2010 5:48:07 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Ref_List SET IsActive='N',Updated=TO_DATE('2010-02-19 17:48:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=665 +; + +-- Feb 19, 2010 5:48:10 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Ref_List SET IsActive='N',Updated=TO_DATE('2010-02-19 17:48:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=664 +; + +-- Feb 19, 2010 5:49:04 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Reference_ID,AD_Ref_List_ID,Created,CreatedBy,Description,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,318,53574,TO_DATE('2010-02-19 17:49:02','YYYY-MM-DD HH24:MI:SS'),100,'Use cron style scheduling pattern','D','Y','Cron Scheduling Pattern',TO_DATE('2010-02-19 17:49:02','YYYY-MM-DD HH24:MI:SS'),100,'C') +; + +-- Feb 19, 2010 5:49:04 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53574 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) +; + +-- Feb 19, 2010 5:53:21 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2010-02-19 17:53:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10053 +; + +-- Feb 19, 2010 5:53:26 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsActive='N',Updated=TO_DATE('2010-02-19 17:53:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10052 +; + +-- Feb 19, 2010 5:54:51 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,59028,58773,0,589,TO_DATE('2010-02-19 17:54:49','YYYY-MM-DD HH24:MI:SS'),100,'Do not include processing time for the DateNextRun calculation',10,'@ScheduleType@=F','D','When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Y','Y','N','N','N','N','N','Ignore Processing Time',160,0,TO_DATE('2010-02-19 17:54:49','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:54:51 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=58773 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) +; + +-- Feb 19, 2010 5:55:49 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsMandatory,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,59029,58774,0,589,TO_DATE('2010-02-19 17:55:48','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.',60,'@ScheduleType@=C','D','Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Y','Y','N','N','N','Y','N','N','Cron Scheduling Pattern',170,0,TO_DATE('2010-02-19 17:55:48','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:55:49 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=58774 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=10053 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=10052 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=9437 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=9430 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=58773 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=58774 +; + +-- Feb 19, 2010 5:57:21 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_DATE('2010-02-19 17:57:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9430 +; + +-- Feb 19, 2010 5:57:28 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_DATE('2010-02-19 17:57:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9437 +; + +-- Feb 22, 2010 9:31:45 AM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgTip,MsgType,Updated,UpdatedBy,Value) VALUES (0,53095,0,TO_DATE('2010-02-22 09:31:41','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Invalid cron scheduling pattern','Invalid cron scheduling pattern - check syntax','E',TO_DATE('2010-02-22 09:31:41','YYYY-MM-DD HH24:MI:SS'),100,'InvalidCronPattern') +; + +-- Feb 22, 2010 9:31:45 AM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53095 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + diff --git a/migration/354a-trunk/postgresql/667_FR2956390_SchedulerEnhancement.sql b/migration/354a-trunk/postgresql/667_FR2956390_SchedulerEnhancement.sql new file mode 100644 index 0000000000..ade82e2b3b --- /dev/null +++ b/migration/354a-trunk/postgresql/667_FR2956390_SchedulerEnhancement.sql @@ -0,0 +1,160 @@ +-- Feb 19, 2010 5:22:38 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54123,0,'IsIgnoreProcessingTime',TO_TIMESTAMP('2010-02-19 17:22:35','YYYY-MM-DD HH24:MI:SS'),100,'Do not include processing time for the DateNextRun calculation','D','When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Ignore Processing Time','Ignore Proccessing Time',TO_TIMESTAMP('2010-02-19 17:22:35','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:22:38 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54123 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Feb 19, 2010 5:26:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,54124,0,'CronPattern',TO_TIMESTAMP('2010-02-19 17:26:04','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.','D','Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Cron Scheduling Pattern','Cron Scheduling Pattern',TO_TIMESTAMP('2010-02-19 17:26:04','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:26:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=54124 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Feb 19, 2010 5:29:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,59028,54123,0,20,688,'IsIgnoreProcessingTime',TO_TIMESTAMP('2010-02-19 17:29:09','YYYY-MM-DD HH24:MI:SS'),100,'N','Do not include processing time for the DateNextRun calculation','D',1,'When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Ignore Processing Time',0,TO_TIMESTAMP('2010-02-19 17:29:09','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Feb 19, 2010 5:29:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=59028 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) +; + +-- Feb 19, 2010 5:29:16 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +ALTER TABLE AD_Scheduler ADD COLUMN IsIgnoreProcessingTime CHAR(1) DEFAULT 'N' CHECK (IsIgnoreProcessingTime IN ('Y','N')) +; + +-- Feb 19, 2010 5:46:42 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Table_ID,ColumnName,Created,CreatedBy,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,59029,54124,0,10,688,'CronPattern',TO_TIMESTAMP('2010-02-19 17:46:38','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.','D',255,'Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Cron Scheduling Pattern',0,TO_TIMESTAMP('2010-02-19 17:46:38','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Feb 19, 2010 5:46:42 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=59029 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID) +; + +-- Feb 19, 2010 5:46:46 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +ALTER TABLE AD_Scheduler ADD COLUMN CronPattern VARCHAR(255) DEFAULT NULL +; + +-- Feb 19, 2010 5:47:11 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2010-02-19 17:47:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11247 +; + +-- Feb 19, 2010 5:47:18 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Column SET IsMandatory='N',Updated=TO_TIMESTAMP('2010-02-19 17:47:18','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=11255 +; + +-- Feb 19, 2010 5:48:07 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Ref_List SET IsActive='N',Updated=TO_TIMESTAMP('2010-02-19 17:48:07','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=665 +; + +-- Feb 19, 2010 5:48:10 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Ref_List SET IsActive='N',Updated=TO_TIMESTAMP('2010-02-19 17:48:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Ref_List_ID=664 +; + +-- Feb 19, 2010 5:49:04 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Reference_ID,AD_Ref_List_ID,Created,CreatedBy,Description,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,318,53574,TO_TIMESTAMP('2010-02-19 17:49:02','YYYY-MM-DD HH24:MI:SS'),100,'Use cron style scheduling pattern','D','Y','Cron Scheduling Pattern',TO_TIMESTAMP('2010-02-19 17:49:02','YYYY-MM-DD HH24:MI:SS'),100,'C') +; + +-- Feb 19, 2010 5:49:04 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53574 AND NOT EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Ref_List_ID=t.AD_Ref_List_ID) +; + +-- Feb 19, 2010 5:53:21 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2010-02-19 17:53:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10053 +; + +-- Feb 19, 2010 5:53:26 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsActive='N',Updated=TO_TIMESTAMP('2010-02-19 17:53:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10052 +; + +-- Feb 19, 2010 5:54:51 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,59028,58773,0,589,TO_TIMESTAMP('2010-02-19 17:54:49','YYYY-MM-DD HH24:MI:SS'),100,'Do not include processing time for the DateNextRun calculation',10,'@ScheduleType@=F','D','When this is selected, the previous DateNextRun is always use as the source for the next DateNextRun calculation.','Y','Y','Y','N','N','N','N','N','Ignore Processing Time',160,0,TO_TIMESTAMP('2010-02-19 17:54:49','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:54:51 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=58773 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) +; + +-- Feb 19, 2010 5:55:49 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsMandatory,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,59029,58774,0,589,TO_TIMESTAMP('2010-02-19 17:55:48','YYYY-MM-DD HH24:MI:SS'),100,'Cron pattern to define when the process should be invoked.',60,'@ScheduleType@=C','D','Cron pattern to define when the process should be invoked. See http://en.wikipedia.org/wiki/Cron#crontab_syntax for cron scheduling syntax and example.','Y','Y','Y','N','N','N','Y','N','N','Cron Scheduling Pattern',170,0,TO_TIMESTAMP('2010-02-19 17:55:48','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Feb 19, 2010 5:55:49 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=58774 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID) +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=10053 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=0,IsDisplayed='N' WHERE AD_Field_ID=10052 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=80,IsDisplayed='Y' WHERE AD_Field_ID=9437 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=90,IsDisplayed='Y' WHERE AD_Field_ID=9430 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=100,IsDisplayed='Y' WHERE AD_Field_ID=58773 +; + +-- Feb 19, 2010 5:57:03 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET SeqNo=110,IsDisplayed='Y' WHERE AD_Field_ID=58774 +; + +-- Feb 19, 2010 5:57:21 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_TIMESTAMP('2010-02-19 17:57:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9430 +; + +-- Feb 19, 2010 5:57:28 PM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +UPDATE AD_Field SET IsMandatory='Y',Updated=TO_TIMESTAMP('2010-02-19 17:57:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9437 +; + +-- Feb 22, 2010 9:31:45 AM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgTip,MsgType,Updated,UpdatedBy,Value) VALUES (0,53095,0,TO_TIMESTAMP('2010-02-22 09:31:41','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Invalid cron scheduling pattern','Invalid cron scheduling pattern - check syntax','E',TO_TIMESTAMP('2010-02-22 09:31:41','YYYY-MM-DD HH24:MI:SS'),100,'InvalidCronPattern') +; + +-- Feb 22, 2010 9:31:45 AM MYT +-- adding cron4j to the Adempiere scheduler - ID: 2950261 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=53095 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + diff --git a/serverRoot/.classpath b/serverRoot/.classpath index e3f33e23b5..7b34e694b2 100644 --- a/serverRoot/.classpath +++ b/serverRoot/.classpath @@ -8,6 +8,7 @@ + diff --git a/serverRoot/build.xml b/serverRoot/build.xml index b6a84908c2..0239bd688b 100644 --- a/serverRoot/build.xml +++ b/serverRoot/build.xml @@ -38,6 +38,7 @@ + diff --git a/serverRoot/src/main/server/org/compiere/server/AdempiereServer.java b/serverRoot/src/main/server/org/compiere/server/AdempiereServer.java index 00286c0202..711da9673a 100644 --- a/serverRoot/src/main/server/org/compiere/server/AdempiereServer.java +++ b/serverRoot/src/main/server/org/compiere/server/AdempiereServer.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -16,30 +16,17 @@ *****************************************************************************/ package org.compiere.server; -import java.sql.Timestamp; -import java.util.Properties; -import java.util.logging.Level; - -import org.compiere.ldap.LdapProcessor; -import org.compiere.model.AdempiereProcessor; -import org.compiere.model.AdempiereProcessorLog; -import org.compiere.model.MAcctProcessor; -import org.compiere.model.MAlertProcessor; -import org.compiere.model.MClient; -import org.compiere.model.MIMPProcessor; -import org.compiere.model.MLdapProcessor; -import org.compiere.model.MRequestProcessor; -import org.compiere.model.MScheduler; -import org.compiere.model.MSystem; -import org.compiere.model.X_R_RequestProcessor; -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.TimeUtil; -import org.compiere.wf.MWorkflowProcessor; +import java.sql.*; +import java.util.*; +import java.util.logging.*; +import org.compiere.ldap.*; +import org.compiere.model.*; +import org.compiere.util.*; +import org.compiere.wf.*; /** * Adempiere Server Base - * + * * @author Jorg Janke * @version $Id: AdempiereServer.java,v 1.3 2006/10/09 00:23:26 jjanke Exp $ */ @@ -70,7 +57,7 @@ public abstract class AdempiereServer extends Thread throw new IllegalArgumentException("Unknown Processor"); } // create - + /************************************************************************** * Server Base Class * @param model model @@ -93,7 +80,7 @@ public abstract class AdempiereServer extends Thread protected AdempiereProcessor p_model; /** Initial nap is seconds */ private int m_initialNap = 0; - + /** Miliseconds to sleep - 10 Min default */ private long m_sleepMS = 600000; /** Sleeping */ @@ -110,16 +97,16 @@ public abstract class AdempiereServer extends Thread private long m_runTotalMS = 0; /** When to run next */ private long m_nextWork = 0; - + /** Logger */ protected CLogger log = CLogger.getCLogger(getClass()); /** Context */ private Properties m_ctx = null; /** System */ - protected static MSystem p_system = null; + protected static MSystem p_system = null; /** Client */ - protected MClient p_client = null; - + protected MClient p_client = null; + /** * Get Server Context * @return context @@ -128,7 +115,7 @@ public abstract class AdempiereServer extends Thread { return m_ctx; } // getCtx - + /** * @return Returns the sleepMS. */ @@ -136,8 +123,8 @@ public abstract class AdempiereServer extends Thread { return m_sleepMS; } // getSleepMS - - + + /** * Sleep for set time * @return true if not interrupted @@ -175,7 +162,7 @@ public abstract class AdempiereServer extends Thread doWork(); long now = System.currentTimeMillis(); // --------------- - + p_runCount++; m_runLastMS = now - p_startWork; m_runTotalMS += m_runLastMS; @@ -185,7 +172,7 @@ public abstract class AdempiereServer extends Thread // log.fine(getName() + ": " + getStatistics()); } // runNow - + /************************************************************************** * Run async */ @@ -201,7 +188,7 @@ public abstract class AdempiereServer extends Thread log.log(Level.SEVERE, getName() + ": pre-nap interrupted", e); return; } - + m_start = System.currentTimeMillis(); while (true) { @@ -223,21 +210,44 @@ public abstract class AdempiereServer extends Thread log.info (getName() + ": interrupted"); break; } - + // --------------- p_startWork = System.currentTimeMillis(); doWork(); now = System.currentTimeMillis(); // --------------- - + p_runCount++; m_runLastMS = now - p_startWork; m_runTotalMS += m_runLastMS; // - m_sleepMS = calculateSleep(); - m_nextWork = now + m_sleepMS; + m_sleepMS = calculateSleep(); + Timestamp lastRun = new Timestamp(now); + if (p_model instanceof AdempiereProcessor2) + { + AdempiereProcessor2 ap = (AdempiereProcessor2) p_model; + if (ap.isIgnoreProcessingTime()) + { + lastRun = new Timestamp(p_startWork); + if (m_nextWork <= 0) + m_nextWork = p_startWork; + m_nextWork = m_nextWork + m_sleepMS; + while (m_nextWork < now) + { + m_nextWork = m_nextWork + m_sleepMS; + } + } + else + { + m_nextWork = now + m_sleepMS; + } + } + else + { + m_nextWork = now + m_sleepMS; + } // - p_model.setDateLastRun(new Timestamp(now)); + p_model.setDateLastRun(lastRun); p_model.setDateNextRun(new Timestamp(m_nextWork)); p_model.save(); // @@ -254,12 +264,12 @@ public abstract class AdempiereServer extends Thread */ public String getStatistics() { - return "Run #" + p_runCount + return "Run #" + p_runCount + " - Last=" + TimeUtil.formatElapsed(m_runLastMS) + " - Total=" + TimeUtil.formatElapsed(m_runTotalMS) + " - Next " + TimeUtil.formatElapsed(m_nextWork - System.currentTimeMillis()); } // getStatistics - + /** * Do the actual Work */ @@ -289,7 +299,7 @@ public abstract class AdempiereServer extends Thread { return p_model.getDateNextRun(requery); } // getDateNextRun - + /** * Get the date Last run * @return date lext run @@ -307,7 +317,7 @@ public abstract class AdempiereServer extends Thread { return p_model.getDescription(); } // getDescription - + /** * Get Model * @return Model @@ -316,7 +326,7 @@ public abstract class AdempiereServer extends Thread { return p_model; } // getModel - + /** * Calculate Sleep ms * @return miliseconds @@ -349,7 +359,7 @@ public abstract class AdempiereServer extends Thread { return m_sleeping; } // isSleeping - + /** * String Representation * @return info @@ -379,7 +389,7 @@ public abstract class AdempiereServer extends Thread long ms = (now-m_start) / 1000; return (int)ms; } // getSecondsAlive - + /** * Get Start Time * @return start time @@ -390,7 +400,7 @@ public abstract class AdempiereServer extends Thread return null; return new Timestamp (m_start); } // getStartTime - + /** * Get Processor Logs * @return logs diff --git a/serverRoot/src/main/server/org/compiere/server/Scheduler.java b/serverRoot/src/main/server/org/compiere/server/Scheduler.java index 1860df0e10..44521d69b6 100644 --- a/serverRoot/src/main/server/org/compiere/server/Scheduler.java +++ b/serverRoot/src/main/server/org/compiere/server/Scheduler.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -16,33 +16,22 @@ *****************************************************************************/ package org.compiere.server; -import java.io.File; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.logging.Level; +import it.sauronsoftware.cron4j.Predictor; +import it.sauronsoftware.cron4j.SchedulingPattern; -import org.compiere.model.MAttachment; -import org.compiere.model.MClient; -import org.compiere.model.MNote; -import org.compiere.model.MPInstance; -import org.compiere.model.MPInstancePara; -import org.compiere.model.MProcess; -import org.compiere.model.MScheduler; -import org.compiere.model.MSchedulerLog; -import org.compiere.model.MSchedulerPara; -import org.compiere.model.MUser; -import org.compiere.print.ReportEngine; -import org.compiere.process.ProcessInfo; -import org.compiere.process.ProcessInfoUtil; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.TimeUtil; -import org.compiere.util.Trx; +import java.io.*; +import java.math.*; +import java.sql.*; +import java.util.logging.*; +import org.compiere.model.*; +import org.compiere.print.*; +import org.compiere.process.*; +import org.compiere.util.*; /** * Scheduler - * + * * @author Jorg Janke * @version $Id: Scheduler.java,v 1.5 2006/07/30 00:53:33 jjanke Exp $ */ @@ -66,6 +55,9 @@ public class Scheduler extends AdempiereServer /** Transaction */ private Trx m_trx = null; + private it.sauronsoftware.cron4j.Scheduler cronScheduler; + private Predictor predictor; + /** * Work */ @@ -91,18 +83,18 @@ public class Scheduler extends AdempiereServer log.log(Level.WARNING, process.toString(), e); m_summary.append(e.toString()); } - finally + finally { if (m_trx != null) m_trx.close(); } - + // int no = m_model.deleteLog(); m_summary.append("Logs deleted=").append(no); // MSchedulerLog pLog = new MSchedulerLog(m_model, m_summary.toString()); - pLog.setReference("#" + String.valueOf(p_runCount) + pLog.setReference("#" + String.valueOf(p_runCount) + " - " + TimeUtil.formatElapsed(new Timestamp(p_startWork))); pLog.save(); } // doWork @@ -127,10 +119,10 @@ public class Scheduler extends AdempiereServer // ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), AD_Table_ID, Record_ID); - pi.setAD_User_ID(getAD_User_ID()); + pi.setAD_User_ID(m_model.getUpdatedBy()); pi.setAD_Client_ID(m_model.getAD_Client_ID()); - pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); - if (!process.processIt(pi, m_trx) && pi.getClassName() != null) + pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); + if (!process.processIt(pi, m_trx) && pi.getClassName() != null) return "Process failed: (" + pi.getClassName() + ") " + pi.getSummary(); // Report @@ -141,41 +133,28 @@ public class Scheduler extends AdempiereServer File report = re.getPDF(); // Notice int AD_Message_ID = 884; // HARDCODED SchedulerResult - MUser from = new MUser(getCtx(), pi.getAD_User_ID(), null); Integer[] userIDs = m_model.getRecipientAD_User_IDs(); for (int i = 0; i < userIDs.length; i++) { - MUser user = new MUser(getCtx(), userIDs[i].intValue(), null); - boolean email = user.isNotificationEMail(); - boolean notice = user.isNotificationNote(); - - if (notice) - { - MNote note = new MNote(getCtx(), - AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName()); - note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); - note.setTextMsg(m_model.getName()); - note.setDescription(m_model.getDescription()); - note.setRecord(AD_Table_ID, Record_ID); - note.save(); - // Attachment - MAttachment attachment = new MAttachment (getCtx(), - MNote.Table_ID, note.getAD_Note_ID(), m_trx.getTrxName()); - attachment.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); - attachment.addEntry(report); - attachment.setTextMsg(m_model.getName()); - attachment.save(); - } - if (email) - { - MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); - client.sendEMail(from, user, m_model.getName(), m_model.getDescription(), report); - } + MNote note = new MNote(getCtx(), + AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName()); + note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); + note.setTextMsg(m_model.getName()); + note.setDescription(m_model.getDescription()); + note.setRecord(AD_Table_ID, Record_ID); + note.save(); + // Attachment + MAttachment attachment = new MAttachment (getCtx(), + X_AD_Note.Table_ID, note.getAD_Note_ID(), m_trx.getTrxName()); + attachment.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); + attachment.addEntry(report); + attachment.setTextMsg(m_model.getName()); + attachment.save(); } // return pi.getSummary(); } // runReport - + /** * Run Process * @param process process @@ -194,89 +173,73 @@ public class Scheduler extends AdempiereServer // ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), AD_Table_ID, Record_ID); - int AD_User_ID = getAD_User_ID(); - - pi.setAD_User_ID(AD_User_ID); + pi.setAD_User_ID(m_model.getUpdatedBy()); pi.setAD_Client_ID(m_model.getAD_Client_ID()); pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); + //notify supervisor if error + MUser from = new MUser(getCtx(), pi.getAD_User_ID(), null); - - //notify supervisor if error - if ( !process.processIt(pi, m_trx) ) + if ( !process.processIt(pi, m_trx) ) { int supervisor = m_model.getSupervisor_ID(); - if (supervisor > 0) + if (supervisor > 0) { MUser user = new MUser(getCtx(), supervisor, null); - boolean email = user.isNotificationEMail(); - boolean notice = user.isNotificationNote(); - - if (email || notice) - ProcessInfoUtil.setLogFromDB(pi); - - if (email) + String type = user.getNotificationType(); + boolean email = X_AD_User.NOTIFICATIONTYPE_EMail.equals(type) || + X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type); + boolean notice = X_AD_User.NOTIFICATIONTYPE_Notice.equals(type) || + X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type); + if (email) { MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); - client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); +// client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); + client.sendEMail(from, user, m_model.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); } if (notice) { int AD_Message_ID = 442; //ProcessRunError - MNote note = new MNote(getCtx(), - AD_Message_ID, supervisor, null); + MNote note = new MNote(getCtx(), + AD_Message_ID, supervisor, m_trx.getTrxName()); note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); note.setTextMsg(pi.getSummary()); //note.setDescription(); - note.setRecord(MPInstance.Table_ID, pi.getAD_PInstance_ID()); + note.setRecord(X_AD_PInstance.Table_ID, pi.getAD_PInstance_ID()); note.save(); } } - } - else - { + } + else + { Integer[] userIDs = m_model.getRecipientAD_User_IDs(); - if (userIDs.length > 0) + for (int i = 0; i < userIDs.length; i++) { - ProcessInfoUtil.setLogFromDB(pi); - for (int i = 0; i < userIDs.length; i++) + MUser user = new MUser(getCtx(), userIDs[i].intValue(), null); + String type = user.getNotificationType(); + boolean email = X_AD_User.NOTIFICATIONTYPE_EMail.equals(type) || + X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type); + boolean notice = X_AD_User.NOTIFICATIONTYPE_Notice.equals(type) || + X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type); + if (email) { - MUser user = new MUser(getCtx(), userIDs[i].intValue(), null); - boolean email = user.isNotificationEMail(); - boolean notice = user.isNotificationNote(); - - if (email) - { - MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); - client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); - } - if (notice) { - int AD_Message_ID = 441; //ProcessOK - MNote note = new MNote(getCtx(), - AD_Message_ID, userIDs[i].intValue(), null); - note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); - note.setTextMsg(pi.getSummary()); - //note.setDescription(); - note.setRecord(MPInstance.Table_ID, pi.getAD_PInstance_ID()); - note.save(); - } + MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); +// client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); + client.sendEMail(from, user, m_model.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); + } + if (notice) { + int AD_Message_ID = 441; //ProcessOK + MNote note = new MNote(getCtx(), + AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName()); + note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); + note.setTextMsg(pi.getSummary()); + //note.setDescription(); + note.setRecord(X_AD_PInstance.Table_ID, pi.getAD_PInstance_ID()); + note.save(); } } } return pi.getSummary(); } // runProcess - private int getAD_User_ID() { - int AD_User_ID; - if (m_model.getSupervisor_ID() > 0) - AD_User_ID = m_model.getSupervisor_ID(); - else if (m_model.getUpdatedBy() > 0) - AD_User_ID = m_model.getUpdatedBy(); - else if (m_model.getCreatedBy() > 0) - AD_User_ID = m_model.getCreatedBy(); - else - AD_User_ID = 100; //fall back to SuperUser - return AD_User_ID; - } - /** * Fill Parameter * @param pInstance process instance @@ -318,25 +281,25 @@ public class Scheduler extends AdempiereServer if (env.length() == 0) { log.warning(sPara.getColumnName() - + " - not in environment =" + columnName + + " - not in environment =" + columnName + "(" + variable + ")"); break; } else value = env; } // @variable@ - + // No Value if (value == null) { log.fine(sPara.getColumnName() + " - empty"); break; } - + // Convert to Type try { - if (DisplayType.isNumeric(sPara.getDisplayType()) + if (DisplayType.isNumeric(sPara.getDisplayType()) || DisplayType.isID(sPara.getDisplayType())) { BigDecimal bd = null; @@ -384,7 +347,7 @@ public class Scheduler extends AdempiereServer } // instance parameter loop } // fillParameter - + /** * Get Server Info * @return info @@ -394,4 +357,34 @@ public class Scheduler extends AdempiereServer return "#" + p_runCount + " - Last=" + m_summary.toString(); } // getServerInfo + @Override + public void run() { + String cronPattern = (String) m_model.getCronPattern(); + if (cronPattern != null && cronPattern.trim().length() > 0 && SchedulingPattern.validate(cronPattern)) { + cronScheduler = new it.sauronsoftware.cron4j.Scheduler(); + cronScheduler.schedule(cronPattern, new Runnable() { + public void run() { + runNow(); + long next = predictor.nextMatchingTime(); + p_model.setDateNextRun(new Timestamp(next)); + p_model.save(); + } + }); + predictor = new Predictor(cronPattern); + long next = predictor.nextMatchingTime(); + p_model.setDateNextRun(new Timestamp(next)); + p_model.save(); + cronScheduler.start(); + while (true) { + if (!sleep()) { + cronScheduler.stop(); + break; + } else if (!cronScheduler.isStarted()) { + break; + } + } + } else { + super.run(); + } + } } // Scheduler diff --git a/tools/build.xml b/tools/build.xml index 8514060666..fe841a5d84 100644 --- a/tools/build.xml +++ b/tools/build.xml @@ -315,6 +315,10 @@ + + + +