use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class EPArtefactManager method isArtefactClosed.
protected boolean isArtefactClosed(AbstractArtefact artefact) {
StringBuilder sb = new StringBuilder();
sb.append("select count(link) from ").append(EPStructureToArtefactLink.class.getName()).append(" link ").append(" inner join link.structureElement structure ").append(" inner join structure.root rootStructure").append(" where link.artefact=:artefact and rootStructure.status='closed'");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("artefact", artefact);
Number count = (Number) query.uniqueResult();
return count.intValue() > 0;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class EPStructureManager method loadMapShortByResourceId.
/**
* @param olatResourceable cannot be null
* @return The structure element or null if not found
*/
public EPMapShort loadMapShortByResourceId(Long resourceableId) {
StringBuilder sb = new StringBuilder();
sb.append("select element from ").append(EPMapShort.class.getName()).append(" element").append(" inner join fetch element.olatResource resource").append(" where resource.resId=:resourceId and resource.resName in ('EPDefaultMap','EPStructuredMap','EPStructuredMapTemplate')");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("resourceId", resourceableId);
@SuppressWarnings("unchecked") List<EPMapShort> resources = query.list();
// if not found, it is an empty list
if (resources.isEmpty())
return null;
return resources.get(0);
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method loadMapChildrenByInternalFK.
// helper to get child not by link, but internal direct link to root-element
private List<PortfolioStructure> loadMapChildrenByInternalFK(PortfolioStructure linkedChildStruct, PortfolioStructure root) {
if (root == null)
return null;
StringBuilder sb = new StringBuilder();
sb.append("select stEl from ").append(EPStructureElement.class.getName()).append(" stEl");
// sb.append(" where stEl.root=:rootEl and stEl.structureElSource=:sourceEl"); // filtered by filterLinkedStructs()
sb.append(" where stEl.root=:rootEl");
DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
query.setEntity("rootEl", root);
// query.setLong("sourceEl", ((EPStructureElement)linkedChildStruct).getStructureElSource());
@SuppressWarnings("unchecked") List<PortfolioStructure> resources = query.list();
return resources;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method queryEntries.
public List<RepositoryEntryUpgrade> queryEntries(int firstResult) {
StringBuilder sb = new StringBuilder();
sb.append("select v from ").append(RepositoryEntryUpgrade.class.getName()).append(" v inner join fetch v.olatResource as res order by v.key asc");
DBQuery dbquery = DBFactory.getInstance().createQuery(sb.toString());
dbquery.setFirstResult(firstResult);
dbquery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
@SuppressWarnings("unchecked") List<RepositoryEntryUpgrade> entries = dbquery.list();
return entries;
}
use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method getGroupsOfBGContext.
private List<BusinessGroupUpgrade> getGroupsOfBGContext(BGContextImpl bgContext) {
String q = "select bg from org.olat.upgrade.model.BusinessGroupImpl bg where bg.groupContextKey = :contextKey";
DBQuery query = DBFactory.getInstance().createQuery(q);
query.setLong("contextKey", bgContext.getKey());
@SuppressWarnings("unchecked") List<BusinessGroupUpgrade> groups = query.list();
return groups;
}
Aggregations