| 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 | 0 | public enum DependencyViews { |
| 19 | 0 | MAIN |
| 20 | |
}; |
| 21 | |
|
| 22 | |
public DependencyAnalysisController(String controllerId) { |
| 23 | 0 | super(controllerId); |
| 24 | 0 | addView(new DependencyAnalysisView(this)); |
| 25 | 0 | setDefaultView(DependencyViews.MAIN); |
| 26 | 0 | } |
| 27 | |
|
| 28 | |
public void showExport(boolean show) { |
| 29 | 0 | DependencyAnalysisView dependancyView = (DependencyAnalysisView) viewMap.get(DependencyViews.MAIN); |
| 30 | 0 | if (dependancyView.getHeader() != null) { |
| 31 | 0 | dependancyView.getHeader().showExport(isExportButtonActive()); |
| 32 | |
|
| 33 | |
} |
| 34 | 0 | } |
| 35 | |
|
| 36 | |
@Override |
| 37 | |
public boolean isExportButtonActive() { |
| 38 | 0 | return true; |
| 39 | |
} |
| 40 | |
|
| 41 | |
@Override |
| 42 | |
public DataModel getExportDataModel() { |
| 43 | |
|
| 44 | 0 | return super.getExportDataModel(); |
| 45 | |
} |
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public List<ExportElement> getExportElementsFromView() { |
| 49 | 0 | DependencyAnalysisView view = (DependencyAnalysisView) this.getCurrentView(); |
| 50 | 0 | ExportElement element = new ExportElement(); |
| 51 | 0 | element.setViewName(view.getName()); |
| 52 | 0 | element.setSectionName(""); |
| 53 | 0 | return view.getDepResultPanel().getExportElementSubset(element); |
| 54 | |
} |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
@Override |
| 60 | |
public String getExportTemplateName() { |
| 61 | 0 | return "analysis.template"; |
| 62 | |
} |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
@Override |
| 70 | |
public String getName() { |
| 71 | 0 | String name = super.getName(); |
| 72 | 0 | if ((name == null) && (this.getCurrentView() != null)) { |
| 73 | 0 | name = this.getCurrentView().getName(); |
| 74 | |
} |
| 75 | 0 | return name; |
| 76 | |
} |
| 77 | |
|
| 78 | |
@Override |
| 79 | |
public boolean isAuthorizationRequired() { |
| 80 | 0 | return true; |
| 81 | |
} |
| 82 | |
|
| 83 | |
@Override |
| 84 | |
public void setAuthorizationRequired(boolean required) { |
| 85 | 0 | throw new UnsupportedOperationException(); |
| 86 | |
} |
| 87 | |
|
| 88 | |
@Override |
| 89 | |
public void checkAuthorization(final AuthorizationCallback authCallback) { |
| 90 | 0 | Application.getApplicationContext().getSecurityContext().checkScreenPermission(LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN, new Callback<Boolean>() { |
| 91 | |
@Override |
| 92 | |
public void exec(Boolean result) { |
| 93 | |
|
| 94 | 0 | final boolean isAuthorized = result; |
| 95 | |
|
| 96 | 0 | if(isAuthorized){ |
| 97 | 0 | authCallback.isAuthorized(); |
| 98 | |
} |
| 99 | |
else |
| 100 | 0 | authCallback.isNotAuthorized("User is not authorized: " + LUUIPermissions.USE_DEPENDENCY_ANALYSIS_SCREEN); |
| 101 | 0 | } |
| 102 | |
}); |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
} |