@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
em.close();
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ApplicationModule applicationModule = em.find(ApplicationModule.class, appModuleId);
ComputeResource computeHost = em.find(ComputeResource.class, hostId);
if (existingDeployment != null){
existingDeployment.setDeploymentID(deploymentId);
existingDeployment.setApplicationDesc(appDes);
existingDeployment.setAppModuleID(appModuleId);
existingDeployment.setApplicationModule(applicationModule);
existingDeployment.setComputeResource(computeHost);
existingDeployment.setHostID(hostId);
existingDeployment.setExecutablePath(executablePath);
existingDeployment.setParallelism(parallelism);
em.merge(existingDeployment);
}else {
ApplicationDeployment deployment = new ApplicationDeployment();
deployment.setApplicationDesc(appDes);
deployment.setDeploymentID(deploymentId);
deployment.setAppModuleID(appModuleId);
deployment.setHostID(hostId);
deployment.setApplicationModule(applicationModule);
deployment.setComputeResource(computeHost);
deployment.setExecutablePath(executablePath);
deployment.setParallelism(parallelism);
em.persist(deployment);
}
em.getTransaction().commit();
em.close();
} catch (Exception e) {