@Override
public void save() throws AppCatalogException {
EntityManager em = null;
try {
em = AppCatalogJPAUtils.getEntityManager();
GridftpEndpoint existingGridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(endpoint, dataMovementInterfaceId));
em.close();
GridftpEndpoint gridftpEndpoint;
em = AppCatalogJPAUtils.getEntityManager();
em.getTransaction().begin();
if (existingGridftpEndpoint == null) {
gridftpEndpoint = new GridftpEndpoint();
} else {
gridftpEndpoint = existingGridftpEndpoint;
}
gridftpEndpoint.setEndpoint(getEndpoint());
gridftpEndpoint.setDataMovementInterfaceId(getDataMovementInterfaceId());
GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, getDataMovementInterfaceId());
gridftpEndpoint.setGridftpDataMovement(gridftpDataMovement);
if (existingGridftpEndpoint == null) {
em.persist(gridftpEndpoint);
} else {
em.merge(gridftpEndpoint);
}