1 | |
package org.kuali.student.lum.lu.ui.course.client.configuration; |
2 | |
|
3 | |
import java.util.*; |
4 | |
|
5 | |
import org.kuali.student.common.assembly.data.Data; |
6 | |
import org.kuali.student.common.assembly.data.Metadata; |
7 | |
import org.kuali.student.common.assembly.data.QueryPath; |
8 | |
import org.kuali.student.common.assembly.data.Data.Property; |
9 | |
import org.kuali.student.common.dto.DtoConstants; |
10 | |
import org.kuali.student.common.ui.client.application.Application; |
11 | |
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly; |
12 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ListToTextBinding; |
13 | |
import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding; |
14 | |
import org.kuali.student.common.ui.client.configurable.mvc.layouts.MenuSectionController; |
15 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityConfiguration; |
16 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityFieldConfiguration; |
17 | |
import org.kuali.student.common.ui.client.configurable.mvc.sections.WarnContainer; |
18 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
19 | |
import org.kuali.student.common.ui.client.mvc.*; |
20 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
21 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
22 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
23 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
24 | |
import org.kuali.student.common.ui.client.widgets.menus.KSListPanel; |
25 | |
import org.kuali.student.common.ui.client.widgets.progress.BlockingTask; |
26 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
27 | |
import org.kuali.student.common.ui.client.widgets.rules.SubrulePreviewWidget; |
28 | |
import org.kuali.student.common.ui.client.widgets.table.summary.ShowRowConditionCallback; |
29 | |
import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldBlock; |
30 | |
import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldRow; |
31 | |
import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection; |
32 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
33 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
34 | |
import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentList; |
35 | |
import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentListBinding; |
36 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
37 | |
import org.kuali.student.core.statement.dto.StatementTypeInfo; |
38 | |
import org.kuali.student.core.workflow.ui.client.widgets.WorkflowEnhancedNavController; |
39 | |
import org.kuali.student.lum.common.client.lo.TreeStringBinding; |
40 | |
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
41 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
42 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.base.AcademicSubjectOrgInfoConstants; |
43 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.base.MetaInfoConstants; |
44 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.base.RichTextInfoConstants; |
45 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.orch.*; |
46 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseConfigurer.CourseSections; |
47 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.ViewCourseConfigurer.ViewCourseSections; |
48 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController; |
49 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsDataModel; |
50 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsSummaryView; |
51 | |
|
52 | |
import com.google.gwt.core.client.GWT; |
53 | |
import com.google.gwt.event.dom.client.ClickEvent; |
54 | |
import com.google.gwt.event.dom.client.ClickHandler; |
55 | |
import com.google.gwt.user.client.ui.Anchor; |
56 | |
import com.google.gwt.user.client.ui.FlowPanel; |
57 | |
import com.google.gwt.user.client.ui.HTML; |
58 | |
import com.google.gwt.user.client.ui.Widget; |
59 | |
import org.kuali.student.lum.lu.ui.course.client.requirements.HasRequirements; |
60 | |
|
61 | 0 | public class CourseSummaryConfigurer implements |
62 | |
CreditCourseProposalConstants, |
63 | |
CreditCourseProposalInfoConstants, |
64 | |
CreditCourseConstants, |
65 | |
CreditCourseFormatConstants, |
66 | |
CreditCourseActivityConstants, |
67 | |
MetaInfoConstants, |
68 | |
CreditCourseDurationConstants, |
69 | |
FeeInfoConstants, |
70 | |
LearningObjectiveConstants, |
71 | |
AcademicSubjectOrgInfoConstants, |
72 | |
AffiliatedOrgInfoConstants, |
73 | |
CreditCourseRevenueInfoConstants, |
74 | |
CreditCourseExpenditureInfoConstants |
75 | |
{ |
76 | |
|
77 | |
public static final String PROPOSAL = ""; |
78 | |
public static final String COURSE = ""; |
79 | |
public static final String PROPOSAL_TITLE_PATH = "proposal/name"; |
80 | 0 | private List<ValidationResultInfo> validationInfos = new ArrayList<ValidationResultInfo>(); |
81 | 0 | private boolean showingValidation = false; |
82 | |
private static final String OPTIONAL = "o"; |
83 | |
|
84 | 0 | protected String type = "course"; |
85 | 0 | protected String state = DtoConstants.STATE_DRAFT; |
86 | |
protected String groupName; |
87 | |
protected DataModelDefinition modelDefinition; |
88 | |
private List<StatementTypeInfo> stmtTypes; |
89 | |
|
90 | |
private Controller controller; |
91 | |
private SummaryTableSection tableSection; |
92 | |
private String modelId; |
93 | |
|
94 | 0 | private BlockingTask loadDataTask = new BlockingTask("Retrieving Data"); |
95 | |
|
96 | |
private class EditHandler implements ClickHandler{ |
97 | |
|
98 | |
Enum<?> view; |
99 | |
|
100 | 0 | public EditHandler(Enum<?> view){ |
101 | 0 | this.view = view; |
102 | 0 | } |
103 | |
|
104 | |
@Override |
105 | |
public void onClick(ClickEvent event) { |
106 | 0 | controller.showView(view); |
107 | 0 | } |
108 | |
} |
109 | |
|
110 | |
public CourseSummaryConfigurer(String type, String state, |
111 | 0 | String groupName, DataModelDefinition modelDefinition, List<StatementTypeInfo> stmtTypes, Controller controller, String modelId) { |
112 | 0 | this.type = type; |
113 | 0 | this.state = state; |
114 | 0 | this.groupName = groupName; |
115 | 0 | this.modelDefinition = modelDefinition; |
116 | 0 | this.stmtTypes = stmtTypes; |
117 | 0 | this.controller = controller; |
118 | 0 | this.modelId = modelId; |
119 | 0 | tableSection = new SummaryTableSection((Controller)controller); |
120 | 0 | } |
121 | |
|
122 | |
protected VerticalSectionView initSectionView (Enum<?> viewEnum, String labelKey) { |
123 | 0 | VerticalSectionView section = new VerticalSectionView(viewEnum, getLabel(labelKey), modelId); |
124 | 0 | section.addStyleName(LUUIConstants.STYLE_SECTION); |
125 | 0 | return section; |
126 | |
} |
127 | |
protected String getLabel(String labelKey) { |
128 | 0 | return Application.getApplicationContext().getUILabel(groupName, type, state, labelKey); |
129 | |
} |
130 | |
protected MessageKeyInfo generateMessageInfo(String labelKey) { |
131 | 0 | return new MessageKeyInfo(groupName, type, state, labelKey); |
132 | |
} |
133 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) { |
134 | 0 | return getFieldRow(fieldKey, messageKey, null, null, null, null, false); |
135 | |
} |
136 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey, boolean optional) { |
137 | 0 | return getFieldRow(fieldKey, messageKey, null, null, null, null, optional); |
138 | |
} |
139 | |
|
140 | |
protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey, Widget widget, Widget widget2, String parentPath, ModelWidgetBinding<?> binding, boolean optional) { |
141 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
142 | 0 | Metadata meta = modelDefinition.getMetadata(path); |
143 | |
|
144 | 0 | FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
145 | 0 | if (widget != null) { |
146 | 0 | fd.setFieldWidget(widget); |
147 | |
} |
148 | 0 | if(binding != null){ |
149 | 0 | fd.setWidgetBinding(binding); |
150 | |
} |
151 | 0 | fd.setOptional(optional); |
152 | |
|
153 | 0 | FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta); |
154 | 0 | if (widget2 != null) { |
155 | 0 | fd2.setFieldWidget(widget2); |
156 | |
} |
157 | 0 | if(binding != null){ |
158 | 0 | fd2.setWidgetBinding(binding); |
159 | |
} |
160 | 0 | fd2.setOptional(optional); |
161 | |
|
162 | 0 | SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd,fd2); |
163 | |
|
164 | 0 | return fieldRow; |
165 | |
} |
166 | |
|
167 | |
public VerticalSectionView generateProposalSummarySection(boolean canEditSections){ |
168 | 0 | tableSection.setEditable(canEditSections); |
169 | 0 | tableSection.addSummaryTableFieldBlock(generateCourseInformationForProposal()); |
170 | 0 | tableSection.addSummaryTableFieldBlock(generateGovernanceSection()); |
171 | 0 | tableSection.addSummaryTableFieldBlock(generateCourseLogisticsSection()); |
172 | 0 | tableSection.addSummaryTableFieldBlock(generateLearningObjectivesSection()); |
173 | 0 | tableSection.addSummaryTableFieldBlock(generateRequirementsSection()); |
174 | 0 | tableSection.addSummaryTableFieldBlock(generateActiveDatesSection()); |
175 | 0 | tableSection.addSummaryTableFieldBlock(generateFeesSection()); |
176 | 0 | tableSection.addSummaryTableFieldBlock(generateProposalDocumentsSection()); |
177 | |
|
178 | 0 | if(controller instanceof WorkflowEnhancedNavController){ |
179 | |
final WarnContainer infoContainer1; |
180 | |
final WarnContainer infoContainer2; |
181 | |
|
182 | 0 | infoContainer1 = generateWorkflowWidgetContainer(((WorkflowEnhancedNavController)controller).getWfUtilities().getWorkflowActionsWidget()); |
183 | 0 | infoContainer2 = generateWorkflowWidgetContainer(((WorkflowEnhancedNavController)controller).getWfUtilities().getWorkflowActionsWidget()); |
184 | |
|
185 | 0 | ((WorkflowEnhancedNavController)controller).getWfUtilities().addSubmitCallback(new Callback<Boolean>(){ |
186 | |
|
187 | |
@Override |
188 | |
public void exec(Boolean result) { |
189 | 0 | if(result){ |
190 | 0 | tableSection.setEditable(false); |
191 | 0 | if(controller instanceof MenuSectionController){ |
192 | 0 | ((MenuSectionController) controller).removeMenuNavigation(); |
193 | |
} |
194 | |
} |
195 | |
|
196 | 0 | } |
197 | |
}); |
198 | |
|
199 | 0 | VerticalSectionView verticalSection = new VerticalSectionView(CourseSections.SUMMARY, getLabel(LUUIConstants.SUMMARY_LABEL_KEY), modelId){ |
200 | |
@Override |
201 | |
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
202 | |
|
203 | 0 | super.beforeShow(new Callback<Boolean>(){ |
204 | |
|
205 | |
@Override |
206 | |
public void exec(final Boolean result) { |
207 | 0 | if(result){ |
208 | |
|
209 | 0 | ((WorkflowEnhancedNavController)controller).getWfUtilities().refresh(); |
210 | |
|
211 | |
|
212 | 0 | ((WorkflowEnhancedNavController)controller).getWfUtilities().doValidationCheck(new Callback<List<ValidationResultInfo>>(){ |
213 | |
|
214 | |
@Override |
215 | |
public void exec( |
216 | |
List<ValidationResultInfo> validationResult) { |
217 | |
|
218 | 0 | tableSection.enableValidation(showingValidation); |
219 | 0 | ErrorLevel isValid = tableSection.processValidationResults(validationResult, true); |
220 | |
|
221 | 0 | validationInfos = validationResult; |
222 | 0 | if(isValid != ErrorLevel.ERROR){ |
223 | 0 | infoContainer1.showWarningLayout(false); |
224 | 0 | infoContainer2.showWarningLayout(false); |
225 | 0 | ((WorkflowEnhancedNavController)controller).getWfUtilities().enableWorkflowActionsWidgets(true); |
226 | |
} |
227 | |
else{ |
228 | 0 | infoContainer1.showWarningLayout(true); |
229 | 0 | infoContainer2.showWarningLayout(true); |
230 | 0 | ((WorkflowEnhancedNavController)controller).getWfUtilities().enableWorkflowActionsWidgets(false); |
231 | |
} |
232 | 0 | onReadyCallback.exec(result); |
233 | |
|
234 | 0 | }}); |
235 | |
} |
236 | |
else{ |
237 | 0 | onReadyCallback.exec(result); |
238 | |
} |
239 | 0 | }}); |
240 | |
|
241 | 0 | } |
242 | |
}; |
243 | |
|
244 | 0 | verticalSection.addWidget(infoContainer1); |
245 | 0 | verticalSection.addSection(tableSection); |
246 | 0 | verticalSection.addWidget(infoContainer2); |
247 | 0 | return verticalSection; |
248 | |
} |
249 | |
else{ |
250 | 0 | VerticalSectionView verticalSection = new VerticalSectionView(CourseSections.SUMMARY, getLabel(LUUIConstants.SUMMARY_LABEL_KEY), modelId); |
251 | 0 | verticalSection.addSection(tableSection); |
252 | 0 | GWT.log("CourseSummaryConfigurer - Summary table needs a workflow controller to provide submit/validation mechanism"); |
253 | 0 | return verticalSection; |
254 | |
} |
255 | |
|
256 | |
|
257 | |
} |
258 | |
|
259 | |
private SummaryTableFieldBlock generateProposalDocumentsSection() { |
260 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
261 | 0 | block.addEditingHandler(new EditHandler(CourseSections.DOCUMENTS)); |
262 | 0 | block.setTitle(getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY)); |
263 | 0 | block.addSummaryTableFieldRow(getFieldRow("proposal/id", generateMessageInfo(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY), |
264 | |
new DocumentList(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,false, false), new DocumentList(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,false, false), null, new DocumentListBinding("proposal/id"), false)); |
265 | 0 | return block; |
266 | |
} |
267 | |
|
268 | 0 | private List<Anchor> validateLinks = new ArrayList<Anchor>(); |
269 | |
private WarnContainer generateWorkflowWidgetContainer(Widget w){ |
270 | 0 | WarnContainer warnContainer = new WarnContainer(); |
271 | 0 | warnContainer.add(w); |
272 | 0 | w.addStyleName("ks-button-spacing"); |
273 | 0 | warnContainer.add(new KSButton("Return to Curriculum Management", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler(){ |
274 | |
|
275 | |
@Override |
276 | |
public void onClick(ClickEvent event) { |
277 | 0 | Application.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT.getLocation()); |
278 | 0 | } |
279 | |
})); |
280 | |
|
281 | 0 | KSLabel label = new KSLabel("This proposal has missing fields. "); |
282 | 0 | final String showText = "Show what's missing."; |
283 | 0 | final String hideText = "Hide error highlighting."; |
284 | 0 | final Anchor link = new Anchor(showText); |
285 | 0 | validateLinks.add(link); |
286 | 0 | link.addClickHandler(new ClickHandler(){ |
287 | |
|
288 | |
@Override |
289 | |
public void onClick(ClickEvent event) { |
290 | 0 | if(!showingValidation){ |
291 | 0 | for(int i=0; i< validateLinks.size(); i++){ |
292 | 0 | validateLinks.get(i).setText(hideText); |
293 | |
} |
294 | 0 | showingValidation = true; |
295 | 0 | tableSection.enableValidation(showingValidation); |
296 | 0 | tableSection.processValidationResults(validationInfos, true); |
297 | |
} |
298 | |
else{ |
299 | 0 | for(int i=0; i< validateLinks.size(); i++){ |
300 | 0 | validateLinks.get(i).setText(showText); |
301 | |
} |
302 | 0 | showingValidation = false; |
303 | 0 | tableSection.enableValidation(showingValidation); |
304 | 0 | tableSection.removeValidationHighlighting(); |
305 | |
} |
306 | 0 | } |
307 | |
}); |
308 | 0 | warnContainer.addWarnWidget(label); |
309 | 0 | warnContainer.addWarnWidget(link); |
310 | 0 | return warnContainer; |
311 | |
} |
312 | |
|
313 | |
public VerticalSectionView generateCourseSummarySection(){ |
314 | 0 | tableSection.setEditable(false); |
315 | 0 | tableSection.addSummaryTableFieldBlock(generateCourseInformation()); |
316 | 0 | tableSection.addSummaryTableFieldBlock(generateGovernanceSection()); |
317 | 0 | tableSection.addSummaryTableFieldBlock(generateCourseLogisticsSection()); |
318 | 0 | tableSection.addSummaryTableFieldBlock(generateLearningObjectivesSection()); |
319 | 0 | tableSection.addSummaryTableFieldBlock(generateRequirementsSection()); |
320 | 0 | tableSection.addSummaryTableFieldBlock(generateActiveDatesSection()); |
321 | 0 | tableSection.addSummaryTableFieldBlock(generateFeesSection()); |
322 | |
|
323 | 0 | VerticalSectionView verticalSection = new VerticalSectionView(ViewCourseSections.DETAILED, getLabel(LUUIConstants.SUMMARY_LABEL_KEY), modelId, false); |
324 | 0 | verticalSection.addSection(tableSection); |
325 | |
|
326 | 0 | return verticalSection; |
327 | |
} |
328 | |
|
329 | |
@SuppressWarnings("unchecked") |
330 | |
public SummaryTableFieldBlock generateCourseInformationForProposal(){ |
331 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
332 | 0 | block.addEditingHandler(new EditHandler(CourseSections.COURSE_INFO)); |
333 | 0 | block.setTitle(getLabel(LUUIConstants.INFORMATION_LABEL_KEY)); |
334 | 0 | block.addSummaryTableFieldRow(getFieldRow(PROPOSAL_TITLE_PATH, generateMessageInfo(LUUIConstants.PROPOSAL_TITLE_LABEL_KEY))); |
335 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + COURSE_TITLE, generateMessageInfo(LUUIConstants.COURSE_TITLE_LABEL_KEY))); |
336 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + TRANSCRIPT_TITLE, generateMessageInfo(LUUIConstants.SHORT_TITLE_LABEL_KEY))); |
337 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + SUBJECT_AREA, generateMessageInfo(LUUIConstants.SUBJECT_CODE_LABEL_KEY))); |
338 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + COURSE_NUMBER_SUFFIX, generateMessageInfo(LUUIConstants.COURSE_NUMBER_LABEL_KEY))); |
339 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + INSTRUCTORS, generateMessageInfo(LUUIConstants.INSTRUCTORS_LABEL_KEY), null, null, null, new KeyListModelWigetBinding("personId"), false)); |
340 | |
|
341 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + CROSS_LISTINGS, |
342 | |
LUUIConstants.CROSS_LISTED_ITEM_LABEL_KEY, |
343 | |
Arrays.asList( |
344 | |
Arrays.asList(SUBJECT_AREA, LUUIConstants.SUBJECT_CODE_LABEL_KEY), |
345 | |
Arrays.asList(COURSE_NUMBER_SUFFIX, LUUIConstants.COURSE_NUMBER_LABEL_KEY)))); |
346 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + JOINTS, |
347 | |
LUUIConstants.JOINT_OFFER_ITEM_LABEL_KEY, |
348 | |
Arrays.asList( |
349 | |
Arrays.asList(CreditCourseJointsConstants.COURSE_ID, LUUIConstants.COURSE_NUMBER_OR_TITLE_LABEL_KEY)))); |
350 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + VERSIONS, |
351 | |
LUUIConstants.VERSION_CODE_LABEL_KEY, |
352 | |
Arrays.asList( |
353 | |
Arrays.asList("variationCode", LUUIConstants.VERSION_CODE_LABEL_KEY), |
354 | |
Arrays.asList("variationTitle", LUUIConstants.TITLE_LABEL_KEY)))); |
355 | |
|
356 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PROPOSAL_DESCRIPTION + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.DESCRIPTION_LABEL_KEY))); |
357 | 0 | block.addSummaryTableFieldRow(getFieldRow("proposal/rationale", generateMessageInfo(LUUIConstants.PROPOSAL_RATIONALE_LABEL_KEY))); |
358 | |
|
359 | |
|
360 | 0 | return block; |
361 | |
} |
362 | |
|
363 | |
public SummaryTableFieldBlock generateCourseInformation(){ |
364 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
365 | 0 | block.addEditingHandler(new EditHandler(CourseSections.COURSE_INFO)); |
366 | 0 | block.setTitle(getLabel(LUUIConstants.INFORMATION_LABEL_KEY)); |
367 | |
|
368 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + COURSE_TITLE, generateMessageInfo(LUUIConstants.COURSE_TITLE_LABEL_KEY))); |
369 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + TRANSCRIPT_TITLE, generateMessageInfo(LUUIConstants.SHORT_TITLE_LABEL_KEY))); |
370 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + SUBJECT_AREA, generateMessageInfo(LUUIConstants.SUBJECT_CODE_LABEL_KEY))); |
371 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + COURSE_NUMBER_SUFFIX, generateMessageInfo(LUUIConstants.COURSE_NUMBER_LABEL_KEY))); |
372 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + INSTRUCTORS, generateMessageInfo(LUUIConstants.INSTRUCTORS_LABEL_KEY), null, null, null, new KeyListModelWigetBinding("personId"), false)); |
373 | |
|
374 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + CROSS_LISTINGS, |
375 | |
LUUIConstants.CROSS_LISTED_ITEM_LABEL_KEY, |
376 | |
Arrays.asList( |
377 | |
Arrays.asList(SUBJECT_AREA, LUUIConstants.SUBJECT_CODE_LABEL_KEY), |
378 | |
Arrays.asList(COURSE_NUMBER_SUFFIX, LUUIConstants.COURSE_NUMBER_LABEL_KEY)))); |
379 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + JOINTS, |
380 | |
LUUIConstants.JOINT_OFFER_ITEM_LABEL_KEY, |
381 | |
Arrays.asList( |
382 | |
Arrays.asList(CreditCourseJointsConstants.COURSE_ID, LUUIConstants.COURSE_NUMBER_OR_TITLE_LABEL_KEY)))); |
383 | 0 | block.addSummaryMultiplicity(getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + VERSIONS, |
384 | |
LUUIConstants.VERSION_CODE_LABEL_KEY, |
385 | |
Arrays.asList( |
386 | |
Arrays.asList("variationCode", LUUIConstants.VERSION_CODE_LABEL_KEY), |
387 | |
Arrays.asList("variationTitle", LUUIConstants.TITLE_LABEL_KEY)))); |
388 | |
|
389 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PROPOSAL_DESCRIPTION + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.DESCRIPTION_LABEL_KEY))); |
390 | |
|
391 | 0 | return block; |
392 | |
} |
393 | |
|
394 | |
public SummaryTableFieldBlock generateGovernanceSection(){ |
395 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
396 | 0 | block.addEditingHandler(new EditHandler(CourseSections.GOVERNANCE)); |
397 | 0 | block.setTitle(getLabel(LUUIConstants.GOVERNANCE_LABEL_KEY)); |
398 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CAMPUS_LOCATIONS, generateMessageInfo(LUUIConstants.CAMPUS_LOCATION_LABEL_KEY))); |
399 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CURRICULUM_OVERSIGHT_ORGS_, generateMessageInfo(LUUIConstants.ACADEMIC_SUBJECT_ORGS_KEY))); |
400 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + ADMIN_ORGS, generateMessageInfo(LUUIConstants.ADMIN_ORG_LABEL_KEY))); |
401 | 0 | return block; |
402 | |
} |
403 | |
|
404 | |
@SuppressWarnings("unchecked") |
405 | |
public SummaryTableFieldBlock generateCourseLogisticsSection(){ |
406 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
407 | 0 | block.addEditingHandler(new EditHandler(CourseSections.COURSE_LOGISTICS)); |
408 | 0 | block.setTitle(getLabel(LUUIConstants.LOGISTICS_LABEL_KEY)); |
409 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + TERMS_OFFERED, generateMessageInfo(LUUIConstants.TERMS_OFFERED_LABEL_KEY))); |
410 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + GRADING_OPTIONS, generateMessageInfo(LUUIConstants.LEARNING_RESULT_ASSESSMENT_SCALE_LABEL_KEY))); |
411 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CreditCourseConstants.DURATION + "/" + "atpDurationTypeKey", generateMessageInfo(LUUIConstants.DURATION_TYPE_LABEL_KEY))); |
412 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CreditCourseConstants.DURATION + "/" + "timeQuantity", generateMessageInfo(LUUIConstants.DURATION_QUANTITY_LABEL_KEY))); |
413 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PASS_FAIL, generateMessageInfo(LUUIConstants.LEARNING_RESULT_PASS_FAIL_LABEL_KEY))); |
414 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + AUDIT, generateMessageInfo(LUUIConstants.LEARNING_RESULT_AUDIT_LABEL_KEY))); |
415 | |
|
416 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CreditCourseConstants.FINAL_EXAM, generateMessageInfo(LUUIConstants.FINAL_EXAM_STATUS_LABEL_KEY))); |
417 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CreditCourseConstants.FINAL_EXAM_RATIONALE, generateMessageInfo(LUUIConstants.FINAL_EXAM_RATIONALE_LABEL_KEY), true)); |
418 | |
|
419 | |
|
420 | 0 | Map<String, ModelWidgetBinding> customBindings = new HashMap<String, ModelWidgetBinding>(); |
421 | 0 | ListToTextBinding resultValuesBinding = new ListToTextBinding(); |
422 | 0 | customBindings.put("resultValues", resultValuesBinding); |
423 | 0 | String outcomesKey = COURSE + QueryPath.getPathSeparator() + CREDIT_OPTIONS; |
424 | 0 | MultiplicityConfiguration outcomesConfig = getMultiplicityConfig(outcomesKey, |
425 | |
LUUIConstants.LEARNING_RESULT_OUTCOME_LABEL_KEY, |
426 | |
Arrays.asList( |
427 | |
Arrays.asList(CreditCourseConstants.TYPE, LUUIConstants.LEARNING_RESULT_OUTCOME_TYPE_LABEL_KEY), |
428 | |
Arrays.asList(CREDIT_OPTION_FIXED_CREDITS, LUUIConstants.CREDIT_VALUE_LABEL_KEY, OPTIONAL), |
429 | |
Arrays.asList(CREDIT_OPTION_MIN_CREDITS, LUUIConstants.CREDIT_OPTION_MIN_CREDITS_LABEL_KEY, OPTIONAL), |
430 | |
Arrays.asList(CREDIT_OPTION_MAX_CREDITS, LUUIConstants.CREDIT_OPTION_MAX_CREDITS_LABEL_KEY, OPTIONAL), |
431 | |
Arrays.asList("resultValues", LUUIConstants.CREDIT_OPTION_FIXED_CREDITS_LABEL_KEY, OPTIONAL)), |
432 | |
customBindings); |
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | 0 | tableSection.addShowRowCallback(new ShowRowConditionCallback(){ |
439 | |
@Override |
440 | |
public void processShowConditions(SummaryTableFieldRow row, |
441 | |
DataModel column1, DataModel column2) { |
442 | 0 | if(row.getFieldDescriptor1() != null && |
443 | |
row.getFieldDescriptor1().getFieldKey().contains(CREDIT_OPTIONS) && |
444 | |
row.getFieldDescriptor1().getFieldKey().contains("resultValues")){ |
445 | 0 | String type = row.getFieldDescriptor1().getFieldKey().replace("resultValues", CreditCourseConstants.TYPE); |
446 | 0 | Object data1 = null; |
447 | 0 | Object data2 = null; |
448 | 0 | if(column1 != null){ |
449 | 0 | data1 = column1.get(type); |
450 | |
} |
451 | 0 | if(column2 != null){ |
452 | 0 | data2 = column2.get(type); |
453 | |
} |
454 | |
|
455 | 0 | if(data1 != null && data1 instanceof String){ |
456 | 0 | if(!((String)data1).equals("kuali.resultComponentType.credit.degree.multiple")){ |
457 | 0 | row.setShown(false); |
458 | |
} |
459 | |
} |
460 | 0 | else if(data2 != null && data2 instanceof String){ |
461 | 0 | if(!((String)data2).equals("kuali.resultComponentType.credit.degree.multiple")){ |
462 | 0 | row.setShown(false); |
463 | |
} |
464 | |
} |
465 | |
} |
466 | 0 | } |
467 | |
}); |
468 | |
|
469 | 0 | block.addSummaryMultiplicity(outcomesConfig); |
470 | |
|
471 | |
|
472 | 0 | MultiplicityConfiguration formatsConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FORMATS, |
473 | |
LUUIConstants.FORMAT_LABEL_KEY, |
474 | |
null); |
475 | 0 | MultiplicityConfiguration activitiesConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FORMATS + QueryPath.getPathSeparator() |
476 | |
+ QueryPath.getWildCard() + QueryPath.getPathSeparator() + ACTIVITIES, |
477 | |
LUUIConstants.ACTIVITY_LITERAL_LABEL_KEY, |
478 | |
Arrays.asList( |
479 | |
Arrays.asList(ACTIVITY_TYPE, LUUIConstants.ACTIVITY_TYPE_LABEL_KEY), |
480 | |
Arrays.asList(CONTACT_HOURS + "/" + "unitQuantity", LUUIConstants.CONTACT_HOURS_LABEL_KEY), |
481 | |
Arrays.asList(CONTACT_HOURS + "/" + "unitType", LUUIConstants.CONTACT_HOURS_FREQUENCY_LABEL_KEY), |
482 | |
Arrays.asList(CreditCourseActivityConstants.DURATION + "/" + "atpDurationTypeKey", LUUIConstants.DURATION_TYPE_LABEL_KEY), |
483 | |
Arrays.asList(CreditCourseActivityConstants.DURATION + "/" + "timeQuantity", LUUIConstants.DURATION_LITERAL_LABEL_KEY), |
484 | |
Arrays.asList(DEFAULT_ENROLLMENT_ESTIMATE, LUUIConstants.CLASS_SIZE_LABEL_KEY))); |
485 | 0 | formatsConfig.setNestedConfig(activitiesConfig); |
486 | 0 | block.addSummaryMultiplicity(formatsConfig); |
487 | |
|
488 | 0 | return block; |
489 | |
} |
490 | |
|
491 | |
public SummaryTableFieldBlock generateLearningObjectivesSection(){ |
492 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
493 | 0 | block.addEditingHandler(new EditHandler(CourseSections.LEARNING_OBJECTIVES)); |
494 | 0 | block.setTitle(getLabel(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY)); |
495 | 0 | SummaryTableFieldRow loRow = getFieldRow(COURSE + "/" + CreditCourseConstants.COURSE_SPECIFIC_LOS, generateMessageInfo(LUUIConstants.LEARNING_OBJECTIVES_LABEL_KEY), |
496 | |
new KSListPanel(), new KSListPanel(), null, new TreeStringBinding(), false); |
497 | 0 | loRow.addContentCellStyleName("summaryTable-lo-cell"); |
498 | 0 | block.addSummaryTableFieldRow(loRow); |
499 | |
|
500 | 0 | return block; |
501 | |
} |
502 | |
|
503 | |
public SummaryTableFieldBlock generateActiveDatesSection(){ |
504 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
505 | 0 | block.addEditingHandler(new EditHandler(CourseSections.ACTIVE_DATES)); |
506 | 0 | block.setTitle(getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY)); |
507 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + START_TERM, generateMessageInfo(LUUIConstants.START_TERM_LABEL_KEY))); |
508 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + END_TERM, generateMessageInfo(LUUIConstants.END_TERM_LABEL_KEY))); |
509 | |
|
510 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PILOT_COURSE, generateMessageInfo(LUUIConstants.PILOT_COURSE_LABEL_KEY))); |
511 | 0 | return block; |
512 | |
} |
513 | |
|
514 | |
public SummaryTableFieldBlock generateFeesSection() { |
515 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
516 | 0 | block.addEditingHandler(new EditHandler(CourseSections.FINANCIALS)); |
517 | 0 | block.setTitle(getLabel(LUUIConstants.FINANCIALS_LABEL_KEY)); |
518 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + "feeJustification" + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.JUSTIFICATION_FEE))); |
519 | |
|
520 | 0 | MultiplicityConfiguration feesConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FEES, |
521 | |
LUUIConstants.FEE, |
522 | |
Arrays.asList( |
523 | |
Arrays.asList("rateType", "Rate Type"), |
524 | |
Arrays.asList("feeType", "Fee Type"))); |
525 | |
|
526 | 0 | MultiplicityConfiguration amountsConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FEES + QueryPath.getPathSeparator() |
527 | |
+ QueryPath.getWildCard() + QueryPath.getPathSeparator() + "feeAmounts", |
528 | |
"", |
529 | |
Arrays.asList( |
530 | |
Arrays.asList("currencyQuantity", "Amount"))); |
531 | 0 | feesConfig.setNestedConfig(amountsConfig); |
532 | 0 | block.addSummaryMultiplicity(feesConfig); |
533 | |
|
534 | |
|
535 | 0 | MultiplicityConfiguration revenueConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + "revenues", |
536 | |
LUUIConstants.REVENUE, |
537 | |
Arrays.asList( |
538 | |
Arrays.asList("affiliatedOrgs/0/orgId", "Organization"), |
539 | |
Arrays.asList("affiliatedOrgs/0/percentage", "Percentage"))); |
540 | 0 | block.addSummaryMultiplicity(revenueConfig); |
541 | |
|
542 | |
|
543 | 0 | MultiplicityConfiguration expenditureConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + "expenditure" |
544 | |
+ QueryPath.getPathSeparator() + "affiliatedOrgs", |
545 | |
LUUIConstants.EXPENDITURE, |
546 | |
Arrays.asList( |
547 | |
Arrays.asList("orgId", "Organization"), |
548 | |
Arrays.asList("percentage", "Percentage"))); |
549 | 0 | block.addSummaryMultiplicity(expenditureConfig); |
550 | |
|
551 | 0 | return block; |
552 | |
} |
553 | |
|
554 | |
public SummaryTableFieldBlock generateRequirementsSection(){ |
555 | |
|
556 | 0 | final SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
557 | 0 | block.addEditingHandler(new EditHandler(CourseSections.COURSE_REQUISITES)); |
558 | 0 | block.setTitle(getLabel(LUUIConstants.REQUISITES_LABEL_KEY)); |
559 | |
|
560 | |
|
561 | 0 | for (StatementTypeInfo stmtType : stmtTypes) { |
562 | 0 | SummaryTableFieldRow arow = new SummaryTableFieldRow(addRequisiteField(new FlowPanel(), stmtType), addRequisiteField(new FlowPanel(), stmtType)); |
563 | 0 | block.addSummaryTableFieldRow(arow); |
564 | 0 | } |
565 | |
|
566 | 0 | return block; |
567 | |
} |
568 | |
|
569 | |
private FieldDescriptorReadOnly addRequisiteField(final FlowPanel panel, final StatementTypeInfo stmtType) { |
570 | |
|
571 | 0 | final ModelWidgetBinding<FlowPanel> widgetBinding = new ModelWidgetBinding<FlowPanel>() { |
572 | |
|
573 | |
@Override |
574 | |
public void setModelValue(FlowPanel panel, DataModel model, String path) { |
575 | 0 | } |
576 | |
|
577 | |
@Override |
578 | |
public void setWidgetValue(final FlowPanel panel, DataModel model, String path) { |
579 | 0 | panel.clear(); |
580 | 0 | if (controller instanceof HasRequirements) { |
581 | 0 | HasRequirements requirementsController = (HasRequirements) controller; |
582 | 0 | List<StatementTreeViewInfo> statementTreeViewInfos = requirementsController.getReqDataModel().getCourseReqInfo(stmtType.getId()); |
583 | 0 | for (StatementTreeViewInfo rule : statementTreeViewInfos) { |
584 | 0 | SubrulePreviewWidget ruleWidget = new SubrulePreviewWidget(rule, true, CourseRequirementsSummaryView.getCluSetWidgetList(rule)); |
585 | 0 | panel.add(ruleWidget); |
586 | 0 | } |
587 | |
} |
588 | 0 | } |
589 | |
}; |
590 | |
|
591 | 0 | FieldDescriptorReadOnly requisiteField = new FieldDescriptorReadOnly(COURSE + "/" + CreditCourseConstants.ID, new MessageKeyInfo(stmtType.getName()), null, panel); |
592 | 0 | requisiteField.setWidgetBinding(widgetBinding); |
593 | |
|
594 | 0 | return requisiteField; |
595 | |
} |
596 | |
|
597 | |
private MultiplicityConfiguration getMultiplicityConfig(String path, |
598 | |
String itemLabelMessageKey, List<List<String>> fieldKeysAndLabels){ |
599 | 0 | return getMultiplicityConfig(path, itemLabelMessageKey, fieldKeysAndLabels, null); |
600 | |
} |
601 | |
|
602 | |
private MultiplicityConfiguration getMultiplicityConfig(String path, |
603 | |
String itemLabelMessageKey, List<List<String>> fieldKeysAndLabels, Map<String, ModelWidgetBinding> customBindings){ |
604 | 0 | QueryPath parentPath = QueryPath.concat(path); |
605 | 0 | MultiplicityConfiguration config = new MultiplicityConfiguration(MultiplicityConfiguration.MultiplicityType.TABLE, |
606 | |
MultiplicityConfiguration.StyleType.TOP_LEVEL_GROUP, modelDefinition.getMetadata(parentPath)); |
607 | 0 | config.setItemLabel(getLabel(itemLabelMessageKey)); |
608 | 0 | config.setUpdateable(false); |
609 | 0 | config.setShowHeaders(true); |
610 | |
|
611 | 0 | FieldDescriptorReadOnly parentFd = buildFieldDescriptor(path, getLabel(itemLabelMessageKey), null); |
612 | 0 | config.setParent(parentFd); |
613 | |
|
614 | 0 | if (fieldKeysAndLabels != null) { |
615 | 0 | for (List<String> fieldKeyAndLabel : fieldKeysAndLabels) { |
616 | 0 | MultiplicityFieldConfiguration fd = buildMultiplicityFD(fieldKeyAndLabel.get(0), |
617 | |
fieldKeyAndLabel.get(1), parentPath.toString()); |
618 | 0 | if(fieldKeyAndLabel.size() == 3 && fieldKeyAndLabel.get(2).equals(OPTIONAL)){ |
619 | 0 | fd.setOptional(true); |
620 | |
} |
621 | 0 | if(customBindings != null && customBindings.containsKey(fieldKeyAndLabel.get(0))){ |
622 | 0 | fd.setModelWidgetBinding(customBindings.get(fieldKeyAndLabel.get(0))); |
623 | |
} |
624 | 0 | config.addFieldConfiguration(fd); |
625 | 0 | } |
626 | |
} |
627 | |
|
628 | 0 | return config; |
629 | |
} |
630 | |
|
631 | |
|
632 | |
|
633 | |
private MultiplicityFieldConfiguration buildMultiplicityFD( |
634 | |
String fieldKey, String labelKey, String parentPath) { |
635 | |
|
636 | 0 | QueryPath fieldPath = QueryPath.concat(parentPath, QueryPath.getWildCard(), fieldKey); |
637 | 0 | Metadata meta = modelDefinition.getMetadata(fieldPath); |
638 | |
|
639 | 0 | MultiplicityFieldConfiguration fd = new MultiplicityFieldConfiguration( |
640 | |
fieldPath.toString(), generateMessageInfo(labelKey), meta, null); |
641 | |
|
642 | |
|
643 | 0 | return fd; |
644 | |
|
645 | |
} |
646 | |
|
647 | |
private FieldDescriptorReadOnly buildFieldDescriptor(String fieldKey, String messageKey,String parentPath) { |
648 | 0 | return buildFieldDescriptor(fieldKey, messageKey, parentPath, null, null); |
649 | |
} |
650 | |
|
651 | |
private FieldDescriptorReadOnly buildFieldDescriptor(String fieldKey, String messageKey, String parentPath, Widget widget, ModelWidgetBinding<?> binding) { |
652 | |
|
653 | 0 | QueryPath path = QueryPath.concat(parentPath, fieldKey); |
654 | 0 | Metadata meta = modelDefinition.getMetadata(path); |
655 | |
|
656 | 0 | FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), generateMessageInfo(messageKey), meta); |
657 | 0 | if (widget != null) { |
658 | 0 | fd.setFieldWidget(widget); |
659 | |
} |
660 | 0 | if (binding != null) { |
661 | 0 | fd.setWidgetBinding(binding); |
662 | |
} |
663 | 0 | return fd; |
664 | |
} |
665 | |
|
666 | |
public VerticalSectionView generateCourseBriefSection() { |
667 | 0 | SummaryTableSection courseBriefSection = new SummaryTableSection(controller); |
668 | 0 | courseBriefSection.setEditable(false); |
669 | 0 | SummaryTableFieldBlock block = new SummaryTableFieldBlock(); |
670 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + COURSE_TITLE, generateMessageInfo(LUUIConstants.COURSE_TITLE_LABEL_KEY))); |
671 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + "code", generateMessageInfo(LUUIConstants.COURSE_NUMBER_LABEL_KEY))); |
672 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + ADMIN_ORGS, generateMessageInfo(LUUIConstants.ADMIN_ORG_LABEL_KEY))); |
673 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PROPOSAL_DESCRIPTION + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.DESCRIPTION_LABEL_KEY))); |
674 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CURRICULUM_OVERSIGHT_ORGS_, generateMessageInfo(LUUIConstants.ACADEMIC_SUBJECT_ORGS_KEY))); |
675 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + CAMPUS_LOCATIONS, generateMessageInfo(LUUIConstants.CAMPUS_LOCATION_LABEL_KEY))); |
676 | |
|
677 | 0 | Map<String, ModelWidgetBinding> customBindings = new HashMap<String, ModelWidgetBinding>(); |
678 | 0 | ListToTextBinding resultValuesBinding = new ListToTextBinding(); |
679 | 0 | customBindings.put("resultValues", resultValuesBinding); |
680 | 0 | String outcomesKey = COURSE + QueryPath.getPathSeparator() + CREDIT_OPTIONS; |
681 | 0 | MultiplicityConfiguration outcomesConfig = getMultiplicityConfig(outcomesKey, |
682 | |
LUUIConstants.LEARNING_RESULT_OUTCOME_LABEL_KEY, |
683 | |
Arrays.asList( |
684 | |
Arrays.asList(CreditCourseConstants.TYPE, LUUIConstants.LEARNING_RESULT_OUTCOME_TYPE_LABEL_KEY), |
685 | |
Arrays.asList(CREDIT_OPTION_FIXED_CREDITS, LUUIConstants.CONTACT_HOURS_LABEL_KEY, OPTIONAL), |
686 | |
Arrays.asList(CREDIT_OPTION_MIN_CREDITS, LUUIConstants.CREDIT_OPTION_MIN_CREDITS_LABEL_KEY, OPTIONAL), |
687 | |
Arrays.asList(CREDIT_OPTION_MAX_CREDITS, LUUIConstants.CREDIT_OPTION_MAX_CREDITS_LABEL_KEY, OPTIONAL), |
688 | |
Arrays.asList("resultValues", LUUIConstants.CREDIT_OPTION_FIXED_CREDITS_LABEL_KEY, OPTIONAL)), |
689 | |
customBindings); |
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | 0 | courseBriefSection.addShowRowCallback(new ShowRowConditionCallback(){ |
696 | |
@Override |
697 | |
public void processShowConditions(SummaryTableFieldRow row, |
698 | |
DataModel column1, DataModel column2) { |
699 | 0 | if(row.getFieldDescriptor1() != null && |
700 | |
row.getFieldDescriptor1().getFieldKey().contains(CREDIT_OPTIONS) && |
701 | |
row.getFieldDescriptor1().getFieldKey().contains("resultValues")){ |
702 | 0 | String type = row.getFieldDescriptor1().getFieldKey().replace("resultValues", CreditCourseConstants.TYPE); |
703 | 0 | Object data1 = null; |
704 | 0 | Object data2 = null; |
705 | 0 | if(column1 != null){ |
706 | 0 | data1 = column1.get(type); |
707 | |
} |
708 | 0 | if(column2 != null){ |
709 | 0 | data2 = column2.get(type); |
710 | |
} |
711 | |
|
712 | 0 | if(data1 != null && data1 instanceof String){ |
713 | 0 | if(!((String)data1).equals("kuali.resultComponentType.credit.degree.multiple")){ |
714 | 0 | row.setShown(false); |
715 | |
} |
716 | |
} |
717 | 0 | else if(data2 != null && data2 instanceof String){ |
718 | 0 | if(!((String)data2).equals("kuali.resultComponentType.credit.degree.multiple")){ |
719 | 0 | row.setShown(false); |
720 | |
} |
721 | |
} |
722 | |
} |
723 | 0 | } |
724 | |
}); |
725 | 0 | block.addSummaryMultiplicity(outcomesConfig); |
726 | |
|
727 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + TERMS_OFFERED, generateMessageInfo(LUUIConstants.TERMS_OFFERED_LABEL_KEY))); |
728 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + GRADING_OPTIONS, generateMessageInfo(LUUIConstants.LEARNING_RESULT_ASSESSMENT_SCALE_LABEL_KEY))); |
729 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + PASS_FAIL, generateMessageInfo(LUUIConstants.LEARNING_RESULT_PASS_FAIL_LABEL_KEY), true)); |
730 | 0 | block.addSummaryTableFieldRow(getFieldRow(COURSE + "/" + AUDIT, generateMessageInfo(LUUIConstants.LEARNING_RESULT_AUDIT_LABEL_KEY), true)); |
731 | 0 | MultiplicityConfiguration formatsConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FORMATS, |
732 | |
LUUIConstants.FORMAT_LABEL_KEY, |
733 | |
null); |
734 | 0 | MultiplicityConfiguration activitiesConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FORMATS + QueryPath.getPathSeparator() |
735 | |
+ QueryPath.getWildCard() + QueryPath.getPathSeparator() + ACTIVITIES, |
736 | |
LUUIConstants.ACTIVITY_LITERAL_LABEL_KEY, |
737 | |
Arrays.asList( |
738 | |
Arrays.asList(ACTIVITY_TYPE, LUUIConstants.ACTIVITY_TYPE_LABEL_KEY), |
739 | |
Arrays.asList(CONTACT_HOURS + "/" + "unitQuantity", LUUIConstants.CONTACT_HOURS_LABEL_KEY), |
740 | |
Arrays.asList(CONTACT_HOURS + "/" + "unitType", "per"), |
741 | |
Arrays.asList(CreditCourseActivityConstants.DURATION + "/" + "atpDurationTypeKey", LUUIConstants.DURATION_TYPE_LABEL_KEY), |
742 | |
Arrays.asList(CreditCourseActivityConstants.DURATION + "/" + "timeQuantity", LUUIConstants.DURATION_LITERAL_LABEL_KEY), |
743 | |
Arrays.asList(DEFAULT_ENROLLMENT_ESTIMATE, LUUIConstants.CLASS_SIZE_LABEL_KEY))); |
744 | 0 | formatsConfig.setNestedConfig(activitiesConfig); |
745 | 0 | block.addSummaryMultiplicity(formatsConfig); |
746 | |
|
747 | 0 | MultiplicityConfiguration feesConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FEES, |
748 | |
LUUIConstants.FEE, |
749 | |
Arrays.asList( |
750 | |
Arrays.asList("rateType", "Rate Type"), |
751 | |
Arrays.asList("feeType", "Fee Type"))); |
752 | |
|
753 | 0 | MultiplicityConfiguration amountsConfig = getMultiplicityConfig(COURSE + QueryPath.getPathSeparator() + FEES + QueryPath.getPathSeparator() |
754 | |
+ QueryPath.getWildCard() + QueryPath.getPathSeparator() + "feeAmounts", |
755 | |
"", |
756 | |
Arrays.asList( |
757 | |
Arrays.asList("currencyQuantity", "Amount"))); |
758 | 0 | feesConfig.setNestedConfig(amountsConfig); |
759 | 0 | block.addSummaryMultiplicity(feesConfig); |
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
|
773 | |
|
774 | 0 | courseBriefSection.addSummaryTableFieldBlock(block); |
775 | 0 | VerticalSectionView verticalSection = new VerticalSectionView(ViewCourseSections.BRIEF, "At a Glance", modelId, false); |
776 | 0 | verticalSection.addSection(courseBriefSection); |
777 | |
|
778 | 0 | return verticalSection; |
779 | |
} |
780 | |
|
781 | |
public VerticalSectionView generateCourseCatalogSection() { |
782 | 0 | VerticalSectionView verticalSection = new VerticalSectionView(ViewCourseSections.CATALOG, "Catalog View", modelId, false); |
783 | 0 | FieldDescriptorReadOnly catalogField = new FieldDescriptorReadOnly("", null, null, new HTML()); |
784 | 0 | catalogField.hideLabel(); |
785 | 0 | catalogField.setWidgetBinding(new ModelWidgetBinding<HTML>(){ |
786 | |
|
787 | |
@Override |
788 | |
public void setModelValue(HTML widget, DataModel model, String path) { |
789 | |
|
790 | |
|
791 | 0 | } |
792 | |
|
793 | |
@Override |
794 | |
public void setWidgetValue(HTML widget, DataModel model, String path) { |
795 | 0 | String code = model.get("code"); |
796 | 0 | String title = model.get(COURSE + "/" + COURSE_TITLE); |
797 | 0 | String credits = ""; |
798 | 0 | String outcomesKey = COURSE + QueryPath.getPathSeparator() + CREDIT_OPTIONS; |
799 | 0 | Data outcomes = model.get(outcomesKey); |
800 | 0 | if(outcomes !=null){ |
801 | 0 | Iterator<Property> iter = outcomes.realPropertyIterator(); |
802 | 0 | String list = ""; |
803 | 0 | ListToTextBinding binding = new ListToTextBinding(); |
804 | 0 | while(iter.hasNext()){ |
805 | 0 | Property prop = iter.next(); |
806 | 0 | if (prop.getKey() instanceof Integer){ |
807 | 0 | Integer number = (Integer)prop.getKey(); |
808 | 0 | Object value = outcomes.get(number); |
809 | 0 | if(value instanceof Data){ |
810 | 0 | list = list + binding.getStringList(model, outcomesKey + "/" + number +"/" + "resultValues") + ", "; |
811 | |
} |
812 | |
} |
813 | 0 | } |
814 | |
|
815 | 0 | if(!list.isEmpty()){ |
816 | 0 | list = list.trim(); |
817 | 0 | list = list.substring(0, list.length() - 1); |
818 | 0 | credits = "(" + list + ")"; |
819 | |
} |
820 | |
} |
821 | |
|
822 | 0 | String description = model.get(COURSE + "/" + PROPOSAL_DESCRIPTION + "/" + RichTextInfoConstants.PLAIN); |
823 | 0 | String catalogText = "<b> " + code + " " + title + " " + credits + "</b> " + description + " "; |
824 | 0 | catalogText.replace(" null ", ""); |
825 | 0 | catalogText.trim(); |
826 | 0 | widget.setHTML(catalogText); |
827 | |
|
828 | 0 | } |
829 | |
}); |
830 | 0 | verticalSection.addField(catalogField); |
831 | |
|
832 | 0 | return verticalSection; |
833 | |
} |
834 | |
} |