Scheduler Enhancement:

* Add cron job support
* Add IsIgnoreProcessingTime flag - use previous DateNextRun as source to calculate the new DateNextRun value
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2956390
This commit is contained in:
Heng Sin Low 2010-02-22 02:20:31 +00:00
parent 59e7297b6a
commit edf4a9b437
14 changed files with 622 additions and 193 deletions

View File

@ -138,5 +138,6 @@
<classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/iText-2.1.7.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/miglayout-3.7.1-swing.jar"/>
<classpathentry exported="true" kind="lib" path="tools/lib/payflow.jar"/> <classpathentry exported="true" kind="lib" path="tools/lib/payflow.jar"/>
<classpathentry kind="lib" path="tools/lib/cron4j-2.2.1.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -23,6 +23,7 @@
<classpathentry kind="lib" path="/tools/lib/looks-2.0.4.jar"/> <classpathentry kind="lib" path="/tools/lib/looks-2.0.4.jar"/>
<classpathentry kind="lib" path="/tools/lib/commons-collections-3.1.jar"/> <classpathentry kind="lib" path="/tools/lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/> <classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/>
<classpathentry kind="lib" path="/tools/lib/cron4j-2.2.1.jar"/>
<classpathentry kind="src" path="/JasperReportsTools"/> <classpathentry kind="src" path="/JasperReportsTools"/>
<classpathentry kind="output" path="build"/> <classpathentry kind="output" path="build"/>
</classpath> </classpath>

View File

@ -31,6 +31,7 @@
<pathelement path="../tools/lib/j2ee.jar"/> <pathelement path="../tools/lib/j2ee.jar"/>
<pathelement path="../tools/lib/jnlp.jar"/> <pathelement path="../tools/lib/jnlp.jar"/>
<pathelement path="../tools/lib/servlet-api.jar" /> <pathelement path="../tools/lib/servlet-api.jar" />
<pathelement path="../tools/lib/cron4j-2.2.1.jar" />
</path> </path>

View File

@ -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();
}

View File

@ -106,6 +106,19 @@ public interface I_AD_Scheduler
*/ */
public int getCreatedBy(); 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 */ /** Column name DateLastRun */
public static final String COLUMNNAME_DateLastRun = "DateLastRun"; public static final String COLUMNNAME_DateLastRun = "DateLastRun";
@ -184,6 +197,19 @@ public interface I_AD_Scheduler
*/ */
public boolean isActive(); 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 */ /** Column name KeepLogDays */
public static final String COLUMNNAME_KeepLogDays = "KeepLogDays"; public static final String COLUMNNAME_KeepLogDays = "KeepLogDays";

View File

