public void save() throws RegistryException {
EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskDetailResource.getTaskId()));
em.close();
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
ApplicationOutput applicationOutput = new ApplicationOutput();
TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
applicationOutput.setTask(taskDetail);
applicationOutput.setTaskId(taskDetail.getTaskId());
applicationOutput.setOutputKey(outputKey);
applicationOutput.setOutputKeyType(outputType);
if (value != null){
applicationOutput.setValue(value.toCharArray());
}
applicationOutput.setMetadata(metadata);
if (existingOutput != null) {
existingOutput.setTask(taskDetail);
existingOutput.setTaskId(taskDetail.getTaskId());
existingOutput.setOutputKey(outputKey);