use of org.apache.airavata.registry.core.app.catalog.model.ApplicationModule in project airavata by apache.
the class AppModuleResource method getIds.
@Override
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> moduleResources = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
List results;
if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationModule applicationModule = (ApplicationModule) result;
moduleResources.add(applicationModule.getModuleID());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app module 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 moduleResources;
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationModule in project airavata by apache.
the class AppModuleResource 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_MODULE);
generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
Query q = generator.selectQuery(em);
ApplicationModule applicationModule = (ApplicationModule) q.getSingleResult();
AppModuleResource appModuleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return appModuleResource;
} 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.ApplicationModule in project airavata by apache.
the class AppModuleResource method get.
@Override
public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
List<AppCatalogResource> moduleResources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
List results;
if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
ApplicationModule applicationModule = (ApplicationModule) result;
AppModuleResource moduleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
moduleResources.add(moduleResource);
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for app module 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 moduleResources;
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationModule in project airavata by apache.
the class AppModuleResource method getAll.
@Override
public List<AppCatalogResource> getAll() throws AppCatalogException {
List<AppCatalogResource> appModuleResources = new ArrayList<AppCatalogResource>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
generator.setParameter(ApplicationModuleConstants.GATEWAY_ID, gatewayId);
Query q = generator.selectQuery(em);
List<?> results = q.getResultList();
for (Object result : results) {
ApplicationModule module = (ApplicationModule) result;
AppModuleResource appModuleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, module);
appModuleResources.add(appModuleResource);
}
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
} 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();
}
}
return appModuleResources;
}
use of org.apache.airavata.registry.core.app.catalog.model.ApplicationModule 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();
}
}
}
Aggregations