Commit 23ae6698 by nilu

data migration changes

parent 07d83d34
......@@ -5,11 +5,13 @@ import java.util.Collection;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.rdbms.filters.IsNullFilter;
import oneit.objstore.services.TransactionServices;
import oneit.objstore.services.TransactionTask;
import oneit.utils.NestedException;
import oneit.utils.filter.CollectionFilter;
import oneit.utils.parsers.FieldException;
import performa.orm.ILOJobTitle;
import performa.orm.Job;
import performa.orm.JobApplication;
import performa.orm.MessageTemplate;
......@@ -31,12 +33,27 @@ public class WorkflowDataMigration
{
try
{
Job[] jobs = Job.searchAll(objTran);
Job[] jobs = Job.SearchByAll().andWorkFlowTemplate(new IsNullFilter<>()).search(objTran);
MessageTemplate[] incomplete = MessageTemplate.SearchByAll().andApplicationStatus(new EqualsFilter<>(ApplicationStatus.DRAFT)).andIsSystemGenerated(new EqualsFilter<>(Boolean.TRUE)).search(objTran);
MessageTemplate[] postIngest = MessageTemplate.SearchByAll().andApplicationStatus(new EqualsFilter<>(ApplicationStatus.POST_INGEST)).andIsSystemGenerated(new EqualsFilter<>(Boolean.TRUE)).search(objTran);
for(Job job : jobs)
{
if(job.getILOJobTitle() == null && job.getOccupation() != null)
{
ILOJobTitle[] titles = ILOJobTitle.SearchByAll().andOccupation(new EqualsFilter<>(job.getOccupation())).search(objTran);
if(titles.length > 0)
{
job.setILOJobTitle(titles[0]);
}
}
if(job.getHiringTeam() == null || job.getILOJobTitle() == null)
{
continue;
}
WorkFlowTemplate wfTemplate = WorkFlowTemplate.createWorkFlowTemplate(objTran);
wfTemplate.setTemplateName(job.getJobTitle());
......@@ -93,7 +110,6 @@ public class WorkflowDataMigration
createWorkFlowStage(objTran, wfTemplate, "Unsuitable", StageType.UNSUITABLE, sortOrder++);
// TODO: might have to move to another transaction
for(JobApplication jobApplication : job.getJobApplicationsSet())
{
jobApplication.setWorkFlowStage(getWFStageByStatus(wfTemplate, jobApplication.getApplicationStatus()));
......@@ -105,31 +121,32 @@ public class WorkflowDataMigration
throw new NestedException(e);
}
}
});
}
private void createWorkFlowMessage(ObjectTransaction objTran, WorkFlowStage stage, MessageTemplate mTemplate) throws StorageException, FieldException
{
WorkFlowMessage wfMessage = WorkFlowMessage.createWorkFlowMessage(objTran);
wfMessage.setWorkFlowStage(stage);
wfMessage.setBusinessHoursOnly(mTemplate.getBusinessHoursOnly());
wfMessage.setMessageTemplate(mTemplate);
wfMessage.setDelay(getDelay(mTemplate));
wfMessage.setVariance(mTemplate.getVariance().toString() + "m");
}
private static void createWorkFlowMessage(ObjectTransaction objTran, WorkFlowStage stage, MessageTemplate mTemplate) throws StorageException, FieldException
{
WorkFlowMessage wfMessage = WorkFlowMessage.createWorkFlowMessage(objTran);
private WorkFlowStage createWorkFlowStage(ObjectTransaction objTran, WorkFlowTemplate wfTemplate, String name, StageType stageType, int sortOrder) throws FieldException, StorageException
{
WorkFlowStage wfStage = WorkFlowStage.createWorkFlowStage(objTran);
wfStage.setWorkFlowTemplate(wfTemplate);
wfStage.setName(name);
wfStage.setStageType(stageType);
return wfStage;
}
});
wfMessage.setWorkFlowStage(stage);
wfMessage.setBusinessHoursOnly(mTemplate.getBusinessHoursOnly());
wfMessage.setMessageTemplate(mTemplate);
wfMessage.setDelay(getDelay(mTemplate));
wfMessage.setVariance(mTemplate.getVariance().toString() + "m");
}
private static WorkFlowStage createWorkFlowStage(ObjectTransaction objTran, WorkFlowTemplate wfTemplate, String name, StageType stageType, int sortOrder) throws FieldException, StorageException
{
WorkFlowStage wfStage = WorkFlowStage.createWorkFlowStage(objTran);
wfStage.setWorkFlowTemplate(wfTemplate);
wfStage.setName(name);
wfStage.setStageType(stageType);
wfStage.setSortOrder(sortOrder);
return wfStage;
}
private static String getDelay(MessageTemplate mTemplate)
{
StringBuilder sb = new StringBuilder();
......@@ -155,9 +172,8 @@ public class WorkflowDataMigration
{
return StageType.UNSUITABLE;
}
// TODO: map other statuses
return null;
return StageType.INTERVIEW;
}
public static WorkFlowStage getWFStageByStatus(WorkFlowTemplate template , ApplicationStatus status)
......@@ -176,7 +192,7 @@ public class WorkflowDataMigration
}
// TODO: map other statuses
return null;
return getWFStage(template, StageType.INTERVIEW);
}
private static WorkFlowStage getWFStage(WorkFlowTemplate template, StageType stageType)
......
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