use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class PreJobCommandResource method getIds.
public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
List<String> gsiSSHPreJobResourceIDs = new ArrayList<String>();
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
Query q;
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
List results;
if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
PreJobCommand preJobCommand = (PreJobCommand) result;
gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
}
}
} else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
generator.setParameter(PreJobCommandConstants.COMMAND, value);
q = generator.selectQuery(em);
results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
PreJobCommand preJobCommand = (PreJobCommand) result;
gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
}
}
} else {
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
logger.error("Unsupported field name for GSISSH Pre Job resource.", new IllegalArgumentException());
throw new IllegalArgumentException("Unsupported field name for GSISSH Pre JOb 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 gsiSSHPreJobResourceIDs;
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class ResourceJobManagerResource method remove.
@Override
public void remove(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
Query q = generator.deleteQuery(em);
q.executeUpdate();
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();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class ResourceJobManagerResource method get.
@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
Query q = generator.selectQuery(em);
ResourceJobManager resourceJobManager = (ResourceJobManager) q.getSingleResult();
ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return resourceJobManagerResource;
} 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.util.AppCatalogQueryGenerator in project airavata by apache.
the class ScpDataMovementResource method remove.
@Override
public void remove(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
Query q = generator.deleteQuery(em);
q.executeUpdate();
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();
}
}
}
use of org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator in project airavata by apache.
the class ScpDataMovementResource method get.
@Override
public AppCatalogResource get(Object identifier) throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
Query q = generator.selectQuery(em);
ScpDataMovement scpDataMovement = (ScpDataMovement) q.getSingleResult();
ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
em.getTransaction().commit();
if (em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
return scpDataMovementResource;
} 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