use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method filterLinkedStructs.
private void filterLinkedStructs(PortfolioStructure filterBase, List<PortfolioStructure> dbChildren) {
for (Iterator<PortfolioStructure> iterator = dbChildren.iterator(); iterator.hasNext(); ) {
PortfolioStructure portfolioStructure = iterator.next();
long filterBaseSourceKey = ((EPStructureElement) filterBase).getStructureElSource();
long structSourceKey = ((EPStructureElement) portfolioStructure).getStructureElSource();
if (portfolioStructure.getKey() == filterBase.getKey() || filterBaseSourceKey != structSourceKey) {
iterator.remove();
}
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method fixInvalidMapReferences.
private void fixInvalidMapReferences(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(TASK_CHECK_AND_FIX_TEMPLATEMAPS)) {
log.audit("+---------------------------------------------------------------------------------------+");
log.audit("+... check templates and collect lost sub-structures to actualy bound pages/structs ...+");
log.audit("+---------------------------------------------------------------------------------------+");
ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean("epFrontendManager");
int amount = 10;
int count = countPortfolioTemplates();
log.audit("found a total of " + count + " portfolio templates. check stepwise with stepsize: " + amount);
for (int start = 0; start < count; start = start + amount) {
List<PortfolioStructure> templates = ePFMgr.getStructureElements(start, amount, ElementType.TEMPLATE_MAP);
log.audit("start at " + start + " . Will check (next) " + templates.size() + " portfolio task for irregularities.");
templates = getInvalidTemplates(templates);
log.audit("#1: found " + templates.size() + " templates that look invalid and might have produced bad portfolio-tasks!");
for (PortfolioStructure templateStruct : templates) {
log.audit(" #2: handling Structured Maps (maps collected from a portfolio task) for template " + templateStruct.getKey() + " " + templateStruct.getTitle());
// get corresponding portfolio-tasks taken from templates
List<PortfolioStructure> structMaps = getStructuredMapsLinkedToTemplate(templateStruct);
log.audit(" this task has been taken " + structMaps.size() + " times.");
for (PortfolioStructure structuredMap : structMaps) {
log.audit(" #3: now work on StructuredMap: " + structuredMap);
processStructuredMapDeeply(structuredMap);
}
// loop struct-maps
// fix template with children
fixTemplateEntry(templateStruct);
DBFactory.getInstance().intermediateCommit();
}
// loop templates
}
// steps
DBFactory.getInstance().intermediateCommit();
}
uhd.setBooleanDataValue(TASK_CHECK_AND_FIX_TEMPLATEMAPS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method getInvalidTemplates.
private List<PortfolioStructure> getInvalidTemplates(List<PortfolioStructure> templates) {
List<PortfolioStructure> temps = new ArrayList<PortfolioStructure>();
for (PortfolioStructure portfolioStructure : templates) {
recurseIntoTemplateAndCheck(temps, new ArrayList<PortfolioStructure>(), portfolioStructure);
}
// get unique root-templates
HashSet<PortfolioStructure> h = new HashSet<PortfolioStructure>(temps);
temps.clear();
temps.addAll(h);
return temps;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method mergeLinkedArtefactsToFinalStruct.
private void mergeLinkedArtefactsToFinalStruct(PortfolioStructure finalStruct, List<PortfolioStructure> wrongStructs) {
if (wrongStructs == null || wrongStructs.isEmpty())
return;
// temporarily remove the collectrestriction, will be added by next sync.
// TODO: somehow user must be warned, that map may contain too much artefacts on one node
finalStruct.getCollectRestrictions().clear();
ePFMgr.savePortfolioStructure(finalStruct);
int artefactCount = 0;
for (PortfolioStructure portfolioStructure : wrongStructs) {
portfolioStructure = ePFMgr.loadPortfolioStructureByKey(portfolioStructure.getKey());
List<AbstractArtefact> artefacts = ePFMgr.getArtefacts(portfolioStructure);
for (AbstractArtefact abstractArtefact : artefacts) {
if (!ePFMgr.isArtefactInStructure(abstractArtefact, finalStruct)) {
artefactCount++;
ePFMgr.moveArtefactFromStructToStruct(abstractArtefact, portfolioStructure, finalStruct);
} else {
log.audit("An Artefact " + abstractArtefact + " has already been added to new target, therefore will be removed from wrong structure.");
// TODO: maybe we should save the reflexion on the link artefact -> structure!
ePFMgr.removeArtefactFromStructure(abstractArtefact, portfolioStructure);
}
}
}
log.audit(" merged " + artefactCount + " artefacts to new destinations.");
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method mergeCommentsToFinalStruct.
private void mergeCommentsToFinalStruct(PortfolioStructure finalStruct, List<PortfolioStructure> wrongStructs) {
if (wrongStructs == null || wrongStructs.isEmpty())
return;
List<UserComment> collectedComments = new ArrayList<UserComment>();
// collect all comments out there
for (PortfolioStructure portfolioStructure : wrongStructs) {
// no comments on StructureElements!
if (!(portfolioStructure instanceof EPPage))
return;
List<UserComment> oldComments = commentAndRatingService.getComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
collectedComments.addAll(oldComments);
commentAndRatingService.deleteAllComments(portfolioStructure.getRootMap(), portfolioStructure.getKey().toString());
}
log.audit(" found " + collectedComments.size() + " comments for this structure, will be merged to new destination.");
if (collectedComments.size() == 0)
return;
Identity ident = collectedComments.get(0).getCreator();
UserComment topComment = commentAndRatingService.createComment(ident, finalStruct.getRootMap(), finalStruct.getKey().toString(), "The following comments were restored from a migration task to rescue lost data.");
// attach all to this info-comment
for (UserComment userComment : collectedComments) {
UserComment attachedComment = commentAndRatingService.replyTo(topComment, userComment.getCreator(), userComment.getComment());
// set original date
attachedComment.setCreationDate(userComment.getCreationDate());
commentAndRatingService.updateComment(attachedComment, attachedComment.getComment());
}
}
Aggregations