use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class JpaOrganizationDao method doRemove.
@Transactional
protected void doRemove(String organizationId) {
final EntityManager manager = managerProvider.get();
final OrganizationImpl organization = manager.find(OrganizationImpl.class, organizationId);
if (organization != null) {
manager.remove(organization);
manager.flush();
}
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationJpaTckModule method configure.
@Override
protected void configure() {
install(new JpaPersistModule("main"));
H2DBTestServer server = H2DBTestServer.startDefault();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
bind(new TypeLiteral<AbstractPermissionsDomain<MemberImpl>>() {
}).to(OrganizationDomain.class);
bind(new TypeLiteral<TckRepository<OrganizationImpl>>() {
}).to(JpaOrganizationImplTckRepository.class);
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).toInstance(new JpaTckRepository<>(UserImpl.class));
bind(new TypeLiteral<TckRepository<MemberImpl>>() {
}).toInstance(new JpaTckRepository<>(MemberImpl.class));
bind(new TypeLiteral<TckRepository<OrganizationDistributedResourcesImpl>>() {
}).toInstance(new JpaTckRepository<>(OrganizationDistributedResourcesImpl.class));
bind(OrganizationDao.class).to(JpaOrganizationDao.class);
bind(MemberDao.class).to(JpaMemberDao.class);
bind(OrganizationDistributedResourcesDao.class).to(JpaOrganizationDistributedResourcesDao.class);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.
the class OrganizationResourcesDistributorTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
lenient().doNothing().when(manager).checkResourcesAvailability(anyString(), any());
lenient().when(resourcesLocks.lock(anyString())).thenReturn(lock);
lenient().when(organizationManager.getById(ORG_ID)).thenReturn(new OrganizationImpl(ORG_ID, ORG_ID + "name", PARENT_ORG_ID));
lenient().when(organizationManager.getById(PARENT_ORG_ID)).thenReturn(new OrganizationImpl(PARENT_ORG_ID, PARENT_ORG_ID + "name", null));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.
the class OrganizationalAccountAvailableResourcesProviderTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
lenient().when(resourceManagerProvider.get()).thenReturn(resourceManager);
rootOrganization = new OrganizationImpl(ROOT_ORG_ID, ROOT_ORG_NAME, null);
suborganization = new OrganizationImpl(SUBORG_ID, "root/suborg", ROOT_ORG_ID);
subsuborganization = new OrganizationImpl(SUBSUBORG_ID, "root/suborg/subsuborg", SUBORG_ID);
lenient().when(organizationManager.getById(ROOT_ORG_ID)).thenReturn(rootOrganization);
lenient().when(organizationManager.getById(SUBORG_ID)).thenReturn(suborganization);
lenient().when(organizationManager.getById(SUBSUBORG_ID)).thenReturn(subsuborganization);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.
the class JpaOrganizationImplTckRepository method removeAll.
@Override
public void removeAll() throws TckRepositoryException {
uow.begin();
final EntityManager manager = managerProvider.get();
try {
manager.getTransaction().begin();
for (int i = createdOrganizations.size() - 1; i > -1; i--) {
// and may also ignore some configuration options, while EntityManager#remove won't
try {
final OrganizationImpl organizationToRemove = manager.createQuery("SELECT o FROM Organization o " + "WHERE o.id = :id", OrganizationImpl.class).setParameter("id", createdOrganizations.get(i).getId()).getSingleResult();
manager.remove(organizationToRemove);
} catch (NoResultException ignored) {
// it is already removed
}
}
createdOrganizations.clear();
manager.getTransaction().commit();
} catch (RuntimeException x) {
if (manager.getTransaction().isActive()) {
manager.getTransaction().rollback();
}
throw new TckRepositoryException(x.getLocalizedMessage(), x);
} finally {
uow.end();
}
// remove all objects that was created in tests
super.removeAll();
}
Aggregations