use of org.olat.upgrade.legacy.NewCacheKey in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method verifyCourseAssessmentData.
/**
* The method compare the content of the cache used in assessment tool
* with the migrated values and vice versa.
*
* @param courseEntry
* @return
*/
private boolean verifyCourseAssessmentData(List<Identity> assessableIdentities, RepositoryEntry courseEntry) {
// load the cache and fill it with the same amount of datas as in assessment tool
final ICourse course = CourseFactory.loadCourse(courseEntry);
final Long courseResourceableId = course.getResourceableId();
StaticCacheWrapper cache = new StaticCacheWrapper();
NewCachePersistingAssessmentManager assessmentManager = new NewCachePersistingAssessmentManager(course, cache);
assessmentManager.preloadCache(assessableIdentities);
dbInstance.commitAndCloseSession();
Set<Identity> assessableIdentitySet = new HashSet<>(assessableIdentities);
List<AssessmentEntryImpl> nodeAssessments = loadAssessmentEntries(courseEntry);
Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap = new HashMap<>();
for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
if (!assessableIdentitySet.contains(nodeAssessment.getIdentity())) {
assessmentManager.preloadCache(nodeAssessment.getIdentity());
}
if (nodeAssessment.getIdentity() != null && nodeAssessment.getRepositoryEntry() != null && nodeAssessment.getRepositoryEntry().getOlatResource() != null) {
nodeAssessmentMap.put(new AssessmentDataKey(nodeAssessment), nodeAssessment);
}
}
dbInstance.commitAndCloseSession();
// compare the value in CourseNodeAssessment with the content of the cache
boolean allOk = true;
for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
allOk &= compareCourseNodeAssessment(nodeAssessment, assessmentManager, course, courseEntry);
}
dbInstance.commitAndCloseSession();
// compare the content of the cache with the CourseNodeAssessments
for (NewCacheKey cacheKey : cache.getKeys()) {
Map<String, Serializable> dataMap = cache.get(cacheKey);
Long identityKey = cacheKey.getIdentityKey();
for (Map.Entry<String, Serializable> data : dataMap.entrySet()) {
String key = data.getKey();
int index = key.indexOf("_");
if (index > 0 && !key.equals("LAST_MODIFIED")) {
String nodeIdent = key.substring(0, index);
String dataType = key.substring(index + 1);
AssessmentDataKey assessmentDataKey = new AssessmentDataKey(identityKey, courseResourceableId, nodeIdent);
AssessmentEntryImpl nodeAssessment = nodeAssessmentMap.get(assessmentDataKey);
allOk &= compareProperty(dataType, data.getValue(), nodeAssessment, courseEntry, nodeIdent, identityKey);
}
}
}
dbInstance.commitAndCloseSession();
if (!allOk) {
log.error("Critical error during course verification: " + courseEntry.getDisplayname() + "(" + courseEntry.getKey() + ")");
}
return allOk;
}
use of org.olat.upgrade.legacy.NewCacheKey in project openolat by klemens.
the class OLATUpgrade_11_0_0 method verifyCourseAssessmentData.
/**
* The method compare the content of the cache used in assessment tool
* with the migrated values and vice versa.
*
* @param courseEntry
* @return
*/
private boolean verifyCourseAssessmentData(List<Identity> assessableIdentities, RepositoryEntry courseEntry) {
// load the cache and fill it with the same amount of datas as in assessment tool
final ICourse course = CourseFactory.loadCourse(courseEntry);
final Long courseResourceableId = course.getResourceableId();
StaticCacheWrapper cache = new StaticCacheWrapper();
NewCachePersistingAssessmentManager assessmentManager = new NewCachePersistingAssessmentManager(course, cache);
assessmentManager.preloadCache(assessableIdentities);
dbInstance.commitAndCloseSession();
Set<Identity> assessableIdentitySet = new HashSet<>(assessableIdentities);
List<AssessmentEntryImpl> nodeAssessments = loadAssessmentEntries(courseEntry);
Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap = new HashMap<>();
for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
if (!assessableIdentitySet.contains(nodeAssessment.getIdentity())) {
assessmentManager.preloadCache(nodeAssessment.getIdentity());
}
if (nodeAssessment.getIdentity() != null && nodeAssessment.getRepositoryEntry() != null && nodeAssessment.getRepositoryEntry().getOlatResource() != null) {
nodeAssessmentMap.put(new AssessmentDataKey(nodeAssessment), nodeAssessment);
}
}
dbInstance.commitAndCloseSession();
// compare the value in CourseNodeAssessment with the content of the cache
boolean allOk = true;
for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
allOk &= compareCourseNodeAssessment(nodeAssessment, assessmentManager, course, courseEntry);
}
dbInstance.commitAndCloseSession();
// compare the content of the cache with the CourseNodeAssessments
for (NewCacheKey cacheKey : cache.getKeys()) {
Map<String, Serializable> dataMap = cache.get(cacheKey);
Long identityKey = cacheKey.getIdentityKey();
for (Map.Entry<String, Serializable> data : dataMap.entrySet()) {
String key = data.getKey();
int index = key.indexOf("_");
if (index > 0 && !key.equals("LAST_MODIFIED")) {
String nodeIdent = key.substring(0, index);
String dataType = key.substring(index + 1);
AssessmentDataKey assessmentDataKey = new AssessmentDataKey(identityKey, courseResourceableId, nodeIdent);
AssessmentEntryImpl nodeAssessment = nodeAssessmentMap.get(assessmentDataKey);
allOk &= compareProperty(dataType, data.getValue(), nodeAssessment, courseEntry, nodeIdent, identityKey);
}
}
}
dbInstance.commitAndCloseSession();
if (!allOk) {
log.error("Critical error during course verification: " + courseEntry.getDisplayname() + "(" + courseEntry.getKey() + ")");
}
return allOk;
}
Aggregations