em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingDataMovementProtocol != null) {
existingDataMovementProtocol.setDataMoveID(dataMoveType);
existingDataMovementProtocol.setDataMoveID(dataMoveID);
ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
existingDataMovementProtocol.setComputeResource(computeResource);
existingDataMovementProtocol.setResourceID(resourceID);
em.merge(existingDataMovementProtocol);
} else {
DataMovementProtocol dataMovementProtocol = new DataMovementProtocol();
dataMovementProtocol.setDataMoveType(dataMoveType);
dataMovementProtocol.setDataMoveID(dataMoveID);
dataMovementProtocol.setResourceID(resourceID);
ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
dataMovementProtocol.setComputeResource(computeResource);
em.persist(dataMovementProtocol);
}
em.getTransaction().commit();
em.close();