use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPArtefactWizzardStepCallback method execute.
/**
* @see org.olat.core.gui.control.generic.wizard.StepRunnerCallback#execute(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.core.gui.control.generic.wizard.StepsRunContext)
*/
@Override
public Step execute(UserRequest ureq2, WindowControl wControl, StepsRunContext runContext) {
boolean hasChanges = false;
if (runContext.containsKey("artefact")) {
hasChanges = true;
AbstractArtefact locArtefact = (AbstractArtefact) runContext.get("artefact");
ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean("epFrontendManager");
PortfolioModule portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule");
// set the defined signature level, if its not from inside olat
if (locArtefact.getSignature() < 0 && ((runContext.containsKey("copyright.accepted") && (Boolean) runContext.get("copyright.accepted")) || !portfolioModule.isCopyrightStepEnabled())) {
locArtefact.setSignature(-1 * locArtefact.getSignature());
}
ePFMgr.updateArtefact(locArtefact);
if (runContext.containsKey("tempArtFolder")) {
// a new text or file-artefact was created, copy everything to destination
VFSContainer tmpFolder = (VFSContainer) runContext.get("tempArtFolder");
copyFromTempToArtefactContainer(locArtefact, tmpFolder);
} else if (tempUpload != null) {
// an artefact was collected in bc, only copy the selected file
copyFromBCToArtefactContainer(locArtefact, tempUpload);
}
// add to a structure if any was selected
if (runContext.containsKey("selectedStructure")) {
PortfolioStructure parentStructure = (PortfolioStructure) runContext.get("selectedStructure");
if (parentStructure != null) {
ePFMgr.addArtefactToStructure(ureq2.getIdentity(), locArtefact, parentStructure);
}
}
@SuppressWarnings("unchecked") List<String> allTags = (List<String>) runContext.get("artefactTagsList");
ePFMgr.setArtefactTags(ureq2.getIdentity(), locArtefact, allTags);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(locArtefact));
ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_ARTEFACT_ADDED, getClass());
}
return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
}
use of org.olat.portfolio.model.structel.PortfolioStructure 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.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class PortfolioHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
OLATResource sourceResource = source.getOlatResource();
OLATResource targetResource = target.getOlatResource();
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
PortfolioStructure structure = ePFMgr.loadPortfolioStructure(sourceResource);
PortfolioStructure newStructure = EPXStreamHandler.copy(structure);
ePFMgr.importPortfolioMapTemplate(newStructure, targetResource);
return target;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class PortfolioHandler method getAsMediaResource.
/**
* Transform the map in a XML file and zip it (Repository export want a zip)
* @see org.olat.repository.handlers.RepositoryHandler#getAsMediaResource(org.olat.core.id.OLATResourceable)
*/
@Override
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
MediaResource mr = null;
EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
PortfolioStructure structure = ePFMgr.loadPortfolioStructure(res);
try {
InputStream inOut = EPXStreamHandler.toStream(structure);
mr = new StreamedMediaResource(inOut, null, null, null);
} catch (IOException e) {
log.error("Cannot export this map: " + structure, e);
}
return mr;
}
use of org.olat.portfolio.model.structel.PortfolioStructure in project OpenOLAT by OpenOLAT.
the class EPImportTest method testImportFromOpenOLAT_81_Hibernate3.
@Test
public void testImportFromOpenOLAT_81_Hibernate3() throws URISyntaxException {
URL mapUrl = EPImportTest.class.getResource("map_81.xml.zip");
assertNotNull(mapUrl);
File mapFile = new File(mapUrl.toURI());
PortfolioStructure rootStructure = EPXStreamHandler.getAsObject(mapFile, false);
OLATResource resource = epStructureManager.createPortfolioMapTemplateResource();
// import the map
PortfolioStructureMap importedMap = epFrontendManager.importPortfolioMapTemplate(rootStructure, resource);
Assert.assertNotNull(importedMap);
dbInstance.commitAndCloseSession();
}
Aggregations