use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class RepositoryEntriesResource method getEntries.
/**
* List all entries in the OLAT repository
* @response.representation.200.qname {http://www.example.com}repositoryEntryVO
* @response.representation.200.mediaType text/plain, text/html, application/xml, application/json
* @response.representation.200.doc List all entries in the repository
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_REPOENTRYVOes}
* @param start (optional)
* @param limit (optional)
* @param managed (optional)
* @param externalId External ID (optional)
* @param externalRef External reference number (optional)
* @param resourceType The resource type (CourseModule) (optional)
* @param httpRequest The HTTP request
* @param request The RESt request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getEntries(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("managed") Boolean managed, @QueryParam("externalId") String externalId, @QueryParam("externalRef") String externalRef, @QueryParam("resourceType") String resourceType, @Context HttpServletRequest httpRequest, @Context Request request) {
try {
// list of courses open for everybody
Roles roles = getRoles(httpRequest);
Identity identity = getIdentity(httpRequest);
RepositoryManager rm = RepositoryManager.getInstance();
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles);
params.setManaged(managed);
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
if (StringHelper.containsNonWhitespace(externalRef)) {
params.setExternalRef(externalRef);
}
if (StringHelper.containsNonWhitespace(resourceType)) {
params.setResourceTypes(Collections.singletonList(resourceType));
}
if (MediaTypeVariants.isPaged(httpRequest, request)) {
int totalCount = rm.countGenericANDQueryWithRolesRestriction(params);
List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, start, limit, true);
RepositoryEntryVOes voes = new RepositoryEntryVOes();
voes.setRepositoryEntries(toArrayOfVOes(res));
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, 0, -1, false);
RepositoryEntryVO[] voes = toArrayOfVOes(res);
return Response.ok(voes).build();
}
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method upgradeEfficiencyStatementTable.
private boolean upgradeEfficiencyStatementTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(EFFICIENCY_STATEMENT_DATAS)) {
int counter = 0;
final Roles roles = new Roles(true, true, true, true, false, true, false);
final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(roles);
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> courses;
do {
courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
for (RepositoryEntry course : courses) {
try {
convertUserEfficiencyStatemen(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Efficiency statement data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(EFFICIENCY_STATEMENT_DATAS, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_12_0_0 method upgradeLastModified.
private boolean upgradeLastModified(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(LAST_USER_MODIFICATION)) {
int counter = 0;
final Roles roles = new Roles(true, true, true, true, false, true, false);
final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(roles);
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> courses;
do {
courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
for (RepositoryEntry course : courses) {
try {
allOk &= processCourseAssessmentLastModified(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Last modifications migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(LAST_USER_MODIFICATION, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_2_1 method upgradeStatus.
private boolean upgradeStatus(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(STATUS_OLD_TASK_ELEMENT)) {
int counter = 0;
final Roles roles = new Roles(true, false, false, false, false, false, false);
final SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(roles);
params.setResourceTypes(Collections.singletonList("CourseModule"));
List<RepositoryEntry> courses;
do {
courses = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, 50, true);
for (RepositoryEntry course : courses) {
processCourse(course);
}
counter += courses.size();
log.audit("Course for checklist and deprecated tasks migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(STATUS_OLD_TASK_ELEMENT, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceImpl method dedupMembers.
@Override
public void dedupMembers(Identity ureqIdentity, boolean coaches, boolean participants, ProgressDelegate delegate) {
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.setResourceTypes(Collections.singletonList("CourseModule"));
float ratio = -1.0f;
if (delegate != null) {
int numOfEntries = repositoryManager.countGenericANDQueryWithRolesRestriction(params);
ratio = 100.0f / numOfEntries;
}
int counter = 0;
int countForCommit = 0;
float actual = 100.0f;
int batch = 25;
List<RepositoryEntry> entries;
do {
entries = repositoryManager.genericANDQueryWithRolesRestriction(params, counter, batch, true);
for (RepositoryEntry re : entries) {
countForCommit += 2 + dedupSingleRepositoryentry(ureqIdentity, re, coaches, participants, false);
if (countForCommit > 25) {
dbInstance.intermediateCommit();
countForCommit = 0;
}
}
counter += entries.size();
if (delegate != null) {
actual -= (entries.size() * ratio);
delegate.setActual(actual);
}
} while (entries.size() == batch);
if (delegate != null) {
delegate.finished();
}
}
Aggregations