use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPPolicyManagerTest method getOwners.
@Test
public void getOwners() {
// create a map
Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Policy-User-1-");
PortfolioStructureMap originalMap = epFrontendManager.createAndPersistPortfolioDefaultMap(user, "Title", "Description");
PortfolioStructure page1 = epFrontendManager.createAndPersistPortfolioPage(originalMap, "Page title", "Page description");
assertNotNull(page1);
dbInstance.commitAndCloseSession();
List<Identity> owners = policyManager.getOwners(originalMap);
Assert.assertNotNull(owners);
Assert.assertEquals(1, owners.size());
Assert.assertEquals(user, owners.get(0));
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method getStructuredMapsLinkedToTemplate.
private List<PortfolioStructure> getStructuredMapsLinkedToTemplate(PortfolioStructure template) {
StringBuilder sb = new StringBuilder();
sb.append("select map from ").append(EPStructuredMap.class.getName()).append(" map").append(" where map.structuredMapSource=:template");
DBQuery query = DBFactory.getInstance().createQuery(sb.toString());
query.setEntity("template", template);
@SuppressWarnings("unchecked") List<PortfolioStructure> maps = query.list();
return maps;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method fixTemplateEntry.
private void fixTemplateEntry(PortfolioStructure template) {
List<PortfolioStructure> temps = new ArrayList<PortfolioStructure>();
recurseIntoTemplateAndCheck(new ArrayList<PortfolioStructure>(), temps, template);
for (PortfolioStructure portfolioStructure : temps) {
((EPStructureElement) portfolioStructure).setStructureElSource(null);
ePFMgr.savePortfolioStructure(portfolioStructure);
}
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method processStructuredMapDeeply.
private void processStructuredMapDeeply(PortfolioStructure structuredMap) {
// check children (StructureElements) first, because of later recursive removal!
List<PortfolioStructure> linkedChildren = ePFMgr.loadStructureChildren(structuredMap);
for (PortfolioStructure linkedPage : linkedChildren) {
log.audit(" #4: processing structs of page: " + linkedPage);
processStructure(linkedPage);
}
log.audit(" #5: processing pages of map: " + structuredMap);
processStructure(structuredMap);
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_7_1_1 method processStructure.
/**
* call the needed methods to really do the magic.
*/
private void processStructure(PortfolioStructure structuredMap) {
List<PortfolioStructure> linkedChildren = ePFMgr.loadStructureChildren(structuredMap);
for (PortfolioStructure childStruct : linkedChildren) {
// reload dbchildren in each run, because of filtering
List<PortfolioStructure> dbChildren;
if (childStruct instanceof EPPage) {
dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap);
} else {
dbChildren = loadMapChildrenByInternalFK(childStruct, structuredMap.getRoot());
}
// filter the struct that is already linked by a struct->struct link
// and filter such with other struct-source
filterLinkedStructs(childStruct, dbChildren);
log.audit(" found " + dbChildren.size() + " faulty children (of " + childStruct + ") linked by internal fk to be merged and removed afterwards.");
// merge artefacts to the linked struct
mergeLinkedArtefactsToFinalStruct(childStruct, dbChildren);
// collect comments on structures and merge to target
mergeCommentsToFinalStruct(childStruct, dbChildren);
// ratings are not merged, see OLAT-6306
// remove the old elements
removeWrongElements(dbChildren);
// fix root-reference on EPStructureElements
if (!(childStruct instanceof EPPage)) {
if (childStruct.getRoot().equals(childStruct.getRootMap())) {
EPStructureElement realParentRoot = (EPStructureElement) ePFMgr.loadStructureParent(childStruct);
((EPStructureElement) childStruct).setRoot(realParentRoot);
ePFMgr.savePortfolioStructure(childStruct);
}
}
}
// loop children
DBFactory.getInstance().intermediateCommit();
}
Aggregations