public void save() throws RegistryException {
EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
User_Workflow existingWF = em.find(User_Workflow.class, new User_Workflow_PK(name, worker.getUser(), gateway.getGatewayName()));
em.close();
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
User_Workflow userWorkflow = new User_Workflow();
userWorkflow.setTemplate_name(name);
if (lastUpdateDate == null) {
java.util.Date date = new java.util.Date();
lastUpdateDate = new Timestamp(date.getTime());
}
userWorkflow.setLast_updated_date(lastUpdateDate);
byte[] bytes = content.getBytes();
userWorkflow.setWorkflow_graph(bytes);
userWorkflow.setGateway_name(this.gateway.getGatewayName());
userWorkflow.setOwner(this.getWorker().getUser());
userWorkflow.setPath(path);
if (existingWF != null) {
existingWF.setGateway_name(this.gateway.getGatewayName());
existingWF.setOwner(this.getWorker().getUser());
existingWF.setTemplate_name(name);
existingWF.setLast_updated_date(lastUpdateDate);