/** @see FlowService#executeJob(String, String, String, long, long, String) */ @Override public Job executeJob( Credentials credentials, String token, String name, String description, long flowInstanceId, long userId, String userEmail) { FlowDao flowDao = daoFactory.getFlowDao(); JobDao jobDao = daoFactory.getJobDao(); Flow flowInstance = flowDao.findById(flowInstanceId, false); Job job = new Job(); job.setToken(token); job.setName(name); job.setDescription(description); job.setFlow(flowInstance); job.setOwnerId(userId); job.setOwnerEmail(userEmail); SimpleCredentials simpleCreds = (SimpleCredentials) credentials; String serializedCreds = simpleCreds.getUserID() + ":" + new String(simpleCreds.getPassword()); job.setCredentials(serializedCreds); jobDao.makePersistent(job); jobScheduler.scheduleJob(job); job.setJobStatus(JobStatus.SCHEDULED); job.setScheduleTimestamp(new Date()); jobDao.makePersistent(job); jobStatusMonitor.start(job, notificationCreator); return job; }
/** @see FlowService#getFlowTemplates() */ @Override public Set<Flow> getFlowTemplates() { FlowDao flowDao = daoFactory.getFlowDao(); Set<Flow> flowSet = new HashSet<Flow>(); flowSet.addAll(flowDao.getFlowTemplates()); return flowSet; }
/** @see FlowService#deleteJob(long) */ @Override public void deleteJob(long jobId) throws IllegalStateException { JobDao jobDao = daoFactory.getJobDao(); JobResultDao resultDao = daoFactory.getJobResultDao(); FlowDao flowDao = daoFactory.getFlowDao(); Job job = jobDao.findById(jobId, false); // Job must be finished to be deleted. if (!job.isDone()) { throw new IllegalArgumentException( "Cannot delete job " + jobId + " because it is still running, scheduled or submitted."); } for (JobResult result : job.getResults()) { resultDao.makeTransient(result); } jobDao.makeTransient(job); flowDao.makeTransient(job.getFlow()); // delete the results from disk? }
/** @see FlowService#getFlow(long) */ @Override public Flow getFlow(long flowId) { FlowDao flowDao = daoFactory.getFlowDao(); Flow flow = flowDao.findById(flowId, false); return flow; }
/** @see FlowService#storeFlowInstance(Flow) */ public Long storeFlowInstance(Flow instance) { FlowDao flowDao = daoFactory.getFlowDao(); flowDao.makePersistent(instance); return instance.getId(); }