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