use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class CmdAddToEPortfolioImpl method execute.
/**
* might return NULL!, if item clicked was removed meanwhile or if portfolio is disabled or if only the folder-artefact-handler is disabled.
*
* @see org.olat.core.commons.modules.bc.commands.FolderCommand#execute(org.olat.core.commons.modules.bc.components.FolderComponent,
* org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.core.gui.translator.Translator)
*/
@Override
public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wControl, Translator translator) {
String pos = ureq.getParameter(ListRenderer.PARAM_EPORT);
if (!StringHelper.containsNonWhitespace(pos)) {
// somehow parameter did not make it to us
status = FolderCommandStatus.STATUS_FAILED;
getWindowControl().setError(translator.translate("failed"));
return null;
}
status = FolderCommandHelper.sanityCheck(wControl, folderComponent);
if (status == FolderCommandStatus.STATUS_SUCCESS) {
currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem);
}
if (status == FolderCommandStatus.STATUS_FAILED) {
return null;
}
if (portfolioV2Module.isEnabled()) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
MediaHandler handler = null;
String extension = FileUtils.getFileSuffix(currentItem.getName());
if (StringHelper.containsNonWhitespace(extension)) {
if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) {
handler = portfolioService.getMediaHandler(ImageHandler.IMAGE_TYPE);
}
// TODO video
}
if (handler == null) {
handler = portfolioService.getMediaHandler(FileHandler.FILE_TYPE);
}
collectStepsCtrl = new CollectArtefactController(ureq, wControl, currentItem, handler, "");
} else {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE);
AbstractArtefact artefact = artHandler.createArtefact();
artHandler.prefillArtefactAccordingToSource(artefact, currentItem);
artefact.setAuthor(getIdentity());
collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer());
}
return collectStepsCtrl;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact 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.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactPoolRunController method initTPAllView.
private void initTPAllView(UserRequest ureq) {
filterSettings = new EPFilterSettings();
List<AbstractArtefact> artefacts = ePFMgr.getArtefactPoolForUser(getIdentity());
initMultiArtefactCtrl(ureq, artefacts);
initFilterPanel(ureq, Filter.read_only);
setSegmentContent(artCtrl);
addToHistory(ureq, OresHelper.createOLATResourceableType("All"), null);
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class ArtefactWizzardStepsController method prepareNewArtefact.
/**
* @param ores
* @param businessPath
*/
private void prepareNewArtefact() {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(ores.getResourceableTypeName());
AbstractArtefact artefact1 = artHandler.createArtefact();
artefact1.setAuthor(getIdentity());
artefact1.setCollectionDate(new Date());
artefact1.setBusinessPath(businessPath);
artHandler.prefillArtefactAccordingToSource(artefact1, ores);
this.artefact = artefact1;
}
use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.
the class EPAddArtefactController method prepareNewTextArtefactWizzard.
/**
* prepare a new text artefact and open with wizzard initialized with a
* special first step for text-artefacts
*
* @param ureq
*/
private void prepareNewTextArtefactWizzard(UserRequest ureq) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EPTextArtefact.TEXT_ARTEFACT_TYPE);
AbstractArtefact artefact1 = artHandler.createArtefact();
artefact1.setAuthor(getIdentity());
artefact1.setSource(translate("text.artefact.source.info"));
artefact1.setCollectionDate(new Date());
artefact1.setSignature(-20);
vfsTemp = ePFMgr.getArtefactsTempContainer(getIdentity());
Step start = new EPCreateTextArtefactStep00(ureq, artefact1, preSelectedStruct, vfsTemp);
StepRunnerCallback finish = new EPArtefactWizzardStepCallback(vfsTemp);
collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.text.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_text_wizard");
listenTo(collectStepsCtrl);
getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
Aggregations