Search in sources :

Example 11 with EPAbstractMap

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

the class PortfolioMapDocument method createDocument.

public static Document createDocument(SearchResourceContext searchResourceContext, PortfolioStructure map) {
    PortfolioMapDocument document = new PortfolioMapDocument();
    if (map instanceof EPAbstractMap) {
        EPAbstractMap abstractMap = (EPAbstractMap) map;
        if (abstractMap.getGroups() != null) {
            List<Identity> identities = policyManager.getOwners(abstractMap);
            StringBuilder authors = new StringBuilder();
            for (Identity identity : identities) {
                if (authors.length() > 0) {
                    authors.append(", ");
                }
                User user = identity.getUser();
                authors.append(user.getProperty(UserConstants.FIRSTNAME, null)).append(' ').append(user.getProperty(UserConstants.LASTNAME, null));
            }
            document.setAuthor(authors.toString());
        }
        document.setCreatedDate(abstractMap.getCreationDate());
    }
    Filter filter = FilterFactory.getHtmlTagAndDescapingFilter();
    document.setTitle(map.getTitle());
    document.setDescription(filter.filter(map.getDescription()));
    StringBuilder sb = new StringBuilder();
    getContent(map, searchResourceContext, sb, filter);
    document.setContent(sb.toString());
    document.setResourceUrl(searchResourceContext.getResourceUrl());
    document.setDocumentType(searchResourceContext.getDocumentType());
    document.setCssIcon("o_ep_icon");
    document.setParentContextType(searchResourceContext.getParentContextType());
    document.setParentContextName(searchResourceContext.getParentContextName());
    if (log.isDebug())
        log.debug(document.toString());
    return document.getLuceneDocument();
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) User(org.olat.core.id.User) Filter(org.olat.core.util.filter.Filter) Identity(org.olat.core.id.Identity)

Example 12 with EPAbstractMap

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

the class PortfolioMapDocument method createDocument.

public static Document createDocument(SearchResourceContext searchResourceContext, PortfolioStructure map) {
    PortfolioMapDocument document = new PortfolioMapDocument();
    if (map instanceof EPAbstractMap) {
        EPAbstractMap abstractMap = (EPAbstractMap) map;
        if (abstractMap.getGroups() != null) {
            List<Identity> identities = policyManager.getOwners(abstractMap);
            StringBuilder authors = new StringBuilder();
            for (Identity identity : identities) {
                if (authors.length() > 0) {
                    authors.append(", ");
                }
                User user = identity.getUser();
                authors.append(user.getProperty(UserConstants.FIRSTNAME, null)).append(' ').append(user.getProperty(UserConstants.LASTNAME, null));
            }
            document.setAuthor(authors.toString());
        }
        document.setCreatedDate(abstractMap.getCreationDate());
    }
    Filter filter = FilterFactory.getHtmlTagAndDescapingFilter();
    document.setTitle(map.getTitle());
    document.setDescription(filter.filter(map.getDescription()));
    StringBuilder sb = new StringBuilder();
    getContent(map, searchResourceContext, sb, filter);
    document.setContent(sb.toString());
    document.setResourceUrl(searchResourceContext.getResourceUrl());
    document.setDocumentType(searchResourceContext.getDocumentType());
    document.setCssIcon("o_ep_icon");
    document.setParentContextType(searchResourceContext.getParentContextType());
    document.setParentContextName(searchResourceContext.getParentContextName());
    if (log.isDebug())
        log.debug(document.toString());
    return document.getLuceneDocument();
}
Also used : EPAbstractMap(org.olat.portfolio.model.structel.EPAbstractMap) User(org.olat.core.id.User) Filter(org.olat.core.util.filter.Filter) Identity(org.olat.core.id.Identity)

Example 13 with EPAbstractMap

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

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 14 with EPAbstractMap

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

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 15 with EPAbstractMap

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

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