| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.kuali.student.lum.lu.ui.course.client.controllers; |
| 5 | |
|
| 6 | |
import java.util.ArrayList; |
| 7 | |
import java.util.List; |
| 8 | |
|
| 9 | |
import org.kuali.student.common.assembly.data.Data; |
| 10 | |
import org.kuali.student.common.dto.DtoConstants; |
| 11 | |
import org.kuali.student.common.rice.StudentIdentityConstants; |
| 12 | |
import org.kuali.student.common.ui.client.application.Application; |
| 13 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
| 14 | |
import org.kuali.student.common.ui.client.event.ActionEvent; |
| 15 | |
import org.kuali.student.common.ui.client.event.SaveActionEvent; |
| 16 | |
import org.kuali.student.common.ui.client.mvc.ActionCompleteCallback; |
| 17 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
| 18 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
| 19 | |
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
| 20 | |
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
| 21 | |
import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcServiceAsync; |
| 22 | |
import org.kuali.student.common.ui.client.service.DataSaveResult; |
| 23 | |
import org.kuali.student.common.ui.client.util.ExportElement; |
| 24 | |
import org.kuali.student.common.ui.client.util.ExportUtils; |
| 25 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
| 26 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 27 | |
import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData; |
| 28 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotification; |
| 29 | |
import org.kuali.student.common.ui.client.widgets.notification.KSNotifier; |
| 30 | |
import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator; |
| 31 | |
import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection; |
| 32 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
| 33 | |
import org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities; |
| 34 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
| 35 | |
import org.kuali.student.lum.lu.LUConstants; |
| 36 | |
import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants; |
| 37 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseProposalConfigurer; |
| 38 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseRetireByProposalConfigurer; |
| 39 | |
import org.kuali.student.lum.lu.ui.course.client.configuration.CourseProposalConfigurer.CourseSections; |
| 40 | |
import org.kuali.student.lum.lu.ui.course.client.service.CreditCourseRetireProposalRpcService; |
| 41 | |
import org.kuali.student.lum.lu.ui.course.client.widgets.CourseWorkflowActionList; |
| 42 | |
|
| 43 | |
import com.google.gwt.core.client.GWT; |
| 44 | |
import com.google.gwt.event.dom.client.ClickEvent; |
| 45 | |
import com.google.gwt.event.dom.client.ClickHandler; |
| 46 | |
import com.google.gwt.user.client.Window; |
| 47 | |
import com.google.gwt.user.client.rpc.AsyncCallback; |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | 0 | public class CourseRetireByProposalController extends CourseProposalController { |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
@Override |
| 61 | |
protected void initializeController() { |
| 62 | 0 | cluProposalRpcServiceAsync = GWT.create(CreditCourseRetireProposalRpcService.class); |
| 63 | 0 | super.cfg = GWT.create(CourseRetireByProposalConfigurer.class); |
| 64 | 0 | proposalPath = cfg.getProposalPath(); |
| 65 | 0 | workflowUtil = new WorkflowUtilities(CourseRetireByProposalController.this, proposalPath, "Proposal Actions", |
| 66 | |
CourseProposalConfigurer.CourseSections.WF_APPROVE_DIALOG,"", cfg.getModelId()); |
| 67 | 0 | cfg.setState(DtoConstants.STATE_DRAFT); |
| 68 | 0 | cfg.setNextState(DtoConstants.STATE_RETIRED); |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | 0 | super.setDefaultModelId(cfg.getModelId()); |
| 92 | 0 | super.registerModelsAndHandlers(); |
| 93 | 0 | super.addStyleName("ks-course-admin"); |
| 94 | 0 | currentDocType = LUConstants.PROPOSAL_TYPE_COURSE_RETIRE; |
| 95 | |
|
| 96 | 0 | } |
| 97 | |
|
| 98 | |
|
| 99 | |
@Override |
| 100 | |
protected void populateModel(final ModelRequestCallback<DataModel> callback, Callback<Boolean> workCompleteCallback){ |
| 101 | 0 | if(getViewContext().getIdType() == IdType.DOCUMENT_ID){ |
| 102 | 0 | getCluProposalFromWorkflowId(callback, workCompleteCallback); |
| 103 | 0 | } else if (getViewContext().getIdType() == IdType.KS_KEW_OBJECT_ID || getViewContext().getIdType() == IdType.OBJECT_ID){ |
| 104 | |
|
| 105 | 0 | getCluProposalFromProposalId(getViewContext().getId(), callback, workCompleteCallback); |
| 106 | 0 | } else if (getViewContext().getIdType() == IdType.COPY_OF_OBJECT_ID){ |
| 107 | 0 | if (LUConstants.PROPOSAL_TYPE_COURSE_RETIRE.equals(getViewContext().getAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME))) |
| 108 | |
{ |
| 109 | 0 | createRetireCluProposalModel(callback, workCompleteCallback); |
| 110 | |
} |
| 111 | |
} |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
protected void createRetireCluProposalModel(final ModelRequestCallback callback, final Callback<Boolean> workCompleteCallback){ |
| 115 | 0 | Data data = new Data(); |
| 116 | 0 | cluProposalModel.setRoot(data); |
| 117 | |
|
| 118 | 0 | Data proposalData = new Data(); |
| 119 | 0 | proposalData.set(new Data.StringKey("type"), LUConstants.PROPOSAL_TYPE_COURSE_RETIRE); |
| 120 | 0 | data.set(new Data.StringKey("proposal"), proposalData); |
| 121 | 0 | if (cfg.getNextState() == null && cfg.getNextState().isEmpty()){ |
| 122 | 0 | proposalData.set(new Data.StringKey("workflowNode"), "PreRoute"); |
| 123 | |
} |
| 124 | |
|
| 125 | 0 | data.set(new Data.StringKey("id"), getViewContext().getId()); |
| 126 | |
|
| 127 | 0 | cluProposalRpcServiceAsync.saveData(cluProposalModel.getRoot(), new AsyncCallback<DataSaveResult>() { |
| 128 | |
public void onSuccess(DataSaveResult result) { |
| 129 | |
|
| 130 | 0 | cluProposalModel.setRoot(result.getValue()); |
| 131 | 0 | setHeaderTitle(); |
| 132 | 0 | setLastUpdated(); |
| 133 | |
|
| 134 | 0 | ViewContext docContext = new ViewContext(); |
| 135 | 0 | docContext.setId((String) cluProposalModel.get(cfg.getProposalPath()+"/id")); |
| 136 | 0 | docContext.setIdType(IdType.KS_KEW_OBJECT_ID); |
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | 0 | getViewContext().setIdType(docContext.getIdType()); |
| 145 | 0 | getViewContext().setId(docContext.getId()); |
| 146 | 0 | callback.onModelReady(cluProposalModel); |
| 147 | 0 | workCompleteCallback.exec(true); |
| 148 | |
|
| 149 | 0 | } |
| 150 | |
|
| 151 | |
public void onFailure(Throwable caught) { |
| 152 | 0 | Window.alert("Error loading Proposal: "+caught.getMessage()); |
| 153 | 0 | createNewCluProposalModel(callback, workCompleteCallback); |
| 154 | 0 | KSBlockingProgressIndicator.removeTask(loadDataTask); |
| 155 | 0 | } |
| 156 | |
}); |
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | 0 | } |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
@Override |
| 168 | |
protected void setHeaderTitle(){ |
| 169 | 0 | StringBuffer sb = new StringBuffer(); |
| 170 | 0 | sb.append(cluProposalModel.get(cfg.getCourseTitlePath())); |
| 171 | 0 | sb.append(" (Proposed Retirement)"); |
| 172 | |
|
| 173 | 0 | currentTitle = sb.toString(); |
| 174 | |
|
| 175 | 0 | this.setContentTitle(currentTitle); |
| 176 | 0 | this.setName(currentTitle); |
| 177 | 0 | WindowTitleUtils.setContextTitle(currentTitle); |
| 178 | 0 | } |
| 179 | |
|
| 180 | |
@Override |
| 181 | |
protected BaseDataOrchestrationRpcServiceAsync getCourseProposalRpcService(){ |
| 182 | 0 | return cluProposalRpcServiceAsync; |
| 183 | |
} |
| 184 | |
|
| 185 | |
public boolean startSectionRequired(){ |
| 186 | |
|
| 187 | 0 | return false; |
| 188 | |
} |
| 189 | |
|
| 190 | |
@Override |
| 191 | |
public boolean isAuthorizationRequired() { |
| 192 | |
|
| 193 | 0 | return true; |
| 194 | |
} |
| 195 | |
|
| 196 | |
@Override |
| 197 | |
protected void progressiveEnableFields() { |
| 198 | |
|
| 199 | 0 | } |
| 200 | |
|
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
@Override |
| 206 | |
protected String getStateforSaveAction(DataModel model){ |
| 207 | 0 | return cfg.getState(); |
| 208 | |
} |
| 209 | |
|
| 210 | |
|
| 211 | |
@Override |
| 212 | |
public String getExportTemplateName() { |
| 213 | 0 | return "base.template"; |
| 214 | |
} |
| 215 | |
|
| 216 | |
@Override |
| 217 | |
public List<ExportElement> getExportElementsFromView() { |
| 218 | 0 | List<ExportElement> exportElements = new ArrayList<ExportElement>(); |
| 219 | 0 | if (this.getCurrentViewEnum().equals(CourseSections.SUMMARY)) { |
| 220 | 0 | SummaryTableSection tableSection = this.cfg.getSummaryConfigurer().getTableSection(); |
| 221 | 0 | ExportElement heading = new ExportElement(); |
| 222 | 0 | heading.setFieldLabel(""); |
| 223 | 0 | heading.setFieldValue("Retire Proposal"); |
| 224 | 0 | exportElements.add(heading); |
| 225 | 0 | exportElements.addAll(ExportUtils.getDetailsForWidget(tableSection.getSummaryTable())); |
| 226 | |
} |
| 227 | 0 | return exportElements; |
| 228 | |
} |
| 229 | |
|
| 230 | |
} |