use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class RepositoryManagerTest method genericANDQueryWithRoles_byauthor.
@Test
public void genericANDQueryWithRoles_byauthor() {
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("author-re-");
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
repositoryEntryRelationDao.addRole(owner, re, GroupRoles.owner.name());
dbInstance.commitAndCloseSession();
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
params.setRoles(new Roles(true, false, false, false, false, false, false));
params.setAuthor(owner.getName());
List<RepositoryEntry> myEntries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, true);
Assert.assertNotNull(myEntries);
Assert.assertEquals(1, myEntries.size());
Assert.assertTrue(myEntries.contains(re));
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
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 klemens.
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 klemens.
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 klemens.
the class OLATUpgrade_11_0_0 method upgradeAssessmentPropertyTable.
private boolean upgradeAssessmentPropertyTable(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
boolean allOk = true;
if (!uhd.getBooleanDataValue(ASSESSMENT_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 {
allOk &= processCourseAssessmentData(course);
} catch (CorruptedCourseException e) {
log.error("Corrupted course: " + course.getKey(), e);
}
}
counter += courses.size();
log.audit("Assessment data migration processed: " + courses.size() + ", total courses processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (courses.size() == BATCH_SIZE);
uhd.setBooleanDataValue(ASSESSMENT_DATAS, allOk);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return allOk;
}
Aggregations