use of org.olat.modules.qpool.model.CollectionToItem in project OpenOLAT by OpenOLAT.
the class CollectionDAO method addItemToCollection.
/**
* Add an item to a collection
* @param itemKey
* @param collection
* @return true if the item is in the collection after the call
*/
public boolean addItemToCollection(QuestionItemShort item, List<QuestionItemCollection> collections) {
QuestionItemImpl lockedItem = questionItemDao.loadForUpdate(item);
if (lockedItem == null) {
return false;
}
Set<QuestionItemCollection> uniqueCollections = new HashSet<>(collections);
for (QuestionItemCollection collection : uniqueCollections) {
if (!isInCollection(collection, lockedItem)) {
CollectionToItem coll2Item = new CollectionToItem();
coll2Item.setCreationDate(new Date());
coll2Item.setCollection(collection);
coll2Item.setItem(lockedItem);
dbInstance.getCurrentEntityManager().persist(coll2Item);
}
}
dbInstance.commit();
return true;
}
use of org.olat.modules.qpool.model.CollectionToItem in project openolat by klemens.
the class CollectionDAO method addItemToCollection.
/**
* Add an item to a collection
* @param itemKey
* @param collection
* @return true if the item is in the collection after the call
*/
public boolean addItemToCollection(QuestionItemShort item, List<QuestionItemCollection> collections) {
QuestionItemImpl lockedItem = questionItemDao.loadForUpdate(item);
if (lockedItem == null) {
return false;
}
Set<QuestionItemCollection> uniqueCollections = new HashSet<>(collections);
for (QuestionItemCollection collection : uniqueCollections) {
if (!isInCollection(collection, lockedItem)) {
CollectionToItem coll2Item = new CollectionToItem();
coll2Item.setCreationDate(new Date());
coll2Item.setCollection(collection);
coll2Item.setItem(lockedItem);
dbInstance.getCurrentEntityManager().persist(coll2Item);
}
}
dbInstance.commit();
return true;
}
Aggregations