Search in sources :

Example 1 with ResourceShareImpl

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

the class QuestionItemDAO method share.

public void share(QuestionItem item, OLATResource resource) {
    QuestionItem lockedItem = loadForUpdate(item);
    if (!isShared(item, resource)) {
        EntityManager em = dbInstance.getCurrentEntityManager();
        ResourceShareImpl share = new ResourceShareImpl();
        share.setCreationDate(new Date());
        share.setItem(lockedItem);
        share.setResource(resource);
        em.persist(share);
    }
    // release the lock asap
    dbInstance.commit();
}
Also used : EntityManager(javax.persistence.EntityManager) ResourceShareImpl(org.olat.modules.qpool.model.ResourceShareImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) Date(java.util.Date)

Example 2 with ResourceShareImpl

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

the class QuestionItemDAO method share.

public void share(QuestionItem item, OLATResource resource) {
    QuestionItem lockedItem = loadForUpdate(item);
    if (!isShared(item, resource)) {
        EntityManager em = dbInstance.getCurrentEntityManager();
        ResourceShareImpl share = new ResourceShareImpl();
        share.setCreationDate(new Date());
        share.setItem(lockedItem);
        share.setResource(resource);
        em.persist(share);
    }
    // release the lock asap
    dbInstance.commit();
}
Also used : EntityManager(javax.persistence.EntityManager) ResourceShareImpl(org.olat.modules.qpool.model.ResourceShareImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) Date(java.util.Date)

Example 3 with ResourceShareImpl

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

the class QuestionItemDAO method share.

public void share(QuestionItemShort item, List<OLATResource> resources, boolean editable) {
    EntityManager em = dbInstance.getCurrentEntityManager();
    QuestionItem lockedItem = loadForUpdate(item);
    for (OLATResource resource : resources) {
        if (!isShared(lockedItem, resource)) {
            ResourceShareImpl share = new ResourceShareImpl();
            share.setCreationDate(new Date());
            share.setItem(lockedItem);
            share.setEditable(editable);
            share.setResource(resource);
            em.persist(share);
        }
    }
    // release the lock asap
    dbInstance.commit();
}
Also used : EntityManager(javax.persistence.EntityManager) OLATResource(org.olat.resource.OLATResource) ResourceShareImpl(org.olat.modules.qpool.model.ResourceShareImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) Date(java.util.Date)

Example 4 with ResourceShareImpl

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

the class QuestionItemDAO method share.

public void share(QuestionItemShort item, List<OLATResource> resources, boolean editable) {
    EntityManager em = dbInstance.getCurrentEntityManager();
    QuestionItem lockedItem = loadForUpdate(item);
    for (OLATResource resource : resources) {
        if (!isShared(lockedItem, resource)) {
            ResourceShareImpl share = new ResourceShareImpl();
            share.setCreationDate(new Date());
            share.setItem(lockedItem);
            share.setEditable(editable);
            share.setResource(resource);
            em.persist(share);
        }
    }
    // release the lock asap
    dbInstance.commit();
}
Also used : EntityManager(javax.persistence.EntityManager) OLATResource(org.olat.resource.OLATResource) ResourceShareImpl(org.olat.modules.qpool.model.ResourceShareImpl) QuestionItem(org.olat.modules.qpool.QuestionItem) Date(java.util.Date)

Aggregations

Date (java.util.Date)4 EntityManager (javax.persistence.EntityManager)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 ResourceShareImpl (org.olat.modules.qpool.model.ResourceShareImpl)4 OLATResource (org.olat.resource.OLATResource)2