Search in sources :

Example 11 with ApplicationDeployment

use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.

the class ModuleLoadCmdResource method save.

@Override
public void save() throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        ModuleLoadCmd moduleLoadCmd;
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        if (existingModuleLoadCmd == null) {
            moduleLoadCmd = new ModuleLoadCmd();
        } else {
            moduleLoadCmd = existingModuleLoadCmd;
        }
        moduleLoadCmd.setCmd(getCmd());
        moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
        moduleLoadCmd.setOrder(order);
        ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class, getAppDeploymentId());
        moduleLoadCmd.setApplicationDeployment(applicationDeployment);
        if (existingModuleLoadCmd == null) {
            em.persist(moduleLoadCmd);
        } else {
            em.merge(moduleLoadCmd);
        }
        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();
        }
    }
}
Also used : ModuleLoadCmd_PK(org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd_PK) EntityManager(javax.persistence.EntityManager) ApplicationDeployment(org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ModuleLoadCmd(org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 12 with ApplicationDeployment

use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.

the class PostJobCommandResource method save.

public void save() throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        PostJobCommand existingPostJobCommand = em.find(PostJobCommand.class, new PostJobCommandPK(appDeploymentId, command));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
        if (existingPostJobCommand != null) {
            existingPostJobCommand.setDeploymentId(appDeploymentId);
            existingPostJobCommand.setCommand(command);
            existingPostJobCommand.setOrder(order);
            existingPostJobCommand.setDeployment(deployment);
            em.merge(existingPostJobCommand);
        } else {
            PostJobCommand postJobCommand = new PostJobCommand();
            postJobCommand.setDeploymentId(appDeploymentId);
            postJobCommand.setCommand(command);
            postJobCommand.setOrder(order);
            postJobCommand.setDeployment(deployment);
            em.persist(postJobCommand);
        }
        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();
        }
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ApplicationDeployment(org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) PostJobCommand(org.apache.airavata.registry.core.app.catalog.model.PostJobCommand) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) PostJobCommandPK(org.apache.airavata.registry.core.app.catalog.model.PostJobCommandPK)

Example 13 with ApplicationDeployment

use of org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment in project airavata by apache.

the class PreJobCommandResource method save.

public void save() throws AppCatalogException {
    EntityManager em = null;
    try {
        em = AppCatalogJPAUtils.getEntityManager();
        PreJobCommand existingPreJobCommand = em.find(PreJobCommand.class, new PreJobCommandPK(appDeploymentId, command));
        if (em.isOpen()) {
            if (em.getTransaction().isActive()) {
                em.getTransaction().rollback();
            }
            em.close();
        }
        em = AppCatalogJPAUtils.getEntityManager();
        em.getTransaction().begin();
        ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
        if (existingPreJobCommand != null) {
            existingPreJobCommand.setDeploymentId(appDeploymentId);
            existingPreJobCommand.setCommand(command);
            existingPreJobCommand.setApplicationDeployment(deployment);
            existingPreJobCommand.setOrder(order);
            em.merge(existingPreJobCommand);
        } else {
            PreJobCommand preJobCommand = new PreJobCommand();
            preJobCommand.setDeploymentId(appDeploymentId);
            preJobCommand.setCommand(command);
            preJobCommand.setOrder(order);
            preJobCommand.setApplicationDeployment(deployment);
            em.persist(preJobCommand);
        }
        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();
        }
    }
}
Also used : PreJobCommand(org.apache.airavata.registry.core.app.catalog.model.PreJobCommand) EntityManager(javax.persistence.EntityManager) ApplicationDeployment(org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) PreJobCommandPK(org.apache.airavata.registry.core.app.catalog.model.PreJobCommandPK) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Aggregations

EntityManager (javax.persistence.EntityManager)13 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)13 ApplicationDeployment (org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment)13 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)13 Query (javax.persistence.Query)5 AppCatalogQueryGenerator (org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AppEnvironment (org.apache.airavata.registry.core.app.catalog.model.AppEnvironment)1 AppEnvironment_PK (org.apache.airavata.registry.core.app.catalog.model.AppEnvironment_PK)1 ApplicationModule (org.apache.airavata.registry.core.app.catalog.model.ApplicationModule)1 ComputeResource (org.apache.airavata.registry.core.app.catalog.model.ComputeResource)1 LibraryApendPath (org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath)1 LibraryApendPath_PK (org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath_PK)1 LibraryPrepandPath (org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath)1 LibraryPrepandPath_PK (org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath_PK)1 ModuleLoadCmd (org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd)1 ModuleLoadCmd_PK (org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd_PK)1 PostJobCommand (org.apache.airavata.registry.core.app.catalog.model.PostJobCommand)1 PostJobCommandPK (org.apache.airavata.registry.core.app.catalog.model.PostJobCommandPK)1