@ -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. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * under the terms version 2 of the GNU General Public License as published *
@ -16,6 +16,8 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import it.sauronsoftware.cron4j.SchedulingPattern;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
@ -27,18 +29,17 @@ import org.compiere.util.DB;
/** /**
* Scheduler Model * Scheduler Model
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MScheduler.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ * @version $Id: MScheduler.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*/ */
public class MScheduler extends X_AD_Scheduler 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 * Get Active
@ -54,7 +55,7 @@ public class MScheduler extends X_AD_Scheduler
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
} // getActive } // getActive
/** /**
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
@ -94,7 +95,7 @@ public class MScheduler extends X_AD_Scheduler
private MSchedulerPara[] m_parameter = null; private MSchedulerPara[] m_parameter = null;
/** Process Recipients */ /** Process Recipients */
private MSchedulerRecipient[] m_recipients = null; private MSchedulerRecipient[] m_recipients = null;
/** /**
* Get Server ID * Get Server ID
* @return id * @return id
@ -141,7 +142,7 @@ public class MScheduler extends X_AD_Scheduler
if (getKeepLogDays() < 1) if (getKeepLogDays() < 1)
return 0; return 0;
String sql = "DELETE AD_SchedulerLog " String sql = "DELETE AD_SchedulerLog "
+ "WHERE AD_Scheduler_ID=" + getAD_Scheduler_ID() + "WHERE AD_Scheduler_ID=" + getAD_Scheduler_ID()
+ " AND (Created+" + getKeepLogDays() + ") < SysDate"; + " AND (Created+" + getKeepLogDays() + ") < SysDate";
int no = DB.executeUpdateEx(sql, get_TrxName()); int no = DB.executeUpdateEx(sql, get_TrxName());
return no; return no;
@ -155,7 +156,7 @@ public class MScheduler extends X_AD_Scheduler
{ {
return MProcess.get(getCtx(), getAD_Process_ID()); return MProcess.get(getCtx(), getAD_Process_ID());
} // getProcess } // getProcess
/** /**
* Get Parameters * Get Parameters
* @param reload reload * @param reload reload
@ -175,7 +176,7 @@ public class MScheduler extends X_AD_Scheduler
list.toArray(m_parameter); list.toArray(m_parameter);
return m_parameter; return m_parameter;
} // getParameter } // getParameter
/** /**
* Get Recipients * Get Recipients
* @param reload reload * @param reload reload
@ -195,7 +196,7 @@ public class MScheduler extends X_AD_Scheduler
list.toArray(m_recipients); list.toArray(m_recipients);
return m_recipients; return m_recipients;
} // getRecipients } // getRecipients
/** /**
* Get Recipient AD_User_IDs * Get Recipient AD_User_IDs
* @return array of 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()]); return list.toArray(new Integer[list.size()]);
} // getRecipientAD_User_IDs } // getRecipientAD_User_IDs
/** /**
* Before Save * Before Save
* @param newRecord new * @param newRecord new
* @return true * @return true
*/ */
protected boolean beforeSave(boolean newRecord) protected boolean beforeSave(boolean newRecord)
{ {
// Set Schedule Type & Frequencies // Set Schedule Type & Frequencies
if (SCHEDULETYPE_Frequency.equals(getScheduleType())) if (SCHEDULETYPE_Frequency.equals(getScheduleType()))
@ -248,22 +249,23 @@ public class MScheduler extends X_AD_Scheduler
setFrequencyType(FREQUENCYTYPE_Day); setFrequencyType(FREQUENCYTYPE_Day);
if (getFrequency() < 1) if (getFrequency() < 1)
setFrequency(1); setFrequency(1);
setCronPattern(null);
} }
else if (SCHEDULETYPE_MonthDay.equals(getScheduleType())) else if (SCHEDULETYPE_CronSchedulingPattern.equals(getScheduleType()))
{ {
if (getMonthDay() < 1 || getMonthDay() > 31) String pattern = getCronPattern();
setMonthDay(1); if (pattern != null && pattern.trim().length() > 0)
} {
else // SCHEDULETYPE_WeekDay if (!SchedulingPattern.validate(pattern))
{ {
if (getScheduleType() == null) log.saveError("Error", "InvalidCronPattern");
setScheduleType(SCHEDULETYPE_WeekDay); return false;
if (getWeekDay() == null) }
setWeekDay(WEEKDAY_Monday); }
} }
return true; return true;
} // beforeSave } // beforeSave
/** /**
* String Representation * String Representation
* @return info * @return info
@ -274,5 +276,5 @@ public class MScheduler extends X_AD_Scheduler
sb.append (get_ID ()).append ("-").append (getName()).append ("]"); sb.append (get_ID ()).append ("-").append (getName()).append ("]");
return sb.toString (); return sb.toString ();
} // toString } // toString
} // MScheduler } // MScheduler

View File

@ -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 */ /** Standard Constructor */
public X_AD_Scheduler (Properties ctx, int AD_Scheduler_ID, String trxName) 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_Process_ID (0);
setAD_Scheduler_ID (0); setAD_Scheduler_ID (0);
setFrequency (0);
setFrequencyType (null);
setKeepLogDays (0); setKeepLogDays (0);
// 7 // 7
setName (null); setName (null);
@ -131,6 +129,23 @@ public class X_AD_Scheduler extends PO implements I_AD_Scheduler, I_Persistent
return ii.intValue(); 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. /** Set Date last run.
@param DateLastRun @param DateLastRun
Date the process was last run. 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); 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. /** Set Days to keep Log.
@param KeepLogDays @param KeepLogDays
Number of days to keep the log entries 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"; public static final String SCHEDULETYPE_WeekDay = "W";
/** Month Day = M */ /** Month Day = M */
public static final String SCHEDULETYPE_MonthDay = "M"; public static final String SCHEDULETYPE_MonthDay = "M";
/** Cron Scheduling Pattern = C */
public static final String SCHEDULETYPE_CronSchedulingPattern = "C";
/** Set Schedule Type. /** Set Schedule Type.
@param ScheduleType @param ScheduleType
Type of schedule Type of schedule

View File

@ -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)
;

View File

@ -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)
;

View File

@ -8,6 +8,7 @@
<classpathentry kind="src" path="/base"/> <classpathentry kind="src" path="/base"/>
<classpathentry kind="lib" path="/jboss/client/jbossall-client.jar"/> <classpathentry kind="lib" path="/jboss/client/jbossall-client.jar"/>
<classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/> <classpathentry kind="lib" path="/tools/lib/activemq-core-5.0.0.jar"/>
<classpathentry kind="lib" path="/tools/lib/cron4j-2.2.1.jar"/>
<classpathentry kind="src" path="/serverApps"/> <classpathentry kind="src" path="/serverApps"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>

View File

@ -38,6 +38,7 @@
<pathelement location="../tools/lib/mail.jar" /> <pathelement location="../tools/lib/mail.jar" />
<pathelement location="../tools/lib/bsh-1.3.0.jar" /> <pathelement location="../tools/lib/bsh-1.3.0.jar" />
<pathelement location="../tools/lib/junit.jar" /> <pathelement location="../tools/lib/junit.jar" />
<pathelement location="../tools/lib/cron4j-2.2.1.jar" />
<pathelement location="../lib/oracle.jar" /> <pathelement location="../lib/oracle.jar" />
<pathelement location="../lib/jboss.jar" /> <pathelement location="../lib/jboss.jar" />
<pathelement location="../lib/postgresql.jar" /> <pathelement location="../lib/postgresql.jar" />

View File

@ -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. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * under the terms version 2 of the GNU General Public License as published *
@ -16,30 +16,17 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.server; package org.compiere.server;
import java.sql.Timestamp; import java.sql.*;
import java.util.Properties; import java.util.*;
import java.util.logging.Level; import java.util.logging.*;
import org.compiere.ldap.*;
import org.compiere.ldap.LdapProcessor; import org.compiere.model.*;
import org.compiere.model.AdempiereProcessor; import org.compiere.util.*;
import org.compiere.model.AdempiereProcessorLog; import org.compiere.wf.*;
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;
/** /**
* Adempiere Server Base * Adempiere Server Base
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: AdempiereServer.java,v 1.3 2006/10/09 00:23:26 jjanke Exp $ * @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"); throw new IllegalArgumentException("Unknown Processor");
} // create } // create
/************************************************************************** /**************************************************************************
* Server Base Class * Server Base Class
* @param model model * @param model model
@ -93,7 +80,7 @@ public abstract class AdempiereServer extends Thread
protected AdempiereProcessor p_model; protected AdempiereProcessor p_model;
/** Initial nap is seconds */ /** Initial nap is seconds */
private int m_initialNap = 0; private int m_initialNap = 0;
/** Miliseconds to sleep - 10 Min default */ /** Miliseconds to sleep - 10 Min default */
private long m_sleepMS = 600000; private long m_sleepMS = 600000;
/** Sleeping */ /** Sleeping */
@ -110,16 +97,16 @@ public abstract class AdempiereServer extends Thread
private long m_runTotalMS = 0; private long m_runTotalMS = 0;
/** When to run next */ /** When to run next */
private long m_nextWork = 0; private long m_nextWork = 0;
/** Logger */ /** Logger */
protected CLogger log = CLogger.getCLogger(getClass()); protected CLogger log = CLogger.getCLogger(getClass());
/** Context */ /** Context */
private Properties m_ctx = null; private Properties m_ctx = null;
/** System */ /** System */
protected static MSystem p_system = null; protected static MSystem p_system = null;
/** Client */ /** Client */
protected MClient p_client = null; protected MClient p_client = null;
/** /**
* Get Server Context * Get Server Context
* @return context * @return context
@ -128,7 +115,7 @@ public abstract class AdempiereServer extends Thread
{ {
return m_ctx; return m_ctx;
} // getCtx } // getCtx
/** /**
* @return Returns the sleepMS. * @return Returns the sleepMS.
*/ */
@ -136,8 +123,8 @@ public abstract class AdempiereServer extends Thread
{ {
return m_sleepMS; return m_sleepMS;
} // getSleepMS } // getSleepMS
/** /**
* Sleep for set time * Sleep for set time
* @return true if not interrupted * @return true if not interrupted
@ -175,7 +162,7 @@ public abstract class AdempiereServer extends Thread
doWork(); doWork();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
// --------------- // ---------------
p_runCount++; p_runCount++;
m_runLastMS = now - p_startWork; m_runLastMS = now - p_startWork;
m_runTotalMS += m_runLastMS; m_runTotalMS += m_runLastMS;
@ -185,7 +172,7 @@ public abstract class AdempiereServer extends Thread
// //
log.fine(getName() + ": " + getStatistics()); log.fine(getName() + ": " + getStatistics());
} // runNow } // runNow
/************************************************************************** /**************************************************************************
* Run async * Run async
*/ */
@ -201,7 +188,7 @@ public abstract class AdempiereServer extends Thread
log.log(Level.SEVERE, getName() + ": pre-nap interrupted", e); log.log(Level.SEVERE, getName() + ": pre-nap interrupted", e);
return; return;
} }
m_start = System.currentTimeMillis(); m_start = System.currentTimeMillis();
while (true) while (true)
{ {
@ -223,21 +210,44 @@ public abstract class AdempiereServer extends Thread
log.info (getName() + ": interrupted"); log.info (getName() + ": interrupted");
break; break;
} }
// --------------- // ---------------
p_startWork = System.currentTimeMillis(); p_startWork = System.currentTimeMillis();
doWork(); doWork();
now = System.currentTimeMillis(); now = System.currentTimeMillis();
// --------------- // ---------------
p_runCount++; p_runCount++;
m_runLastMS = now - p_startWork; m_runLastMS = now - p_startWork;
m_runTotalMS += m_runLastMS; m_runTotalMS += m_runLastMS;
// //
m_sleepMS = calculateSleep(); m_sleepMS = calculateSleep();
m_nextWork = now + m_sleepMS; 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.setDateNextRun(new Timestamp(m_nextWork));
p_model.save(); p_model.save();
// //
@ -254,12 +264,12 @@ public abstract class AdempiereServer extends Thread
*/ */
public String getStatistics() public String getStatistics()
{ {
return "Run #" + p_runCount return "Run #" + p_runCount
+ " - Last=" + TimeUtil.formatElapsed(m_runLastMS) + " - Last=" + TimeUtil.formatElapsed(m_runLastMS)
+ " - Total=" + TimeUtil.formatElapsed(m_runTotalMS) + " - Total=" + TimeUtil.formatElapsed(m_runTotalMS)
+ " - Next " + TimeUtil.formatElapsed(m_nextWork - System.currentTimeMillis()); + " - Next " + TimeUtil.formatElapsed(m_nextWork - System.currentTimeMillis());
} // getStatistics } // getStatistics
/** /**
* Do the actual Work * Do the actual Work
*/ */
@ -289,7 +299,7 @@ public abstract class AdempiereServer extends Thread
{ {
return p_model.getDateNextRun(requery); return p_model.getDateNextRun(requery);
} // getDateNextRun } // getDateNextRun
/** /**
* Get the date Last run * Get the date Last run
* @return date lext run * @return date lext run
@ -307,7 +317,7 @@ public abstract class AdempiereServer extends Thread
{ {
return p_model.getDescription(); return p_model.getDescription();
} // getDescription } // getDescription
/** /**
* Get Model * Get Model
* @return Model * @return Model
@ -316,7 +326,7 @@ public abstract class AdempiereServer extends Thread
{ {
return p_model; return p_model;
} // getModel } // getModel
/** /**
* Calculate Sleep ms * Calculate Sleep ms
* @return miliseconds * @return miliseconds
@ -349,7 +359,7 @@ public abstract class AdempiereServer extends Thread
{ {
return m_sleeping; return m_sleeping;
} // isSleeping } // isSleeping
/** /**
* String Representation * String Representation
* @return info * @return info
@ -379,7 +389,7 @@ public abstract class AdempiereServer extends Thread
long ms = (now-m_start) / 1000; long ms = (now-m_start) / 1000;
return (int)ms; return (int)ms;
} // getSecondsAlive } // getSecondsAlive
/** /**
* Get Start Time * Get Start Time
* @return start time * @return start time
@ -390,7 +400,7 @@ public abstract class AdempiereServer extends Thread
return null; return null;
return new Timestamp (m_start); return new Timestamp (m_start);
} // getStartTime } // getStartTime
/** /**
* Get Processor Logs * Get Processor Logs
* @return logs * @return logs

View File

@ -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. * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it * * 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 * * under the terms version 2 of the GNU General Public License as published *
@ -16,33 +16,22 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.server; package org.compiere.server;
import java.io.File; import it.sauronsoftware.cron4j.Predictor;
import java.math.BigDecimal; import it.sauronsoftware.cron4j.SchedulingPattern;
import java.sql.Timestamp;
import java.util.logging.Level;
import org.compiere.model.MAttachment; import java.io.*;
import org.compiere.model.MClient; import java.math.*;
import org.compiere.model.MNote; import java.sql.*;
import org.compiere.model.MPInstance; import java.util.logging.*;
import org.compiere.model.MPInstancePara; import org.compiere.model.*;
import org.compiere.model.MProcess; import org.compiere.print.*;
import org.compiere.model.MScheduler; import org.compiere.process.*;
import org.compiere.model.MSchedulerLog; import org.compiere.util.*;
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;
/** /**
* Scheduler * Scheduler
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: Scheduler.java,v 1.5 2006/07/30 00:53:33 jjanke Exp $ * @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 */ /** Transaction */
private Trx m_trx = null; private Trx m_trx = null;
private it.sauronsoftware.cron4j.Scheduler cronScheduler;
private Predictor predictor;
/** /**
* Work * Work
*/ */
@ -91,18 +83,18 @@ public class Scheduler extends AdempiereServer
log.log(Level.WARNING, process.toString(), e); log.log(Level.WARNING, process.toString(), e);
m_summary.append(e.toString()); m_summary.append(e.toString());
} }
finally finally
{ {
if (m_trx != null) if (m_trx != null)
m_trx.close(); m_trx.close();
} }
// //
int no = m_model.deleteLog(); int no = m_model.deleteLog();
m_summary.append("Logs deleted=").append(no); m_summary.append("Logs deleted=").append(no);
// //
MSchedulerLog pLog = new MSchedulerLog(m_model, m_summary.toString()); 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))); + " - " + TimeUtil.formatElapsed(new Timestamp(p_startWork)));
pLog.save(); pLog.save();
} // doWork } // doWork
@ -127,10 +119,10 @@ public class Scheduler extends AdempiereServer
// //
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
AD_Table_ID, Record_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_Client_ID(m_model.getAD_Client_ID());
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
if (!process.processIt(pi, m_trx) && pi.getClassName() != null) if (!process.processIt(pi, m_trx) && pi.getClassName() != null)
return "Process failed: (" + pi.getClassName() + ") " + pi.getSummary(); return "Process failed: (" + pi.getClassName() + ") " + pi.getSummary();
// Report // Report
@ -141,41 +133,28 @@ public class Scheduler extends AdempiereServer
File report = re.getPDF(); File report = re.getPDF();
// Notice // Notice
int AD_Message_ID = 884; // HARDCODED SchedulerResult int AD_Message_ID = 884; // HARDCODED SchedulerResult
MUser from = new MUser(getCtx(), pi.getAD_User_ID(), null);
Integer[] userIDs = m_model.getRecipientAD_User_IDs(); Integer[] userIDs = m_model.getRecipientAD_User_IDs();
for (int i = 0; i < userIDs.length; i++) for (int i = 0; i < userIDs.length; i++)
{ {
MUser user = new MUser(getCtx(), userIDs[i].intValue(), null); MNote note = new MNote(getCtx(),
boolean email = user.isNotificationEMail(); AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName());
boolean notice = user.isNotificationNote(); note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID());
note.setTextMsg(m_model.getName());
if (notice) note.setDescription(m_model.getDescription());
{ note.setRecord(AD_Table_ID, Record_ID);
MNote note = new MNote(getCtx(), note.save();
AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName()); // Attachment
note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); MAttachment attachment = new MAttachment (getCtx(),
note.setTextMsg(m_model.getName()); X_AD_Note.Table_ID, note.getAD_Note_ID(), m_trx.getTrxName());
note.setDescription(m_model.getDescription()); attachment.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID());
note.setRecord(AD_Table_ID, Record_ID); attachment.addEntry(report);
note.save(); attachment.setTextMsg(m_model.getName());
// Attachment attachment.save();
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);
}
} }
// //
return pi.getSummary(); return pi.getSummary();
} // runReport } // runReport
/** /**
* Run Process * Run Process
* @param process process * @param process process
@ -194,89 +173,73 @@ public class Scheduler extends AdempiereServer
// //
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
AD_Table_ID, Record_ID); AD_Table_ID, Record_ID);
int AD_User_ID = getAD_User_ID(); pi.setAD_User_ID(m_model.getUpdatedBy());
pi.setAD_User_ID(AD_User_ID);
pi.setAD_Client_ID(m_model.getAD_Client_ID()); pi.setAD_Client_ID(m_model.getAD_Client_ID());
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
//notify supervisor if error
MUser from = new MUser(getCtx(), pi.getAD_User_ID(), null); MUser from = new MUser(getCtx(), pi.getAD_User_ID(), null);
if ( !process.processIt(pi, m_trx) )
//notify supervisor if error
if ( !process.processIt(pi, m_trx) )
{ {
int supervisor = m_model.getSupervisor_ID(); int supervisor = m_model.getSupervisor_ID();
if (supervisor > 0) if (supervisor > 0)
{ {
MUser user = new MUser(getCtx(), supervisor, null); MUser user = new MUser(getCtx(), supervisor, null);
boolean email = user.isNotificationEMail(); String type = user.getNotificationType();
boolean notice = user.isNotificationNote(); boolean email = X_AD_User.NOTIFICATIONTYPE_EMail.equals(type) ||
X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type);
if (email || notice) boolean notice = X_AD_User.NOTIFICATIONTYPE_Notice.equals(type) ||
ProcessInfoUtil.setLogFromDB(pi); X_AD_User.NOTIFICATIONTYPE_EMailPlusNotice.equals(type);
if (email)
if (email)
{ {
MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); 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) { if (notice) {
int AD_Message_ID = 442; //ProcessRunError int AD_Message_ID = 442; //ProcessRunError
MNote note = new MNote(getCtx(), MNote note = new MNote(getCtx(),
AD_Message_ID, supervisor, null); AD_Message_ID, supervisor, m_trx.getTrxName());
note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID());
note.setTextMsg(pi.getSummary()); note.setTextMsg(pi.getSummary());
//note.setDescription(); //note.setDescription();
note.setRecord(MPInstance.Table_ID, pi.getAD_PInstance_ID()); note.setRecord(X_AD_PInstance.Table_ID, pi.getAD_PInstance_ID());
note.save(); note.save();
} }
} }
} }
else else
{ {
Integer[] userIDs = m_model.getRecipientAD_User_IDs(); Integer[] userIDs = m_model.getRecipientAD_User_IDs();
if (userIDs.length > 0) for (int i = 0; i < userIDs.length; i++)
{ {
ProcessInfoUtil.setLogFromDB(pi); MUser user = new MUser(getCtx(), userIDs[i].intValue(), null);
for (int i = 0; i < userIDs.length; i++) 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); MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID());
boolean email = user.isNotificationEMail(); // client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null);
boolean notice = user.isNotificationNote(); client.sendEMail(from, user, m_model.getName(), pi.getSummary() + " " + pi.getLogInfo(), null);
}
if (email) if (notice) {
{ int AD_Message_ID = 441; //ProcessOK
MClient client = MClient.get(m_model.getCtx(), m_model.getAD_Client_ID()); MNote note = new MNote(getCtx(),
client.sendEMail(from, user, process.getName(), pi.getSummary() + " " + pi.getLogInfo(), null); AD_Message_ID, userIDs[i].intValue(), m_trx.getTrxName());
} note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID());
if (notice) { note.setTextMsg(pi.getSummary());
int AD_Message_ID = 441; //ProcessOK //note.setDescription();
MNote note = new MNote(getCtx(), note.setRecord(X_AD_PInstance.Table_ID, pi.getAD_PInstance_ID());
AD_Message_ID, userIDs[i].intValue(), null); note.save();
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();
}
} }
} }
} }
return pi.getSummary(); return pi.getSummary();
} // runProcess } // 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 * Fill Parameter
* @param pInstance process instance * @param pInstance process instance
@ -318,25 +281,25 @@ public class Scheduler extends AdempiereServer
if (env.length() == 0) if (env.length() == 0)
{ {
log.warning(sPara.getColumnName() log.warning(sPara.getColumnName()
+ " - not in environment =" + columnName + " - not in environment =" + columnName
+ "(" + variable + ")"); + "(" + variable + ")");
break; break;
} }
else else
value = env; value = env;
} // @variable@ } // @variable@
// No Value // No Value
if (value == null) if (value == null)
{ {
log.fine(sPara.getColumnName() + " - empty"); log.fine(sPara.getColumnName() + " - empty");
break; break;
} }
// Convert to Type // Convert to Type
try try
{ {
if (DisplayType.isNumeric(sPara.getDisplayType()) if (DisplayType.isNumeric(sPara.getDisplayType())
|| DisplayType.isID(sPara.getDisplayType())) || DisplayType.isID(sPara.getDisplayType()))
{ {
BigDecimal bd = null; BigDecimal bd = null;
@ -384,7 +347,7 @@ public class Scheduler extends AdempiereServer
} // instance parameter loop } // instance parameter loop
} // fillParameter } // fillParameter
/** /**
* Get Server Info * Get Server Info
* @return info * @return info
@ -394,4 +357,34 @@ public class Scheduler extends AdempiereServer
return "#" + p_runCount + " - Last=" + m_summary.toString(); return "#" + p_runCount + " - Last=" + m_summary.toString();
} // getServerInfo } // 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 } // Scheduler

View File

@ -315,6 +315,10 @@
<zipfileset src="lib/xercesImpl.jar"> <zipfileset src="lib/xercesImpl.jar">
<patternset refid="manifest.exclude" /> <patternset refid="manifest.exclude" />
</zipfileset> </zipfileset>
<!-- cron job -->
<zipfileset src="lib/cron4j-2.2.1.jar">
<patternset refid="manifest.exclude" />
</zipfileset>
</jar> </jar>
</target> </target>