Commit 23ae6698 by nilu

data migration changes

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