Skip to content
Snippets Groups Projects
Commit ce51713e authored by srosse's avatar srosse
Browse files

OO-2057: fix selenium test after changes to make home controllers reusable

parent 5f7883ed
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,7 @@ public class HomeMainController extends MainLayoutBasicController implements Act ...@@ -86,7 +86,7 @@ public class HomeMainController extends MainLayoutBasicController implements Act
} }
} }
if(navKey.equals(currentNavKey) && currentCtr != null) { if(navKey.equals(currentNavKey) && currentCtr instanceof ReusableHomeController) {
if (currentCtr instanceof Activateable2) { if (currentCtr instanceof Activateable2) {
((Activateable2) currentCtr).activate(ureq, entries, entry.getTransientState()); ((Activateable2) currentCtr).activate(ureq, entries, entry.getTransientState());
} }
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.home;
import org.olat.core.gui.control.Controller;
/**
* This is a marker interface for personal tools which main controller
* are reusable.
*
* Initial date: 27.06.2016<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public interface ReusableHomeController extends Controller {
}
...@@ -32,6 +32,7 @@ import org.olat.core.id.OLATResourceable; ...@@ -32,6 +32,7 @@ import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry; import org.olat.core.id.context.StateEntry;
import org.olat.core.util.resource.OresHelper; import org.olat.core.util.resource.OresHelper;
import org.olat.home.ReusableHomeController;
/** /**
* *
...@@ -39,7 +40,7 @@ import org.olat.core.util.resource.OresHelper; ...@@ -39,7 +40,7 @@ import org.olat.core.util.resource.OresHelper;
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
* *
*/ */
public class PortfolioPersonalToolController extends BasicController implements Activateable2 { public class PortfolioPersonalToolController extends BasicController implements Activateable2, ReusableHomeController {
private final TooledStackedPanel stackPanel; private final TooledStackedPanel stackPanel;
private final PortfolioHomeController overviewCtrl; private final PortfolioHomeController overviewCtrl;
......
...@@ -32,8 +32,15 @@ import org.olat.core.gui.control.Event; ...@@ -32,8 +32,15 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.core.util.FileUtils;
import org.olat.core.util.StringHelper; import org.olat.core.util.StringHelper;
import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSItem;
import org.olat.modules.portfolio.MediaHandler;
import org.olat.modules.portfolio.PortfolioService;
import org.olat.modules.portfolio.PortfolioV2Module;
import org.olat.modules.portfolio.handler.FileHandler;
import org.olat.modules.portfolio.handler.ImageHandler;
import org.olat.modules.portfolio.ui.wizard.CollectArtefactController;
import org.olat.portfolio.EPArtefactHandler; import org.olat.portfolio.EPArtefactHandler;
import org.olat.portfolio.PortfolioModule; import org.olat.portfolio.PortfolioModule;
import org.olat.portfolio.model.artefacts.AbstractArtefact; import org.olat.portfolio.model.artefacts.AbstractArtefact;
...@@ -54,11 +61,14 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE ...@@ -54,11 +61,14 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE
private int status; private int status;
private VFSItem currentItem; private VFSItem currentItem;
private PortfolioModule portfolioModule; private PortfolioModule portfolioModule;
private PortfolioV2Module portfolioV2Module;
private Controller collectStepsCtrl; private Controller collectStepsCtrl;
public CmdAddToEPortfolioImpl(UserRequest ureq, WindowControl wControl) { public CmdAddToEPortfolioImpl(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl); super(ureq, wControl);
portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule"); portfolioModule = CoreSpringFactory.getImpl(PortfolioModule.class);
portfolioV2Module = CoreSpringFactory.getImpl(PortfolioV2Module.class);
} }
/** /**
...@@ -84,14 +94,36 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE ...@@ -84,14 +94,36 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE
currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos)); currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem); status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem);
} }
if (status == FolderCommandStatus.STATUS_FAILED) { return null; } if (status == FolderCommandStatus.STATUS_FAILED) {
return null;
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE); }
AbstractArtefact artefact = artHandler.createArtefact();
artHandler.prefillArtefactAccordingToSource(artefact, currentItem); if(portfolioV2Module.isEnabled()) {
artefact.setAuthor(getIdentity()); 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()); collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer());
}
return collectStepsCtrl; return collectStepsCtrl;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment