diff --git a/src/main/java/org/olat/modules/quality/analysis/AnalysisPresentation.java b/src/main/java/org/olat/modules/quality/analysis/AnalysisPresentation.java index c496b974901759e07373a4826c0090d6bcc6da7c..e0f8c4b9841c0fadbc52029e349ba9fa23f46027 100644 --- a/src/main/java/org/olat/modules/quality/analysis/AnalysisPresentation.java +++ b/src/main/java/org/olat/modules/quality/analysis/AnalysisPresentation.java @@ -21,7 +21,6 @@ package org.olat.modules.quality.analysis; import org.olat.core.id.CreateInfo; import org.olat.core.id.ModifiedInfo; -import org.olat.core.id.OLATResourceable; import org.olat.repository.RepositoryEntry; /** @@ -30,9 +29,7 @@ import org.olat.repository.RepositoryEntry; * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com * */ -public interface AnalysisPresentation extends AnalysisPresentationRef, OLATResourceable, CreateInfo, ModifiedInfo { - - public String RESOURCEABLE_TYPE = "presentation"; +public interface AnalysisPresentation extends AnalysisPresentationRef, CreateInfo, ModifiedInfo { public String getName(); diff --git a/src/main/java/org/olat/modules/quality/analysis/EvaluationFormView.java b/src/main/java/org/olat/modules/quality/analysis/EvaluationFormView.java index 4f70dab3d527a91b43fd1a3e9f9232760c748d83..b78c5b48a47ffe18632404d9746d45ca6efb2595 100644 --- a/src/main/java/org/olat/modules/quality/analysis/EvaluationFormView.java +++ b/src/main/java/org/olat/modules/quality/analysis/EvaluationFormView.java @@ -21,7 +21,6 @@ package org.olat.modules.quality.analysis; import java.util.Date; -import org.olat.core.id.OLATResourceable; import org.olat.repository.RepositoryEntry; /** @@ -30,10 +29,8 @@ import org.olat.repository.RepositoryEntry; * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com * */ -public interface EvaluationFormView extends OLATResourceable { +public interface EvaluationFormView { - public String RESOURCEABLE_TYPE = "form"; - public RepositoryEntry getFormEntry(); public Long getNumberDataCollections(); diff --git a/src/main/java/org/olat/modules/quality/analysis/model/AnalysisPresentationImpl.java b/src/main/java/org/olat/modules/quality/analysis/model/AnalysisPresentationImpl.java index 4cfb37adb04c5f58cdfb037dcdc7ee96d8f39d45..065ebc917ccec267176577aea1c0793d00420eae 100644 --- a/src/main/java/org/olat/modules/quality/analysis/model/AnalysisPresentationImpl.java +++ b/src/main/java/org/olat/modules/quality/analysis/model/AnalysisPresentationImpl.java @@ -96,16 +96,6 @@ public class AnalysisPresentationImpl implements AnalysisPresentation, Persistab this.key = key; } - @Override - public String getResourceableTypeName() { - return AnalysisPresentation.RESOURCEABLE_TYPE; - } - - @Override - public Long getResourceableId() { - return key; - } - @Override public Date getCreationDate() { return creationDate; diff --git a/src/main/java/org/olat/modules/quality/analysis/model/EvaluationFormViewImpl.java b/src/main/java/org/olat/modules/quality/analysis/model/EvaluationFormViewImpl.java index 3e7cfe384a894b88be444cfeba9b15c3b0f0b3ed..1749cf99f93f4c7cd19cbdb5bc8fe13cfec68cdf 100644 --- a/src/main/java/org/olat/modules/quality/analysis/model/EvaluationFormViewImpl.java +++ b/src/main/java/org/olat/modules/quality/analysis/model/EvaluationFormViewImpl.java @@ -47,16 +47,6 @@ public class EvaluationFormViewImpl implements EvaluationFormView { this.numberParticipationsDone = numberParticipationsDone; } - @Override - public String getResourceableTypeName() { - return EvaluationFormView.RESOURCEABLE_TYPE; - } - - @Override - public Long getResourceableId() { - return formEntry.getKey(); - } - @Override public RepositoryEntry getFormEntry() { return formEntry; diff --git a/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisListController.java b/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisListController.java index 73cfd64995dc7e8b921e53580de90e4538b8c249..36f84b8e2c233a5ca1c2ee7df0b2bb7c071d2177 100644 --- a/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisListController.java +++ b/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisListController.java @@ -48,9 +48,11 @@ import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.generic.dtabs.Activateable2; +import org.olat.core.id.OLATResourceable; import org.olat.core.id.Organisation; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; +import org.olat.core.util.resource.OresHelper; import org.olat.modules.quality.QualitySecurityCallback; import org.olat.modules.quality.analysis.AnalysisPresentation; import org.olat.modules.quality.analysis.EvaluationFormView; @@ -67,6 +69,8 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class AnalysisListController extends FormBasicController implements FlexiTableComponentDelegate, Activateable2 { + private static final String ORES_TYPE_FORM = "form"; + private static final String ORES_TYPE_PRESENTATION = "presentation"; private static final String CMD_OPEN = "open"; private static final Comparator<? super EvaluationFormView> CREATED_DESC = (f1, f2) -> f2.getLatestDataCollectionFinishedDate().compareTo(f1.getLatestDataCollectionFinishedDate()); @@ -80,7 +84,7 @@ public class AnalysisListController extends FormBasicController implements Flexi private final List<Organisation> organisations; private int counter = 0; - private EvaluationFormView currentFormView; + private AnalysisPresentation presentation; @Autowired private QualityAnalysisService analysisService; @@ -97,6 +101,12 @@ public class AnalysisListController extends FormBasicController implements Flexi secCallback.getAnalysisViewRoles()); initForm(ureq); } + + public static OLATResourceable getOlatResourceable(AnalysisPresentation presentation) { + return presentation.getKey() != null + ? OresHelper.createOLATResourceableInstance(ORES_TYPE_PRESENTATION, presentation.getKey()) + : OresHelper.createOLATResourceableInstance(ORES_TYPE_FORM, presentation.getFormEntry().getKey()); + } @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { @@ -173,14 +183,14 @@ public class AnalysisListController extends FormBasicController implements Flexi if(entries == null || entries.isEmpty()) return; String type = entries.get(0).getOLATResourceable().getResourceableTypeName(); - if (EvaluationFormView.RESOURCEABLE_TYPE.equalsIgnoreCase(type)) { + if (ORES_TYPE_FORM.equalsIgnoreCase(type)) { Long formEntryKey = entries.get(0).getOLATResourceable().getResourceableId(); AnalysisRow row = dataModel.getObjectByFormEntryKey(formEntryKey); if (row != null) { - currentFormView = row; + presentation = createPresentation(row); doOpenAnalysis(ureq); } - } else if (AnalysisPresentation.RESOURCEABLE_TYPE.equalsIgnoreCase(type)) { + } else if (ORES_TYPE_PRESENTATION.equalsIgnoreCase(type)) { Long presentationKey = entries.get(0).getOLATResourceable().getResourceableId(); doOpenPresentation(ureq, presentationKey); } @@ -203,40 +213,49 @@ public class AnalysisListController extends FormBasicController implements Flexi if (source == tableEl && event instanceof SelectionEvent) { SelectionEvent se = (SelectionEvent)event; String cmd = se.getCommand(); - currentFormView = dataModel.getObject(se.getIndex()); + AnalysisRow row = dataModel.getObject(se.getIndex()); + presentation = createPresentation(row); if (CMD_OPEN.equals(cmd)) { doOpenAnalysis(ureq); } } else if (source instanceof FormLink) { FormLink link = (FormLink)source; if(CMD_OPEN.equals(link.getCmd())) { - currentFormView = (AnalysisRow)link.getUserObject(); + AnalysisRow row = (AnalysisRow)link.getUserObject(); + presentation = createPresentation(row); doOpenAnalysis(ureq); } } super.formInnerEvent(ureq, source, event); } - - private void doOpenAnalysis(UserRequest ureq) { - AnalysisPresentation presentation = analysisService.createPresentation(currentFormView.getFormEntry()); - WindowControl bwControl = addToHistory(ureq, currentFormView, null); - doOpenAnalysis(ureq, bwControl, presentation); + + private AnalysisPresentation createPresentation(EvaluationFormView formView) { + return analysisService.createPresentation(formView.getFormEntry()); } private void doOpenPresentation(UserRequest ureq, Long presentationKey) { - AnalysisPresentation presentation = analysisService.loadPresentationByKey(() -> presentationKey); - WindowControl bwControl = addToHistory(ureq, presentation, null); - doOpenAnalysis(ureq, bwControl, presentation); + presentation = analysisService.loadPresentationByKey(() -> presentationKey); + if (presentation != null) { + doOpenAnalysis(ureq); + } } - private void doOpenAnalysis(UserRequest ureq, WindowControl wControl, AnalysisPresentation presentation) { - analysisCtrl = new AnalysisSegmentsController(ureq, wControl, secCallback, stackPanel, presentation); + private void doOpenAnalysis(UserRequest ureq) { + OLATResourceable ores = getOlatResourceable(presentation); + WindowControl bwControl = addToHistory(ureq, ores, null); + analysisCtrl = new AnalysisSegmentsController(ureq, bwControl, secCallback, stackPanel, presentation); listenTo(analysisCtrl); - String title = presentation.getFormEntry().getDisplayname(); + String title = getBreadcrumbTitle(presentation); stackPanel.pushController(title, analysisCtrl); analysisCtrl.activate(ureq, null, null); } + + private String getBreadcrumbTitle(AnalysisPresentation presentation) { + return presentation.getKey() != null + ? presentation.getName() + : presentation.getFormEntry().getDisplayname(); + } @Override protected void formOK(UserRequest ureq) { diff --git a/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisRow.java b/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisRow.java index 6b34064d5626d4e34d123219192ec7d09b35feeb..68efb2a9d50a216604184a470aa68d2d50803f29 100644 --- a/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisRow.java +++ b/src/main/java/org/olat/modules/quality/analysis/ui/AnalysisRow.java @@ -41,16 +41,6 @@ public class AnalysisRow implements EvaluationFormView { this.openLink = openLink; } - @Override - public String getResourceableTypeName() { - return formView.getResourceableTypeName(); - } - - @Override - public Long getResourceableId() { - return formView.getResourceableId(); - } - @Override public RepositoryEntry getFormEntry() { return formView.getFormEntry(); diff --git a/src/main/java/org/olat/modules/quality/ui/QualityHomeController.java b/src/main/java/org/olat/modules/quality/ui/QualityHomeController.java index cbe51f6d38f41871ac780721ca6481c68bf4980e..1dc32084e70cedaa4745d54e9df90e85d571e9c3 100644 --- a/src/main/java/org/olat/modules/quality/ui/QualityHomeController.java +++ b/src/main/java/org/olat/modules/quality/ui/QualityHomeController.java @@ -234,7 +234,8 @@ public class QualityHomeController extends BasicController implements Activateab } private void doOpenPresentation(UserRequest ureq, AnalysisPresentation presentation) { - ContextEntry contextEntry = BusinessControlFactory.getInstance().createContextEntry(presentation); + OLATResourceable ores = AnalysisListController.getOlatResourceable(presentation); + ContextEntry contextEntry = BusinessControlFactory.getInstance().createContextEntry(ores); List<ContextEntry> entries = Collections.singletonList(contextEntry); doOpenAnalysis(ureq, entries); }