Search in sources :

Example 1 with EPAbstractMap

use of org.olat.portfolio.model.structel.EPAbstractMap in project OpenOLAT by OpenOLAT.

the class EPStructureManager method removeStructureRecursively.

public void removeStructureRecursively(PortfolioStructure struct) {
    List<PortfolioStructure> children = loadStructureChildren(struct);
    for (PortfolioStructure childstruct : children) {
        removeStructureRecursively(childstruct);
    }
    // remove artefact-links
    List<AbstractArtefact> thisStructsArtefacts = getArtefacts(struct);
    for (AbstractArtefact artefact : thisStructsArtefacts) {
        removeArtefactFromStructure(artefact, struct, false);
    }
    // remove from parent
    PortfolioStructure parent = loadStructureParent(struct);
    if (parent == null && struct.getRoot() != null)
        parent = struct.getRoot();
    removeStructure(parent, struct);
    // remove collect restriction
    struct.getCollectRestrictions().clear();
    // remove sharings
    if (struct instanceof EPAbstractMap) {
        ((EPAbstractMap) struct).getGroups().clear();
    }
    // remove comments and ratings
    CommentAndRatingService commentAndRatingService = CoreSpringFactory.getImpl(CommentAndRatingService.class);
    commentAndRatingService.deleteAllIgnoringSubPath(struct.getOlatResource());
    // FXOLAT-431 remove subscriptions if the current struct is a map
    if (struct instanceof EPAbstractMap) {
        SubscriptionContext subsContext = new SubscriptionContext(EPNotificationsHandler.TYPENNAME, struct.getResourceableId(), EPNotificationsHandler.TYPENNAME);
        NotificationsManager.getInstance().delete(subsContext);
    }
    // remove structure itself
    struct = (EPStructureElement) dbInstance.loadObject((EPStructureElement) struct);
    dbInstance.deleteObject(struct);
    if (struct instanceof EPAbstractMap) {
        removeBaseGroup((EPAbstractMap) struct);
    }
    // which need the resource
    if (!(struct instanceof EPStructuredMapTemplate)) {
        resourceManager.deleteOLATResourceable(struct);
    }
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPStructuredMapTemplate(org.olat.portfolio.model.structel.EPStructuredMapTemplate) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CommentAndRatingService(org.olat.core.commons.services.commentAndRating.CommentAndRatingService) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext)

Example 2 with EPAbstractMap

use of org.olat.portfolio.model.structel.EPAbstractMap in project OpenOLAT by OpenOLAT.

the class EPXStreamHandler method getAsObject.

public static final PortfolioStructure getAsObject(File fMapXml, boolean withArtefacts) {
    try {
        // extract from zip
        InputStream in = new FileInputStream(fMapXml);
        ZipInputStream zipIn = new ZipInputStream(in);
        // open the entry of the map
        zipIn.getNextEntry();
        Writer buffer = new StringWriter();
        if (!withArtefacts) {
            Transformer transformer = filterArtefactsTemplates.newTransformer();
            transformer.transform(new StreamSource(zipIn), new StreamResult(buffer));
        } else {
            IOUtils.copy(zipIn, buffer, "UTF-8");
        }
        PortfolioStructure struct = (PortfolioStructure) myStream.fromXML(buffer.toString());
        // OLAT-6344: reset ownerGroup from earlier exports. A new group is created by import in ePFMgr.importPortfolioMapTemplate() later on anyway.
        ((EPAbstractMap) struct).setGroups(null);
        return struct;
    } catch (Exception e) {
        log.error("Cannot export this map: " + fMapXml, e);
    }
    return null;
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) ZipInputStream(java.util.zip.ZipInputStream) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) FileInputStream(java.io.FileInputStream) StringWriter(java.io.StringWriter) Writer(java.io.Writer) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException)

Example 3 with EPAbstractMap

use of org.olat.portfolio.model.structel.EPAbstractMap in project OpenOLAT by OpenOLAT.

the class EPTOCController method checkArtefactTarget.

private boolean checkArtefactTarget(AbstractArtefact artefact, Object targetObj) {
    PortfolioStructure newParStruct;
    if (targetObj instanceof EPAbstractMap) {
        return false;
    } else if (targetObj instanceof PortfolioStructure) {
        newParStruct = (PortfolioStructure) targetObj;
    } else {
        return false;
    }
    boolean sameTarget = ePFMgr.isArtefactInStructure(artefact, newParStruct);
    if (sameTarget) {
        return false;
    }
    return true;
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure)

Example 4 with EPAbstractMap

use of org.olat.portfolio.model.structel.EPAbstractMap in project OpenOLAT by OpenOLAT.

the class EPTOCController method refreshAddElements.

/**
 * refreshing the add elements link to actual structure
 * @param ureq
 * @param struct maybe null -> hiding the add-button
 */
private void refreshAddElements(UserRequest ureq, PortfolioStructure struct) {
    tocV.remove(tocV.getComponent("addElement"));
    removeAsListenerAndDispose(addElCtrl);
    if (struct != null) {
        addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
        if (struct instanceof EPPage) {
            if (secCallback.canAddStructure()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
            }
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        } else if (struct instanceof EPAbstractMap) {
            if (secCallback.canAddPage()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
            }
        } else {
            // its a structure element
            if (secCallback.canAddArtefact()) {
                addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
            }
        }
        listenTo(addElCtrl);
        tocV.put("addElement", addElCtrl.getInitialComponent());
    }
}
Also used : EPPage(org.olat.portfolio.model.structel.EPPage) EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPAddElementsController(org.olat.portfolio.ui.structel.EPAddElementsController)

Example 5 with EPAbstractMap

use of org.olat.portfolio.model.structel.EPAbstractMap in project OpenOLAT by OpenOLAT.

the class EPMultiplePageController method instantiateCLController.

/**
 * @param ureq
 * @return
 */
private EPChangelogController instantiateCLController(UserRequest ureq) {
    PageTab page = pageList.get(0);
    EPAbstractMap abstrMap = (EPAbstractMap) ePFMgr.loadStructureParent(page);
    return new EPChangelogController(ureq, getWindowControl(), abstrMap);
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) EPChangelogController(org.olat.portfolio.ui.structel.view.EPChangelogController)

Aggregations

EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)18 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)12 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 EPPage (org.olat.portfolio.model.structel.EPPage)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 StringWriter (java.io.StringWriter)2 Writer (java.io.Writer)2 ZipInputStream (java.util.zip.ZipInputStream)2 Transformer (javax.xml.transform.Transformer)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 StreamResult (javax.xml.transform.stream.StreamResult)2 StreamSource (javax.xml.transform.stream.StreamSource)2 CommentAndRatingService (org.olat.core.commons.services.commentAndRating.CommentAndRatingService)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 Link (org.olat.core.gui.components.link.Link)2 TreeDropEvent (org.olat.core.gui.components.tree.TreeDropEvent)2 TreeEvent (org.olat.core.gui.components.tree.TreeEvent)2