use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class LibraryPrepandPathResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
LibraryPrepandPath existigPrepPath = em.find(LibraryPrepandPath.class, new LibraryPrepandPath_PK(deploymentId, name));
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
if (existigPrepPath != null) {
existigPrepPath.setValue(value);
existigPrepPath.setApplicationDeployment(deployment);
em.merge(existigPrepPath);
} else {
LibraryPrepandPath prepandPath = new LibraryPrepandPath();
prepandPath.setDeploymentID(deploymentId);
prepandPath.setName(name);
prepandPath.setValue(value);
prepandPath.setApplicationDeployment(deployment);
em.persist(prepandPath);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class AppDeploymentResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
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);
existingDeployment.setGatewayId(gatewayId);
existingDeployment.setDefaultQueueName(defaultQueueName);
existingDeployment.setDefaultCPUCount(defaultCPUCount);
existingDeployment.setDefaultNodeCount(defaultNodeCount);
existingDeployment.setDefaultWalltime(defaultWalltime);
existingDeployment.setEditableByUser(editableByUser);
existingDeployment.setUpdateTime(AiravataUtils.getCurrentTimestamp());
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);
deployment.setGatewayId(gatewayId);
deployment.setDefaultQueueName(defaultQueueName);
deployment.setDefaultCPUCount(defaultCPUCount);
deployment.setDefaultNodeCount(defaultNodeCount);
deployment.setDefaultWalltime(defaultWalltime);
deployment.setEditableByUser(editableByUser);
deployment.setCreationTime(AiravataUtils.getCurrentTimestamp());
em.persist(deployment);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class AppDeploymentResource method get.
@Override
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
List results;
if (fieldName.equals(ApplicationDeploymentConstants.APP_MODULE_ID)) {
generator.setParameter(ApplicationDeploymentConstants.APP_MODULE_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationDeployment deployment = (ApplicationDeployment) result;
AppDeploymentResource deploymentResource = (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
appDeployments.add(deploymentResource);
}
}
} else if (fieldName.equals(ApplicationDeploymentConstants.COMPUTE_HOST_ID)) {
generator.setParameter(ApplicationDeploymentConstants.COMPUTE_HOST_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationDeployment deployment = (ApplicationDeployment) result;
AppDeploymentResource deploymentResource = (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
appDeployments.add(deploymentResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
return appDeployments;
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class AppDeploymentResource method get.
@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
generator.setParameter(ApplicationDeploymentConstants.DEPLOYMENT_ID, identifier);
Query q = generator.selectQuery(em);
ApplicationDeployment deployment = (ApplicationDeployment) q.getSingleResult();
AppDeploymentResource deploymentResource = (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return deploymentResource;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class AppDeploymentResource method isExists.
@Override
public boolean isExists(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
ApplicationDeployment deployment = em.find(ApplicationDeployment.class, identifier);
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return deployment != null;
} catch (ApplicationSettingsException e) {
logger.error(e.getMessage(), e);
throw new AppCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
Aggregations