1 | |
package org.kuali.student.lum.program.client; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
|
5 | |
import org.kuali.student.common.ui.client.configurable.mvc.Configurer; |
6 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
7 | |
import org.kuali.student.lum.common.client.configuration.AbstractControllerConfiguration; |
8 | |
import org.kuali.student.lum.common.client.configuration.Configuration; |
9 | |
import org.kuali.student.lum.common.client.configuration.ConfigurationManager; |
10 | |
import org.kuali.student.lum.program.client.major.edit.MajorSummaryConfiguration; |
11 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | 0 | public abstract class AbstractProgramConfigurer extends Configurer { |
17 | |
|
18 | |
protected ProgramController programController; |
19 | |
|
20 | |
protected ConfigurationManager programSectionConfigManager; |
21 | |
|
22 | |
public static final String PROPOSAL_PATH = "proposal"; |
23 | |
|
24 | |
public void configure(ProgramController viewController) { |
25 | 0 | this.programController = viewController; |
26 | 0 | configureProgramSections(); |
27 | 0 | } |
28 | |
|
29 | |
public String getProposalPath() { |
30 | 0 | return PROPOSAL_PATH; |
31 | |
} |
32 | |
|
33 | |
|
34 | |
|
35 | |
private void configureProgramSections() { |
36 | 0 | String programSectionLabel = ProgramProperties.get().program_menu_sections(); |
37 | 0 | programController.addMenu(programSectionLabel); |
38 | 0 | ArrayList<Configuration> configurations = programSectionConfigManager.getConfigurations(); |
39 | 0 | for (Configuration configuration : configurations) { |
40 | 0 | if (configuration instanceof AbstractControllerConfiguration) { |
41 | 0 | ((AbstractControllerConfiguration) configuration).setController(programController); |
42 | |
} |
43 | 0 | if (configuration instanceof MajorSummaryConfiguration) { |
44 | 0 | programController.addSpecialMenuItem(configuration.getView(), programSectionLabel); |
45 | |
} else { |
46 | 0 | programController.addMenuItem(programSectionLabel, configuration.getView()); |
47 | |
} |
48 | |
} |
49 | 0 | } |
50 | |
|
51 | |
public ProgramController getProgramController() { |
52 | 0 | return programController; |
53 | |
} |
54 | |
|
55 | |
public void applyPermissions() { |
56 | 0 | DataModel dataModel = programController.getProgramModel(); |
57 | 0 | for (Configuration configuration : programSectionConfigManager.getConfigurations()) { |
58 | 0 | if (configuration.checkPermission(dataModel)) { |
59 | 0 | configuration.applyRestrictions(); |
60 | |
}else{ |
61 | 0 | configuration.removeRestrictions(); |
62 | |
} |
63 | |
} |
64 | 0 | } |
65 | |
|
66 | |
public ConfigurationManager getProgramSectionConfigManager() { |
67 | 0 | return programSectionConfigManager; |
68 | |
} |
69 | |
} |