use of org.olat.core.commons.persistence.DBQuery in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_8_1_0 method getEfficiencyStatement.
private List<Property> getEfficiencyStatement(int firstResult) {
StringBuilder query = new StringBuilder();
query.append("select p from ").append(Property.class.getName()).append(" as p ");
query.append(" where p.category='efficiencyStatement' order by p.key");
DBQuery dbQuery = dbInstance.createQuery(query.toString());
dbQuery.setFirstResult(firstResult);
dbQuery.setMaxResults(REPO_ENTRIES_BATCH_SIZE);
@SuppressWarnings("unchecked") List<Property> props = dbQuery.list();
return props;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPStructureManager method getAllReferencesForArtefact.
protected List<PortfolioStructure> getAllReferencesForArtefact(AbstractArtefact artefact) {
StringBuilder sb = new StringBuilder();
sb.append("select link.structureElement from ").append(EPStructureToArtefactLink.class.getName()).append(" link").append(" where link.artefact=:artefactEl ");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setEntity("artefactEl", artefact);
@SuppressWarnings("unchecked") List<PortfolioStructure> pfList = query.list();
return pfList;
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
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 klemens.
the class EPStructureManager method loadPortfolioRepositoryEntryByMapKey.
/**
* Load the repository entry of a template with the map key
* @param key The template key
* @return The repository entry
*/
public RepositoryEntry loadPortfolioRepositoryEntryByMapKey(Long key) {
if (key == null)
throw new NullPointerException();
StringBuilder sb = new StringBuilder();
sb.append("select repo from ").append(RepositoryEntry.class.getName()).append(" repo").append(" where repo.olatResource in (select map.olatResource from ").append(EPStructuredMapTemplate.class.getName()).append(" map where map.key=:key").append(")");
DBQuery query = dbInstance.createQuery(sb.toString());
query.setLong("key", key);
@SuppressWarnings("unchecked") List<RepositoryEntry> entries = query.list();
// if not found, it is an empty list
if (entries.isEmpty())
return null;
return entries.get(0);
}
use of org.olat.core.commons.persistence.DBQuery in project openolat by klemens.
the class EPArtefactManager method loadArtefactsByBusinessPath.
protected List<AbstractArtefact> loadArtefactsByBusinessPath(String businessPath, Identity author) {
if (!StringHelper.containsNonWhitespace(businessPath))
return null;
StringBuilder sb = new StringBuilder();
sb.append("select artefact from ").append(AbstractArtefact.class.getName()).append(" artefact").append(" where artefact.businessPath=:bpath");
if (author != null) {
sb.append(" and artefact.author=:ident");
}
DBQuery query = dbInstance.createQuery(sb.toString());
query.setString("bpath", businessPath);
if (author != null) {
query.setEntity("ident", author);
}
@SuppressWarnings("unchecked") List<AbstractArtefact> artefacts = query.list();
// if not found, it is an empty list
if (artefacts.isEmpty())
return null;
return artefacts;
}
Aggregations