use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaStackDao method doCreate.
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
protected void doCreate(StackImpl stack) throws ConflictException, ServerException {
if (stack.getWorkspaceConfig() != null) {
stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
EntityManager manager = managerProvider.get();
manager.persist(stack);
manager.flush();
eventService.publish(new StackPersistedEvent(stack)).propagateException();
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaStackDao method doRemove.
@Transactional(rollbackOn = { RuntimeException.class, ServerException.class })
protected void doRemove(String id) throws ServerException {
final EntityManager manager = managerProvider.get();
final StackImpl stack = manager.find(StackImpl.class, id);
if (stack != null) {
eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException();
manager.remove(stack);
manager.flush();
}
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaStackDao method doUpdate.
@Transactional
protected StackImpl doUpdate(StackImpl update) throws NotFoundException {
final EntityManager manager = managerProvider.get();
if (manager.find(StackImpl.class, update.getId()) == null) {
throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId()));
}
if (update.getWorkspaceConfig() != null) {
update.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
StackImpl merged = manager.merge(update);
manager.flush();
return merged;
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaWorkspaceDao method get.
@Override
@Transactional
public WorkspaceImpl get(String name, String namespace) throws NotFoundException, ServerException {
requireNonNull(name, "Required non-null name");
requireNonNull(namespace, "Required non-null namespace");
try {
return new WorkspaceImpl(managerProvider.get().createNamedQuery("Workspace.getByName", WorkspaceImpl.class).setParameter("namespace", namespace).setParameter("name", name).getSingleResult());
} catch (NoResultException noResEx) {
throw new NotFoundException(format("Workspace with name '%s' in namespace '%s' doesn't exist", name, namespace));
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaFactoryDao method doUpdate.
@Transactional
protected FactoryImpl doUpdate(FactoryImpl update) throws NotFoundException {
final EntityManager manager = managerProvider.get();
if (manager.find(FactoryImpl.class, update.getId()) == null) {
throw new NotFoundException(format("Could not update factory with id %s because it doesn't exist", update.getId()));
}
if (update.getWorkspace() != null) {
update.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
FactoryImpl merged = manager.merge(update);
manager.flush();
return merged;
}
Aggregations