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();
}
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();
}
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);
}
}
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;
}
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);
}
Aggregations