use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.
the class AppEnvironmentResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
AppEnvironment existigAppEnv = em.find(AppEnvironment.class, new AppEnvironment_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 (existigAppEnv != null) {
existigAppEnv.setValue(value);
existigAppEnv.setApplicationDeployment(deployment);
existigAppEnv.setOrder(order);
em.merge(existigAppEnv);
} else {
AppEnvironment appEnvironment = new AppEnvironment();
appEnvironment.setDeploymentID(deploymentId);
appEnvironment.setName(name);
appEnvironment.setValue(value);
appEnvironment.setOrder(order);
appEnvironment.setApplicationDeployment(deployment);
em.persist(appEnvironment);
}
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 getIds.
@Override
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> appDeployments = new ArrayList<String>();
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;
appDeployments.add(deployment.getDeploymentID());
}
}
} 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;
appDeployments.add(deployment.getDeploymentID());
}
}
} 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();
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 getAllIds.
@Override
public List<String> getAllIds() throws AppCatalogException {
List<String> appDeployments = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
Query q = generator.selectQuery(em);
List results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationDeployment deployment = (ApplicationDeployment) result;
appDeployments.add(deployment.getDeploymentID());
}
}
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 getAll.
@Override
public List<AppCatalogResource> getAll() throws AppCatalogException {
List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
generator.setParameter(ApplicationDeploymentConstants.GATEWAY_ID, gatewayId);
Query q = generator.selectQuery(em);
List 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);
}
}
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 LibraryApendPathResource method save.
@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_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 (existigApendPath != null) {
existigApendPath.setValue(value);
existigApendPath.setApplicationDeployment(deployment);
em.merge(existigApendPath);
} else {
LibraryApendPath apendPath = new LibraryApendPath();
apendPath.setDeploymentID(deploymentId);
apendPath.setName(name);
apendPath.setValue(value);
apendPath.setApplicationDeployment(deployment);
em.persist(apendPath);
}
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();
}
}
}
Aggregations