1 |
|
package org.kuali.student.lum.program.client; |
2 |
|
|
3 |
|
import java.util.ArrayList; |
4 |
|
import java.util.HashMap; |
5 |
|
import java.util.List; |
6 |
|
import java.util.Map; |
7 |
|
|
8 |
|
import org.kuali.student.common.assembly.data.Data; |
9 |
|
import org.kuali.student.common.assembly.data.Metadata; |
10 |
|
import org.kuali.student.common.dto.DtoConstants; |
11 |
|
import org.kuali.student.common.rice.authorization.PermissionType; |
12 |
|
import org.kuali.student.common.ui.client.application.ViewContext; |
13 |
|
import org.kuali.student.common.ui.client.configurable.mvc.layouts.MenuSectionController; |
14 |
|
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
15 |
|
import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView; |
16 |
|
import org.kuali.student.common.ui.client.mvc.Callback; |
17 |
|
import org.kuali.student.common.ui.client.mvc.DataModel; |
18 |
|
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
19 |
|
import org.kuali.student.common.ui.client.mvc.ModelProvider; |
20 |
|
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
21 |
|
import org.kuali.student.common.ui.client.mvc.View; |
22 |
|
import org.kuali.student.common.ui.client.mvc.dto.ReferenceModel; |
23 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
24 |
|
import org.kuali.student.common.ui.client.service.DataSaveResult; |
25 |
|
import org.kuali.student.common.ui.client.util.ExportElement; |
26 |
|
import org.kuali.student.common.ui.client.util.ExportUtils; |
27 |
|
import org.kuali.student.common.ui.client.widgets.KSButton; |
28 |
|
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract; |
29 |
|
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations; |
30 |
|
import org.kuali.student.common.ui.client.widgets.dialog.ButtonMessageDialog; |
31 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.button.ButtonGroup; |
32 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.button.YesNoCancelGroup; |
33 |
|
import org.kuali.student.common.ui.shared.IdAttributes; |
34 |
|
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
35 |
|
import org.kuali.student.core.comments.ui.client.widgets.commenttool.CommentTool; |
36 |
|
import org.kuali.student.lum.common.client.helpers.RecentlyViewedHelper; |
37 |
|
import org.kuali.student.lum.common.client.widgets.AppLocations; |
38 |
|
import org.kuali.student.lum.program.client.events.ModelLoadedEvent; |
39 |
|
import org.kuali.student.lum.program.client.events.UpdateEvent; |
40 |
|
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
41 |
|
import org.kuali.student.lum.program.client.rpc.AbstractCallback; |
42 |
|
import org.kuali.student.lum.program.client.rpc.MajorDisciplineRpcService; |
43 |
|
import org.kuali.student.lum.program.client.rpc.MajorDisciplineRpcServiceAsync; |
44 |
|
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
45 |
|
|
46 |
|
import com.google.gwt.core.client.GWT; |
47 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
48 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
49 |
|
import com.google.gwt.event.shared.HandlerManager; |
50 |
|
import com.google.gwt.user.client.ui.Label; |
51 |
|
import com.google.gwt.user.client.ui.Widget; |
52 |
|
|
53 |
|
|
54 |
|
@author |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 290 (290) |
Complexity: 82 |
Complexity Density: 0.43 |
|
56 |
|
public abstract class ProgramController extends MenuSectionController { |
57 |
|
|
58 |
|
protected MajorDisciplineRpcServiceAsync programRemoteService; |
59 |
|
|
60 |
|
protected boolean initialized = false; |
61 |
|
|
62 |
|
protected DataModel programModel; |
63 |
|
|
64 |
|
protected AbstractProgramConfigurer configurer; |
65 |
|
|
66 |
|
protected HandlerManager eventBus; |
67 |
|
|
68 |
|
protected Label statusLabel = new Label(); |
69 |
|
|
70 |
|
protected ProgramSideBar sideBar; |
71 |
|
|
72 |
|
private boolean needToLoadOldModel = false; |
73 |
|
|
74 |
|
private ProgramStatus lastLoadedStatus; |
75 |
|
|
76 |
|
protected boolean reloadMetadata = false; |
77 |
|
|
78 |
|
protected boolean processBeforeShow = true; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
85 |
0
|
public ProgramController(String name, DataModel programModel, ViewContext viewContext, HandlerManager eventBus) {... |
86 |
0
|
super(); |
87 |
0
|
programRemoteService = createProgramRemoteService(); |
88 |
0
|
this.eventBus = eventBus; |
89 |
0
|
this.programModel = programModel; |
90 |
0
|
setViewContext(viewContext); |
91 |
0
|
initializeModel(); |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0
|
protected MajorDisciplineRpcServiceAsync createProgramRemoteService() {... |
99 |
0
|
return GWT.create(MajorDisciplineRpcService.class); |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
102 |
0
|
@Override... |
103 |
|
public void beforeViewChange(Enum<?> viewChangingTo, final Callback<Boolean> okToChange) { |
104 |
0
|
if (processBeforeShow) { |
105 |
0
|
super.beforeViewChange(viewChangingTo, new Callback<Boolean>() { |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
107 |
0
|
@Override... |
108 |
|
public void exec(Boolean result) { |
109 |
0
|
if (result) { |
110 |
0
|
if (getCurrentView() instanceof SectionView && ((SectionView) getCurrentView()).isDirty()) { |
111 |
0
|
ButtonGroup<ButtonEnumerations.YesNoCancelEnum> buttonGroup = new YesNoCancelGroup(); |
112 |
0
|
final ButtonMessageDialog<ButtonEnumerations.YesNoCancelEnum> dialog = new ButtonMessageDialog<ButtonEnumerations.YesNoCancelEnum>("Warning", "You may have unsaved changes. Save changes?", buttonGroup); |
113 |
0
|
buttonGroup.addCallback(new Callback<ButtonEnumerations.YesNoCancelEnum>() { |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.24 |
|
115 |
0
|
@Override... |
116 |
|
public void exec(ButtonEnumerations.YesNoCancelEnum result) { |
117 |
0
|
switch (result) { |
118 |
0
|
case YES: |
119 |
0
|
dialog.hide(); |
120 |
0
|
fireUpdateEvent(okToChange); |
121 |
0
|
break; |
122 |
0
|
case NO: |
123 |
0
|
dialog.hide(); |
124 |
0
|
resetModel(); |
125 |
0
|
needToLoadOldModel = true; |
126 |
0
|
resetFieldInteractionFlag(); |
127 |
0
|
okToChange.exec(true); |
128 |
0
|
break; |
129 |
0
|
case CANCEL: |
130 |
0
|
okToChange.exec(false); |
131 |
0
|
dialog.hide(); |
132 |
|
|
133 |
0
|
HistoryManager.logHistoryChange(); |
134 |
0
|
break; |
135 |
|
} |
136 |
|
} |
137 |
|
}); |
138 |
0
|
dialog.show(); |
139 |
|
} else { |
140 |
0
|
okToChange.exec(true); |
141 |
|
} |
142 |
|
} else { |
143 |
0
|
okToChange.exec(false); |
144 |
|
} |
145 |
|
} |
146 |
|
}); |
147 |
|
} else { |
148 |
0
|
processBeforeShow = true; |
149 |
|
} |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0
|
protected void fireUpdateEvent(final Callback<Boolean> okToChange) {... |
153 |
0
|
eventBus.fireEvent(new UpdateEvent(okToChange)); |
154 |
|
} |
155 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
0
|
protected void resetModel() {... |
157 |
0
|
programModel.resetRoot(); |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
160 |
0
|
protected void resetFieldInteractionFlag() {... |
161 |
0
|
View currentView = getCurrentView(); |
162 |
0
|
if (currentView instanceof Section) { |
163 |
0
|
((Section) currentView).resetFieldInteractionFlags(); |
164 |
|
} |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
170 |
0
|
private void initializeModel() {... |
171 |
0
|
setDefaultModelId(ProgramConstants.PROGRAM_MODEL_ID); |
172 |
0
|
registerModel(ProgramConstants.PROGRAM_MODEL_ID, new ModelProvider<DataModel>() { |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
173 |
0
|
@Override... |
174 |
|
public void requestModel(final ModelRequestCallback<DataModel> callback) { |
175 |
0
|
if (programModel.getRoot() == null || programModel.getRoot().size() == 0) { |
176 |
0
|
loadModel(callback); |
177 |
|
} else { |
178 |
0
|
callback.onModelReady(programModel); |
179 |
|
} |
180 |
|
} |
181 |
|
}); |
182 |
|
} |
183 |
|
|
184 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
185 |
0
|
@Override... |
186 |
|
public void requestModel(Class modelType, ModelRequestCallback callback) { |
187 |
0
|
if (modelType == ReferenceModel.class) { |
188 |
0
|
ReferenceModel referenceModel = new ReferenceModel(); |
189 |
0
|
referenceModel.setReferenceId(ProgramUtils.getProgramId(programModel)); |
190 |
0
|
referenceModel.setReferenceTypeKey(ProgramConstants.MAJOR_REFERENCE_TYPE_ID); |
191 |
0
|
referenceModel.setReferenceType(ProgramConstants.MAJOR_LU_TYPE_ID); |
192 |
0
|
Map<String, String> attributes = new HashMap<String, String>(); |
193 |
0
|
attributes.put("name", getStringProperty("name")); |
194 |
0
|
referenceModel.setReferenceAttributes(attributes); |
195 |
0
|
callback.onModelReady(referenceModel); |
196 |
|
} else { |
197 |
0
|
super.requestModel(modelType, callback); |
198 |
|
} |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
@param |
206 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
0
|
protected void loadModel(final ModelRequestCallback<DataModel> callback) {... |
208 |
0
|
programRemoteService.getData(getViewContext().getId(), new AbstractCallback<Data>(ProgramProperties.get().common_retrievingData()) { |
209 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
210 |
0
|
@Override... |
211 |
|
public void onFailure(Throwable caught) { |
212 |
0
|
super.onFailure(caught); |
213 |
0
|
callback.onRequestFail(caught); |
214 |
|
} |
215 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
216 |
0
|
@Override... |
217 |
|
public void onSuccess(Data result) { |
218 |
0
|
super.onSuccess(result); |
219 |
0
|
programModel.setRoot(result); |
220 |
0
|
setHeaderTitle(); |
221 |
0
|
callback.onModelReady(programModel); |
222 |
|
} |
223 |
|
}); |
224 |
|
} |
225 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
226 |
0
|
private void setModelData() {... |
227 |
0
|
setHeaderTitle(); |
228 |
0
|
setStatus(); |
229 |
0
|
configurer.applyPermissions(); |
230 |
|
|
231 |
0
|
if (needToLoadOldModel) { |
232 |
0
|
needToLoadOldModel = false; |
233 |
|
} else { |
234 |
0
|
String id = ProgramUtils.getProgramId(programModel); |
235 |
0
|
if (null != id) { |
236 |
|
|
237 |
0
|
ViewContext docContext = new ViewContext(); |
238 |
0
|
docContext.setId(id); |
239 |
0
|
docContext.setIdType(IdType.OBJECT_ID); |
240 |
0
|
String pgmType = getStringProperty(ProgramConstants.TYPE); |
241 |
0
|
docContext.setAttribute(ProgramConstants.TYPE, pgmType + '/' + ProgramSections.PROGRAM_DETAILS_VIEW); |
242 |
0
|
RecentlyViewedHelper.addDocument(getProgramName(), |
243 |
|
HistoryManager.appendContext(getProgramViewLocation(pgmType), docContext)); |
244 |
|
} |
245 |
0
|
eventBus.fireEvent(new ModelLoadedEvent(programModel)); |
246 |
0
|
onModelLoadedEvent(); |
247 |
|
} |
248 |
|
} |
249 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
250 |
0
|
private String getProgramViewLocation(String pgmType) {... |
251 |
0
|
if (ProgramClientConstants.MAJOR_PROGRAM.equals(pgmType)) { |
252 |
0
|
return AppLocations.Locations.VIEW_PROGRAM.getLocation(); |
253 |
0
|
} else if (ProgramClientConstants.CORE_PROGRAM.equals(pgmType)) { |
254 |
0
|
return AppLocations.Locations.VIEW_CORE_PROGRAM.getLocation(); |
255 |
0
|
} else if (ProgramClientConstants.CREDENTIAL_PROGRAM_TYPES.contains(pgmType)) { |
256 |
0
|
return AppLocations.Locations.VIEW_BACC_PROGRAM.getLocation(); |
257 |
|
} |
258 |
0
|
return null; |
259 |
|
} |
260 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
261 |
0
|
protected void setStatus() {... |
262 |
0
|
statusLabel.setText(ProgramProperties.get().common_status(getStringProperty(ProgramConstants.STATE))); |
263 |
|
} |
264 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
265 |
0
|
public String getProgramName() {... |
266 |
0
|
String name = getStringProperty(ProgramConstants.LONG_TITLE); |
267 |
0
|
if (name == null) { |
268 |
0
|
name = ProgramProperties.get().common_newProgram(); |
269 |
|
} |
270 |
0
|
return name; |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
@param |
277 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
278 |
0
|
@Override... |
279 |
|
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
280 |
0
|
if (programModel.getRoot() == null) { |
281 |
0
|
loadModel(new ModelRequestCallback<DataModel>() { |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
282 |
0
|
@Override... |
283 |
|
public void onModelReady(DataModel model) { |
284 |
0
|
if (loadMetadataCondition()) { |
285 |
0
|
loadMetadata(onReadyCallback); |
286 |
|
} else { |
287 |
|
|
288 |
0
|
onReadyCallback.exec(true); |
289 |
|
} |
290 |
|
} |
291 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
292 |
0
|
@Override... |
293 |
|
public void onRequestFail(Throwable cause) { |
294 |
0
|
GWT.log(cause.getMessage()); |
295 |
|
} |
296 |
|
}); |
297 |
|
} else { |
298 |
0
|
afterMetadataLoaded(onReadyCallback); |
299 |
|
} |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
@return |
306 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
307 |
0
|
protected boolean loadMetadataCondition() {... |
308 |
0
|
return lastLoadedStatus == null || ProgramStatus.of(programModel) != lastLoadedStatus; |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
@param |
315 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
316 |
0
|
protected void loadMetadata(final Callback<Boolean> onReadyCallback) {... |
317 |
0
|
Map<String, String> idAttributes = new HashMap<String, String>(); |
318 |
0
|
ViewContext viewContext = getViewContext(); |
319 |
0
|
IdType idType = viewContext.getIdType(); |
320 |
0
|
String viewContextId = null; |
321 |
0
|
if (idType != null) { |
322 |
0
|
idAttributes.put(IdAttributes.ID_TYPE, idType.toString()); |
323 |
0
|
viewContextId = viewContext.getId(); |
324 |
0
|
if (idType == IdType.COPY_OF_OBJECT_ID) { |
325 |
0
|
viewContextId = null; |
326 |
|
} |
327 |
|
} |
328 |
0
|
if (programModel.getRoot() != null) { |
329 |
0
|
ProgramStatus programStatus = ProgramStatus.of(programModel); |
330 |
0
|
idAttributes.put(DtoConstants.DTO_STATE, programStatus.getValue()); |
331 |
0
|
if (programStatus.getNextStatus() != null) { |
332 |
0
|
idAttributes.put(DtoConstants.DTO_NEXT_STATE, programStatus.getNextStatus().getValue()); |
333 |
|
} |
334 |
|
} |
335 |
0
|
programRemoteService.getMetadata(viewContextId, idAttributes, new AbstractCallback<Metadata>() { |
336 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
337 |
0
|
@Override... |
338 |
|
public void onSuccess(Metadata result) { |
339 |
0
|
super.onSuccess(result); |
340 |
0
|
DataModelDefinition def = new DataModelDefinition(result); |
341 |
0
|
programModel.setDefinition(def); |
342 |
0
|
lastLoadedStatus = ProgramStatus.of(programModel); |
343 |
0
|
afterMetadataLoaded(onReadyCallback); |
344 |
|
} |
345 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
346 |
0
|
@Override... |
347 |
|
public void onFailure(Throwable caught) { |
348 |
0
|
super.onFailure(caught); |
349 |
0
|
onReadyCallback.exec(false); |
350 |
|
} |
351 |
|
}); |
352 |
|
} |
353 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
354 |
0
|
protected void configureView() {... |
355 |
0
|
addStyleName("programController"); |
356 |
0
|
configurer.setModelDefinition(programModel.getDefinition()); |
357 |
0
|
configurer.configure(this); |
358 |
0
|
addContentWidget(statusLabel); |
359 |
0
|
setSideBarWidget(sideBar); |
360 |
|
} |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
362 |
0
|
@Override... |
363 |
|
public void setViewContext(ViewContext viewContext) { |
364 |
0
|
super.setViewContext(viewContext); |
365 |
0
|
if (viewContext.getId() != null && !viewContext.getId().isEmpty()) { |
366 |
0
|
viewContext.setPermissionType(PermissionType.OPEN); |
367 |
|
} else { |
368 |
0
|
viewContext.setPermissionType(PermissionType.INITIATE); |
369 |
|
} |
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
@param |
376 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
377 |
0
|
protected void afterMetadataLoaded(Callback<Boolean> onReadyCallback) {... |
378 |
0
|
if (!reloadMetadata) { |
379 |
0
|
configureView(); |
380 |
0
|
onReadyCallback.exec(true); |
381 |
0
|
reloadMetadata = true; |
382 |
|
} else { |
383 |
0
|
onReadyCallback.exec(true); |
384 |
0
|
ProgramUtils.syncMetadata(configurer, programModel.getDefinition()); |
385 |
|
} |
386 |
0
|
if (programModel.getRoot() != null) { |
387 |
0
|
setModelData(); |
388 |
|
} |
389 |
|
} |
390 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
391 |
0
|
protected void setHeaderTitle() {... |
392 |
0
|
String title = getProgramName(); |
393 |
0
|
this.setContentTitle(title); |
394 |
0
|
this.setName(title); |
395 |
|
} |
396 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
397 |
0
|
protected Widget createCommentPanel() {... |
398 |
0
|
final CommentTool commentTool = new CommentTool(ProgramSections.COMMENTS, "Comments", "kuali.comment.type.generalRemarks", "Program Comments"); |
399 |
0
|
commentTool.setController(this); |
400 |
0
|
KSButton commentsButton = new KSButton(ProgramProperties.get().comments_button(), KSButtonAbstract.ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() { |
401 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
402 |
0
|
@Override... |
403 |
|
public void onClick(ClickEvent event) { |
404 |
0
|
commentTool.show(); |
405 |
|
} |
406 |
|
}); |
407 |
0
|
return commentsButton; |
408 |
|
} |
409 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
410 |
0
|
protected void doSave() {... |
411 |
|
} |
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
@param |
434 |
|
@param |
435 |
|
@param |
436 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
437 |
0
|
protected void updateState(String state, final Callback<Boolean> okCallback) {... |
438 |
|
|
439 |
0
|
programRemoteService.updateState(programModel.getRoot(), state, new AbstractCallback<DataSaveResult>(ProgramProperties.get().common_savingData()) { |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
440 |
0
|
@Override... |
441 |
|
public void onSuccess(DataSaveResult result) { |
442 |
0
|
if(result.getValidationResults()==null || result.getValidationResults().isEmpty()){ |
443 |
0
|
super.onSuccess(result); |
444 |
0
|
okCallback.exec(true); |
445 |
0
|
refreshModelAndView(result); |
446 |
|
}else{ |
447 |
|
|
448 |
0
|
super.onSuccess(result); |
449 |
|
|
450 |
0
|
isValid(result.getValidationResults(), false, true); |
451 |
0
|
ProgramUtils.handleValidationErrorsForSpecializations(result.getValidationResults(), programModel); |
452 |
|
|
453 |
0
|
okCallback.exec(false); |
454 |
|
} |
455 |
|
} |
456 |
|
|
457 |
|
}); |
458 |
|
|
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
465 |
0
|
public void refreshModelAndView(DataSaveResult result){... |
466 |
0
|
if (result != null) { |
467 |
0
|
programModel.setRoot(result.getValue()); |
468 |
|
} |
469 |
0
|
setHeaderTitle(); |
470 |
0
|
setStatus(); |
471 |
|
} |
472 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
473 |
0
|
public DataModel getProgramModel() {... |
474 |
0
|
return programModel; |
475 |
|
} |
476 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
477 |
0
|
public void onModelLoadedEvent() {... |
478 |
|
} |
479 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
480 |
0
|
protected String getStringProperty(String key) {... |
481 |
0
|
return programModel.get(key); |
482 |
|
} |
483 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
484 |
0
|
protected Data getDataProperty(String key) {... |
485 |
0
|
return programModel.get(key); |
486 |
|
} |
487 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
488 |
0
|
public boolean isExportButtonActive() {... |
489 |
0
|
if (this.getCurrentViewEnum() != null) { |
490 |
0
|
if (this.getCurrentViewEnum().equals(ProgramSections.SUMMARY) |
491 |
|
|| this.getCurrentViewEnum().equals(ProgramSections.VIEW_ALL)) { |
492 |
0
|
return true; |
493 |
|
} else { |
494 |
0
|
return false; |
495 |
|
} |
496 |
|
|
497 |
|
} else { |
498 |
0
|
return false; |
499 |
|
} |
500 |
|
} |
501 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 9 |
Complexity Density: 0.38 |
|
502 |
0
|
@Override... |
503 |
|
public ArrayList<ExportElement> getExportElementsFromView() { |
504 |
|
|
505 |
0
|
String viewName = null; |
506 |
0
|
String sectionTitle = null; |
507 |
0
|
View currentView = this.getCurrentView(); |
508 |
0
|
if (currentView != null) { |
509 |
|
|
510 |
0
|
ArrayList<ExportElement> exportElements = new ArrayList<ExportElement>(); |
511 |
0
|
if (currentView != null && currentView instanceof Section) { |
512 |
0
|
Section currentSection = (Section) currentView; |
513 |
0
|
List<Section> nestedSections = currentSection.getSections(); |
514 |
0
|
for (int i = 0; i < nestedSections.size(); i++) { |
515 |
0
|
ExportElement sectionExportItem = new ExportElement(); |
516 |
0
|
ArrayList<ExportElement> subList = null; |
517 |
0
|
Section nestedSection = nestedSections.get(i); |
518 |
0
|
if (nestedSection != null && nestedSection instanceof SectionView) { |
519 |
0
|
SectionView nestedSectionView = (SectionView) nestedSection; |
520 |
0
|
viewName = nestedSectionView.getName(); |
521 |
0
|
sectionTitle = nestedSectionView.getTitle(); |
522 |
0
|
sectionExportItem.setSectionName(sectionTitle + " " + i + " - " + viewName); |
523 |
0
|
sectionExportItem.setViewName(sectionTitle + " " + i + " - " + viewName); |
524 |
0
|
subList = ExportUtils.getExportElementsFromView(nestedSectionView, subList, viewName, sectionTitle); |
525 |
0
|
if (subList != null && subList.size()> 0) { |
526 |
0
|
sectionExportItem.setSubset(subList); |
527 |
0
|
exportElements.add(sectionExportItem); |
528 |
|
} |
529 |
|
} |
530 |
|
} |
531 |
|
} |
532 |
0
|
return exportElements; |
533 |
|
|
534 |
|
} else { |
535 |
|
|
536 |
|
} |
537 |
0
|
return null; |
538 |
|
|
539 |
|
} |
540 |
|
} |