Search in sources :

Example 1 with PoolImpl

use of org.olat.modules.qpool.model.PoolImpl in project OpenOLAT by OpenOLAT.

the class PoolDAO method createPool.

public PoolImpl createPool(Identity owner, String name, boolean publicPool) {
    PoolImpl pool = new PoolImpl();
    pool.setCreationDate(new Date());
    pool.setLastModified(new Date());
    pool.setName(name);
    pool.setPublicPool(publicPool);
    SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
    pool.setOwnerGroup(ownerGroup);
    dbInstance.getCurrentEntityManager().persist(pool);
    if (owner != null) {
        securityManager.addIdentityToSecurityGroup(owner, ownerGroup);
    }
    return pool;
}
Also used : PoolImpl(org.olat.modules.qpool.model.PoolImpl) SecurityGroup(org.olat.basesecurity.SecurityGroup) Date(java.util.Date)

Example 2 with PoolImpl

use of org.olat.modules.qpool.model.PoolImpl in project openolat by klemens.

the class PoolsAdminController method doManageOwners.

private void doManageOwners(UserRequest ureq, Pool pool) {
    if (pool instanceof PoolImpl) {
        PoolImpl poolImpl = (PoolImpl) pool;
        groupCtrl = new GroupController(ureq, getWindowControl(), true, true, false, true, false, false, poolImpl.getOwnerGroup());
        groupCtrl.setUserObject(pool);
        listenTo(groupCtrl);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), groupCtrl.getInitialComponent(), true, translate("pool.owners"));
        cmc.activate();
        listenTo(cmc);
    }
}
Also used : GroupController(org.olat.admin.securitygroup.gui.GroupController) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) PoolImpl(org.olat.modules.qpool.model.PoolImpl)

Example 3 with PoolImpl

use of org.olat.modules.qpool.model.PoolImpl in project openolat by klemens.

the class PoolDAO method deletePool.

public void deletePool(Pool pool) {
    StringBuilder sb = new StringBuilder();
    sb.append("delete from qpool2item pool2item where pool2item.pool.key=:poolKey");
    dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("poolKey", pool.getKey()).executeUpdate();
    PoolImpl poolRef = dbInstance.getCurrentEntityManager().getReference(PoolImpl.class, pool.getKey());
    dbInstance.getCurrentEntityManager().remove(poolRef);
}
Also used : PoolImpl(org.olat.modules.qpool.model.PoolImpl)

Example 4 with PoolImpl

use of org.olat.modules.qpool.model.PoolImpl in project OpenOLAT by OpenOLAT.

the class PoolDAO method deletePool.

public void deletePool(Pool pool) {
    StringBuilder sb = new StringBuilder();
    sb.append("delete from qpool2item pool2item where pool2item.pool.key=:poolKey");
    dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("poolKey", pool.getKey()).executeUpdate();
    PoolImpl poolRef = dbInstance.getCurrentEntityManager().getReference(PoolImpl.class, pool.getKey());
    dbInstance.getCurrentEntityManager().remove(poolRef);
}
Also used : PoolImpl(org.olat.modules.qpool.model.PoolImpl)

Example 5 with PoolImpl

use of org.olat.modules.qpool.model.PoolImpl in project OpenOLAT by OpenOLAT.

the class QuestionPoolServiceImpl method removeOwners.

@Override
public void removeOwners(List<Identity> owners, List<Pool> pools) {
    if (owners == null || owners.isEmpty() || pools == null || pools.isEmpty()) {
        // nothing to do
        return;
    }
    List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>(pools.size());
    for (Pool pool : pools) {
        SecurityGroup secGroup = ((PoolImpl) pool).getOwnerGroup();
        secGroups.add(secGroup);
    }
    securityManager.removeIdentityFromSecurityGroups(owners, secGroups);
}
Also used : ArrayList(java.util.ArrayList) QuestionItem2Pool(org.olat.modules.qpool.QuestionItem2Pool) Pool(org.olat.modules.qpool.Pool) SecurityGroup(org.olat.basesecurity.SecurityGroup) PoolImpl(org.olat.modules.qpool.model.PoolImpl)

Aggregations

PoolImpl (org.olat.modules.qpool.model.PoolImpl)8 SecurityGroup (org.olat.basesecurity.SecurityGroup)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 GroupController (org.olat.admin.securitygroup.gui.GroupController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Pool (org.olat.modules.qpool.Pool)2 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)2