Coverage Report - org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities
 
Classes in this File Line Coverage Branch Coverage Complexity
WorkflowUtilities
0%
0/174
0%
0/62
1.873
WorkflowUtilities$1
0%
0/6
N/A
1.873
WorkflowUtilities$10
0%
0/20
N/A
1.873
WorkflowUtilities$10$1
0%
0/8
0%
0/4
1.873
WorkflowUtilities$10$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$11
0%
0/8
0%
0/2
1.873
WorkflowUtilities$12
0%
0/24
N/A
1.873
WorkflowUtilities$12$1
0%
0/14
0%
0/10
1.873
WorkflowUtilities$12$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$13
0%
0/5
N/A
1.873
WorkflowUtilities$14
0%
0/3
N/A
1.873
WorkflowUtilities$14$1
0%
0/6
0%
0/2
1.873
WorkflowUtilities$15
0%
0/4
N/A
1.873
WorkflowUtilities$15$1
0%
0/10
0%
0/4
1.873
WorkflowUtilities$2
0%
0/4
N/A
1.873
WorkflowUtilities$2$1
0%
0/13
0%
0/4
1.873
WorkflowUtilities$3
0%
0/4
N/A
1.873
WorkflowUtilities$4
0%
0/5
N/A
1.873
WorkflowUtilities$5
0%
0/4
N/A
1.873
WorkflowUtilities$5$1
0%
0/10
0%
0/4
1.873
WorkflowUtilities$6
0%
0/16
N/A
1.873
WorkflowUtilities$6$1
0%
0/6
0%
0/2
1.873
WorkflowUtilities$6$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$7
0%
0/20
N/A
1.873
WorkflowUtilities$7$1
0%
0/8
0%
0/4
1.873
WorkflowUtilities$7$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$8
0%
0/20
N/A
1.873
WorkflowUtilities$8$1
0%
0/8
0%
0/4
1.873
WorkflowUtilities$8$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$9
0%
0/20
N/A
1.873
WorkflowUtilities$9$1
0%
0/8
0%
0/4
1.873
WorkflowUtilities$9$1$1
0%
0/12
0%
0/4
1.873
WorkflowUtilities$DecisionRationaleDetail
0%
0/21
0%
0/4
1.873
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  * 
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 package org.kuali.student.core.workflow.ui.client.widgets;
 16  
 
 17  
 import java.util.ArrayList;
 18  
 import java.util.List;
 19  
 
 20  
 import org.kuali.student.common.ui.client.application.Application;
 21  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 22  
 import org.kuali.student.common.ui.client.configurable.mvc.LayoutController;
 23  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 24  
 import org.kuali.student.common.ui.client.event.SaveActionEvent;
 25  
 import org.kuali.student.common.ui.client.mvc.Callback;
 26  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 27  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 28  
 import org.kuali.student.common.ui.client.service.CommentRpcService;
 29  
 import org.kuali.student.common.ui.client.service.CommentRpcServiceAsync;
 30  
 import org.kuali.student.common.ui.client.widgets.KSDropDown;
 31  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 32  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 33  
 import org.kuali.student.common.ui.client.widgets.KSRichEditor;
 34  
 import org.kuali.student.common.ui.client.widgets.StylishDropDown;
 35  
 import org.kuali.student.common.ui.client.widgets.buttongroups.AcknowledgeCancelGroup;
 36  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ConfirmApprovalCancelGroup;
 37  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ConfirmCancelGroup;
 38  
 import org.kuali.student.common.ui.client.widgets.buttongroups.RejectCancelGroup;
 39  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.AcknowledgeCancelEnum;
 40  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ConfirmApprovalCancelEnum;
 41  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ConfirmCancelEnum;
 42  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.RejectCancelEnum;
 43  
 import org.kuali.student.common.ui.client.widgets.dialog.ConfirmationDialog;
 44  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrPanel;
 45  
 import org.kuali.student.common.ui.client.widgets.list.impl.SimpleListItems;
 46  
 import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData;
 47  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotification;
 48  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotifier;
 49  
 import org.kuali.student.core.assembly.data.QueryPath;
 50  
 import org.kuali.student.core.comment.dto.CommentInfo;
 51  
 import org.kuali.student.core.dto.RichTextInfo;
 52  
 import org.kuali.student.core.dto.DtoConstants.DtoState;
 53  
 import org.kuali.student.core.validation.dto.ValidationResultInfo;
 54  
 import org.kuali.student.core.workflow.ui.client.WorkflowConstants;
 55  
 import org.kuali.student.core.workflow.ui.client.service.WorkflowRpcService;
 56  
 import org.kuali.student.core.workflow.ui.client.service.WorkflowRpcServiceAsync;
 57  
 
 58  
 import com.google.gwt.core.client.GWT;
 59  
 import com.google.gwt.event.dom.client.ClickEvent;
 60  
 import com.google.gwt.event.dom.client.ClickHandler;
 61  
 import com.google.gwt.user.client.Window;
 62  
 import com.google.gwt.user.client.rpc.AsyncCallback;
 63  
 import com.google.gwt.user.client.ui.VerticalPanel;
 64  
 import com.google.gwt.user.client.ui.Widget;
 65  
 
 66  0
 public class WorkflowUtilities{
 67  
 
 68  
         //TODO: This should come from the ReferenceModel like it does in CommentTool
 69  
     public static final String PROPOSAL_REF_TYPE_KEY = "referenceType.clu.proposal";
 70  
     
 71  0
         public static enum DecisionRationaleDetail {
 72  0
         APPROVE("kuali.comment.type.workflowDecisionRationale.approve", "Approved"),
 73  0
         REJECT("kuali.comment.type.workflowDecisionRationale.reject", "Rejected"),
 74  0
         RETURN_TO_PREVIOUS("kuali.comment.type.workflowDecisionRationale.return", "Sent for Revisions"),
 75  0
         WITHDRAW("kuali.comment.type.workflowDecisionRationale.withdraw", "Withdrawn"),
 76  0
         ACKNOWLEDGE("kuali.comment.type.workflowDecisionRationale.acknowledge", "Acknowledged"),
 77  0
         FYI("kuali.comment.type.workflowDecisionRationale.fyi", "FYI"),
 78  0
         CANCEL_WORKFLOW("kuali.comment.type.workflowDecisionRationale.cancelWorkflow", "Cancelled"),
 79  0
         BLANKET_APPROVE("kuali.comment.type.workflowDecisionRationale.blanketApprove", "Blanket Approved")
 80  
         ;
 81  
 
 82  0
         private String type = "";
 83  0
         private String label = "";
 84  
 
 85  0
         private DecisionRationaleDetail(String type, String label) {
 86  0
             this.type = type;
 87  0
             this.label = label;
 88  0
         }
 89  
 
 90  
         public String getType() {
 91  0
             return type;
 92  
         }
 93  
 
 94  
         public String getLabel() {
 95  0
             return label;
 96  
         }
 97  
 
 98  
         public static DecisionRationaleDetail getByType(String type) {
 99  0
             for (DecisionRationaleDetail detail : DecisionRationaleDetail.values()) {
 100  0
                 if (detail.getType().equals(type)) {
 101  0
                     return detail;
 102  
                 }
 103  
             }
 104  0
             return null;
 105  
         }
 106  
 
 107  
     }
 108  
 
 109  0
         DataModel dataModel=null;
 110  
         
 111  0
         boolean loaded=false;
 112  
     
 113  0
         private boolean workflowWidgetsEnabled = true;
 114  
         
 115  
         private KSMenuItemData wfApproveItem;
 116  
         private KSMenuItemData wfDisApproveItem;
 117  
         private KSMenuItemData wfAcknowledgeItem;
 118  
         private KSMenuItemData wfStartWorkflowItem;
 119  
     private KSMenuItemData wfCancelWorkflowItem;
 120  
         private KSMenuItemData wfFYIWorkflowItem;
 121  
         private KSMenuItemData wfWithdrawItem;
 122  
     private KSMenuItemData wfReturnToPreviousItem;
 123  
     private KSMenuItemData wfBlanketApproveItem;
 124  
         
 125  0
         private List<KSMenuItemData> items = new ArrayList<KSMenuItemData>();
 126  
             
 127  
     SaveActionEvent approveSaveActionEvent;
 128  
     SaveActionEvent startWorkflowSaveActionEvent;
 129  
     
 130  0
     WorkflowRpcServiceAsync workflowRpcServiceAsync = GWT.create(WorkflowRpcService.class);
 131  0
     private CommentRpcServiceAsync commentServiceAsync = GWT.create(CommentRpcService.class);
 132  
     
 133  
     private String modelName;
 134  
     private String proposalPath;
 135  0
     private String proposalId = "";
 136  
     private String workflowId;
 137  0
     private String proposalName="";
 138  0
     private String workflowActions="";
 139  
         
 140  0
         private List<StylishDropDown> workflowWidgets = new ArrayList<StylishDropDown>();
 141  
         private Callback<Boolean> submitCallback;
 142  0
         private ConfirmationDialog dialog = new ConfirmationDialog("Submit Proposal", "Are you sure you want to submit the proposal to workflow?", "Submit");
 143  
         private AbbrPanel required; 
 144  
         private KSLightBox submitSuccessDialog;
 145  
         private VerticalPanel dialogPanel;
 146  
     
 147  0
     private KSLabel workflowStatusLabel = new KSLabel("");
 148  
     
 149  
     private LayoutController parentController;
 150  
         
 151  0
         public WorkflowUtilities(LayoutController parentController, String proposalPath) {
 152  0
                 this.parentController = parentController;
 153  0
                 this.proposalPath = proposalPath;
 154  0
                 setupWFButtons();
 155  0
                 setupDialog();
 156  0
         }
 157  
         
 158  
         public void requestAndSetupModel() {
 159  
                 
 160  0
                 if(null==dataModel){
 161  
                         //Get the Model from the controller and register a model change handler when the workflow model is updated
 162  0
                         parentController.requestModel(modelName, new ModelRequestCallback<DataModel>() {
 163  
                         
 164  
                                 @Override
 165  
                                 public void onRequestFail(Throwable cause) {
 166  0
                                         Window.alert("Model Request Failed. "+cause.getMessage());
 167  0
                                 }
 168  
 
 169  
                                 @Override
 170  
                                 public void onModelReady(DataModel model) {
 171  
                                         //After we get the model update immediately
 172  0
                                         dataModel = model;
 173  0
                                         updateWorkflow(dataModel);
 174  0
                                 }
 175  
                         });
 176  
                 }else{
 177  
                         //If the model has been set don't waste time finding it again and don't register 
 178  
                         //another change listener, just update
 179  0
                         updateWorkflow(dataModel);
 180  
                 }
 181  0
         }
 182  
         
 183  
         private void setupWFButtons() {
 184  0
                 wfApproveItem = getApproveItem();
 185  0
                 wfDisApproveItem = getDisApproveItem();
 186  0
                 wfAcknowledgeItem = getAcknowledgeItem();
 187  0
                 wfStartWorkflowItem = getStartItem();
 188  0
                 wfCancelWorkflowItem = getCancelWorkflowItem();
 189  0
                 wfFYIWorkflowItem = getFYIWorkflowItem();
 190  0
                 wfWithdrawItem = getWithdrawItem();
 191  0
                 wfReturnToPreviousItem = getReturnToPreviousItem();
 192  0
                 wfBlanketApproveItem = getBlanketApproveItem();
 193  0
         }
 194  
         
 195  
         private void setupSubmitSuccessDialog(){
 196  0
                 if(submitSuccessDialog==null){
 197  0
                         submitSuccessDialog= new KSLightBox();
 198  0
                         submitSuccessDialog.setSize(580, 400);
 199  0
                         dialogPanel = new VerticalPanel();
 200  0
                         submitSuccessDialog.setWidget(dialogPanel);
 201  
                         
 202  
                 }
 203  
 
 204  0
         }
 205  
         
 206  
         private void setupDialog(){
 207  
 
 208  0
                 dialog.getConfirmButton().addClickHandler(new ClickHandler(){
 209  
 
 210  
                         @Override
 211  
                         public void onClick(ClickEvent event) {
 212  0
                                 dialog.getConfirmButton().setEnabled(false);
 213  0
                                 workflowRpcServiceAsync.submitDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){
 214  
                                         public void handleFailure(Throwable caught) {
 215  0
                                                 Window.alert("Error starting Proposal workflow");
 216  0
                                                 dialog.getConfirmButton().setEnabled(true);
 217  0
                                         }
 218  
                                         public void onSuccess(Boolean result) {
 219  0
                                                 if (result){
 220  0
                                                         updateWorkflow(dataModel);                                                
 221  0
                                                         dialog.hide();
 222  0
                                                         dialog.getConfirmButton().setEnabled(true);
 223  0
                                                         if(submitCallback != null){
 224  0
                                                                 submitCallback.exec(true);
 225  
                                                         }
 226  
                                                         //Notify the user that the document was submitted
 227  0
                                                         KSNotifier.add(new KSNotification("Proposal has been routed to workflow", false));
 228  
                                                 } else {
 229  0
                                                         Window.alert("Error starting Proposal workflow");
 230  
                                                 }
 231  0
                                         }
 232  
                                 });
 233  
                                 
 234  0
                         }
 235  
                 });
 236  0
         }
 237  
         
 238  
         public Widget getWorkflowActionsWidget(){
 239  
                 //InfoMessage infoContainer = new InfoMessage();
 240  0
                 StylishDropDown workflowActionsDropDown = new StylishDropDown("Workflow Actions");
 241  0
                 workflowActionsDropDown.makeAButtonWhenOneItem(true);
 242  0
                 workflowActionsDropDown.addStyleName("KS-Workflow-DropDown");
 243  0
                 workflowWidgets.add(workflowActionsDropDown);
 244  0
                 workflowActionsDropDown.setVisible(false);
 245  0
                 refresh();
 246  
 /*                infoContainer.add(workflowActionsDropDown);
 247  
                 infoContainer.showWarnStyling(false);
 248  
                 infoContainer.setVisible(true);*/
 249  
                 //workflowActionsDropDown
 250  0
                 return workflowActionsDropDown;
 251  
         }
 252  
         
 253  
         public void enableWorkflowActionsWidgets(boolean enable){
 254  0
                 workflowWidgetsEnabled = enable;
 255  0
                 updateWorkflowActionsWidget();
 256  0
         }
 257  
         
 258  
         public void doValidationCheck(Callback<List<ValidationResultInfo>> callback){
 259  0
                 dataModel.validateNextState(callback);
 260  0
         }
 261  
         
 262  
         public KSLabel getWorkflowStatusLabel(){
 263  0
                 return workflowStatusLabel;
 264  
         }
 265  
         
 266  
         private void updateWorkflowIdFromModel(final DataModel model){
 267  0
                 if(model!=null){
 268  0
                         String modelProposalId = model.get(QueryPath.parse(proposalPath + "/id"));
 269  
                         
 270  
                         //If proposalId in model has been set or changed, get new workflowId and update workfow widget
 271  0
                         if (modelProposalId != null && !modelProposalId.isEmpty() && !modelProposalId.equals(proposalId)){
 272  0
                                 proposalId = modelProposalId;
 273  0
                                 workflowId = model.get(QueryPath.parse(proposalPath + "/workflowId"));
 274  0
                                 proposalName = model.get(QueryPath.parse(proposalPath + "/name"));
 275  0
                                 updateWorkflow(model);
 276  
                         }
 277  
                 }
 278  0
         }
 279  
 
 280  
         private void updateWorkflow(DataModel model){
 281  0
                 updateWorkflowIdFromModel(model);
 282  
                 
 283  0
                 if (workflowId != null && !workflowId.isEmpty()){
 284  
                         //Determine which workflow actions are displayed in the drop down
 285  0
                         workflowRpcServiceAsync.getActionsRequested(workflowId, new KSAsyncCallback<String>(){
 286  
                 
 287  
                                 public void onSuccess(String result) {
 288  0
                                         workflowActions = result;
 289  0
                                         updateWorkflowActionsWidget();
 290  0
                                 }
 291  
                         });
 292  
                 
 293  0
                         workflowRpcServiceAsync.getDocumentStatus(workflowId, new KSAsyncCallback<String>(){
 294  
                                 @Override
 295  
                                 public void handleFailure(Throwable caught) {
 296  0
                                         workflowStatusLabel.setText("Status: Unknown");
 297  0
                                 }
 298  
 
 299  
                                 @Override
 300  
                                 public void onSuccess(String result) {
 301  0
                                         setWorkflowStatus(result);
 302  0
                                 }                                                
 303  
                         });
 304  
                 } else {
 305  0
                         workflowStatusLabel.setText("Status: Draft");
 306  
                 }                        
 307  0
         }
 308  
         
 309  
         private void updateWorkflowActionsWidget(){
 310  0
                 items.clear();
 311  
 
 312  
                 //Display all workflow actions if workflowWidgetsEnabled, otherwise just display
 313  
                 //the cancel option.
 314  0
                 if (workflowWidgetsEnabled){
 315  0
                         if(workflowActions.contains("S")){
 316  0
                                 items.add(wfStartWorkflowItem);
 317  
                         }
 318  0
             if(workflowActions.contains("C")){
 319  0
                 items.add(wfCancelWorkflowItem);
 320  
             }
 321  0
                         if(workflowActions.contains("A")){
 322  0
                                 items.add(wfApproveItem);
 323  0
                                 items.add(wfDisApproveItem);
 324  
                         }
 325  0
                         if(workflowActions.contains("K")){
 326  0
                                 items.add(wfAcknowledgeItem);
 327  
                         }
 328  0
                         if(workflowActions.contains("F")){
 329  0
                                 items.add(wfFYIWorkflowItem);
 330  
                         }
 331  0
             if(workflowActions.contains("R")){
 332  0
                 items.add(wfReturnToPreviousItem);
 333  
             }
 334  0
             if(workflowActions.contains("B")){
 335  0
                 items.add(wfBlanketApproveItem);
 336  
             }
 337  0
             if(workflowActions.contains("W")){
 338  0
                 items.add(wfWithdrawItem);
 339  
             }
 340  
                 } else {
 341  0
             if(workflowActions.contains("C")){
 342  0
                 items.add(wfCancelWorkflowItem);
 343  
             }
 344  0
             if(workflowActions.contains("W")){
 345  0
                 items.add(wfWithdrawItem);
 346  
             }
 347  
                 }
 348  0
                 for(StylishDropDown widget: workflowWidgets){
 349  
                         
 350  0
                         widget.setItems(items);
 351  0
                         widget.setEnabled(true);
 352  0
                         if(items.isEmpty()){
 353  0
                                 widget.setVisible(false);
 354  
                         }
 355  
                         else{
 356  0
                                 widget.setVisible(true);
 357  
                         }
 358  
                 }                
 359  0
         }
 360  
         
 361  
         private KSMenuItemData getFYIWorkflowItem() {
 362  
                 KSMenuItemData wfFYIWorkflowItem;
 363  0
                 final KSRichEditor rationaleEditor = new KSRichEditor();
 364  0
                 wfFYIWorkflowItem = new KSMenuItemData("FYI Proposal", new ClickHandler(){
 365  
                 public void onClick(ClickEvent event) {           
 366  0
                         addRationale(rationaleEditor,DecisionRationaleDetail.FYI.getType());
 367  0
                                 workflowRpcServiceAsync.fyiDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){
 368  
                                         public void handleFailure(Throwable caught) {
 369  0
                                                 Window.alert("Error FYIing Proposal");
 370  0
                                         }
 371  
                                         public void onSuccess(
 372  
                                                         Boolean result) {
 373  0
                                                 if(result){
 374  0
                                                         updateWorkflow(dataModel);
 375  0
                                                         if(submitCallback != null){
 376  0
                                                                 submitCallback.exec(true);
 377  
                                                         }
 378  
                                                         //Notify the user that the document was FYIed
 379  0
                                                         KSNotifier.add(new KSNotification("Proposal was FYIed", false));
 380  
                                                 }else{
 381  0
                                                         Window.alert("Error FYIing Proposal");
 382  
                                                 }
 383  0
                                         }
 384  
                                         
 385  
                                 });
 386  0
                 }        
 387  
             });
 388  0
                 return wfFYIWorkflowItem;
 389  
         }
 390  
 
 391  
         private KSMenuItemData getAcknowledgeItem() {
 392  
                 KSMenuItemData wfAcknowledgeItem;
 393  0
                 wfAcknowledgeItem = new KSMenuItemData("Acknowledge Proposal", new ClickHandler(){
 394  
                 public void onClick(ClickEvent event) {
 395  0
                         setupSubmitSuccessDialog();
 396  0
                                 final KSRichEditor rationaleEditor = new KSRichEditor();
 397  0
                                 AcknowledgeCancelGroup approvalButton = new AcknowledgeCancelGroup(new Callback<AcknowledgeCancelEnum>(){
 398  
 
 399  
                                         @Override
 400  
                                         public void exec(AcknowledgeCancelEnum result) {
 401  0
                                                 if(!result.name().equals("CANCEL")){
 402  0
                                                         addRationale(rationaleEditor,DecisionRationaleDetail.ACKNOWLEDGE.getType());
 403  0
                                                         workflowRpcServiceAsync.acknowledgeDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){
 404  
                                                                 public void handleFailure(Throwable caught) {
 405  0
                                                                         submitSuccessDialog.hide();
 406  0
                                                                         Window.alert("Error acknowledging Proposal");
 407  0
                                                                 }
 408  
                                                                 public void onSuccess(Boolean result) {
 409  0
                                                                         submitSuccessDialog.hide();
 410  0
                                                                         if(result){
 411  0
                                                                                 updateWorkflow(dataModel);
 412  0
                                                                                 if(submitCallback != null){
 413  0
                                                                                         submitCallback.exec(true);
 414  
                                                                                 }
 415  
                                                                                 //Notify the user that the document was acknowledged
 416  0
                                                                                 KSNotifier.add(new KSNotification("Proposal was acknowledged", false));
 417  
                                                                         }else{
 418  0
                                                                                 Window.alert("Error acknowledging Proposal");
 419  
                                                                         }
 420  0
                                                                 }
 421  
                                                         });
 422  
                                                 }
 423  
                                                 else{
 424  0
                                                         submitSuccessDialog.hide();
 425  
                                                 }
 426  0
                                         }
 427  
                                 });
 428  
                                 
 429  0
                                 SectionTitle headerTitle = SectionTitle.generateH3Title("Acknowledge Proposal");
 430  0
                                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are acknowledging the " + proposalName +" proposal");
 431  0
                                 SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 432  0
                                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 433  0
                                 dialogPanel.clear();
 434  0
                                 dialogPanel.add(headerTitle);        
 435  0
                                 dialogPanel.add(dialogLabel);
 436  0
                                 dialogPanel.add(fieldLabel);
 437  0
                                 dialogPanel.add(rationaleEditor);
 438  0
                                 dialogPanel.add(approvalButton);
 439  0
                                 submitSuccessDialog.show();
 440  0
                 }        
 441  
             });
 442  0
                 return wfAcknowledgeItem;
 443  
         }
 444  
 
 445  
         private KSMenuItemData getDisApproveItem() {
 446  
                 KSMenuItemData wfDisApproveItem;
 447  0
                 wfDisApproveItem = new KSMenuItemData("Reject Proposal", new ClickHandler(){
 448  
                 public void onClick(ClickEvent event) {   
 449  0
                         setupSubmitSuccessDialog();
 450  0
                                 final KSRichEditor rationaleEditor = new KSRichEditor();
 451  0
                                 RejectCancelGroup disapprovalButton = new RejectCancelGroup(new Callback<RejectCancelEnum>(){
 452  
 
 453  
                                         @Override
 454  
                                         public void exec(RejectCancelEnum result) {
 455  0
                                                 if(!result.name().equals("CANCEL")){
 456  0
                                                         if(rationaleEditor.getText().trim().equals("")){
 457  0
                                                                 required.setText("Please enter the decision rationale");
 458  
                                                         }
 459  
                                                         else{
 460  0
                                                                 addRationale(rationaleEditor,DecisionRationaleDetail.REJECT.getType());
 461  0
                                                                 workflowRpcServiceAsync.disapproveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){
 462  
                                                                         public void handleFailure(Throwable caught) {
 463  0
                                                                                 submitSuccessDialog.hide();
 464  0
                                                                                 Window.alert("Error rejecting Proposal");
 465  0
                                                                         }
 466  
                                                                         public void onSuccess(Boolean result) {
 467  0
                                                                                 submitSuccessDialog.hide();
 468  0
                                                                                 if(submitCallback != null){
 469  0
                                                                                         submitCallback.exec(result);
 470  
                                                                                 }
 471  0
                                                                                 if(result){
 472  0
                                                                                         KSNotifier.add(new KSNotification("Proposal was rejected", false));
 473  0
                                                                                         updateWorkflow(dataModel);
 474  
                                                                                 }else{
 475  0
                                                                                         Window.alert("Error rejecting Proposal");
 476  
                                                                                 }
 477  0
                                                                         }
 478  
                                                                         
 479  
                                                                 });
 480  
                                                         }
 481  
 
 482  
                                         }
 483  
                                         else{
 484  0
                                                 submitSuccessDialog.hide();
 485  
                                         }
 486  0
                                         }
 487  
                                 });
 488  0
                                 SectionTitle headerTitle = SectionTitle.generateH3Title("Reject Proposal");
 489  0
                                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are rejecting the " + proposalName +" proposal");
 490  0
                                 SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 491  0
                                 required = new AbbrPanel("Required", "ks-form-module-elements-required", " * ");
 492  0
                                 required.setVisible(true);
 493  
 //                                final KSRichEditor rationaleEditor = new KSRichEditor();
 494  
 //                                rationaleEditor.addStyleName("ks-textarea-width");
 495  
 //                                rationaleEditor.addStyleName("ks-textarea-large-height");
 496  0
                                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 497  0
                                 dialogPanel.clear();
 498  0
                                 dialogPanel.add(headerTitle);        
 499  0
                                 dialogPanel.add(dialogLabel);
 500  0
                                 dialogPanel.add(fieldLabel);
 501  0
                                 dialogPanel.add(required);
 502  0
                                 dialogPanel.add(rationaleEditor);
 503  0
                                 dialogPanel.add(disapprovalButton);
 504  0
                                 submitSuccessDialog.setWidget(dialogPanel);
 505  0
                                 submitSuccessDialog.show();
 506  0
                 }        
 507  
             });
 508  0
                 return wfDisApproveItem;
 509  
         }
 510  
 
 511  
         private KSMenuItemData getApproveItem() {
 512  
                 KSMenuItemData wfApproveItem;
 513  
 
 514  0
                 wfApproveItem= new KSMenuItemData("Approve Proposal", new ClickHandler(){
 515  
                         public void onClick(ClickEvent event) {
 516  0
                                 setupSubmitSuccessDialog();
 517  0
                                 final KSRichEditor rationaleEditor = new KSRichEditor();
 518  0
                                 ConfirmApprovalCancelGroup approvalButton = new ConfirmApprovalCancelGroup(new Callback<ConfirmApprovalCancelEnum>(){
 519  
 
 520  
                                         @Override
 521  
                                         public void exec(ConfirmApprovalCancelEnum result) {
 522  0
                                                 if(!result.name().equals("CANCEL")){
 523  0
                                                         if(rationaleEditor.getText().trim().equals("")){
 524  0
                                                                 required.setText("Please enter the decision rationale");
 525  
                                                         }
 526  
                                                         else{
 527  0
                                                                 addRationale(rationaleEditor,DecisionRationaleDetail.APPROVE.getType());
 528  
                                                                 
 529  0
                                                                 workflowRpcServiceAsync.approveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>(){
 530  
                                                                 public void handleFailure(Throwable caught) {
 531  0
                                                                         submitSuccessDialog.hide();
 532  0
                                                                         Window.alert("Error approving Proposal");
 533  0
                                                                 }
 534  
                                                                 public void onSuccess(Boolean result) {
 535  0
                                                                         submitSuccessDialog.hide();
 536  0
                                                                         if (result){
 537  0
                                                                                 updateWorkflow(dataModel);
 538  0
                                                                                 if(submitCallback != null){
 539  0
                                                                                         submitCallback.exec(result);
 540  
                                                                                 }
 541  
                                                                                 //Notify the user that the document was approved
 542  0
                                                                                 KSNotifier.add(new KSNotification("Proposal was approved", false));
 543  
                                                                         } else {
 544  0
                                                                                 Window.alert("Error approving Proposal");
 545  
                                                                         }
 546  0
                                                                 }
 547  
                                                         });
 548  
                                                         }
 549  
 
 550  
                                         }
 551  
                                         else{
 552  0
                                                 submitSuccessDialog.hide();
 553  
                                         }
 554  0
                                         }
 555  
                                 });
 556  
                                 
 557  0
                                 SectionTitle headerTitle = SectionTitle.generateH3Title("Approve Proposal");
 558  0
                                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are approving the " + proposalName +" proposal");
 559  0
                                 SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 560  0
                                 required = new AbbrPanel("Required", "ks-form-module-elements-required", " * ");
 561  0
                                 required.setVisible(true);
 562  0
                                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 563  0
                                 dialogPanel.clear();
 564  0
                                 dialogPanel.add(headerTitle);        
 565  0
                                 dialogPanel.add(dialogLabel);
 566  0
                                 dialogPanel.add(fieldLabel);
 567  0
                                 dialogPanel.add(required);
 568  0
                                 dialogPanel.add(rationaleEditor);
 569  0
                                 dialogPanel.add(approvalButton);
 570  0
                                 dialogPanel.setSize("580px", "400px");
 571  
 //                                submitSuccessDialog.setWidget(dialogPanel);
 572  0
                                 submitSuccessDialog.show();
 573  0
                         }        
 574  
                 });
 575  0
                 return wfApproveItem;
 576  
         }
 577  
 
 578  
     private KSMenuItemData getWithdrawItem() {
 579  
         KSMenuItemData wfWithdrawItem;
 580  
 
 581  0
         wfWithdrawItem = new KSMenuItemData("Withdraw Proposal", new ClickHandler() {
 582  
             public void onClick(ClickEvent event) {
 583  0
                 setupSubmitSuccessDialog();
 584  0
                 final KSRichEditor rationaleEditor = new KSRichEditor();
 585  0
                 ConfirmCancelGroup withdrawButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() {
 586  
 
 587  
                     @Override
 588  
                     public void exec(ConfirmCancelEnum result) {
 589  0
                         if (!result.name().equals("CANCEL")) {
 590  0
                             if (rationaleEditor.getText().trim().equals("")) {
 591  0
                                 required.setText("Please enter the decision rationale");
 592  
                             } else {
 593  0
                                 addRationale(rationaleEditor, DecisionRationaleDetail.WITHDRAW.getType());
 594  
 
 595  0
                                 workflowRpcServiceAsync.withdrawDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() {
 596  
                                     public void handleFailure(Throwable caught) {
 597  0
                                         submitSuccessDialog.hide();
 598  0
                                         Window.alert("Error withdrawing Proposal");
 599  0
                                     }
 600  
 
 601  
                                     public void onSuccess(Boolean result) {
 602  0
                                         submitSuccessDialog.hide();
 603  0
                                         if (result) {
 604  0
                                             updateWorkflow(dataModel);
 605  0
                                             if (submitCallback != null) {
 606  0
                                                 submitCallback.exec(result);
 607  
                                             }
 608  
                                             // Notify the user that the document was approved
 609  0
                                             KSNotifier.add(new KSNotification("Proposal will be withdrawn", false));
 610  
                                         } else {
 611  0
                                             Window.alert("Error withdrawing Proposal");
 612  
                                         }
 613  0
                                     }
 614  
                                 });
 615  
                             }
 616  
 
 617  
                         } else {
 618  0
                             submitSuccessDialog.hide();
 619  
                         }
 620  0
                     }
 621  
                 });
 622  
 
 623  0
                 SectionTitle headerTitle = SectionTitle.generateH3Title("Withdraw Proposal");
 624  0
                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are withdrawing the " + proposalName + " proposal");
 625  0
                 SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 626  0
                 required = new AbbrPanel("Required", "ks-form-module-elements-required", " * ");
 627  0
                 required.setVisible(true);
 628  0
                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 629  0
                 dialogPanel.clear();
 630  0
                 dialogPanel.add(headerTitle);
 631  0
                 dialogPanel.add(dialogLabel);
 632  0
                 dialogPanel.add(fieldLabel);
 633  0
                 dialogPanel.add(required);
 634  0
                 dialogPanel.add(rationaleEditor);
 635  0
                 dialogPanel.add(withdrawButton);
 636  0
                 dialogPanel.setSize("580px", "400px");
 637  
                 // submitSuccessDialog.setWidget(dialogPanel);
 638  0
                 submitSuccessDialog.show();
 639  0
             }
 640  
         });
 641  0
         return wfWithdrawItem;
 642  
     }
 643  
 
 644  
     private KSMenuItemData getBlanketApproveItem() {
 645  
         KSMenuItemData wfBlanketApproveItem;
 646  
 
 647  0
         wfBlanketApproveItem = new KSMenuItemData("Blanket Approve Proposal", new ClickHandler() {
 648  
             public void onClick(ClickEvent event) {
 649  0
                 setupSubmitSuccessDialog();
 650  0
                 final KSRichEditor rationaleEditor = new KSRichEditor();
 651  0
                 ConfirmCancelGroup blanketApprovalButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() {
 652  
 
 653  
                     @Override
 654  
                     public void exec(ConfirmCancelEnum result) {
 655  0
                         if (!result.name().equals("CANCEL")) {
 656  0
                             if (rationaleEditor.getText().trim().equals("")) {
 657  0
                                 required.setText("Please enter the decision rationale");
 658  
                             } else {
 659  0
                                 addRationale(rationaleEditor, DecisionRationaleDetail.BLANKET_APPROVE.getType());
 660  
 
 661  0
                                 workflowRpcServiceAsync.blanketApproveDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() {
 662  
                                     public void handleFailure(Throwable caught) {
 663  0
                                         submitSuccessDialog.hide();
 664  0
                                         Window.alert("Error blanket approving Proposal");
 665  0
                                     }
 666  
 
 667  
                                     public void onSuccess(Boolean result) {
 668  0
                                         submitSuccessDialog.hide();
 669  0
                                         if (result) {
 670  0
                                             updateWorkflow(dataModel);
 671  0
                                             if (submitCallback != null) {
 672  0
                                                 submitCallback.exec(result);
 673  
                                             }
 674  
                                             // Notify the user that the document was approved
 675  0
                                             KSNotifier.add(new KSNotification("Proposal will be blanket approved", false));
 676  
                                         } else {
 677  0
                                             Window.alert("Error blanket approving Proposal");
 678  
                                         }
 679  0
                                     }
 680  
                                 });
 681  
                             }
 682  
                         } else {
 683  0
                             submitSuccessDialog.hide();
 684  
                         }
 685  0
                     }
 686  
                 });
 687  
 
 688  0
                 SectionTitle headerTitle = SectionTitle.generateH3Title("Blanket Approve Proposal");
 689  0
                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are blanket approving the " + proposalName + " proposal");
 690  0
                 SectionTitle fieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 691  0
                 required = new AbbrPanel("Required", "ks-form-module-elements-required", " * ");
 692  0
                 required.setVisible(true);
 693  0
                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 694  0
                 dialogPanel.clear();
 695  0
                 dialogPanel.add(headerTitle);
 696  0
                 dialogPanel.add(dialogLabel);
 697  0
                 dialogPanel.add(fieldLabel);
 698  0
                 dialogPanel.add(required);
 699  0
                 dialogPanel.add(rationaleEditor);
 700  0
                 dialogPanel.add(blanketApprovalButton);
 701  0
                 dialogPanel.setSize("580px", "400px");
 702  
                 // submitSuccessDialog.setWidget(dialogPanel);
 703  0
                 submitSuccessDialog.show();
 704  0
             }
 705  
         });
 706  0
         return wfBlanketApproveItem;
 707  
     }
 708  
 
 709  
     protected KSDropDown setUpReturnToPreviousDropDown(String workflowId) {
 710  
 //        nodeNameList.clear();
 711  0
         final KSDropDown nodeNameDropDown = new KSDropDown();
 712  0
         nodeNameDropDown.setBlankFirstItem(true);
 713  0
         workflowRpcServiceAsync.getPreviousRouteNodeNames(workflowId, new KSAsyncCallback<List<String>>() {
 714  
             public void handleFailure(Throwable caught) {
 715  0
                 Window.alert("Error getting previous node names for Proposal");
 716  0
             }
 717  
 
 718  
             public void onSuccess(List<String> result) {
 719  0
                 SimpleListItems nodeNameList = new SimpleListItems();
 720  0
                 for (String nodeName : result) {
 721  0
                     nodeNameList.addItem(nodeName, nodeName);
 722  
                 }
 723  0
                 nodeNameDropDown.setListItems(nodeNameList);
 724  0
             }
 725  
         });
 726  0
         nodeNameDropDown.setInitialized(true);
 727  0
         return nodeNameDropDown;
 728  
     }
 729  
 
 730  
     private KSMenuItemData getReturnToPreviousItem() {
 731  
         KSMenuItemData wfReturnToPreviousItem;
 732  
 
 733  0
         wfReturnToPreviousItem = new KSMenuItemData("Return Proposal to Previous Node", new ClickHandler() {
 734  
             public void onClick(ClickEvent event) {
 735  0
                 setupSubmitSuccessDialog();
 736  0
                 final KSRichEditor rationaleEditor = new KSRichEditor();
 737  0
                 final KSDropDown nodeNameDropDown = setUpReturnToPreviousDropDown(workflowId);
 738  0
                 ConfirmCancelGroup returnButton = new ConfirmCancelGroup(new Callback<ConfirmCancelEnum>() {
 739  
 
 740  
                     @Override
 741  
                     public void exec(ConfirmCancelEnum result) {
 742  0
                         if (!result.name().equals("CANCEL")) {
 743  0
                             if ((rationaleEditor.getText().trim().equals("")) && (nodeNameDropDown.getSelectedItem().trim().equals(""))) {
 744  0
                                 required.setText("Please enter the decision rationale and select a node name to return to");
 745  0
                             } else if (rationaleEditor.getText().trim().equals("")) {
 746  0
                                 required.setText("Please enter the decision rationale");
 747  0
                             } else if (nodeNameDropDown.getSelectedItem().trim().equals("")) {
 748  0
                                 required.setText("Please select a node name to return to");
 749  
                             } else {
 750  0
                                 addRationale(rationaleEditor, DecisionRationaleDetail.RETURN_TO_PREVIOUS.getType());
 751  0
                                 String nodeName = nodeNameDropDown.getSelectedItem().trim();
 752  0
                                 workflowRpcServiceAsync.returnDocumentWithId(workflowId, nodeName, new KSAsyncCallback<Boolean>() {
 753  
                                     public void handleFailure(Throwable caught) {
 754  0
                                         submitSuccessDialog.hide();
 755  0
                                         Window.alert("Error returning the Proposal to a previous node");
 756  0
                                     }
 757  
 
 758  
                                     public void onSuccess(Boolean result) {
 759  0
                                         submitSuccessDialog.hide();
 760  0
                                         if (result) {
 761  0
                                             updateWorkflow(dataModel);
 762  0
                                             if (submitCallback != null) {
 763  0
                                                 submitCallback.exec(result);
 764  
                                             }
 765  
                                             // Notify the user that the document was approved
 766  0
                                             KSNotifier.add(new KSNotification("Proposal was returned", false));
 767  
                                         } else {
 768  0
                                             Window.alert("Error returning the Proposal to a previous node");
 769  
                                         }
 770  0
                                     }
 771  
                                 });
 772  0
                             }
 773  
 
 774  
                         } else {
 775  0
                             submitSuccessDialog.hide();
 776  
                         }
 777  0
                     }
 778  
                 });
 779  
 
 780  0
                 SectionTitle headerTitle = SectionTitle.generateH3Title("Return Proposal to Previous Node");
 781  0
                 SectionTitle dialogLabel = SectionTitle.generateH4Title("You are returning the " + proposalName + " proposal to a previous node");
 782  0
                 SectionTitle nnFieldLabel = SectionTitle.generateH4Title("Workflow Node Name");
 783  0
                 SectionTitle drFieldLabel = SectionTitle.generateH4Title("Decision Rationale");
 784  0
                 required = new AbbrPanel("Required", "ks-form-module-elements-required", " * ");
 785  0
                 required.setVisible(true);
 786  0
                 rationaleEditor.addStyleName("KS-Comment-Create-Editor");
 787  0
                 dialogPanel.clear();
 788  0
                 dialogPanel.add(headerTitle);
 789  0
                 dialogPanel.add(dialogLabel);
 790  0
                 dialogPanel.add(nnFieldLabel);
 791  0
                 dialogPanel.add(nodeNameDropDown);
 792  0
                 dialogPanel.add(drFieldLabel);
 793  0
                 dialogPanel.add(required);
 794  0
                 dialogPanel.add(rationaleEditor);
 795  0
                 dialogPanel.add(returnButton);
 796  0
                 dialogPanel.setSize("580px", "400px");
 797  
                 // submitSuccessDialog.setWidget(dialogPanel);
 798  0
                 submitSuccessDialog.show();
 799  0
             }
 800  
         });
 801  0
         return wfReturnToPreviousItem;
 802  
         }
 803  
 
 804  
     private void addRationale(KSRichEditor rationaleEditor, String rationaleType) {
 805  0
         CommentInfo newDecisionRationale = new CommentInfo();
 806  0
         RichTextInfo text = new RichTextInfo();
 807  0
         text.setFormatted(rationaleEditor.getHTML());
 808  0
         text.setPlain(rationaleEditor.getText());
 809  0
         newDecisionRationale.setReferenceTypeKey(PROPOSAL_REF_TYPE_KEY);
 810  0
         newDecisionRationale.setReferenceId(proposalId);
 811  0
         newDecisionRationale.setState(DtoState.ACTIVE.toString());
 812  0
         newDecisionRationale.setCommentText(text);
 813  0
         newDecisionRationale.setType(rationaleType);
 814  
 
 815  
         try {
 816  0
             commentServiceAsync.addComment(proposalId, PROPOSAL_REF_TYPE_KEY, newDecisionRationale, new KSAsyncCallback<CommentInfo>() {
 817  
 
 818  
                 @Override
 819  
                 public void handleFailure(Throwable caught) {
 820  0
                     GWT.log("Add Comment Failed", caught);
 821  0
                 }
 822  
 
 823  
                 @Override
 824  
                 public void onSuccess(CommentInfo result) {
 825  0
                     System.out.println("Rationale Added successfully");
 826  0
                 }
 827  
             });
 828  0
         } catch (Exception e) {
 829  0
             GWT.log("Add Comment Failed", e);
 830  0
         }
 831  0
     }
 832  
 
 833  
     private KSMenuItemData getStartItem() {
 834  
         KSMenuItemData wfStartWorkflowItem;
 835  0
             wfStartWorkflowItem = new KSMenuItemData("Submit Proposal", new ClickHandler(){
 836  
                     public void onClick(ClickEvent event) {
 837  
                 //Make sure the entire data model is valid before submit
 838  0
                                 dataModel.validateNextState(new Callback<List<ValidationResultInfo>>() {
 839  
                     @Override
 840  
                     public void exec(List<ValidationResultInfo> result) {
 841  
                             
 842  0
                             boolean isValid = ((LayoutController)parentController).isValid(result, false);
 843  0
                             if(isValid){
 844  0
                                             dialog.show();
 845  
                             }
 846  
                             else{
 847  0
                                     Window.alert("Unable to submit to workflow.  Please check sections for missing fields.");
 848  
                             }                            
 849  0
                     }
 850  
                 });
 851  0
                     }
 852  
 
 853  
             });
 854  0
                 return wfStartWorkflowItem;
 855  
         }
 856  
 
 857  
     private KSMenuItemData getCancelWorkflowItem() {
 858  
         KSMenuItemData wfCancelWorkflowItem;
 859  0
         final KSRichEditor rationaleEditor = new KSRichEditor();
 860  0
         wfCancelWorkflowItem = new KSMenuItemData("Cancel Proposal", new ClickHandler() {
 861  
             public void onClick(ClickEvent event) {
 862  0
                 addRationale(rationaleEditor, DecisionRationaleDetail.CANCEL_WORKFLOW.getType());
 863  0
                 workflowRpcServiceAsync.cancelDocumentWithId(workflowId, new KSAsyncCallback<Boolean>() {
 864  
                     public void handleFailure(Throwable caught) {
 865  0
                         Window.alert("Error Cancelling Proposal");
 866  0
                     }
 867  
 
 868  
                     public void onSuccess(Boolean result) {
 869  0
                         if (result) {
 870  0
                             updateWorkflow(dataModel);
 871  0
                             if (submitCallback != null) {
 872  0
                                 submitCallback.exec(true);
 873  
                             }
 874  
                             // Notify the user that the document was FYIed
 875  0
                             KSNotifier.add(new KSNotification("Proposal will be Cancelled", false));
 876  
                         } else {
 877  0
                             Window.alert("Error Cancelling Proposal");
 878  
                         }
 879  0
                     }
 880  
 
 881  
                 });
 882  0
             }
 883  
         });
 884  0
         return wfCancelWorkflowItem;
 885  
     }
 886  
 
 887  
         private void setWorkflowStatus(String statusCd){
 888  0
                 String statusTranslation = "";
 889  0
                 if (WorkflowConstants.ROUTE_HEADER_SAVED_CD.equals(statusCd)){
 890  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_SAVED_LABEL_KEY);
 891  0
                 } else  if (WorkflowConstants.ROUTE_HEADER_INITIATED_CD.equals(statusCd)){
 892  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_INITIATED_LABEL_KEY);
 893  0
                 } else if (WorkflowConstants.ROUTE_HEADER_ENROUTE_CD.equals(statusCd)){
 894  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_ENROUTE_LABEL_KEY);
 895  0
                 } else if (WorkflowConstants.ROUTE_HEADER_APPROVED_CD.equals(statusCd)){
 896  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_APPROVED_LABEL_KEY);
 897  0
                 } else if (WorkflowConstants.ROUTE_HEADER_CANCEL_CD.equals(statusCd)){
 898  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_CANCEL_LABEL_KEY);
 899  0
                 } else if (WorkflowConstants.ROUTE_HEADER_EXCEPTION_CD.equals(statusCd)){
 900  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_EXCEPTION_LABEL_KEY);
 901  0
                 } else if (WorkflowConstants.ROUTE_HEADER_DISAPPROVED_CD.equals(statusCd)){
 902  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_DISAPPROVED_LABEL_KEY);
 903  0
                 } else if (WorkflowConstants.ROUTE_HEADER_FINAL_CD.equals(statusCd)){
 904  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_FINAL_LABEL_KEY);
 905  0
                 } else if (WorkflowConstants.ROUTE_HEADER_DISAPPROVE_CANCEL_CD.equals(statusCd)){
 906  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_DISAPPROVE_CANCEL_LABEL_KEY);
 907  0
                 } else if (WorkflowConstants.ROUTE_HEADER_PROCESSED_CD.equals(statusCd)){
 908  0
                         statusTranslation = getLabel(WorkflowConstants.ROUTE_HEADER_PROCESSED_LABEL_KEY);
 909  
                 } else {
 910  0
                         statusTranslation = statusCd;
 911  
                 }
 912  
                 
 913  0
                 workflowStatusLabel.setText("Status: " + statusTranslation);        
 914  0
         }
 915  
         
 916  
         /**
 917  
          * Use to set the modelName to use when this widget requests the data model.
 918  
          * 
 919  
          * @param modelName
 920  
          */
 921  
         public void setModelName(String modelName) {
 922  0
                 this.modelName = modelName;
 923  0
         }
 924  
         
 925  
         /**
 926  
          * Use to set the data model path to retrieve the propsal data to use for this workflow. 
 927  
          * @param idPath
 928  
          */
 929  
         public void setProposalPath(String proposalPath) {
 930  0
                 this.proposalPath = proposalPath;
 931  0
         }
 932  
                 
 933  
         public void setWorkflowRpcService(WorkflowRpcServiceAsync workflowRpcServiceAsync){
 934  0
                 this.workflowRpcServiceAsync = workflowRpcServiceAsync;
 935  0
         }
 936  
 
 937  
         public void refresh(){
 938  0
                 updateWorkflow(dataModel);
 939  0
         }
 940  
         
 941  
     private String getLabel(String labelKey) {
 942  0
         return Application.getApplicationContext().getUILabel("common", null, null, labelKey);
 943  
     }
 944  
     
 945  
     public void getDataIdFromWorkflowId(String workflowId, AsyncCallback<String> callback){
 946  0
             workflowRpcServiceAsync.getDataIdFromWorkflowId(workflowId, callback);
 947  0
     }
 948  
 
 949  
         public void addSubmitCallback(Callback<Boolean> callback) {
 950  0
                 this.submitCallback = callback;
 951  
                 
 952  0
         }
 953  
 }