use of org.apache.airavata.registry.core.replica.catalog.model.DataProduct in project airavata by apache.
the class ReplicaCatalogImpl method createDataProduct.
private String createDataProduct(DataProductModel productModel) throws ReplicaCatalogException {
DataProduct dataProduct = ThriftDataModelConversion.getDataProduct(productModel);
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
em.persist(dataProduct);
em.getTransaction().commit();
em.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new ReplicaCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
return dataProduct.getProductUri();
}
use of org.apache.airavata.registry.core.replica.catalog.model.DataProduct in project airavata by apache.
the class ReplicaCatalogImpl method getParentDataProduct.
@Override
public DataProductModel getParentDataProduct(String productUri) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productUri);
return ThriftDataModelConversion.getDataProductModel(dataProduct.getParentDataProduct());
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new ReplicaCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
use of org.apache.airavata.registry.core.replica.catalog.model.DataProduct in project airavata by apache.
the class ReplicaCatalogImpl method removeDataProduct.
@Override
public boolean removeDataProduct(String productUri) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productUri);
if (dataProduct == null)
return false;
em.getTransaction().begin();
em.remove(dataProduct);
em.getTransaction().commit();
em.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new ReplicaCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
return true;
}
use of org.apache.airavata.registry.core.replica.catalog.model.DataProduct in project airavata by apache.
the class ReplicaCatalogImpl method updateDataProduct.
@Override
public boolean updateDataProduct(DataProductModel productModel) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productModel.getProductUri());
if (dataProduct == null)
return false;
em.getTransaction().begin();
productModel.setCreationTime(dataProduct.getCreationTime().getTime());
productModel.setLastModifiedTime(System.currentTimeMillis());
em.merge(ThriftDataModelConversion.getUpdatedDataProduct(productModel, dataProduct));
em.getTransaction().commit();
em.close();
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new ReplicaCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
return true;
}
use of org.apache.airavata.registry.core.replica.catalog.model.DataProduct in project airavata by apache.
the class ReplicaCatalogImpl method getDataProduct.
@Override
public DataProductModel getDataProduct(String productUri) throws ReplicaCatalogException {
EntityManager em = null;
try {
em = ReplicaCatalogJPAUtils.getEntityManager();
DataProduct dataProduct = em.find(DataProduct.class, productUri);
return ThriftDataModelConversion.getDataProductModel(dataProduct);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new ReplicaCatalogException(e);
} finally {
if (em != null && em.isOpen()) {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
}
}
}
Aggregations