Commit 216afacf by Nilu Committed by Harsh Shah

Batch process to close jobs that have passed the apply by date. Making status…

Batch process to close jobs that have passed the apply by date. Making status readonly for such jobs on UI. Setting apply by date when making a job open (not when it's created)
parent 6d0e28ea
package performa.batch;
import oneit.appservices.batch.ORMBatch;
import oneit.logging.*;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.LessThanFilter;
import oneit.utils.DateDiff;
import oneit.utils.parsers.FieldException;
import performa.orm.Job;
import performa.orm.types.JobStatus;
public class CloseJobBatch extends ORMBatch
{
public static LoggingArea CLOSE_JOB_BATCH = LoggingArea.createLoggingArea("CloseJobBatch");
@Override
public void run(ObjectTransaction ot) throws StorageException, FieldException
{
LogMgr.log (CLOSE_JOB_BATCH, LogLevel.DEBUG2, "RUNNING Close Job Batch");
Job[] expiringJobs = Job.SearchByAll()
.andApplyBy(new LessThanFilter<>(DateDiff.getToday()))
.search(ot);
for (Job job : expiringJobs)
{
job.setJobStatus(JobStatus.COMPLETE);
LogMgr.log(CLOSE_JOB_BATCH, LogLevel.DEBUG2, "Setting Job Status to Closed in job : ", job);
}
}
}
\ No newline at end of file
package performa.form;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import oneit.logging.LogLevel;
......@@ -10,6 +11,7 @@ import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import oneit.utils.DateDiff;
import performa.orm.Job;
import performa.orm.types.JobStatus;
......@@ -24,6 +26,7 @@ public class SaveJobFP extends SaveFP
LogMgr.log(Job.LOG, LogLevel.PROCESSING1,"In SaveJobFP saving job : ", job );
job.setJobStatus(JobStatus.OPEN);
job.setApplyBy(DateDiff.add(DateDiff.getToday(), Calendar.DATE, 30));
job.setOpenDate(new Date());
return super.processForm(process, submission, params);
......
......@@ -47,13 +47,14 @@ public class Job extends BaseJob
}
}
public void initAttribs() throws BusinessException
{
setRandomKey(RandomStringGen.getRandomStringGen().generateAlphaNum(4));
setSecUser(SecUser.getTXUser(getTransaction()));
setApplyBy(DateDiff.add(DateDiff.getToday(), Calendar.DATE, 30));
}
@Override
public void validate(ValidationContext context)
{
......@@ -64,6 +65,18 @@ public class Job extends BaseJob
context.check(getAssessmentCriteriasCount() > 0 , this, MULTIPLEREFERENCE_AssessmentCriterias, "atleastOneRequirement");
}
}
@Override
public FieldWriteability getWriteability_JobStatus()
{
if(getJobStatus() == JobStatus.COMPLETE && getApplyBy() != null && getApplyBy().before(DateDiff.getToday()))
{
return FieldWriteability.NOT_IN_GUI;
}
return super.getWriteability_JobStatus();
}
public Boolean jobDetailsCompleted()
......
......@@ -89,4 +89,21 @@
<Attribute name="Additional CSS Class" factory="MetaComponent" component="StringAttrib" mandatory="false"/>
</NODE>
</OBJECTS>
<NODE name="WEB_BATCH::PERFORMA_ADMIN_PORTAL_BATCH">
<TASK factory="Participant" class="oneit.appservices.batch.DefaultTask" lockName="performa">
<RUN class="performa.batch.CloseJobBatch" factory="Participant"/>
<WHEN factory="MetaComponent" component="BatchSchedule" selector="performa.runbatch">
<NODE name="schedule" class="oneit.appservices.batch.DailySchedule">
<NODE name="hourOfDay" factory="Integer" value="0"/>
<NODE name="minuteOfHour" factory="Integer" value="5"/>
</NODE>
</WHEN>
</TASK>
</NODE>
</OBJECTS>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment