Search in sources :

Example 36 with PortfolioStructure

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));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 37 with PortfolioStructure

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;
}
Also used : EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) DBQuery(org.olat.core.commons.persistence.DBQuery)

Example 38 with PortfolioStructure

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);
    }
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) ArrayList(java.util.ArrayList)

Example 39 with 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);
}
Also used : PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 40 with PortfolioStructure

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();
}
Also used : EPStructureElement(org.olat.portfolio.model.structel.EPStructureElement) EPPage(org.olat.portfolio.model.structel.EPPage) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Aggregations

PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)236 Test (org.junit.Test)90 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)70 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)54 ArrayList (java.util.ArrayList)40 OLATResource (org.olat.resource.OLATResource)30 Identity (org.olat.core.id.Identity)26 RepositoryEntry (org.olat.repository.RepositoryEntry)24 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)22 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 EPPage (org.olat.portfolio.model.structel.EPPage)16 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)12 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)12 DBQuery (org.olat.core.commons.persistence.DBQuery)10 EPFrontendManager (org.olat.portfolio.manager.EPFrontendManager)10 Date (java.util.Date)8 Document (org.apache.lucene.document.Document)8 Link (org.olat.core.gui.components.link.Link)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)8 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)8