return i;
}
private Integer addDeliverable(String path, String fileLabel) throws IOException
{
Deliverable d = null;
EntityManager em = Helpers.getNewEm();
try
{
this.ji = em.find(JobInstance.class, ji.getId());
String outputRoot = this.ji.getNode().getDlRepo();
String ext = FilenameUtils.getExtension(path);
String destPath = FilenameUtils.concat(outputRoot,
"" + ji.getJd().getApplicationName() + "/" + ji.getId() + "/" + UUID.randomUUID() + "." + ext);
String fileName = FilenameUtils.getName(path);
FileUtils.moveFile(new File(path), new File(destPath));
jqmlogger.debug("A deliverable is added. Stored as " + destPath + ". Initial name: " + fileName);
em.getTransaction().begin();
d = Helpers.createDeliverable(destPath, fileName, fileLabel, this.ji.getId(), em);
em.getTransaction().commit();
}
finally
{
em.close();
}
return d.getId();
}