| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.lum.program.client.requirements; |
| 17 | |
|
| 18 | |
import java.util.HashMap; |
| 19 | |
import java.util.List; |
| 20 | |
import java.util.Map; |
| 21 | |
|
| 22 | |
import org.kuali.student.common.assembly.data.Metadata; |
| 23 | |
import org.kuali.student.common.ui.client.application.Application; |
| 24 | |
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
| 25 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
| 26 | |
import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView; |
| 27 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 28 | |
import org.kuali.student.common.ui.client.mvc.View; |
| 29 | |
import org.kuali.student.common.ui.client.service.MetadataRpcService; |
| 30 | |
import org.kuali.student.common.ui.client.service.MetadataRpcServiceAsync; |
| 31 | |
import org.kuali.student.common.ui.client.widgets.KSProgressIndicator; |
| 32 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations; |
| 33 | |
import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup; |
| 34 | |
import org.kuali.student.common.ui.client.widgets.progress.BlockingTask; |
| 35 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
| 36 | |
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
| 37 | |
import org.kuali.student.core.statement.dto.*; |
| 38 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.ReqCompEditWidget; |
| 39 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.ReqComponentInfoUi; |
| 40 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.RuleManageWidget; |
| 41 | |
import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil; |
| 42 | |
import org.kuali.student.lum.common.client.widgets.*; |
| 43 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
| 44 | |
import org.kuali.student.lum.program.client.ProgramMsgConstants; |
| 45 | |
import org.kuali.student.lum.program.client.rpc.StatementRpcService; |
| 46 | |
import org.kuali.student.lum.program.client.rpc.StatementRpcServiceAsync; |
| 47 | |
import org.kuali.student.lum.program.dto.ProgramRequirementInfo; |
| 48 | |
|
| 49 | |
|
| 50 | |
import com.google.gwt.core.client.GWT; |
| 51 | |
import com.google.gwt.user.client.Window; |
| 52 | |
import com.google.gwt.user.client.rpc.AsyncCallback; |
| 53 | |
import com.google.gwt.user.client.ui.SimplePanel; |
| 54 | |
import com.google.gwt.user.client.ui.VerticalPanel; |
| 55 | |
import com.google.gwt.user.client.ui.Widget; |
| 56 | |
|
| 57 | 0 | public class ProgramRequirementsManageView extends VerticalSectionView { |
| 58 | |
|
| 59 | 0 | private StatementRpcServiceAsync statementRpcServiceAsync = GWT.create(StatementRpcService.class); |
| 60 | 0 | private MetadataRpcServiceAsync metadataServiceAsync = GWT.create(MetadataRpcService.class); |
| 61 | |
|
| 62 | |
protected static final String TEMLATE_LANGUAGE = "en"; |
| 63 | |
protected static final String RULEEDIT_TEMLATE = "KUALI.RULE"; |
| 64 | |
protected static final String RULEPREVIEW_TEMLATE = RULEEDIT_TEMLATE + ".PREVIEW"; |
| 65 | |
protected static final String COMPOSITION_TEMLATE = "KUALI.RULE.COMPOSITION"; |
| 66 | |
private static final String LU_NAMESPACE = "http://student.kuali.org/wsdl/lu"; |
| 67 | |
private static final String CLU_NAMESPACE_URI = "{" + LU_NAMESPACE + "}cluInfo"; |
| 68 | |
|
| 69 | |
private ProgramRequirementsViewController parentController; |
| 70 | |
|
| 71 | |
|
| 72 | 0 | private VerticalPanel layout = new VerticalPanel(); |
| 73 | |
private ReqCompEditWidget editReqCompWidget; |
| 74 | |
private RuleManageWidget ruleManageWidget; |
| 75 | 0 | private SimplePanel twiddlerPanel = new SimplePanel(); |
| 76 | 0 | private ActionCancelGroup actionCancelButtons = new ActionCancelGroup(ButtonEnumerations.SaveCancelEnum.SAVE, ButtonEnumerations.SaveCancelEnum.CANCEL); |
| 77 | |
|
| 78 | |
|
| 79 | 0 | private StatementTreeViewInfo rule = null; |
| 80 | 0 | private boolean isInitialized = false; |
| 81 | 0 | private boolean isNewRule = false; |
| 82 | 0 | private ReqComponentInfo editedReqCompInfo = null; |
| 83 | 0 | private Integer internalProgReqID = null; |
| 84 | |
private String originalReqCompNL; |
| 85 | |
private String originalLogicExpression; |
| 86 | |
|
| 87 | |
|
| 88 | 0 | private BlockingTask creatingRuleTask = new BlockingTask("Creating Rule"); |
| 89 | |
|
| 90 | |
public ProgramRequirementsManageView(ProgramRequirementsViewController parentController, Enum<?> viewEnum, String name, String modelId) { |
| 91 | 0 | super(viewEnum, name, modelId); |
| 92 | 0 | this.parentController = parentController; |
| 93 | 0 | } |
| 94 | |
|
| 95 | |
@Override |
| 96 | |
public void beforeShow(final Callback<Boolean> onReadyCallback) { |
| 97 | |
|
| 98 | 0 | retrieveAndSetupReqCompTypes(); |
| 99 | 0 | if (!isInitialized) { |
| 100 | 0 | setupHandlers(); |
| 101 | 0 | draw(); |
| 102 | 0 | isInitialized = true; |
| 103 | |
} |
| 104 | |
|
| 105 | 0 | onReadyCallback.exec(true); |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
private void setupHandlers() { |
| 109 | 0 | editReqCompWidget.setReqCompConfirmButtonClickCallback(actionButtonClickedReqCompCallback); |
| 110 | 0 | editReqCompWidget.setNewReqCompSelectedCallbackCallback(newReqCompSelectedCallbackCallback); |
| 111 | 0 | editReqCompWidget.setRetrieveCompositionTemplateCallback(retrieveCompositionTemplateCallback); |
| 112 | 0 | editReqCompWidget.setRetrieveFieldsMetadataCallback(retrieveFieldsMetadataCallback); |
| 113 | 0 | editReqCompWidget.setRetrieveCustomWidgetCallback(retrieveCustomWidgetCallback); |
| 114 | 0 | ruleManageWidget.setReqCompEditButtonClickCallback(editReqCompCallback); |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
private void draw() { |
| 118 | |
|
| 119 | 0 | remove(layout); |
| 120 | 0 | layout.clear(); |
| 121 | |
|
| 122 | |
|
| 123 | 0 | SectionTitle title = SectionTitle.generateH3Title(getLabel(ProgramMsgConstants.PROGRAMREQUIREMENTS_MANAGEVIEWPAGESTEP1TITLE)); |
| 124 | 0 | title.setStyleName("KS-Program-Requirements-Manage-Step-header1"); |
| 125 | 0 | layout.add(title); |
| 126 | |
|
| 127 | 0 | layout.add(editReqCompWidget); |
| 128 | |
|
| 129 | |
|
| 130 | 0 | title = SectionTitle.generateH3Title(getLabel(ProgramMsgConstants.PROGRAMREQUIREMENTS_MANAGEVIEWPAGESTEP2TITLE)); |
| 131 | 0 | title.setStyleName("KS-Program-Requirements-Manage-Step-header2"); |
| 132 | 0 | layout.add(title); |
| 133 | |
|
| 134 | 0 | layout.add(ruleManageWidget); |
| 135 | |
|
| 136 | |
|
| 137 | 0 | KSProgressIndicator twiddler = new KSProgressIndicator(); |
| 138 | 0 | twiddler.setVisible(false); |
| 139 | 0 | twiddlerPanel.setWidget(twiddler); |
| 140 | 0 | layout.add(twiddlerPanel); |
| 141 | |
|
| 142 | 0 | addWidget(layout); |
| 143 | |
|
| 144 | 0 | displaySaveButton(); |
| 145 | 0 | } |
| 146 | |
|
| 147 | |
private void displaySaveButton() { |
| 148 | 0 | actionCancelButtons.addStyleName("KS-Program-Requirements-Save-Button"); |
| 149 | 0 | actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){ |
| 150 | |
@Override |
| 151 | |
public void exec(final ButtonEnumerations.ButtonEnum result) { |
| 152 | 0 | parentController.getView(ProgramRequirementsViewController.ProgramRequirementsViews.PREVIEW, new Callback<View>(){ |
| 153 | |
@Override |
| 154 | |
public void exec(View preview) { |
| 155 | |
|
| 156 | 0 | if ((result == ButtonEnumerations.SaveCancelEnum.SAVE) && isDirty()) { |
| 157 | 0 | ProgramRequirementInfo affectedRule = ((ProgramRequirementsSummaryView) preview).getRules().updateRules(getRuleTree(), internalProgReqID, isNewRule()); |
| 158 | 0 | ((ProgramRequirementsSummaryView) preview).updateRequirementWidgets(affectedRule); |
| 159 | |
} |
| 160 | 0 | isDirty = false; |
| 161 | 0 | parentController.showView(ProgramRequirementsViewController.ProgramRequirementsViews.PREVIEW); |
| 162 | 0 | } |
| 163 | |
}); |
| 164 | 0 | } |
| 165 | |
}); |
| 166 | 0 | addWidget(actionCancelButtons); |
| 167 | 0 | } |
| 168 | |
|
| 169 | |
|
| 170 | |
public void setRuleTree(StatementTreeViewInfo stmtTreeInfo, boolean newRuleFlag, Integer internalProgReqID) { |
| 171 | |
|
| 172 | 0 | if (!isInitialized) { |
| 173 | 0 | editReqCompWidget = new ReqCompEditWidget(ProgramRequirementsSummaryView.NEW_REQ_COMP_ID); |
| 174 | 0 | ruleManageWidget = new RuleManageWidget(); |
| 175 | 0 | ruleManageWidget.setReqCompEditButtonClickCallback(editReqCompCallback); |
| 176 | 0 | ruleManageWidget.setRuleChangedButtonClickCallback(ruleChangedCallback); |
| 177 | |
} |
| 178 | |
|
| 179 | 0 | this.internalProgReqID = internalProgReqID; |
| 180 | 0 | editedReqCompInfo = null; |
| 181 | 0 | rule = RulesUtil.clone(stmtTreeInfo); |
| 182 | 0 | isNewRule = newRuleFlag; |
| 183 | 0 | originalReqCompNL = getAllReqCompNLs(); |
| 184 | |
|
| 185 | |
|
| 186 | 0 | editReqCompWidget.setupNewReqComp(); |
| 187 | 0 | ruleManageWidget.redraw(rule, false); |
| 188 | |
|
| 189 | 0 | } |
| 190 | |
|
| 191 | |
|
| 192 | |
public StatementTreeViewInfo getRuleTree() { |
| 193 | 0 | rule = ruleManageWidget.getStatementTreeViewInfo(); |
| 194 | 0 | return rule; |
| 195 | |
} |
| 196 | |
|
| 197 | |
public boolean isNewRule() { |
| 198 | 0 | return isNewRule; |
| 199 | |
} |
| 200 | |
|
| 201 | |
|
| 202 | 0 | protected Callback<ReqComponentInfo> editReqCompCallback = new Callback<ReqComponentInfo>(){ |
| 203 | |
public void exec(ReqComponentInfo reqComp) { |
| 204 | 0 | setEnabled(false); |
| 205 | 0 | editReqCompWidget.setupExistingReqComp(reqComp); |
| 206 | 0 | editedReqCompInfo = reqComp; |
| 207 | 0 | } |
| 208 | |
}; |
| 209 | |
|
| 210 | 0 | protected Callback<Boolean> ruleChangedCallback = new Callback<Boolean>(){ |
| 211 | |
public void exec(Boolean ruleChanged) { |
| 212 | 0 | actionCancelButtons.getButton(ButtonEnumerations.SaveCancelEnum.SAVE).setEnabled(ruleChanged); |
| 213 | 0 | } |
| 214 | |
}; |
| 215 | |
|
| 216 | |
protected void setEnabled(boolean enabled) { |
| 217 | 0 | ruleManageWidget.setEnabled(enabled); |
| 218 | 0 | actionCancelButtons.getButton(ButtonEnumerations.SaveCancelEnum.SAVE).setEnabled(enabled); |
| 219 | 0 | } |
| 220 | |
|
| 221 | |
@Override |
| 222 | |
public boolean isDirty() { |
| 223 | 0 | if (!isInitialized) { |
| 224 | 0 | return false; |
| 225 | |
} |
| 226 | |
|
| 227 | |
|
| 228 | 0 | return true; |
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
} |
| 242 | |
|
| 243 | |
private String getAllReqCompNLs() { |
| 244 | 0 | StringBuilder NL = new StringBuilder(); |
| 245 | 0 | for (StatementTreeViewInfo tree : rule.getStatements()) { |
| 246 | 0 | for (ReqComponentInfo reqComp : tree.getReqComponents()) { |
| 247 | 0 | NL.append(reqComp.getNaturalLanguageTranslation()); |
| 248 | |
} |
| 249 | |
} |
| 250 | 0 | return NL.toString(); |
| 251 | |
} |
| 252 | |
|
| 253 | |
|
| 254 | 0 | protected Callback<ReqComponentInfoUi> actionButtonClickedReqCompCallback = new Callback<ReqComponentInfoUi>(){ |
| 255 | |
public void exec(final ReqComponentInfoUi reqComp) { |
| 256 | |
|
| 257 | 0 | editReqCompWidget.setupNewReqComp(); |
| 258 | 0 | setEnabled(true); |
| 259 | |
|
| 260 | |
|
| 261 | 0 | if (reqComp == null) { |
| 262 | 0 | return; |
| 263 | |
} |
| 264 | |
|
| 265 | 0 | KSBlockingProgressIndicator.addTask(creatingRuleTask); |
| 266 | |
|
| 267 | |
|
| 268 | 0 | statementRpcServiceAsync.translateReqComponentToNLs(reqComp, new String[]{RULEEDIT_TEMLATE,RULEPREVIEW_TEMLATE}, TEMLATE_LANGUAGE, new KSAsyncCallback<List<String>>() { |
| 269 | |
public void handleFailure(Throwable caught) { |
| 270 | 0 | KSBlockingProgressIndicator.removeTask(creatingRuleTask); |
| 271 | 0 | Window.alert(caught.getMessage()); |
| 272 | 0 | GWT.log("translateReqComponentToNL failed", caught); |
| 273 | 0 | } |
| 274 | |
|
| 275 | |
public void onSuccess(final List<String> reqCompNL) { |
| 276 | |
|
| 277 | 0 | reqComp.setNaturalLanguageTranslation(reqCompNL.get(0)); |
| 278 | 0 | reqComp.setPreviewNaturalLanguageTranslation(reqCompNL.get(1)); |
| 279 | |
|
| 280 | |
|
| 281 | 0 | rule = ruleManageWidget.getStatementTreeViewInfo(); |
| 282 | |
|
| 283 | 0 | if (editedReqCompInfo == null) { |
| 284 | 0 | if (rule.getStatements() != null && !rule.getStatements().isEmpty()) { |
| 285 | 0 | StatementTreeViewInfo newStatementTreeViewInfo = new StatementTreeViewInfo(); |
| 286 | 0 | newStatementTreeViewInfo.setId(ProgramRequirementsSummaryView.NEW_STMT_TREE_ID + Integer.toString(ProgramRequirementsSummaryView.tempStmtTreeID++)); |
| 287 | 0 | newStatementTreeViewInfo.setOperator(rule.getStatements().get(0).getOperator()); |
| 288 | 0 | newStatementTreeViewInfo.getReqComponents().add(reqComp); |
| 289 | 0 | rule.getStatements().add(newStatementTreeViewInfo); |
| 290 | 0 | } else { |
| 291 | 0 | rule.getReqComponents().add(reqComp); |
| 292 | |
|
| 293 | 0 | if (rule.getOperator() == null) { |
| 294 | 0 | rule.setOperator(StatementOperatorTypeKey.AND); |
| 295 | |
} |
| 296 | |
} |
| 297 | |
} else { |
| 298 | 0 | editedReqCompInfo.setNaturalLanguageTranslation(reqComp.getNaturalLanguageTranslation()); |
| 299 | 0 | editedReqCompInfo.setReqCompFields(reqComp.getReqCompFields()); |
| 300 | 0 | editedReqCompInfo.setType(reqComp.getType()); |
| 301 | 0 | editedReqCompInfo = null; |
| 302 | |
} |
| 303 | |
|
| 304 | 0 | ruleManageWidget.redraw(rule, true); |
| 305 | 0 | KSBlockingProgressIndicator.removeTask(creatingRuleTask); |
| 306 | 0 | } |
| 307 | |
}); |
| 308 | 0 | } |
| 309 | |
}; |
| 310 | |
|
| 311 | |
|
| 312 | 0 | protected Callback<ReqComponentInfo> newReqCompSelectedCallbackCallback = new Callback<ReqComponentInfo>(){ |
| 313 | |
public void exec(final ReqComponentInfo reqComp) { |
| 314 | 0 | setEnabled(false); |
| 315 | 0 | } |
| 316 | |
}; |
| 317 | |
|
| 318 | |
private void retrieveAndSetupReqCompTypes() { |
| 319 | |
|
| 320 | 0 | statementRpcServiceAsync.getReqComponentTypesForStatementType(rule.getType(), new KSAsyncCallback<List<ReqComponentTypeInfo>>() { |
| 321 | |
public void handleFailure(Throwable cause) { |
| 322 | 0 | GWT.log("Failed to get req. component types for statement of type:" + rule.getType(), cause); |
| 323 | 0 | Window.alert("Failed to get req. component types for statement of type:" + rule.getType()); |
| 324 | 0 | } |
| 325 | |
|
| 326 | |
public void onSuccess(final List<ReqComponentTypeInfo> reqComponentTypeInfoList) { |
| 327 | 0 | if (reqComponentTypeInfoList == null || reqComponentTypeInfoList.size() == 0) { |
| 328 | 0 | GWT.log("Missing Requirement Component Types", null); |
| 329 | 0 | Window.alert("Missing Requirement Component Types"); |
| 330 | 0 | return; |
| 331 | |
} |
| 332 | 0 | editReqCompWidget.setReqCompList(reqComponentTypeInfoList); |
| 333 | 0 | editReqCompWidget.setCustomWidgets(getCustomWidgets(reqComponentTypeInfoList)); |
| 334 | 0 | } |
| 335 | |
}); |
| 336 | 0 | } |
| 337 | |
|
| 338 | |
private Map<String, Widget> getCustomWidgets(List<ReqComponentTypeInfo> reqComponentTypeInfoList) { |
| 339 | 0 | Map<String, Widget> customWidgets = new HashMap<String, Widget>(); |
| 340 | |
|
| 341 | 0 | for (ReqComponentTypeInfo reqCompTypeInfo : reqComponentTypeInfoList) { |
| 342 | 0 | for (ReqCompFieldTypeInfo fieldTypeInfo : reqCompTypeInfo.getReqCompFieldTypeInfos()) { |
| 343 | 0 | if (RulesUtil.isGradeWidget(fieldTypeInfo.getId())) { |
| 344 | 0 | customWidgets.put("kuali.reqComponent.field.type.grade.id", new GradeWidget()); |
| 345 | 0 | } else if (RulesUtil.isCourseWidget(fieldTypeInfo.getId())) { |
| 346 | |
|
| 347 | 0 | final CourseWidget courseWidget = GWT.create(CourseWidget.class); |
| 348 | |
|
| 349 | 0 | courseWidget.addGetCluNameCallback(new Callback() { |
| 350 | |
|
| 351 | |
@Override |
| 352 | |
public void exec(Object id) { |
| 353 | |
|
| 354 | 0 | statementRpcServiceAsync.getCurrentVersion(CLU_NAMESPACE_URI, (String)id, new AsyncCallback<VersionDisplayInfo>() { |
| 355 | |
@Override |
| 356 | |
public void onFailure(Throwable throwable) { |
| 357 | 0 | Window.alert(throwable.getMessage()); |
| 358 | 0 | GWT.log("Failed to retrieve clu for id: '" + "'", throwable); |
| 359 | 0 | } |
| 360 | |
|
| 361 | |
@Override |
| 362 | |
public void onSuccess(final VersionDisplayInfo versionInfo) { |
| 363 | 0 | statementRpcServiceAsync.getClu(versionInfo.getId(), new AsyncCallback<CluInfo>() { |
| 364 | |
@Override |
| 365 | |
public void onFailure(Throwable throwable) { |
| 366 | 0 | Window.alert(throwable.getMessage()); |
| 367 | 0 | GWT.log("Failed to retrieve clu", throwable); |
| 368 | 0 | } |
| 369 | |
|
| 370 | |
@Override |
| 371 | |
public void onSuccess(CluInfo cluInfo) { |
| 372 | 0 | courseWidget.setLabelContent(cluInfo.getVersionInfo().getVersionIndId(), cluInfo.getOfficialIdentifier().getCode()); |
| 373 | 0 | } |
| 374 | |
}); |
| 375 | 0 | } |
| 376 | |
}); |
| 377 | |
|
| 378 | |
|
| 379 | 0 | } |
| 380 | |
}); |
| 381 | |
|
| 382 | 0 | customWidgets.put("kuali.reqComponent.field.type.course.clu.id", courseWidget); |
| 383 | 0 | } else if (RulesUtil.isProgramWidget(fieldTypeInfo.getId())) { |
| 384 | 0 | final ProgramWidget programWidget = new ProgramWidget(); |
| 385 | |
|
| 386 | 0 | programWidget.addGetCluNameCallback(new Callback() { |
| 387 | |
|
| 388 | |
@Override |
| 389 | |
public void exec(Object id) { |
| 390 | |
|
| 391 | 0 | statementRpcServiceAsync.getCurrentVersion(CLU_NAMESPACE_URI, (String)id, new AsyncCallback<VersionDisplayInfo>() { |
| 392 | |
@Override |
| 393 | |
public void onFailure(Throwable throwable) { |
| 394 | 0 | Window.alert(throwable.getMessage()); |
| 395 | 0 | GWT.log("Failed to retrieve clu for id: '" + "'", throwable); |
| 396 | 0 | } |
| 397 | |
|
| 398 | |
@Override |
| 399 | |
public void onSuccess(final VersionDisplayInfo versionInfo) { |
| 400 | 0 | statementRpcServiceAsync.getClu(versionInfo.getId(), new AsyncCallback<CluInfo>() { |
| 401 | |
@Override |
| 402 | |
public void onFailure(Throwable throwable) { |
| 403 | 0 | Window.alert(throwable.getMessage()); |
| 404 | 0 | GWT.log("Failed to retrieve clu", throwable); |
| 405 | 0 | } |
| 406 | |
|
| 407 | |
@Override |
| 408 | |
public void onSuccess(CluInfo cluInfo) { |
| 409 | 0 | programWidget.setLabelContent(cluInfo.getVersionInfo().getVersionIndId(), cluInfo.getOfficialIdentifier().getCode()); |
| 410 | 0 | } |
| 411 | |
}); |
| 412 | 0 | } |
| 413 | |
}); |
| 414 | 0 | } |
| 415 | |
}); |
| 416 | |
|
| 417 | 0 | customWidgets.put("kuali.reqComponent.field.type.program.clu.id", programWidget); |
| 418 | 0 | } |
| 419 | |
} |
| 420 | |
} |
| 421 | 0 | return customWidgets; |
| 422 | |
} |
| 423 | |
|
| 424 | |
|
| 425 | 0 | protected Callback<ReqComponentInfo> retrieveCompositionTemplateCallback = new Callback<ReqComponentInfo>(){ |
| 426 | |
public void exec(final ReqComponentInfo reqComp) { |
| 427 | 0 | statementRpcServiceAsync.translateReqComponentToNL(reqComp, COMPOSITION_TEMLATE, TEMLATE_LANGUAGE, new KSAsyncCallback<String>() { |
| 428 | |
public void handleFailure(Throwable caught) { |
| 429 | 0 | Window.alert(caught.getMessage()); |
| 430 | 0 | GWT.log("translateReqComponentToNL failed for req. comp. type: '" + reqComp.getType() + "'",caught); |
| 431 | 0 | } |
| 432 | |
|
| 433 | |
public void onSuccess(final String compositionTemplate) { |
| 434 | 0 | editReqCompWidget.displayFieldsStart(compositionTemplate); |
| 435 | 0 | } |
| 436 | |
}); |
| 437 | 0 | } |
| 438 | |
}; |
| 439 | |
|
| 440 | 0 | protected Callback<List<String>> retrieveFieldsMetadataCallback = new Callback<List<String>>(){ |
| 441 | |
public void exec(final List<String> fieldTypes) { |
| 442 | |
|
| 443 | 0 | if (fieldTypes.contains("kuali.reqComponent.field.type.grade.id")) { |
| 444 | 0 | fieldTypes.add("kuali.reqComponent.field.type.gradeType.id"); |
| 445 | |
} |
| 446 | |
|
| 447 | 0 | metadataServiceAsync.getMetadataList(ReqCompFieldInfo.class.getName(), fieldTypes, null, new KSAsyncCallback<List<Metadata>>() { |
| 448 | |
public void handleFailure(Throwable caught) { |
| 449 | 0 | Window.alert(caught.getMessage()); |
| 450 | 0 | GWT.log("getMetadataList failed for req. comp. types: '" + fieldTypes.toString() + "'",caught); |
| 451 | 0 | } |
| 452 | |
|
| 453 | |
public void onSuccess(final List<Metadata> metadataList) { |
| 454 | 0 | editReqCompWidget.displayFieldsEnd(metadataList); |
| 455 | 0 | } |
| 456 | |
}); |
| 457 | 0 | } |
| 458 | |
}; |
| 459 | |
|
| 460 | 0 | protected Callback<String> retrieveCustomWidgetCallback = new Callback<String>(){ |
| 461 | |
public void exec(final String fieldType) { |
| 462 | 0 | if (RulesUtil.isCluSetWidget(fieldType)) { |
| 463 | 0 | String clusetType = "kuali.cluSet.type.Course"; |
| 464 | 0 | if (fieldType.toLowerCase().indexOf("program") > 0) { |
| 465 | 0 | clusetType = "kuali.cluSet.type.Program"; |
| 466 | |
} |
| 467 | 0 | editReqCompWidget.displayCustomWidget(fieldType, new BuildCluSetWidget(new CluSetRetrieverImpl(), clusetType, false)); |
| 468 | |
} |
| 469 | 0 | } |
| 470 | |
}; |
| 471 | |
|
| 472 | |
public Integer getInternalProgReqID() { |
| 473 | 0 | return internalProgReqID; |
| 474 | |
} |
| 475 | |
|
| 476 | |
private String getLabel(String messageKey) { |
| 477 | 0 | return Application.getApplicationContext().getUILabel(ProgramMsgConstants.PROGRAM_MSG_GROUP, messageKey); |
| 478 | |
} |
| 479 | |
} |