1 package org.kuali.student.lum.lu.ui.dependency.client.controllers;
2
3 import java.util.List;
4
5 import org.kuali.student.common.rice.authorization.PermissionType;
6 import org.kuali.student.common.ui.client.application.Application;
7 import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayout;
8 import org.kuali.student.common.ui.client.mvc.Callback;
9 import org.kuali.student.common.ui.client.mvc.DataModel;
10 import org.kuali.student.common.ui.client.security.AuthorizationCallback;
11 import org.kuali.student.common.ui.client.security.RequiresAuthorization;
12 import org.kuali.student.common.ui.client.util.ExportElement;
13 import org.kuali.student.lum.common.client.lu.LUUIPermissions;
14 import org.kuali.student.lum.lu.ui.dependency.client.views.DependencyAnalysisView;
15
16 public class DependencyAnalysisController extends BasicLayout implements RequiresAuthorization{
17
18 public enum DependencyViews {
19 MAIN
20 };
21
22 public DependencyAnalysisController(String controllerId) {
23 super(controllerId);
24 addView(new DependencyAnalysisView(this));
25 setDefaultView(DependencyViews.MAIN);
26 }
27
28 public void showExport(boolean show) {
29 DependencyAnalysisView dependancyView = (DependencyAnalysisView) viewMap.get(DependencyViews.MAIN);
30 if (dependancyView.getHeader() != null) {
31 dependancyView.getHeader().showExport(isExportButtonActive());
32
33 }
34 }
35
36 @Override
37 public boolean isExportButtonActive() {
38 return true;
39 }
40
41 @Override
42 public DataModel getExportDataModel() {
43
44 return super.getExportDataModel();
45 }
46
47 @Override
48 public List<ExportElement> getExportElementsFromView() {
49 DependencyAnalysisView view = (DependencyAnalysisView) this.getCurrentView();
50 ExportElement element = new ExportElement();
51 element.setViewName(view.getName());
52 element.setSectionName("");
53 return view.getDepResultPanel().getExportElementSubset(element);
54 }
55
56
57
58
59 @Override
60 public String getExportTemplateName() {
61 return "analysis.template";
62 }
63
64
65
66
67
68
69 @Override
70 public String getName() {
71 String name = super.getName();
72 if ((name == null) && (this.getCurrentView() != null)) {
73 name = this.getCurrentView().getName();
74 }
75 return name;
76 }
77
78 @Override
79 public boolean isAuthorizationRequired() {
80 return true;
81 }
82
83 @Override
84 public void setAuthorizationRequired(boolean required) {
85 throw new UnsupportedOperationException();
86 }
87
88 @Override
89 public void checkAuthorization(final AuthorizationCallback authCallback) {
90 Application.getApplicationContext().getSecurityContext().checkScreenPermission(LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN, new Callback<Boolean>() {
91 @Override
92 public void exec(Boolean result) {
93
94 final boolean isAuthorized = result;
95
96 if(isAuthorized){
97 authCallback.isAuthorized();
98 }
99 else
100 authCallback.isNotAuthorized("User is not authorized: " + LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN);
101 }
102 });
103 }
104
105 }